Pooling2DOperator
public class Pooling2DOperator: ComputableOperator
This class is an abstract class for 2D pooling operators.
-
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 = "" // need override by child class
-
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]?
-
Pad mode, default is
PaddingMode.Valid
.Declaration
Swift
public var paddingMode: PaddingMode = PaddingMode.Valid
-
Kernel size array which contains the kernel size in each dimension.
Declaration
Swift
public var kernelSize: [Int]
-
Stride array which contains the stride in each dimension.
Declaration
Swift
public var stride: [Int]
-
CPU computation block. Two tensors are input and output tensors.
-
Channel position. Default is
ImageChannelOrder.First
Declaration
Swift
public var channelPosition: TensorChannelOrder = .First
-
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.
Declaration
Swift
public var trainable: Bool = false
-
The mapping type of this operator.
OneToOne
for this operator.Declaration
Swift
public var mapType: OperatorMappingType
-
Pool operator cannot do in-place calculation
Declaration
Swift
public var inPlaceble: Bool = false
-
if disable MPS kernel
Declaration
Swift
public var disabledMPS: Bool = false
-
init(kernelSize:stride:channelPosition:paddingMode:inputTensors:outputTensors:computationDelegate:operatorLabel:)
Initializer.
Declaration
Swift
required public init(kernelSize: [Int], stride: [Int]? = nil, channelPosition: TensorChannelOrder = TensorChannelOrder.First, paddingMode: PaddingMode = PaddingMode.Valid, inputTensors: [Tensor]? = nil, outputTensors: [Tensor]? = nil, computationDelegate: OperatorCalculationDelegate? = nil, operatorLabel: String = "Pooling")
Parameters
kernelSize
Array of int values. Should has 2 elemetns for height and width dimesnsions.
stride
Array of int values. If
stride
isnil
, it will be assigned as same value askernelSize
channelPosition
channel position in input data
paddingMode
paddingMode
inputTensors
inputTensors
outputTensors
outputTensors
computationDelegate
computationDelegate
operatorLabel
operatorLabel
-
Compute output shape according to
kernelSize
,stride
andpaddingMode
Declaration
Swift
public func outputShape(shapeArray shapes: [TensorShape]) -> [TensorShape]?
Parameters
shapes
shapes description
Return Value
return value description
-
Check validation between
inputTensors
/outputTensors
andstride
,kernelSize
.Declaration
Swift
public func inputOutputTensorsCheck() -> (check: Bool, msg: String)
Return Value
check indicating if pass checking, msg for error message.
-
Compute sync
Declaration
Swift
public func compute(_ computationMode: OperatorComputationMode)
Parameters
computationMode
computationMode
-
Compute async
Declaration
Swift
public func computeAsync(_ computationMode: OperatorComputationMode)
Parameters
computationMode
computationMode
-
Calulate grads sync. All unary operator return grads tensor with same number and shape as attribute
inputTensors
.Declaration
Swift
public func gradCompute(_ computationMode: OperatorComputationMode) -> [String: DataSymbolSupportedDataType]
Parameters
computationMode
computationMode
Return Value
return grads tensor
-
Cal grads async
Declaration
Swift
public func gradComputAsync(_ computationMode: OperatorComputationMode)
Parameters
computationMode
computationMode
-
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
-
CPU calcualtion. Call
cpuComputeBlock
which is defined in subclassDeclaration
Swift
internal func cpu()
-
GPU calculation
Declaration
Swift
internal func gpu()
-
Undocumented
Declaration
Swift
internal func gpu_kernel_MPS()