maxPooling2DGradient(withGradientTensor:indicesTensor:outputShape:descriptor:name:)
Creates a max-pooling gradient operation and returns the result tensor.
Declaration
func maxPooling2DGradient(withGradientTensor gradient: MPSGraphTensor, indicesTensor indices: MPSGraphTensor, outputShape: [NSNumber], descriptor: MPSGraphPooling2DOpDescriptor, name: String?) -> MPSGraphTensorParameters
- gradient:
A 2D input gradient tensor - must be of rank=4. The layout is defined by
descriptor.dataLayout. - indices:
The indices tensor returned from Maxpooling2dreturnindices(_:descriptor:name:).
- outputShape:
The shape of the destination gradient.
- descriptor:
A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates, paddings and layouts.
- name:
The name for the operation.
Return Value
Destination gradient tensor.
Discussion
With this API MPSGraph computes the max-pooling gradient efficiently by reusing the indices from the forward API instead of recomputing them. The descriptor must set returnIndicesMode and returnIndicesDataType to the same value as that set by the forward pass.