MPSCNNArithmeticGradient(3) MetalPerformanceShaders.framework MPSCNNArithmeticGradient(3)

MPSCNNArithmeticGradient

#import <MPSCNNMath.h>

Inherits MPSCNNGradientKernel.

Inherited by MPSCNNAddGradient, MPSCNNMultiplyGradient, and MPSCNNSubtractGradient.


(nonnull instancetype) - initWithDevice:
(nonnull instancetype) - initWithDevice:isSecondarySourceFilter:


float primaryScale
float secondaryScale
float bias
NSUInteger secondaryStrideInFeatureChannels
float minimumValue
float maximumValue
BOOL isSecondarySourceFilter

This depends on Metal.framework The MPSCNNArithmeticGradient filter is the backward filter for the MPSCNNArithmetic forward filter.

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.

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.

The forward filter takes the following additional parameters:

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.

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.

In the case of no broadcasting, the following arithmetic gradient operations are copy operations (that can be optimized away by the graph interface):

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.

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).

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.

The number of output feature channels remains the same as the number of input feature channels.

You must use one of the sub-classes of MPSImageArithmeticGradient.

- (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device

Standard init with default properties per filter type

Parameters:

device The device that the filter will be used on. May not be NULL.

Returns:

A 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.

Reimplemented from MPSCNNGradientKernel.

- (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device(BOOL) isSecondarySourceFilter

Reimplemented in MPSCNNAddGradient, MPSCNNSubtractGradient, and MPSCNNMultiplyGradient.

- (float) bias [read], [write], [nonatomic], [assign]

- isSecondarySourceFilter [read], [nonatomic], [assign]

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.

- maximumValue [read], [write], [nonatomic], [assign]

maximumValue is used to clamp the result of an arithmetic operation: result = clamp(result, minimumValue, maximumValue). The default value of maximumValue is FLT_MAX.

- minimumValue [read], [write], [nonatomic], [assign]

minimumValue is to clamp the result of an arithmetic operation: result = clamp(result, minimumValue, maximumValue). The default value of minimumValue is -FLT_MAX.

- (float) primaryScale [read], [write], [nonatomic], [assign]

- (float) secondaryScale [read], [write], [nonatomic], [assign]

- (NSUInteger) secondaryStrideInFeatureChannels [read], [write], [nonatomic], [assign]

Generated automatically by Doxygen for MetalPerformanceShaders.framework from the source code.

Mon Jul 9 2018 Version MetalPerformanceShaders-119.3