Class MPSCNNArithmeticGradient

  • All Implemented Interfaces:
    NSCoding, NSCopying, NSSecureCoding, NSObject
    Direct Known Subclasses:
    MPSCNNAddGradient, MPSCNNMultiplyGradient, MPSCNNSubtractGradient

    public class MPSCNNArithmeticGradient
    extends MPSCNNGradientKernel
    MPSCNNArithmeticGradient [@dependency] 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: - primaryStrideInPixelsX, primaryStrideInPixelsY, primaryStrideInFeatureChannels - 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. 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): - Add (primarySource, secondarySource) - Subtract (primarySource) 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.
    • Constructor Detail

      • MPSCNNArithmeticGradient

        protected MPSCNNArithmeticGradient​(org.moe.natj.general.Pointer peer)
    • Method Detail

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • allocWithZone

        public static java.lang.Object allocWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
      • automaticallyNotifiesObserversForKey

        public static boolean automaticallyNotifiesObserversForKey​(java.lang.String key)
      • bias

        public float bias()
        bias is ignored in the backward pass
      • cancelPreviousPerformRequestsWithTarget

        public static void cancelPreviousPerformRequestsWithTarget​(java.lang.Object aTarget)
      • cancelPreviousPerformRequestsWithTargetSelectorObject

        public static void cancelPreviousPerformRequestsWithTargetSelectorObject​(java.lang.Object aTarget,
                                                                                 org.moe.natj.objc.SEL aSelector,
                                                                                 java.lang.Object anArgument)
      • classFallbacksForKeyedArchiver

        public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
      • classForKeyedUnarchiver

        public static org.moe.natj.objc.Class classForKeyedUnarchiver()
      • debugDescription_static

        public static java.lang.String debugDescription_static()
      • description_static

        public static java.lang.String description_static()
      • hash_static

        public static long hash_static()
      • initWithCoderDevice

        public MPSCNNArithmeticGradient initWithCoderDevice​(NSCoder aDecoder,
                                                            java.lang.Object device)
        Description copied from class: MPSCNNGradientKernel
        NSSecureCoding compatability While the standard NSSecureCoding/NSCoding method -initWithCoder: should work, since the file can't know which device your data is allocated on, we have to guess and may guess incorrectly. To avoid that problem, use initWithCoder:device instead.
        Overrides:
        initWithCoderDevice in class MPSCNNGradientKernel
        Parameters:
        aDecoder - The NSCoder subclass with your serialized MPSKernel
        device - The MTLDevice on which to make the MPSKernel
        Returns:
        A new MPSKernel object, or nil if failure.
      • initWithDevice

        public MPSCNNArithmeticGradient initWithDevice​(java.lang.Object device)
        Description copied from class: MPSCNNGradientKernel
        Standard init with default properties per filter type
        Overrides:
        initWithDevice in class MPSCNNGradientKernel
        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.
      • instanceMethodSignatureForSelector

        public static NSMethodSignature instanceMethodSignatureForSelector​(org.moe.natj.objc.SEL aSelector)
      • instancesRespondToSelector

        public static boolean instancesRespondToSelector​(org.moe.natj.objc.SEL aSelector)
      • isSecondarySourceFilter

        public boolean isSecondarySourceFilter()
        [@property] isSecondarySourceFilter 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.
      • isSubclassOfClass

        public static boolean isSubclassOfClass​(org.moe.natj.objc.Class aClass)
      • keyPathsForValuesAffectingValueForKey

        public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey​(java.lang.String key)
      • maximumValue

        public float maximumValue()
        [@property] maximumValue 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

        public float minimumValue()
        [@property] minimumValue minimumValue is to clamp the result of an arithmetic operation: result = clamp(result, minimumValue, maximumValue). The default value of minimumValue is -FLT_MAX.
      • new_objc

        public static java.lang.Object new_objc()
      • primaryScale

        public float primaryScale()
      • resolveClassMethod

        public static boolean resolveClassMethod​(org.moe.natj.objc.SEL sel)
      • resolveInstanceMethod

        public static boolean resolveInstanceMethod​(org.moe.natj.objc.SEL sel)
      • secondaryScale

        public float secondaryScale()
      • secondaryStrideInFeatureChannels

        public long secondaryStrideInFeatureChannels()
        [@property] secondaryStrideInPixels The secondarySource stride in the feature channel dimension. The only supported values are 0 or 1. The default value for each dimension is 1.
      • setBias

        public void setBias​(float value)
        bias is ignored in the backward pass
      • setMaximumValue

        public void setMaximumValue​(float value)
        [@property] maximumValue maximumValue is used to clamp the result of an arithmetic operation: result = clamp(result, minimumValue, maximumValue). The default value of maximumValue is FLT_MAX.
      • setMinimumValue

        public void setMinimumValue​(float value)
        [@property] minimumValue minimumValue is to clamp the result of an arithmetic operation: result = clamp(result, minimumValue, maximumValue). The default value of minimumValue is -FLT_MAX.
      • setPrimaryScale

        public void setPrimaryScale​(float value)
      • setSecondaryScale

        public void setSecondaryScale​(float value)
      • setSecondaryStrideInFeatureChannels

        public void setSecondaryStrideInFeatureChannels​(long value)
        [@property] secondaryStrideInPixels The secondarySource stride in the feature channel dimension. The only supported values are 0 or 1. The default value for each dimension is 1.
      • setVersion_static

        public static void setVersion_static​(long aVersion)
      • superclass_static

        public static org.moe.natj.objc.Class superclass_static()
      • supportsSecureCoding

        public static boolean supportsSecureCoding()
      • _supportsSecureCoding

        public boolean _supportsSecureCoding()
        Description copied from interface: NSSecureCoding
        This property must return YES on all classes that allow secure coding. Subclasses of classes that adopt NSSecureCoding and override initWithCoder: must also override this method and return YES. The Secure Coding Guide should be consulted when writing methods that decode data.
        Specified by:
        _supportsSecureCoding in interface NSSecureCoding
        Overrides:
        _supportsSecureCoding in class MPSCNNGradientKernel
      • version_static

        public static long version_static()