Tensor
public class Tensor: Hashable, Equatable, TensorSymbol
A Tensor
object is a n-dimension page-aligned data container with fixed-size memory space.
The attribute shape
specifying the dimension information of a Tensor
object.
All elements stored as Float
values
No matter what type of array user passing in: Double
or Float
or Int
, inside a Tensor
object
values will be converted and stored as Float
(32-bit signle precision).
Serrano
chose this because 32-bit Float
is the maximum precise floating data type Metal
could support (v1.2).
Inside Memory Layout
Inside a Tensor
object, it maintains a virtual 1-d array as a contiguous memory space manually allocated.
Elements are stored following row-major
order. Details can be found in TensorShape
docs.
Tensor-Tensor arithmetic operators
Besides Operators which contains many math and NN operations, Tensor
object itself implements/overloads common
arithmetic operators.
Tensor object support element-wise arithmetic operation with or without broadcasting.
Also it supports in-place operation choice.
Element-wise operation without broadcasting:
+
Addition without broadcasting-
Substraction without broadcasting*
Multiplication without broadcasting/
Division without broadcasting
Element-wise in-place operation:
&+
Addition without broadcasting&-
Substraction without broadcasting&*
Multiplication without broadcasting&/
Division without broadcasting
Element-wise operation with broadcasting:
.+
Addition without broadcasting.-
Substraction without broadcasting.*
Multiplication without broadcasting./
Division without broadcasting
Element-wise in-place operation with broadcasting:
.&+
Addition without broadcasting.&-
Substraction without broadcasting.&*
Multiplication without broadcasting.&/
Division without broadcasting
Example usage:
/// Element wise addition without broadcasting
let tensorA = Tensor(repeatingValue: 1.0,
tensorShape: TensorShape(dataType:.float, shape: [2, 5]))
let tensorB = Tensor(repeatingValue: 2.0,
tensorShape: TensorShape(dataType:.float, shape: [2, 5]))
let result1 = tensorA + tensorB
/// Element wise in-place addition without broadcasting
let result2 = tensorA &+ tensorB
print(result2 == tensorA) // true
/// Element wise addition with broadcasting
let tensorD = Tensor(repeatingValue: 2.0,
tensorShape: TensorShape(dataType:.float, shape: [1, 5]))
let result3 = tensorA .+ tensorD
/// Element wise in-place addition with broadcasting
let resunt4 = tensorA .&+ tensorD
print(result4 == tensorA) // true
Directly used as TensorSymbol
Tensor
conforms to TensorSymbol
protocol.
So a tensor object could be used as a symbol participating in graph computation.
-
shape
Declaration
Swift
internal var _shape: TensorShape
-
Allocated aligned memory size in bytes
Declaration
Swift
internal var _allocatedSize: Int
-
The base address of allocated memory.
Declaration
Swift
internal var _dataMemoryBaseAdrress: UnsafeMutablePointer<Float>
-
Convenience
Float
readerDeclaration
Swift
internal var _elementReader: UnsafeMutableBufferPointer<Float>
-
How many elements can store
Declaration
Swift
internal var _capacity: Int
-
Slice marker. Indicate if this tensor object is a slice from another tensor. If
true
, this object is just a reference slice and should not own the memeory.Declaration
Swift
internal var _sliceMarker: Bool = false
-
The root tensor of a sliced tensor
Declaration
Swift
internal var _sliceRootTensor: Tensor? = nil
-
The index array of this slice object in raw tensor.
nil
if not a sliced tensorDeclaration
Swift
internal var _sliceIndex: [Int]?
-
MTLBuffer
binded to this tensor.Note
If the tensor is sliced, this isnil
.Declaration
Swift
internal var _mtlbuffer: MTLBuffer?
-
Count of data elements tored
Declaration
Swift
public var count: Int
-
Dimension of the array
Declaration
Swift
public var dimension: Int
-
How many elements can store
Declaration
Swift
public var capacity: Int
-
Shape
Declaration
Swift
public var shape: TensorShape
-
Allocated memeory bytes
Declaration
Swift
public var allocatedBytes: Int
-
Readable description of a object
Declaration
Swift
public var description: String
-
A readable label for distinguishing different tensors. Serrano does not check label unique.
Declaration
Swift
public var label: String = "Tensor"
-
Base address of allocated memeory space
Warning
User could reuse aTensor
object with this pointer by assigning new values. However, it must be very careful with the boundary.Declaration
Swift
public var contentsAddress: UnsafeMutablePointer<Float>
-
Float value reader pointer
Declaration
Swift
public var floatValueReader: UnsafeMutableBufferPointer<Float>
-
Rank
Declaration
Swift
public var rank: Int
-
Slice marker. Indicate if this tensor object is a slice from another tensor. If
true
, this object is just a reference slice and should not own the memeory.Declaration
Swift
public var isSliceTensor: Bool
-
The root tensor of a sliced tensor
Declaration
Swift
public var sliceRootTensor: Tensor?
-
The index of this slice object in raw tensor.
nil
if not a sliced tensorDeclaration
Swift
public var sliceIndex: [Int]?
-
Conforms to protocol
TensorSymbol
.Declaration
Swift
public var symbolType: SymbolType = SymbolType.Tensor
-
Conforms to protocol
TensorSymbol
.Declaration
Swift
public var UID: String = ""
-
Conforms to protocol
TensorSymbol
.Declaration
Swift
public var symbolLabel: String = ""
-
Inbound symbols list. Conforms to
GraphSymbol
. To prevent from cycle reference, we dynamic constructing this attribute frominBoundsWeak
.Declaration
Swift
public var inBounds: [GraphSymbol]
-
Outbound symbols list. Conforms to
GraphSymbol
. To prevent from cycle reference, we dynamic constructing this attribute frominBoundsWeak
.Declaration
Swift
public var outBounds: [GraphSymbol]
-
Weak reference array of inbounds objects
Declaration
Swift
internal var inBoundsWeak: [WeakSerranoGraphSymbol] = [WeakSerranoGraphSymbol]()
-
Weak reference array of outbounds objects
Declaration
Swift
internal var outBoundsWeak: [WeakSerranoGraphSymbol] = [WeakSerranoGraphSymbol]()
-
Read-only. Conforms to protocol
TensorSymbol
.Declaration
Swift
public var bindedData: DataSymbolSupportedDataType?
-
Conforms to protocol
TensorSymbol
.Declaration
Swift
public var dataSource: SymbolDataSource = SymbolDataSource.Other
-
If differentiable
Declaration
Swift
public var updatable = false
-
Current grad
Declaration
Swift
public var currentGrad: DataSymbolSupportedDataType?
-
If enabled history grads recording. Default is
false
.Declaration
Swift
public var historyGradsEnabled = false
-
history grads
Declaration
Swift
public var historyGrads: [DataSymbolSupportedDataType] = [Tensor]()
-
Check if index is valid for fetching a single element
Declaration
Swift
public func indexIsValid(_ index: [Int]) -> Bool
Parameters
index
index description
Return Value
return value description
-
Get offset in terms of element counting from valid index
Declaration
Swift
internal func offSetFromIndex(_ index: [Int]) -> Int
Parameters
index
valid index list
Return Value
offset
-
Custom subscript to fetch single
Float
elementDeclaration
Swift
public subscript(_ index: Int...) -> Float
Parameters
index
Indices list
-
Custom subscript to fetch single
Float
elementDeclaration
Swift
public subscript(_ index: [Int]) -> Float
Parameters
index
Indices list
-
Internal use, already checked boundary before fetch or set
Warning
May cause unexpected result or fatal error if
index
is not valid.Declaration
Swift
public subscript(withoutChecking index:[Int]) -> Float
Parameters
index
index array
-
Get element value from
index
. If input index is invalid, returnmissingValue
.Declaration
Swift
public func fetchValueOrDefault(_ index: [Int], missingValue: Float = 0.0) -> Float
Parameters
index
index array
missingValue
default value for missing elements. Default is
0.0
Return Value
value
-
Designated init.
Declaration
Swift
internal init(shape: TensorShape, allocateSize: Int, capacity: Int, dataMemoryBaseAddres: UnsafeMutablePointer<Float>, elementReader:UnsafeMutableBufferPointer<Float>)
Parameters
shape
shape
allocateSize
allocateSize
capacity
capacity
dataMemoryBaseAddres
dataMemoryBaseAddres
elementReader
elementReader
-
Initial a tensor with repeating value
Declaration
Swift
public convenience init(repeatingValue value: Float, tensorShape shape: TensorShape)
Parameters
repeatingValue
repeat value
shape
shape
-
Construct a tensor from a flatten (1-D) swift array.
Declaration
Swift
public convenience init(fromFlatArray array:[SupportedScalarDataType], tensorShape shape: TensorShape)
Parameters
array
1-D array.
shape
The shape which the constructed tensor have. The count of this shape should be the same of count of passed in array.
-
Construct a tensor from a nested (N-D) swift array.
Declaration
Swift
public convenience init(dataArray array:[Any], tensorShape shape: TensorShape)
Parameters
array
The nested array object. Note that this array should only contains objects of type
SupportedScalarDataType
. Also this dimension of this array should be matching with parametertensorShape
.shape
The shape describing the passed in array.
-
Used internal only to generate slice tensor
Declaration
Swift
internal init(sliceTensorFrom rootTensor: Tensor, sliceContentAddress: UnsafeMutablePointer<Float>, count: Int, shape: TensorShape, index: [Int])
Parameters
sliceTensorFrom
contentAddress
- sliceContentAddress: slice content address
count
count
shape
shape
-
Need to free allcoated memory space manually.
Declaration
Swift
deinit
-
Generate a random tensor.
Declaration
Swift
public static func randomTensor(_ shape: TensorShape, min: Float = 0.0, max: Float = 1.0) -> Tensor
Parameters
shape
min
max
Return Value
-
Reload data from a flat array.
Note
If
array
size < tensor’scount
Declaration
Swift
public func reloadData(fromFlatArray array:[SupportedScalarDataType], tensorShape shape: TensorShape)
Parameters
array
-
Set tensor’s all selements to a same
value
.Warning
This operation will erase current values of tensor object.
Declaration
Swift
public func resetValues(_ value:SupportedScalarDataType)
Parameters
value
initial value
-
Set tensor’s all elements to
0
.Warning
This operation will erase current values of tensor object.
Declaration
Swift
public func clear()
Parameters
value
initial value
-
Copy values from another tensor.
Dimension check
This function just check cp from tensor’s total element count. If two tensors has same number of elements, do the copy. If not, raise
fatalError
Declaration
Swift
public func copyValues(_ tensor: Tensor)
Parameters
tensor
cp from tensor
-
Return flat array containing all elements stored in tensor with
Float
type.Declaration
Swift
public func flatArrayFloat() -> [Float]
Return Value
Type of declared.
-
Recursively construct nested array
Declaration
Swift
internal func constructNestedArrayFrom(location: [Int]) -> [Any]
Parameters
shape
shape needs to construct
Return Value
result
-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Declaration
Swift
public var hashValue: Int
-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Declaration
Swift
public static func ==(lhs: Tensor, rhs: Tensor) -> Bool
-
Get a
MTLBuffer
associated with this tensor object.Declaration
Swift
public func gpuBufferResource() -> MTLBufferResource
Return Value
-
Return a new tensor contains the absolute values of this tensor. Same effect as using
AbsOperator
.Declaration
Swift
public func abs() -> Tensor
Return Value
new tensor object with absed values.
-
Element-wise addition. Not support braodcasting. Same effect as using
AddOperator
.Warning
If two tensors don’t have same shape, program would be aborted (
fatalError()
called).- left: left tensor
- right: right tensor
Declaration
Swift
public static func +(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
result tensor
-
Element-wise substraction. Not support braodcasting. Same effect as using
SubOperator
.Warning
If two tensors don’t have same shape, program would be aborted (
fatalError()
called).- left: left tensor
- right: right tensor
Declaration
Swift
public static func -(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
result tensor
-
Element-wise multiplication. Not support braodcasting. Same effect as using
AddOperator
.Warning
If two tensors don’t have same shape, program would be aborted (
fatalError()
called).- left: left tensor
- right: right tensor
Declaration
Swift
public static func *(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
result tensor
-
Element-wise division. Not support braodcasting. Same effect as using
DivOperator
.Warning
If two tensors don’t have same shape, program would be aborted (
fatalError()
called).- left: left tensor
- right: right tensor
Declaration
Swift
public static func /(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
result tensor
-
Element-wise in-place addition. Not support braodcasting. Same effect as using
AddOperator
.Note
This is an in place operation. Result stored in left tensor and return the calcualted left tensor.
Warning
If two tensors don’t have same shape, program would be aborted (fatalError()
called).Declaration
Swift
@discardableResult public static func &+(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
left tensor after calculated.
-
Element-wise in-place substraction. Not support braodcasting. Same effect as using
SubOperator
.Note
This is an in place operation. Result stored in left tensor and return the calcualted left tensor.
Warning
If two tensors don’t have same shape, program would be aborted (fatalError()
called).Declaration
Swift
@discardableResult public static func &-(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
left tensor after calculated.
-
Element-wise in-place multiplication. Not support braodcasting. Same effect as using
MultOperator
.Note
This is an in place operation. Result stored in left tensor and return the calcualted left tensor.
Warning
If two tensors don’t have same shape, program would be aborted (fatalError()
called).Declaration
Swift
@discardableResult public static func &*(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
left tensor after calculated.
-
Element-wise in-place division. Not support braodcasting. Same effect as using
DivOperator
.Note
This is an in place operation. Result stored in left tensor and return the calcualted left tensor.
Warning
If two tensors don’t have same shape, program would be aborted (fatalError()
called).Declaration
Swift
@discardableResult public static func &/(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
left tensor after calculated.
-
Element-wise addition. support braodcasting. Same effect as using
BrodcastAddOperator
.Warning
If two tensors don’t have same shape or one of them cannot be broadcasted to anoter one, program would be aborted (
fatalError()
called).- left: left tensor
- right: right tensor
Declaration
Swift
public static func .+(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
result tensor
-
Element-wise substraction. support braodcasting. Same effect as using
BroadcastSubOperator
.Warning
If two tensors don’t have same shape or one of them cannot be broadcasted to anoter one, program would be aborted (
fatalError()
called).- left: left tensor
- right: right tensor
Declaration
Swift
public static func .-(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
result tensor
-
Element-wise multiplication. support braodcasting. Same effect as using
BroadcastMultOperator
.Warning
If two tensors don’t have same shape or one of them cannot be broadcasted to anoter one, program would be aborted (
fatalError()
called).- left: left tensor
- right: right tensor
Declaration
Swift
public static func .*(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
result tensor
-
Element-wise division. support braodcasting. Same effect as using
BroadcastDivOperator
.Warning
If two tensors don’t have same shape or one of them cannot be broadcasted to anoter one, program would be aborted (
fatalError()
called).- left: left tensor
- right: right tensor
Declaration
Swift
public static func ./(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
result tensor, a new created tensor.
-
Element-wise in-place addition. support braodcasting. Same effect as using
BrodcastAddOperator
.Note
This is an in place operation. Result stored in left tensor and return the calcualted left tensor.
Warning
If two tensors don’t have same shape or one of them cannot be broadcasted to anoter one, program would be aborted (fatalError()
called).Declaration
Swift
@discardableResult public static func .&+(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
left tensor after calcualted
-
Element-wise in-place substraction. support braodcasting. Same effect as using
BroadcastSubOperator
.Note
This is an in place operation. Result stored in left tensor and return the calcualted left tensor.
Warning
If two tensors don’t have same shape or one of them cannot be broadcasted to anoter one, program would be aborted (fatalError()
called).Declaration
Swift
@discardableResult public static func .&-(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
left tensor after calcualted
-
Element-wise in-place multiplication. support braodcasting. Same effect as using
BroadcastMultOperator
.Note
This is an in place operation. Result stored in left tensor and return the calcualted left tensor.
Warning
If two tensors don’t have same shape or one of them cannot be broadcasted to anoter one, program would be aborted (fatalError()
called).Declaration
Swift
@discardableResult public static func .&*(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
left tensor after calcualted
-
Element-wise in-place division. support braodcasting. Same effect as using
BroadcastDivOperator
.Note
This is an in place operation. Result stored in left tensor and return the calcualted left tensor.
Warning
If two tensors don’t have same shape or one of them cannot be broadcasted to anoter one, program would be aborted (fatalError()
called).Declaration
Swift
@discardableResult public static func .&/(left: Tensor, right:Tensor) -> Tensor
Parameters
left
left tensor
right
right tensor
Return Value
left tensor after calcualted
-
A tensor plus a scalar variable. Ex.
[2, 3] + 0.5 --> [2.5, 3.5]
.Declaration
Swift
public static func + (left: Tensor, rightScalar: SupportedScalarDataType) -> Tensor
Parameters
left
A tensor object
rightScalar
A scalar variable
Return Value
Result tensor, new created.
-
A tensor substract a scalar variable. Ex.
[2, 3] - 0.5 --> [1.5, 2.5]
.Declaration
Swift
public static func - (left: Tensor, rightScalar: SupportedScalarDataType) -> Tensor
Parameters
left
A tensor object
rightScalar
A scalar variable
Return Value
Result tensor, new created.
-
A tensor multiply a scalar variable. Ex.
[2, 3] * 0.5 --> [1.0, 1.5]
.Declaration
Swift
public static func * (left: Tensor, rightScalar: SupportedScalarDataType) -> Tensor
Parameters
left
A tensor object
rightScalar
A scalar variable
Return Value
Result tensor, new created.
-
A tensor divide a scalar variable. Ex.
[2, 3] / 0.5 --> [4.0, 6.0]
.Declaration
Swift
public static func / (left: Tensor, rightScalar: SupportedScalarDataType) -> Tensor
Parameters
left
A tensor object
rightScalar
A scalar variable
Return Value
Result tensor, new created.
-
A tensor plus a scalar variable. Ex.
[2, 3] + 0.5 --> [2.5, 3.5]
.Note
This is an in place operation. Result stored in left tensor and return the calcualted left tensor.
Declaration
Swift
@discardableResult public static func &+ (left: Tensor, rightScalar: SupportedScalarDataType) -> Tensor
Parameters
left
A tensor object
rightScalar
A scalar variable
Return Value
-
A tensor substract a scalar variable. Ex.
[2, 3] - 0.5 --> [1.5, 2.5]
.Note
This is an in place operation. Result stored in left tensor and return the calcualted left tensor.
Declaration
Swift
@discardableResult public static func &- (left: Tensor, rightScalar: SupportedScalarDataType) -> Tensor
Parameters
left
A tensor object
rightScalar
A scalar variable
Return Value
-
A tensor multiply a scalar variable. Ex.
[2, 3] * 0.5 --> [1.0, 1.5]
.Note
This is an in place operation. Result stored in left tensor and return the calcualted left tensor.
Declaration
Swift
@discardableResult public static func &* (left: Tensor, rightScalar: SupportedScalarDataType) -> Tensor
Parameters
left
A tensor object
rightScalar
A scalar variable
Return Value
left tensor after calculated.
-
A tensor divide a scalar variable. Ex.
[2, 3] / 0.5 --> [4.0, 6.0]
.Note
This is an in place operation. Result stored in left tensor and return the calcualted left tensor.
Declaration
Swift
@discardableResult public static func &/ (left: Tensor, rightScalar: SupportedScalarDataType) -> Tensor
Parameters
left
A tensor object
rightScalar
A scalar variable
Return Value
-
A scalar plus a tensor variable. Ex.
0.5 + [2, 3] --> [2.5, 3.5]
.Declaration
Swift
public static func + (leftScalar: SupportedScalarDataType, right: Tensor) -> Tensor
Parameters
leftScalar
A scalar variable
right
A tensor object
Return Value
Result tensor, new created.
-
A scalar substracts a tensor variable. Ex.
0.5 - [2, 3] --> [-1.5, -2.5]
.Declaration
Swift
public static func - (leftScalar: SupportedScalarDataType, right: Tensor) -> Tensor
Parameters
leftScalar
A scalar variable
right
A tensor object
Return Value
Result tensor, new created.
-
A scalar multiplies a tensor variable. Ex.
0.5 * [2, 3] --> [1.0, 1.5]
.Declaration
Swift
public static func * (leftScalar: SupportedScalarDataType, right: Tensor) -> Tensor
Parameters
leftScalar
A scalar variable
right
A tensor object
Return Value
Result tensor, new created.
-
A scalar divides by a tensor variable. Ex.
0.5 / [2, 3] --> [0.25, 0.16]
.Declaration
Swift
public static func / (leftScalar: SupportedScalarDataType, right: Tensor) -> Tensor
Parameters
leftScalar
A scalar variable
right
A tensor object
Return Value
Result tensor, new created.
-
A scalar plus a tensor variable. Ex.
0.5 + [2, 3] --> [2.5, 3.5]
.Note
This is an in place operation. Result stored in right tensor and return the calcualted left tensor.
Declaration
Swift
@discardableResult public static func &+ (leftScalar: SupportedScalarDataType, right: Tensor) -> Tensor
Parameters
leftScalar
A scalar variable
right
A tensor object
Return Value
Result right tensor.
-
A scalar substracts a tensor variable. Ex.
0.5 - [2, 3] --> [-1.5, -2.5]
.Note
This is an in place operation. Result stored in right tensor and return the calcualted left tensor.
Declaration
Swift
@discardableResult public static func &- (leftScalar: SupportedScalarDataType, right: Tensor) -> Tensor
Parameters
leftScalar
A scalar variable
right
A tensor object
Return Value
Result right tensor.
-
A scalar multiplies a tensor variable. Ex.
0.5 * [2, 3] --> [1.0, 1.5]
.Note
This is an in place operation. Result stored in right tensor and return the calcualted left tensor.
Declaration
Swift
@discardableResult public static func &* (leftScalar: SupportedScalarDataType, right: Tensor) -> Tensor
Parameters
leftScalar
A scalar variable
right
A tensor object
Return Value
Result tensor, new created.
-
A scalar divides by a tensor variable. Ex.
0.5 / [2, 3] --> [0.25, 0.16]
.Note
This is an in place operation. Result stored in right tensor and return the calcualted left tensor.
Declaration
Swift
@discardableResult public static func &/ (leftScalar: SupportedScalarDataType, right: Tensor) -> Tensor
Parameters
leftScalar
A scalar variable
right
A tensor object
Return Value
Result tensor, new created.
-
Make a slice tensor from this object.
Declaration
Swift
public func slice(sliceIndex:[Int]) -> Tensor
Parameters
sliceIndex
Slice Inde
Return Value
A sliced tensor
-
Check if a slice tensor object belong to this tensor.
Note
If the passed in tensor is not a slice tensor, always returns
false
.Declaration
Swift
public func containsSlice(_ slice: Tensor) -> Bool
Parameters
slice
slice tensor
Return Value
Bool. Result
-
Get the bytes offset for a slice tensor spawned from this tensor.
Note
The function will first check if contains this slice, if not it will return
nil
Declaration
Swift
public func slicedTensorOffset(_ slice: Tensor) -> Int?
Parameters
slice
slice object
Return Value
offset in bytes
-
Return self
Declaration
Swift
public func evaluate() -> [DataSymbolSupportedDataType]?
Return Value
tensor
-
Add new symbol to
inBounds
. Should check duplicate.Declaration
Swift
public func addToInBound(_ symbol: GraphSymbol)
-
Add new symbol to
outBounds
Should check duplicate.Declaration
Swift
public func addToOutBound(_ symbol: GraphSymbol)
-
A tensor object could not be binded to another tensor.
Warning
This function will do nonthing and always return
false
. A error logging will be gaven.Declaration
Swift
public func bindData(_ data:DataSymbolSupportedDataType) -> Bool
Parameters
data
data. Should be a
Tensor
object.Return Value
always
False
-
Undocumented
Declaration
Swift
public func getMPSImage(dataFormat: TensorChannelOrder) -> MPSImage
-
Undocumented
Declaration
Swift
public var scarlarValue: Float
-
Undocumented
Declaration
Swift
public var tensorValue: Tensor