.TH "MPSCNNArithmeticGradient" 3 "Mon Jul 9 2018" "Version MetalPerformanceShaders-119.3" "MetalPerformanceShaders.framework" \" -*- nroff -*- .ad l .nh .SH NAME MPSCNNArithmeticGradient .SH SYNOPSIS .br .PP .PP \fC#import \fP .PP Inherits \fBMPSCNNGradientKernel\fP\&. .PP Inherited by \fBMPSCNNAddGradient\fP, \fBMPSCNNMultiplyGradient\fP, and \fBMPSCNNSubtractGradient\fP\&. .SS "Instance Methods" .in +1c .ti -1c .RI "(nonnull instancetype) \- \fBinitWithDevice:\fP" .br .ti -1c .RI "(nonnull instancetype) \- \fBinitWithDevice:isSecondarySourceFilter:\fP" .br .in -1c .SS "Properties" .in +1c .ti -1c .RI "float \fBprimaryScale\fP" .br .ti -1c .RI "float \fBsecondaryScale\fP" .br .ti -1c .RI "float \fBbias\fP" .br .ti -1c .RI "NSUInteger \fBsecondaryStrideInFeatureChannels\fP" .br .ti -1c .RI "float \fBminimumValue\fP" .br .ti -1c .RI "float \fBmaximumValue\fP" .br .ti -1c .RI "BOOL \fBisSecondarySourceFilter\fP" .br .in -1c .SS "Additional Inherited Members" .SH "Detailed Description" .PP This depends on Metal\&.framework The \fBMPSCNNArithmeticGradient\fP filter is the backward filter for the \fBMPSCNNArithmetic\fP forward filter\&. .PP The forward filter takes two inputs, primary and secondary source images, and produces a single output image\&. Thus, going backwards requires two separate filters (one for the primary source image and one for the secondary source image) that take multiple inputs and produce a single output\&. The secondarySourceFilter property is used to indicate whether the filter is operating on the primary or secondary source image from the forward pass\&. .PP All the arithmetic gradient filters require the following inputs: gradient image from the previous layer (going backwards) and all the applicable input source images from the forward pass\&. .PP The forward filter takes the following additional parameters: .IP "\(bu" 2 primaryStrideInPixelsX, primaryStrideInPixelsY, primaryStrideInFeatureChannels .IP "\(bu" 2 secondaryStrideInPixelsX, secondaryStrideInPixelsY, secondaryStrideInFeatureChannels These parameters can be used in the forward filter to control broadcasting for the data stored in the primary and secondary source images\&. For example, setting all strides for the primary source image to 0 will result in the primarySource image being treated as a single pixel\&. The only supported values are 0 or 1\&. The default value of these parameters is 1\&. .PP .PP The first input to the backward filter is the gradient image from the previous layer (going backwards), so there are no broadcasting parameters for this input\&. For the backward filter, the broadcasting parameters for the second input must match the broadcasting parameters set for the same image in the forward filter\&. .PP In the backward pass, broadcasting results in a reduction operation (sum) across all of the applicable broadcasting dimensions (rows, columns, feature channels, or any combination thereof) to produce the destination image of the size that matches the primary/secondary input images used in the forward pass\&. .PP In the case of no broadcasting, the following arithmetic gradient operations are copy operations (that can be optimized away by the graph interface): .IP "\(bu" 2 Add (primarySource, secondarySource) .IP "\(bu" 2 Subtract (primarySource) .PP .PP Similarly to the forward filter, this backward filter takes additional parameters: primaryScale, secondaryScale, and bias\&. The default value for primaryScale and secondaryScale is 1\&.0f\&. The default value for bias is 0\&.0f\&. This filter applies primaryScale to the primary source image, applies the secondaryScale to the secondary source image, where appropriate, and applies bias to the result, i\&.e\&.: result = ((primaryScale * x) [insert operation] (secondaryScale * y)) + bias\&. .PP The subtraction gradient filter for the secondary source image requires that the primaryScale property is set to -1\&.0f (for x - y, d/dy(x - y) = -1)\&. .PP In the forward filter, there is support for clamping the result of the available operations, where result = clamp(result, minimumValue, maximumValue)\&. The clamp backward operation is not supported in the arithmetic gradient filters\&. If you require this functionality, it can be implemented by performing a clamp backward operation before calling the arithmetic gradient filters\&. You would need to apply the following function on the incomping gradient input image: f(x) = ((minimumValue < x) && (x < maximumValue)) ? 1 : 0, where x is the original result (before clamping) of the forward arithmetic filter\&. .PP The number of output feature channels remains the same as the number of input feature channels\&. .PP You must use one of the sub-classes of MPSImageArithmeticGradient\&. .SH "Method Documentation" .PP .SS "\- (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device" Standard init with default properties per filter type .PP \fBParameters:\fP .RS 4 \fIdevice\fP The device that the filter will be used on\&. May not be NULL\&. .RE .PP \fBReturns:\fP .RS 4 \fBA\fP pointer to the newly initialized object\&. This will fail, returning nil if the device is not supported\&. Devices must be MTLFeatureSet_iOS_GPUFamily2_v1 or later\&. .RE .PP .PP Reimplemented from \fBMPSCNNGradientKernel\fP\&. .SS "\- (nonnull instancetype) \fBinitWithDevice:\fP (nonnull id< MTLDevice >) device(BOOL) isSecondarySourceFilter" .PP Reimplemented in \fBMPSCNNAddGradient\fP, \fBMPSCNNSubtractGradient\fP, and \fBMPSCNNMultiplyGradient\fP\&. .SH "Property Documentation" .PP .SS "\- (float) bias\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" .SS "\- isSecondarySourceFilter\fC [read]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" The isSecondarySourceFilter property is used to indicate whether the arithmetic gradient filter is operating on the primary or secondary source image from the forward pass\&. .SS "\- maximumValue\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" maximumValue is used to clamp the result of an arithmetic operation: result = clamp(result, minimumValue, maximumValue)\&. The default value of maximumValue is FLT_MAX\&. .SS "\- minimumValue\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" minimumValue is to clamp the result of an arithmetic operation: result = clamp(result, minimumValue, maximumValue)\&. The default value of minimumValue is -FLT_MAX\&. .SS "\- (float) primaryScale\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" .SS "\- (float) secondaryScale\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" .SS "\- (NSUInteger) secondaryStrideInFeatureChannels\fC [read]\fP, \fC [write]\fP, \fC [nonatomic]\fP, \fC [assign]\fP" .SH "Author" .PP Generated automatically by Doxygen for MetalPerformanceShaders\&.framework from the source code\&.