Class MPSNNPad

  • All Implemented Interfaces:
    NSCoding, NSCopying, NSSecureCoding, NSObject

    public class MPSNNPad
    extends MPSCNNKernel
    MPSNNPad [@dependency] This depends on Metal.framework Describes a padding operation You should not use this filter to zero pad your data in the XY-plane. This filter achieves padding by copying the input image and therefore should only be used in special circumstances where the normal padding operation, defined for most filters through [@ref] MPSNNPadding, cannot achieve the necessary padding. Therefore use this filter only when you need one of the special edge modes: @ref MPSImageEdgeModeConstant, [@ref] MPSImageEdgeModeMirror, @ref MPSImageEdgeModeMirrorWithEdge or, if you need padding in the feature-channel dimesion. In other cases use to @ref MPSNNPadding for best performance. This kernel copies data from source MPSImage into the destination MPSImage allowing special padding modes to be applied. It also enables easy to use arbitrary padding area sizes when used in conjuction with @ref destinationImageDescriptorForSourceImages:sourceStates: function. There are two main ways to control the amount of padding to be added in 'x' and 'y' image dimensions: - The first one involves passing in an existing MPSImage as the destination image to the @ref MPSCNNKernel encode call, in which case the padding size in (x,y) plane is defined by the user-specified @ref clipRect and @ref offset properties of the kernel. - In the second one the destination image size and @ref clipRect and @ref offset properties of the kernel are automatically computed by calling [@ref] destinationImageDescriptorForSourceImages:sourceStates: or the -encode calls that return the resulting image from the left hand side of the call. In this case, the properties [@ref] paddingSizeBefore and @ref paddingSizeAfter together with the source image dimensions define the size of the destination image and set the correct @ref offset and @ref clipRect properties to the filter. Padding in the feature channel dimension is handled a bit differently: the amount of padding is always determined by @ref paddingSizeBefore.channel and [@ref] paddingSizeAfter.channel for this direction and the amount of feature channels filled in the destination is determined by the number of active feature channels determined by @ref sourceFeatureChannelOffset and @ref sourceFeatureChannelMaxCount and the amount of padding to be added on each side of the source. Example for feature channel indices: [@code] paddingSizeBefore.channel = 2, paddingSizeAfter.channel = 3, sourceFeatureChannelOffset = 1, sourceFeatureChannelMaxCount = 3, destinationFeatureChannelOffset = 4. We get the following padding operation: Source: |-----------------------------| | x0 | x1 | x2 | x3 | x4 | x5 | |-----------------------------| Destination: |----------------------------------------------------------------| | - | - | - | - | 0 | 0 | x1 | x2 | x3 | 0 | 0 | 0 | - | |----------------------------------------------------------------| And with @ref edgeMode = MPSImageEdgeModeMirrorWithEdge: Source: |-----------------------------| | x0 | x1 | x2 | x3 | x4 | x5 | |-----------------------------| Destination: |----------------------------------------------------------------| | - | - | - | - | x2 | x1 | x1 | x2 | x3 | x3 | x2 | x1 | - | |----------------------------------------------------------------| Here the symbols '-' denote pixels not written by the kernel. NOTE: The 'channel' coordinate and size in sourceRegion can be set to other values than those with multiple of four channels, but the @ref destinationFeatureChannelOffset property must be multiple of four, which means that there are some limitations to what can be achieved with this filter alone. [@endcode] [@NOTE] MPSNNPad is currently the only filter that supports [@ref] MPSImageEdgeModeMirror, @ref MPSImageEdgeModeMirrorWithEdge and [@ref] MPSImageEdgeModeConstant.
    • Constructor Detail

      • MPSNNPad

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

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • alloc

        public static MPSNNPad alloc()
      • allocWithZone

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

        public static boolean automaticallyNotifiesObserversForKey​(java.lang.String key)
      • 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()
      • fillValue

        public float fillValue()
        [@property] fillValue Determines the constant value to apply when using @ref MPSImageEdgeModeConstant. Default: 0.0f. NOTE: this value is ignored if the filter is initialized with a per-channel fill value using @ref initWithDevice:paddingSizeBefore:paddingSizeAfter:fillValueArray:.
      • hash_static

        public static long hash_static()
      • initWithCoderDevice

        public MPSNNPad initWithCoderDevice​(NSCoder aDecoder,
                                            java.lang.Object device)
        NSSecureCoding compatability See @ref MPSKernel#initWithCoder.
        Overrides:
        initWithCoderDevice in class MPSCNNKernel
        Parameters:
        aDecoder - The NSCoder subclass with your serialized MPSNNPad
        device - The MTLDevice on which to make the MPSNNPad
        Returns:
        A new MPSNNPad object, or nil if failure.
      • initWithDevice

        public MPSNNPad initWithDevice​(java.lang.Object device)
        Initialize a MPSNNPad kernel
        Overrides:
        initWithDevice in class MPSCNNKernel
        Parameters:
        device - The device the filter will run on.
        Returns:
        A valid MPSNNPad object or nil, if failure.
      • initWithDevicePaddingSizeBeforePaddingSizeAfter

        public MPSNNPad initWithDevicePaddingSizeBeforePaddingSizeAfter​(MTLDevice device,
                                                                        MPSImageCoordinate paddingSizeBefore,
                                                                        MPSImageCoordinate paddingSizeAfter)
        Initialize a MPSNNPad kernel
        Parameters:
        device - The device the filter will run on
        paddingSizeBefore - The amount of padding to add before the source image - see details above.
        paddingSizeAfter - The amount of padding to add after the source image - see details above.
        Returns:
        A valid MPSNNPad object or nil, if failure.
      • initWithDevicePaddingSizeBeforePaddingSizeAfterFillValueArray

        public MPSNNPad initWithDevicePaddingSizeBeforePaddingSizeAfterFillValueArray​(MTLDevice device,
                                                                                      MPSImageCoordinate paddingSizeBefore,
                                                                                      MPSImageCoordinate paddingSizeAfter,
                                                                                      NSData fillValueArray)
        Initialize a MPSNNPad kernel
        Parameters:
        device - The device the filter will run on
        paddingSizeBefore - The amount of padding to add before the source image - see details above.
        paddingSizeAfter - The amount of padding to add after the source image - see details above.
        fillValueArray - A NSData containing a float array to use with @ref MPSImageEdgeModeConstant. The first value of the array will correspond to the first feature channel written out to the destination image and the number of float values in the data must be at least as large as the number of feature channels written onto the destination by the filter. Failing to pass a large enough array will result in undefined behavior. Passing in nil is fine.
        Returns:
        A valid MPSNNPad object or nil, if failure.
      • instanceMethodSignatureForSelector

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

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

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

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

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

        public MPSImageCoordinate paddingSizeAfter()
        [@property] paddingSizeAfter This property is used for automatically sizing the destination image for the function @ref destinationImageDescriptorForSourceImages:sourceStates:. Defines how much padding to assign on the right, bottom and higher feature channel indices of the image. NOTE: the x and y coordinates of this property are only used through @ref destinationImageDescriptorForSourceImages:sourceStates:, since the clipRect and offset together define the padding sizes in those directions, but the 'channel' size defines the amount of padding to be applied in the feature channel dimension after source feature channel index determined by the sum of [@ref] sourceFeatureChannelOffset and @ref sourceFeatureChannelMaxCount, naturally clipped to fit the feature channels in the provided source image. Default: { 0, 0, 0 }
      • paddingSizeBefore

        public MPSImageCoordinate paddingSizeBefore()
        [@property] paddingSizeBefore This property is used for automatically sizing the destination image for the function @ref destinationImageDescriptorForSourceImages:sourceStates:. Defines how much padding to assign on the left, top and smaller feature channel indices of the image. NOTE: the x and y coordinates of this property are only used through @ref destinationImageDescriptorForSourceImages:sourceStates:, since the clipRect and offset together define the padding sizes in those directions, but the 'channel' size defines the amount of padding to be applied in the feature channel dimension, before the feature channels starting from feature channel index @ref sourceFeatureChannelOffset. Default: { 0, 0, 0 }
      • resolveClassMethod

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

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

        public void setFillValue​(float value)
        [@property] fillValue Determines the constant value to apply when using @ref MPSImageEdgeModeConstant. Default: 0.0f. NOTE: this value is ignored if the filter is initialized with a per-channel fill value using @ref initWithDevice:paddingSizeBefore:paddingSizeAfter:fillValueArray:.
      • setPaddingSizeAfter

        public void setPaddingSizeAfter​(MPSImageCoordinate value)
        [@property] paddingSizeAfter This property is used for automatically sizing the destination image for the function @ref destinationImageDescriptorForSourceImages:sourceStates:. Defines how much padding to assign on the right, bottom and higher feature channel indices of the image. NOTE: the x and y coordinates of this property are only used through @ref destinationImageDescriptorForSourceImages:sourceStates:, since the clipRect and offset together define the padding sizes in those directions, but the 'channel' size defines the amount of padding to be applied in the feature channel dimension after source feature channel index determined by the sum of [@ref] sourceFeatureChannelOffset and @ref sourceFeatureChannelMaxCount, naturally clipped to fit the feature channels in the provided source image. Default: { 0, 0, 0 }
      • setPaddingSizeBefore

        public void setPaddingSizeBefore​(MPSImageCoordinate value)
        [@property] paddingSizeBefore This property is used for automatically sizing the destination image for the function @ref destinationImageDescriptorForSourceImages:sourceStates:. Defines how much padding to assign on the left, top and smaller feature channel indices of the image. NOTE: the x and y coordinates of this property are only used through @ref destinationImageDescriptorForSourceImages:sourceStates:, since the clipRect and offset together define the padding sizes in those directions, but the 'channel' size defines the amount of padding to be applied in the feature channel dimension, before the feature channels starting from feature channel index @ref sourceFeatureChannelOffset. Default: { 0, 0, 0 }
      • 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 MPSCNNKernel
      • version_static

        public static long version_static()