One Logo Pool Ball
CoreML · IOS API REFERENCE

MLMultiArray

class · iOS 11.0+ · SDK 27.1

class MLMultiArray

Members (19)

init · iOS 14.0+

init

TypeScript
static initConcatenatingAxisDataType(multiArrays: Array<MLMultiArray>, axis: number, dataType: MLMultiArrayDataType): MLMultiArray
Swift declaration
convenience init(concatenating multiArrays: [MLMultiArray], axis: Int, dataType: MLMultiArrayDataType)
init

init

TypeScript
static initDataPointerShapeDataTypeStridesDeallocator(dataPointer: SDKHandle, shape: Array<_Foundation_NSNumber>, dataType: MLMultiArrayDataType, strides: Array<_Foundation_NSNumber>, deallocator?: (((arg0: SDKHandle) => void)) | null): MLMultiArray
Swift declaration
init(dataPointer: UnsafeMutableRawPointer, shape: [NSNumber], dataType: MLMultiArrayDataType, strides: [NSNumber], deallocator: ((UnsafeMutableRawPointer) -> Void)? = nil) throws
init · iOS 16.0+

init

TypeScript
static initPixelBufferShape(pixelBuffer: _CoreVideo_CVBuffer, shape: Array<_Foundation_NSNumber>): MLMultiArray
Swift declaration
init(pixelBuffer: CVPixelBuffer, shape: [NSNumber])
init

init

TypeScript
static initShapeDataType(shape: Array<_Foundation_NSNumber>, dataType: MLMultiArrayDataType): MLMultiArray
Swift declaration
init(shape: [NSNumber], dataType: MLMultiArrayDataType) throws
subscript

subscript

TypeScript
subscript(idx: number): _Foundation_NSNumber
Swift declaration
subscript(idx: Int) -> NSNumber { get set }
subscript

subscript

TypeScript
subscript66708(key: Array<_Foundation_NSNumber>): _Foundation_NSNumber
Swift declaration
subscript(key: [NSNumber]) -> NSNumber { get set }
method · iOS 18.0+

transfer

TypeScript
transfer(destinationMultiArray: MLMultiArray): void
Swift declaration
func transfer(to destinationMultiArray: MLMultiArray)
get · iOS 11.0+

count

TypeScript
get count(): number
Swift declaration
var count: Int { get }
get · iOS 11.0+ · Deprecated in iOS 100000.0

dataPointer

TypeScript
get dataPointer(): SDKHandle
Swift declaration
var dataPointer: UnsafeMutableRawPointer { get }
get · iOS 11.0+

dataType

TypeScript
get dataType(): MLMultiArrayDataType
Swift declaration
var dataType: MLMultiArrayDataType { get }
get · iOS 16.0+

pixelBuffer

TypeScript
get pixelBuffer(): (_CoreVideo_CVBuffer) | null
Swift declaration
var pixelBuffer: CVPixelBuffer? { get }
get · iOS 11.0+

shape

TypeScript
get shape(): Array<_Foundation_NSNumber>
Swift declaration
var shape: [NSNumber] { get }
get · iOS 11.0+

strides

TypeScript
get strides(): Array<_Foundation_NSNumber>
Swift declaration
var strides: [NSNumber] { get }
method · iOS 15.4+

withUnsafeBytes

TypeScript
withUnsafeBytes(body: ((arg0: ArrayBuffer) => unknown)): unknown
Swift declaration
func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R

Calls a given closure with a raw pointer to the multi array’s storage. ``` let A = try MLMultiArray(shape:[3, 2], dataType: .int32) A[[1, 2]] = 42 A.withUnsafeBytes { bytes in let scalarBuffer = bytes.bindMemory(to: Int32.self) let strideY = A.strides[0].intValue // Print 42 print("Scalar at (1, 2): \(scalarBuffer[1 * strideY + 2])") } ``` - Parameter body: A closure with an `UnsafeRawBufferPointer` parameter that points to the storage for the multi array. If body has a return value, that value is also used as the return value for the `withUnsafeBytes(_:)` method. The pointer argument is valid only for the duration of the method's execution. - Parameter ptr: The pointer to the memory buffer of the multi array.

