BroadcastOperator
public class BroadcastOperator: ComputableOperator
Doing broadcasting on input tensors and store result in output tensors. Serrano follows the broadcasting rule of Scipy.
-
Operator label. Conforms to
ComputableOperator
Declaration
Swift
public var operatorLabel: String = ""
-
This operator does not operator on GPU. Conforms to
ComputableOperator
Declaration
Swift
public var metalKernelFuncLabel:String
-
Conforms to
ComputableOperator
Declaration
Swift
public var computationDelegate: OperatorCalculationDelegate?
-
Conforms to
ComputableOperator
Declaration
Swift
public var inputTensors: [Tensor]?
-
Conforms to
ComputableOperator
Declaration
Swift
public var outputTensors: [Tensor]?
-
Target shape.
Note
This atrribute could benil
when initialize an object. If it isnil
doing calculation, afatalError()
will be raise.Declaration
Swift
public var targetShape: TensorShape?
-
If
true
, operator will not check theupGrads
‘s shape. This is used inside framework to speed up in situation we know it will not be wrong. Cases like auto generated differentiation graph.Declaration
Swift
public var disableUpGradShapeCheck: Bool = false
-
If
true
, operator will not callinputOutputTensorsCheck()
before doing calculation. This is used inside framework to speed up in situation we know it will not be wrong.Declaration
Swift
public var disableInputOutputCheck: Bool = false
-
Indicate if this operator would do paramter update.
Note
BroadcastOperator
is not trainable.Declaration
Swift
public var trainable: Bool = false
-
The mapping type of this operator.
OneToOne
for this operator.Declaration
Swift
public var mapType: OperatorMappingType
-
Broadcast operator cannot do in-place calculation
Declaration
Swift
public var inPlaceble: Bool = false
-
init(operatorLabel:metalKernelFuncLabel:computationDelegate:inputTensors:outputTensors:targetShape:)
Initializers
Note
In most cases, this initializer should not be called. Call one of the convenience initializers instead.
Declaration
Swift
public init(operatorLabel label: String, metalKernelFuncLabel kernelLabel: String, computationDelegate: OperatorCalculationDelegate?, inputTensors: [Tensor]?, outputTensors: [Tensor]?, targetShape: TensorShape?)
Parameters
label
kernelLabel
computationDelegate
inputTensors
outputTensors
targetShape
-
Declaration
Swift
public convenience init(computationDelegate: OperatorCalculationDelegate, targetShape: TensorShape?)
Parameters
computationDelegate
targetShape
-
Initializer
Declaration
Swift
public convenience init(targetShape: TensorShape? = nil, inputTensors: [Tensor]? = nil, outputTensors: [Tensor]? = nil)
Parameters
targetShape
target broadcast shape
-
The input shapes and target shape should follow the
scipy rule
Declaration
Swift
public func outputShape(shapeArray shapes: [TensorShape]) -> [TensorShape]?
Parameters
shapes
input shapes
Return Value
return shapes.
nil
if not valid -
Check if shapes of all input tensors and output tensors are compatible with
targetShape
Declaration
Swift
public func inputOutputTensorsCheck() -> (check: Bool, msg: String)
Return Value
check and message
-
Declaration
Swift
public func compute(_ computationMode: OperatorComputationMode = SerranoEngine.configuredEngine.defaultComputationMode)
-
Declaration
Swift
public func computeAsync(_ computationMode: OperatorComputationMode = SerranoEngine.configuredEngine.defaultComputationMode)
-
Calulate grads sync. Broadcast operator itself does not generate any grads. Should be ignored in gaph AD.
Declaration
Swift
public func gradCompute(_ computationMode: OperatorComputationMode) -> [String: DataSymbolSupportedDataType]
Parameters
computationMode
computationMode
Return Value
return
upGrads
if not nil. Else return an empty array. -
Cal grads async
Declaration
Swift
public func gradComputAsync(_ computationMode: OperatorComputationMode)
Parameters
computationMode
computationMode
-
No updatable parameters. This function just returns.
Declaration
Swift
public func updateParams(grads: [Tensor], LR: Float)
Parameters
grads
grads
LR
LR
-
This operator has no parameters. Do nothing
Declaration
Swift
public func bindParamSymbols(_ symbols: [GraphSymbol])
-
This operator has no parameters.
Declaration
Swift
public func paramSymbols() -> [GraphSymbol]
Return Value
An empty array
-
Undocumented
Declaration
Swift
public func cpu()