method · iOS 15.4+

withUnsafeMutableBytes

TypeScript
withUnsafeMutableBytes(body: ((arg0: ArrayBuffer, arg1: Array<number>) => unknown)): unknown
Swift declaration
func withUnsafeMutableBytes<R>(_ body: (UnsafeMutableRawBufferPointer, [Int]) throws -> R) rethrows -> R

Calls a given closure with a raw pointer to the multi array’s mutable storage. Use strides passed to the closure to access the buffer. This is a mutating function, which may change the underlying buffer layoout. ``` let A = try MLMultiArray(shape:[3, 2], dataType: .int32) A.withUnsafeMutableBytes { bytes, strides in let scalarBuffer = bytes.bindMemory(to: Int32.self) let strideY = strides[0] scalarBuffer[1 * strideY + 2] = 42 // Set 42 at A[1, 2] } ``` - Parameter body: A closure with an `UnsafeRawBufferPointer` parameter that points to the storage for the multi array. If body has a return value, that value is also used as the return value for the `withUnsafeMutableBytes(_:)` method. The pointer argument is valid only for the duration of the method's execution. - Parameter ptr: The pointer to the memory buffer of the multi array. - Parameter strides: The strides of the buffer in number of scalars, not bytes.

init · iOS 18.0+

init

TypeScript
static initShapeDataTypeStrides(shape: Array<number>, dataType: MLMultiArrayDataType, strides: Array<number>): MLMultiArray
Swift declaration
convenience init(shape: [Int], dataType: MLMultiArrayDataType, strides: [Int])

Creates the object with specified strides. The contents of the object are left uninitialized; the client must initialize it. - Parameters: - shape: The shape - dataType: The data type - strides: The strides.

init · iOS 13.0+

init

TypeScript
static init(data: Array<number>): MLMultiArray
Swift declaration
convenience init<C>(_ data: C) throws where C : Collection, C.Element == Double

An MLMultiArray constructed with the elements of a collection whose elements are type Double. ~~~~ let v:[Double] = [3.14159, 2.71828, 1.61803] let m = try MLMultiArray(v) print(m) Double 3 vector [3.14159,2.71828,1.61803] ~~~~

init · iOS 13.0+

init

TypeScript
static init98457(data: Array<number>): MLMultiArray
Swift declaration
convenience init<C>(_ data: C) throws where C : Collection, C.Element == Float

An MLMultiArray constructed with the elements of a collection whose elements are type Float. ~~~~ let v:[Float] = [3.14159, 2.71828, 1.61803] let m = try MLMultiArray(v) print(m) Float32 3 vector [3.14159,2.71828,1.61803] ~~~~

init · iOS 13.0+

init

TypeScript
static init99583(data: Array<number>): MLMultiArray
Swift declaration
convenience init<C>(_ data: C) throws where C : Collection, C.Element : FixedWidthInteger

An MLMultiArray constructed with the FixedWidthInteger elements of the collection converted to Int32. ~~~~ let v:[Int32] = [3, 2, 1] let m = try MLMultiArray(v) print(m) Int32 3 vector [3,2,1] ~~~~ This initializer will trap if called with data containing FixedWidthInteger elements that cannot be safely converted to Int32, but it is safe to use with wider types so long as the actual data is within range. ~~~~ let a = try MLMultiArray([Int.max]) // trap! let b = try MLMultiArray([Int(Int32.max), Int(Int32.min)]) // This is fine. ~~~~

Skipped declarations

4 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

MLMultiArray.init(_:)

This declaration needs Swift generic type arguments. (no canonical witness for ShapedArray)

MLMultiArray.withUnsafeBufferPointer(ofType:_:)

Passing a Swift type itself is not supported.

MLMultiArray.withUnsafeMutableBufferPointer(ofType:_:)

Passing a Swift type itself is not supported.

MLMultiArray.init()

inherited init: cannot prove legal (class declares 10 custom initializers)

All CoreML types →