MPSCNNDropoutGradient

Struct MPSCNNDropoutGradient 

Source
pub struct MPSCNNDropoutGradient { /* private fields */ }
Available on crate features MPSCNNDropout and MPSCNNKernel and MPSCore and MPSKernel only.
Expand description

Dependencies: This depends on Metal.framework

This filter is the backward filter for the MPSCNNDropout forward filter. It requires the mask data, along with all the associated parameters used to generate the mask, from the forward pass. The mask is associated with a MPSCNNDropoutGradientState object.

In this kernel, use the secondaryOffset to apply an offset to the mask data.

See also Apple’s documentation

Implementations§

Source§

impl MPSCNNDropoutGradient

Source

pub unsafe fn keepProbability(&self) -> c_float

Available on crate feature MPSNeuralNetwork only.

The probability that each element in the input is kept. The valid range is (0.0f, 1.0f).

Source

pub unsafe fn seed(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

The seed used to generate random numbers.

Source

pub unsafe fn maskStrideInPixels(&self) -> MTLSize

Available on crate feature MPSNeuralNetwork only.

The mask stride in the x, y, and x dimensions, which allows for the broadcasting the mask data.

The only valid values are 0 and 1 for each dimension. For no broadcasting, set the values for each dimension to 1. For broadcasting, set desired values to 0.

Source

pub unsafe fn initWithDevice( this: Allocated<Self>, device: &ProtocolObject<dyn MTLDevice>, ) -> Retained<Self>

Available on crate feature MPSNeuralNetwork only.
Source

pub unsafe fn initWithCoder_device( this: Allocated<Self>, a_decoder: &NSCoder, device: &ProtocolObject<dyn MTLDevice>, ) -> Option<Retained<Self>>

Available on crate feature MPSNeuralNetwork only.

<NSSecureCoding

support

§Safety

a_decoder possibly has further requirements.

Source

pub unsafe fn initWithDevice_keepProbability_seed_maskStrideInPixels( this: Allocated<Self>, device: &ProtocolObject<dyn MTLDevice>, keep_probability: c_float, seed: NSUInteger, mask_stride_in_pixels: MTLSize, ) -> Retained<Self>

Available on crate feature MPSNeuralNetwork only.

Standard init with default properties per filter type.

Parameter device: The device that the filter will be used on.

Parameter keepProbability: The probability that each element in the input is kept. The valid range is (0.0f, 1.0f).

Parameter seed: The seed used to generate random numbers.

Parameter maskStrideInPixels: The mask stride in the x, y, and z dimensions, which allows for the broadcasting of mask data. The only valid values are 0 and 1 for each dimension. For no broadcasting, set the values for each dimension to 1. For broadcasting, set desired values to 0.

Returns: A valid MPSCNNDropoutGradient object or nil, if failure.

Source§

impl MPSCNNDropoutGradient

Methods declared on superclass MPSKernel.

Source

pub unsafe fn initWithCoder( this: Allocated<Self>, a_decoder: &NSCoder, ) -> Option<Retained<Self>>

Available on crate feature MPSNeuralNetwork only.

Called by NSCoder to decode MPSKernels

This isn’t the right interface to decode a MPSKernel, but it is the one that NSCoder uses. To enable your NSCoder (e.g. NSKeyedUnarchiver) to set which device to use extend the object to adopt the MPSDeviceProvider protocol. Otherwise, the Metal system default device will be used.

§Safety

a_decoder possibly has further requirements.

Source§

impl MPSCNNDropoutGradient

Methods declared on superclass NSObject.

Source

pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>

Available on crate feature MPSNeuralNetwork only.
Source

pub unsafe fn new() -> Retained<Self>

Available on crate feature MPSNeuralNetwork only.

Methods from Deref<Target = MPSCNNGradientKernel>§

Source

pub unsafe fn kernelOffsetX(&self) -> NSInteger

Available on crate feature MPSNeuralNetwork only.

Offset in the kernel reference frame to position the kernel in the X dimension

In some cases, the input gradient must be upsampled with zero insertion to account for things like strides in the forward MPSCNNKernel pass. As such, the offset, which describes a X,Y offset in the source coordinate space is insufficient to fully describe the offset applied to a kernel. The kernel offset is the offset after upsampling. Both the source offset and kernel offset are additive: effective offset = source offset * stride + kernel offset. The offset is applied to the (upsampled) source gradient

Source

pub unsafe fn setKernelOffsetX(&self, kernel_offset_x: NSInteger)

Available on crate feature MPSNeuralNetwork only.

Setter for kernelOffsetX.

Source

pub unsafe fn kernelOffsetY(&self) -> NSInteger

Available on crate feature MPSNeuralNetwork only.

Offset in the kernel reference frame to position the kernel in the Y dimension

In some cases, the input gradient must be upsampled with zero insertion to account for things like strides in the forward MPSCNNKernel pass. As such, the offset, which describes a X,Y offset in the source coordinate space is insufficient to fully describe the offset applied to a kernel. The kernel offset is the offset after upsampling. Both the source offset and kernel offset are additive: effective offset = source offset * stride + kernel offset. The offset is applied to the (upsampled) source gradient

Source

pub unsafe fn setKernelOffsetY(&self, kernel_offset_y: NSInteger)

Available on crate feature MPSNeuralNetwork only.

Setter for kernelOffsetY.

Source

pub unsafe fn encodeToCommandBuffer_sourceGradient_sourceImage_gradientState( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, source_gradient: &MPSImage, source_image: &MPSImage, gradient_state: &MPSState, ) -> Retained<MPSImage>

Available on crate features MPSNeuralNetwork and MPSImage and MPSState only.

Encode a gradient filter and return a gradient

During training, gradient filters are used to calculate the gradient associated with the loss for each feature channel in the forward pass source image. For those nodes that are trainable, these are then used to refine the value used in the trainable parameter. They consume a source gradient image which contains the gradients corresponding with the forward pass destination image, and calculate the gradients corresponding to the forward pass source image.

A gradient filter consumes a MPSNNGradientState object which captured various forward pass properties such as offset and edgeMode at the time the forward pass was encoded. These are transferred to the MPSCNNBinaryKernel secondary image properties automatically when this method creates its destination image.

Parameter commandBuffer: The MTLCommandBuffer on which to encode

Parameter sourceGradient: The gradient image from the “next” filter in the graph (in the inference direction)

Parameter sourceImage: The image used as source image by the forward inference pass

Parameter gradientState: The MPSNNGradientState or MPSNNBinaryGradientState subclass produced by the forward inference pass

Returns: The result gradient from the gradient filter

Source

pub unsafe fn encodeToCommandBuffer_sourceGradient_sourceImage_gradientState_destinationGradient( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, source_gradient: &MPSImage, source_image: &MPSImage, gradient_state: &MPSState, destination_gradient: &MPSImage, )

Available on crate features MPSNeuralNetwork and MPSImage and MPSState only.

Encode a gradient filter and return a gradient

During training, gradient filters are used to calculate the gradient associated with the loss for each feature channel in the forward pass source image. For those nodes that are trainable, these are then used to refine the value used in the trainable parameter. They consume a source gradient image which contains the gradients corresponding with the forward pass destination image, and calculate the gradients corresponding to the forward pass source image.

A gradient filter consumes a MPSNNGradientState object which captured various forward pass properties such as offset and edgeMode at the time the forward pass was encoded. These are transferred to the MPSCNNBinaryKernel secondary image properties automatically when you use -[MPSCNNGradientKernel destinationImageDescriptorForSourceImages:sourceStates:]. If you do not call this method, then you are responsible for configuring all of the primary and secondary image properties in MPSCNNBinaryKernel. Please see class description for expected ordering of operations.

Parameter commandBuffer: The MTLCommandBuffer on which to encode

Parameter sourceGradient: The gradient image from the “next” filter in the graph

Parameter sourceImage: The image used as source image from the forward pass

Parameter gradientState: The MPSNNGradientState and MPSNNBinaryGradientState subclass produced by the forward pass

Parameter destinationGradient: The MPSImage into which to write the filter result

Source

pub unsafe fn encodeBatchToCommandBuffer_sourceGradients_sourceImages_gradientStates( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, source_gradients: &MPSImageBatch, source_images: &MPSImageBatch, gradient_states: &MPSStateBatch, ) -> Retained<MPSImageBatch>

Available on crate features MPSNeuralNetwork and MPSImage and MPSNDArray and MPSState only.

Encode a gradient filter and return a gradient

During training, gradient filters are used to calculate the gradient associated with the loss for each feature channel in the forward pass source image. For those nodes that are trainable, these are then used to refine the value used in the trainable parameter. They consume a source gradient image which contains the gradients corresponding with the forward pass destination image, and calculate the gradients corresponding to the forward pass source image.

A gradient filter consumes a MPSNNGradientState object which captured various forward pass properties such as offset and edgeMode at the time the forward pass was encoded. These are transferred to the MPSCNNBinaryKernel secondary image properties automatically when this method creates its destination image.

Parameter commandBuffer: The MTLCommandBuffer on which to encode

Parameter sourceGradients: The gradient images from the “next” filter in the graph

Parameter sourceImages: The images used as source image from the forward pass

Parameter gradientStates: The MPSNNGradientState or MPSNNBinaryGradientState subclass produced by the forward pass

Source

pub unsafe fn encodeBatchToCommandBuffer_sourceGradients_sourceImages_gradientStates_destinationGradients( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, source_gradients: &MPSImageBatch, source_images: &MPSImageBatch, gradient_states: &MPSStateBatch, destination_gradients: &MPSImageBatch, )

Available on crate features MPSNeuralNetwork and MPSImage and MPSNDArray and MPSState only.

Encode a gradient filter and return a gradient

During training, gradient filters are used to calculate the gradient associated with the loss for each feature channel in the forward pass source image. For those nodes that are trainable, these are then used to refine the value used in the trainable parameter. They consume a source gradient image which contains the gradients corresponding with the forward pass destination image, and calculate the gradients corresponding to the forward pass source image.

A gradient filter consumes a MPSNNGradientState object which captured various forward pass properties such as offset and edgeMode at the time the forward pass was encoded. These are transferred to the MPSCNNBinaryKernel secondary image properties automatically when you use -[MPSCNNGradientKernel destinationImageDescriptorForSourceImages:sourceStates:]. If you do not call this method, then you are responsible for configuring all of the primary and secondary image properties in MPSCNNBinaryKernel. Please see class description for expected ordering of operations.

Parameter commandBuffer: The MTLCommandBuffer on which to encode

Parameter sourceGradients: The gradient images from the “next” filter in the graph

Parameter sourceImages: The image used as source images from the forward pass

Parameter gradientStates: An array of the MPSNNGradientState or MPSNNBinaryGradientState subclass produced by the forward pass

Parameter destinationGradients: The MPSImages into which to write the filter result

Methods from Deref<Target = MPSCNNBinaryKernel>§

Source

pub unsafe fn primaryOffset(&self) -> MPSOffset

Available on crate features MPSNeuralNetwork and MPSCoreTypes only.

The position of the destination clip rectangle origin relative to the primary source buffer.

The offset is defined to be the position of clipRect.origin in source coordinates. Default: {0,0,0}, indicating that the top left corners of the clipRect and primary source image align. offset.z is the index of starting source image in batch processing mode.

See Also: subsubsection_mpsoffset

Source

pub unsafe fn setPrimaryOffset(&self, primary_offset: MPSOffset)

Available on crate features MPSNeuralNetwork and MPSCoreTypes only.

Setter for primaryOffset.

Source

pub unsafe fn secondaryOffset(&self) -> MPSOffset

Available on crate features MPSNeuralNetwork and MPSCoreTypes only.

The position of the destination clip rectangle origin relative to the secondary source buffer.

The offset is defined to be the position of clipRect.origin in source coordinates. Default: {0,0,0}, indicating that the top left corners of the clipRect and secondary source image align. offset.z is the index of starting source image in batch processing mode.

See Also: subsubsection_mpsoffset

Source

pub unsafe fn setSecondaryOffset(&self, secondary_offset: MPSOffset)

Available on crate features MPSNeuralNetwork and MPSCoreTypes only.

Setter for secondaryOffset.

Source

pub unsafe fn clipRect(&self) -> MTLRegion

Available on crate feature MPSNeuralNetwork only.

An optional clip rectangle to use when writing data. Only the pixels in the rectangle will be overwritten.

A MTLRegion that indicates which part of the destination to overwrite. If the clipRect does not lie completely within the destination image, the intersection between clip rectangle and destination bounds is used. Default: MPSRectNoClip (MPSKernel::MPSRectNoClip) indicating the entire image. clipRect.origin.z is the index of starting destination image in batch processing mode. clipRect.size.depth is the number of images to process in batch processing mode.

See Also: subsubsection_clipRect

Source

pub unsafe fn setClipRect(&self, clip_rect: MTLRegion)

Available on crate feature MPSNeuralNetwork only.

Setter for clipRect.

Source

pub unsafe fn destinationFeatureChannelOffset(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

The number of channels in the destination MPSImage to skip before writing output.

This is the starting offset into the destination image in the feature channel dimension at which destination data is written. This allows an application to pass a subset of all the channels in MPSImage as output of MPSKernel. E.g. Suppose MPSImage has 24 channels and a MPSKernel outputs 8 channels. If we want channels 8 to 15 of this MPSImage to be used as output, we can set destinationFeatureChannelOffset = 8. Note that this offset applies independently to each image when the MPSImage is a container for multiple images and the MPSCNNKernel is processing multiple images (clipRect.size.depth > 1). The default value is 0 and any value specifed shall be a multiple of 4. If MPSKernel outputs N channels, destination image MUST have at least destinationFeatureChannelOffset + N channels. Using a destination image with insufficient number of feature channels result in an error. E.g. if the MPSCNNConvolution outputs 32 channels, and destination has 64 channels, then it is an error to set destinationFeatureChannelOffset > 32.

Source

pub unsafe fn setDestinationFeatureChannelOffset( &self, destination_feature_channel_offset: NSUInteger, )

Available on crate feature MPSNeuralNetwork only.
Source

pub unsafe fn primarySourceFeatureChannelOffset(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

The number of channels in the primary source MPSImage to skip before reading the input.

This is the starting offset into the primary source image in the feature channel dimension at which source data is read. Unit: feature channels This allows an application to read a subset of all the channels in MPSImage as input of MPSKernel. E.g. Suppose MPSImage has 24 channels and a MPSKernel needs to read 8 channels. If we want channels 8 to 15 of this MPSImage to be used as input, we can set primarySourceFeatureChannelOffset = 8. Note that this offset applies independently to each image when the MPSImage is a container for multiple images and the MPSCNNKernel is processing multiple images (clipRect.size.depth > 1). The default value is 0 and any value specifed shall be a multiple of 4. If MPSKernel inputs N channels, the source image MUST have at least primarySourceFeatureChannelOffset + N channels. Using a source image with insufficient number of feature channels will result in an error. E.g. if the MPSCNNConvolution inputs 32 channels, and the source has 64 channels, then it is an error to set primarySourceFeatureChannelOffset > 32.

Source

pub unsafe fn setPrimarySourceFeatureChannelOffset( &self, primary_source_feature_channel_offset: NSUInteger, )

Available on crate feature MPSNeuralNetwork only.
Source

pub unsafe fn secondarySourceFeatureChannelOffset(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

The number of channels in the secondary source MPSImage to skip before reading the input.

This is the starting offset into the secondary source image in the feature channel dimension at which source data is read. Unit: feature channels This allows an application to read a subset of all the channels in MPSImage as input of MPSKernel. E.g. Suppose MPSImage has 24 channels and a MPSKernel needs to read 8 channels. If we want channels 8 to 15 of this MPSImage to be used as input, we can set secondarySourceFeatureChannelOffset = 8. Note that this offset applies independently to each image when the MPSImage is a container for multiple images and the MPSCNNKernel is processing multiple images (clipRect.size.depth > 1). The default value is 0 and any value specifed shall be a multiple of 4. If MPSKernel inputs N channels, the source image MUST have at least primarySourceFeatureChannelOffset + N channels. Using a source image with insufficient number of feature channels will result in an error. E.g. if the MPSCNNConvolution inputs 32 channels, and the source has 64 channels, then it is an error to set primarySourceFeatureChannelOffset > 32.

Source

pub unsafe fn setSecondarySourceFeatureChannelOffset( &self, secondary_source_feature_channel_offset: NSUInteger, )

Available on crate feature MPSNeuralNetwork only.
Source

pub unsafe fn primarySourceFeatureChannelMaxCount(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

The maximum number of channels in the primary source MPSImage to use

Most filters can insert a slice operation into the filter for free. Use this to limit the size of the feature channel slice taken from the input image. If the value is too large, it is truncated to be the remaining size in the image after the sourceFeatureChannelOffset is taken into account. Default: ULONG_MAX

Source

pub unsafe fn setPrimarySourceFeatureChannelMaxCount( &self, primary_source_feature_channel_max_count: NSUInteger, )

Available on crate feature MPSNeuralNetwork only.
Source

pub unsafe fn secondarySourceFeatureChannelMaxCount(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

The maximum number of channels in the secondary source MPSImage to use

Most filters can insert a slice operation into the filter for free. Use this to limit the size of the feature channel slice taken from the input image. If the value is too large, it is truncated to be the remaining size in the image after the sourceFeatureChannelOffset is taken into account. Default: ULONG_MAX

Source

pub unsafe fn setSecondarySourceFeatureChannelMaxCount( &self, secondary_source_feature_channel_max_count: NSUInteger, )

Available on crate feature MPSNeuralNetwork only.
Source

pub unsafe fn primaryEdgeMode(&self) -> MPSImageEdgeMode

Available on crate features MPSNeuralNetwork and MPSCoreTypes only.

The MPSImageEdgeMode to use when texture reads stray off the edge of the primary source image

Most MPSKernel objects can read off the edge of the source image. This can happen because of a negative offset property, because the offset + clipRect.size is larger than the source image or because the filter looks at neighboring pixels, such as a Convolution filter. Default: MPSImageEdgeModeZero.

See Also: subsubsection_edgemode

Source

pub unsafe fn setPrimaryEdgeMode(&self, primary_edge_mode: MPSImageEdgeMode)

Available on crate features MPSNeuralNetwork and MPSCoreTypes only.

Setter for primaryEdgeMode.

Source

pub unsafe fn secondaryEdgeMode(&self) -> MPSImageEdgeMode

Available on crate features MPSNeuralNetwork and MPSCoreTypes only.

The MPSImageEdgeMode to use when texture reads stray off the edge of the primary source image

Most MPSKernel objects can read off the edge of the source image. This can happen because of a negative offset property, because the offset + clipRect.size is larger than the source image or because the filter looks at neighboring pixels, such as a Convolution filter. Default: MPSImageEdgeModeZero.

See Also: subsubsection_edgemode

Source

pub unsafe fn setSecondaryEdgeMode(&self, secondary_edge_mode: MPSImageEdgeMode)

Available on crate features MPSNeuralNetwork and MPSCoreTypes only.

Setter for secondaryEdgeMode.

Source

pub unsafe fn primaryKernelWidth(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

The width of the MPSCNNBinaryKernel filter window

This is the horizontal diameter of the region read by the filter for each result pixel. If the MPSCNNKernel does not have a filter window, then 1 will be returned.

Source

pub unsafe fn primaryKernelHeight(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

The height of the MPSCNNBinaryKernel filter window

This is the vertical diameter of the region read by the filter for each result pixel. If the MPSCNNKernel does not have a filter window, then 1 will be returned.

Source

pub unsafe fn secondaryKernelWidth(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

The width of the MPSCNNBinaryKernel filter window for the second image source

This is the horizontal diameter of the region read by the filter for each result pixel. If the MPSCNNBinaryKernel does not have a filter window, then 1 will be returned.

Source

pub unsafe fn secondaryKernelHeight(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

The height of the MPSCNNBinaryKernel filter window for the second image source

This is the vertical diameter of the region read by the filter for each result pixel. If the MPSCNNBinaryKernel does not have a filter window, then 1 will be returned.

Source

pub unsafe fn primaryStrideInPixelsX(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

The downsampling (or upsampling if a backwards filter) factor in the horizontal dimension for the primary source image

If the filter does not do up or downsampling, 1 is returned.

Source

pub unsafe fn setPrimaryStrideInPixelsX( &self, primary_stride_in_pixels_x: NSUInteger, )

Available on crate feature MPSNeuralNetwork only.
Source

pub unsafe fn primaryStrideInPixelsY(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

The downsampling (or upsampling if a backwards filter) factor in the vertical dimension for the primary source image

If the filter does not do up or downsampling, 1 is returned.

Source

pub unsafe fn setPrimaryStrideInPixelsY( &self, primary_stride_in_pixels_y: NSUInteger, )

Available on crate feature MPSNeuralNetwork only.
Source

pub unsafe fn secondaryStrideInPixelsX(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

The downsampling (or upsampling if a backwards filter) factor in the horizontal dimension for the secondary source image

If the filter does not do up or downsampling, 1 is returned.

Source

pub unsafe fn setSecondaryStrideInPixelsX( &self, secondary_stride_in_pixels_x: NSUInteger, )

Available on crate feature MPSNeuralNetwork only.
Source

pub unsafe fn secondaryStrideInPixelsY(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

The downsampling (or upsampling if a backwards filter) factor in the vertical dimension for the secondary source image

If the filter does not do up or downsampling, 1 is returned.

Source

pub unsafe fn setSecondaryStrideInPixelsY( &self, secondary_stride_in_pixels_y: NSUInteger, )

Available on crate feature MPSNeuralNetwork only.
Source

pub unsafe fn primaryDilationRateX(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

Stride in source coordinates from one kernel tap to the next in the X dimension.

Source

pub unsafe fn primaryDilationRateY(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

Stride in source coordinates from one kernel tap to the next in the Y dimension.

Source

pub unsafe fn secondaryDilationRateX(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

Stride in source coordinates from one kernel tap to the next in the X dimension.

As applied to the secondary source image.

Source

pub unsafe fn secondaryDilationRateY(&self) -> NSUInteger

Available on crate feature MPSNeuralNetwork only.

Stride in source coordinates from one kernel tap to the next in the Y dimension.

As applied to the secondary source image.

Source

pub unsafe fn isBackwards(&self) -> bool

Available on crate feature MPSNeuralNetwork only.

YES if the filter operates backwards.

This influences how strideInPixelsX/Y should be interpreted.

Source

pub unsafe fn isStateModified(&self) -> bool

Available on crate feature MPSNeuralNetwork only.

Returns true if the -encode call modifies the state object it accepts.

Source

pub unsafe fn padding(&self) -> Retained<ProtocolObject<dyn MPSNNPadding>>

Available on crate features MPSNeuralNetwork and MPSNeuralNetworkTypes only.

The padding method used by the filter

This influences how strideInPixelsX/Y should be interpreted. Default: MPSNNPaddingMethodAlignCentered | MPSNNPaddingMethodAddRemainderToTopLeft | MPSNNPaddingMethodSizeSame Some object types (e.g. MPSCNNFullyConnected) may override this default with something appropriate to its operation.

Source

pub unsafe fn setPadding(&self, padding: &ProtocolObject<dyn MPSNNPadding>)

Available on crate features MPSNeuralNetwork and MPSNeuralNetworkTypes only.

Setter for padding.

Source

pub unsafe fn destinationImageAllocator( &self, ) -> Retained<ProtocolObject<dyn MPSImageAllocator>>

Available on crate features MPSNeuralNetwork and MPSImage only.

Method to allocate the result image for -encodeToCommandBuffer:sourceImage:

Default: MPSTemporaryImage.defaultAllocator

Source

pub unsafe fn setDestinationImageAllocator( &self, destination_image_allocator: &ProtocolObject<dyn MPSImageAllocator>, )

Available on crate features MPSNeuralNetwork and MPSImage only.
Source

pub unsafe fn encodeToCommandBuffer_primaryImage_secondaryImage_destinationImage( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, primary_image: &MPSImage, secondary_image: &MPSImage, destination_image: &MPSImage, )

Available on crate features MPSNeuralNetwork and MPSImage only.

Encode a MPSCNNKernel into a command Buffer. The operation shall proceed out-of-place.

This is the older style of encode which reads the offset, doesn’t change it, and ignores the padding method.

Parameter commandBuffer: A valid MTLCommandBuffer to receive the encoded filter

Parameter primaryImage: A valid MPSImage object containing the primary source image.

Parameter secondaryImage: A valid MPSImage object containing the secondary source image.

Parameter destinationImage: A valid MPSImage to be overwritten by result image. destinationImage may not alias primarySourceImage or secondarySourceImage.

Source

pub unsafe fn encodeBatchToCommandBuffer_primaryImages_secondaryImages_destinationImages( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, primary_images: &MPSImageBatch, secondary_images: &MPSImageBatch, destination_images: &MPSImageBatch, )

Available on crate features MPSNeuralNetwork and MPSImage and MPSNDArray only.

Encode a MPSCNNKernel into a command Buffer. The operation shall proceed out-of-place.

This is the older style of encode which reads the offset, doesn’t change it, and ignores the padding method. Multiple images are processed concurrently. All images must have MPSImage.numberOfImages = 1.

Parameter commandBuffer: A valid MTLCommandBuffer to receive the encoded filter

Parameter primaryImages: An array of MPSImage objects containing the primary source images.

Parameter secondaryImages: An array MPSImage objects containing the secondary source images.

Parameter destinationImages: An array of MPSImage objects to contain the result images. destinationImages may not alias primarySourceImages or secondarySourceImages in any manner.

Source

pub unsafe fn encodeToCommandBuffer_primaryImage_secondaryImage( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, primary_image: &MPSImage, secondary_image: &MPSImage, ) -> Retained<MPSImage>

Available on crate features MPSNeuralNetwork and MPSImage only.

Encode a MPSCNNKernel into a command Buffer. Create a texture to hold the result and return it.

In the first iteration on this method, encodeToCommandBuffer:sourceImage:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself.

This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h.

Parameter commandBuffer: The command buffer

Parameter primaryImage: A MPSImages to use as the primary source images for the filter.

Parameter secondaryImage: A MPSImages to use as the secondary source images for the filter.

Returns: A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

Source

pub unsafe fn encodeBatchToCommandBuffer_primaryImages_secondaryImages( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, primary_image: &MPSImageBatch, secondary_image: &MPSImageBatch, ) -> Retained<MPSImageBatch>

Available on crate features MPSNeuralNetwork and MPSImage and MPSNDArray only.

Encode a MPSCNNKernel into a command Buffer. Create textures to hold the results and return them.

In the first iteration on this method, encodeBatchToCommandBuffer:sourceImage:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself.

This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. All images in a batch must have MPSImage.numberOfImages = 1.

Parameter commandBuffer: The command buffer

Parameter primaryImage: A MPSImages to use as the primary source images for the filter.

Parameter secondaryImage: A MPSImages to use as the secondary source images for the filter.

Returns: A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

Source

pub unsafe fn encodeToCommandBuffer_primaryImage_secondaryImage_destinationState_destinationStateIsTemporary( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, primary_image: &MPSImage, secondary_image: &MPSImage, out_state: &mut Option<Retained<MPSState>>, is_temporary: bool, ) -> Retained<MPSImage>

Available on crate features MPSNeuralNetwork and MPSImage and MPSState only.

Encode a MPSCNNKernel into a command Buffer. Create a texture and state to hold the results and return them.

In the first iteration on this method, encodeToCommandBuffer:sourceImage:destinationState:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself.

This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. All images in a batch must have MPSImage.numberOfImages = 1.

Parameter commandBuffer: The command buffer

Parameter primaryImage: A MPSImage to use as the source images for the filter.

Parameter secondaryImage: A MPSImage to use as the source images for the filter.

Parameter outState: The address of location to write the pointer to the result state of the operation

Parameter isTemporary: YES if the outState should be a temporary object

Returns: A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The offset property will be adjusted to reflect the offset used during the encode. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

Source

pub unsafe fn encodeBatchToCommandBuffer_primaryImages_secondaryImages_destinationStates_destinationStateIsTemporary( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, primary_images: &MPSImageBatch, secondary_images: &MPSImageBatch, out_state: &mut Option<Retained<MPSStateBatch>>, is_temporary: bool, ) -> Retained<MPSImageBatch>

Available on crate features MPSNeuralNetwork and MPSImage and MPSNDArray and MPSState only.

Encode a MPSCNNKernel into a command Buffer. Create a texture and state to hold the results and return them.

In the first iteration on this method, encodeToCommandBuffer:sourceImage:destinationState:destinationImage: some work was left for the developer to do in the form of correctly setting the offset property and sizing the result buffer. With the introduction of the padding policy (see padding property) the filter can do this work itself. If you would like to have some input into what sort of MPSImage (e.g. temporary vs. regular) or what size it is or where it is allocated, you may set the destinationImageAllocator to allocate the image yourself.

This method uses the MPSNNPadding padding property to figure out how to size the result image and to set the offset property. See discussion in MPSNeuralNetworkTypes.h. All images in a batch must have MPSImage.numberOfImages = 1.

Parameter commandBuffer: The command buffer

Parameter primaryImages: A MPSImage to use as the source images for the filter.

Parameter secondaryImages: A MPSImage to use as the source images for the filter.

Parameter outState: A new state object is returned here.

Parameter isTemporary: YES if the outState should be a temporary object

Returns: A MPSImage or MPSTemporaryImage allocated per the destinationImageAllocator containing the output of the graph. The offset property will be adjusted to reflect the offset used during the encode. The returned image will be automatically released when the command buffer completes. If you want to keep it around for longer, retain the image. (ARC will do this for you if you use it later.)

Source

pub unsafe fn resultStateForPrimaryImage_secondaryImage_sourceStates_destinationImage( &self, primary_image: &MPSImage, secondary_image: &MPSImage, source_states: Option<&NSArray<MPSState>>, destination_image: &MPSImage, ) -> Option<Retained<MPSState>>

Available on crate features MPSNeuralNetwork and MPSImage and MPSState only.

Allocate a MPSState (subclass) to hold the results from a -encodeBatchToCommandBuffer… operation

A graph may need to allocate storage up front before executing. This may be necessary to avoid using too much memory and to manage large batches. The function should allocate a MPSState object (if any) that will be produced by an -encode call with the indicated sourceImages and sourceStates inputs. Though the states can be further adjusted in the ensuing -encode call, the states should be initialized with all important data and all MTLResource storage allocated. The data stored in the MTLResource need not be initialized, unless the ensuing -encode call expects it to be.

The MTLDevice used by the result is derived from the source image. The padding policy will be applied to the filter before this is called to give it the chance to configure any properties like MPSCNNKernel.offset.

CAUTION: the result state should be made after the kernel properties are configured for the -encode call that will write to the state, and after -destinationImageDescriptorForSourceImages:sourceStates: is called (if it is called). Otherwise, behavior is undefined. Please see the description of -[MPSCNNKernel resultStateForSourceImage:sourceStates:destinationImage:] for more.

Default: returns nil

Parameter primaryImage: The MPSImage consumed by the associated -encode call.

Parameter secondaryImage: The MPSImage consumed by the associated -encode call.

Parameter sourceStates: The list of MPSStates consumed by the associated -encode call, for a batch size of 1.

Returns: The list of states produced by the -encode call for batch size of 1. When the batch size is not 1, this function will be called repeatedly unless -isResultStateReusedAcrossBatch returns YES. If -isResultStateReusedAcrossBatch returns YES, then it will be called once per batch and the MPSStateBatch array will contain MPSStateBatch.length references to the same object.

Source

pub unsafe fn resultStateBatchForPrimaryImage_secondaryImage_sourceStates_destinationImage( &self, primary_image: &MPSImageBatch, secondary_image: &MPSImageBatch, source_states: Option<&NSArray<MPSStateBatch>>, destination_image: &MPSImageBatch, ) -> Option<Retained<MPSStateBatch>>

Available on crate features MPSNeuralNetwork and MPSImage and MPSNDArray and MPSState only.
Source

pub unsafe fn temporaryResultStateForCommandBuffer_primaryImage_secondaryImage_sourceStates_destinationImage( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, primary_image: &MPSImage, secondary_image: &MPSImage, source_states: Option<&NSArray<MPSState>>, destination_image: &MPSImage, ) -> Option<Retained<MPSState>>

Available on crate features MPSNeuralNetwork and MPSImage and MPSState only.

Allocate a temporary MPSState (subclass) to hold the results from a -encodeBatchToCommandBuffer… operation

A graph may need to allocate storage up front before executing. This may be necessary to avoid using too much memory and to manage large batches. The function should allocate any MPSState objects that will be produced by an -encode call with the indicated sourceImages and sourceStates inputs. Though the states can be further adjusted in the ensuing -encode call, the states should be initialized with all important data and all MTLResource storage allocated. The data stored in the MTLResource need not be initialized, unless the ensuing -encode call expects it to be.

The MTLDevice used by the result is derived from the command buffer. The padding policy will be applied to the filter before this is called to give it the chance to configure any properties like MPSCNNKernel.offset.

CAUTION: the result state should be made after the kernel properties are configured for the -encode call that will write to the state, and after -destinationImageDescriptorForSourceImages:sourceStates: is called (if it is called). Otherwise, behavior is undefined. Please see the description of -[MPSCNNKernel resultStateForSourceImage:sourceStates:destinationImage] for more.

Default: returns nil

Parameter commandBuffer: The command buffer to allocate the temporary storage against The state will only be valid on this command buffer.

Parameter primaryImage: The MPSImage consumed by the associated -encode call.

Parameter secondaryImage: The MPSImage consumed by the associated -encode call.

Parameter sourceStates: The list of MPSStates consumed by the associated -encode call, for a batch size of 1.

Returns: The list of states produced by the -encode call for batch size of 1. When the batch size is not 1, this function will be called repeatedly unless -isResultStateReusedAcrossBatch returns YES. If -isResultStateReusedAcrossBatch returns YES, then it will be called once per batch and the MPSStateBatch array will contain MPSStateBatch.length references to the same object.

Source

pub unsafe fn temporaryResultStateBatchForCommandBuffer_primaryImage_secondaryImage_sourceStates_destinationImage( &self, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, primary_image: &MPSImageBatch, secondary_image: &MPSImageBatch, source_states: Option<&NSArray<MPSStateBatch>>, destination_image: &MPSImageBatch, ) -> Option<Retained<MPSStateBatch>>

Available on crate features MPSNeuralNetwork and MPSImage and MPSNDArray and MPSState only.
Source

pub unsafe fn isResultStateReusedAcrossBatch(&self) -> bool

Available on crate feature MPSNeuralNetwork only.

Returns YES if the same state is used for every operation in a batch

If NO, then each image in a MPSImageBatch will need a corresponding (and different) state to go with it. Set to YES to avoid allocating redundant state in the case when the same state is used all the time. Default: NO

Source

pub unsafe fn appendBatchBarrier(&self) -> bool

Available on crate feature MPSNeuralNetwork only.

Returns YES if the filter must be run over the entire batch before its results may be considered complete

The MPSNNGraph may split batches into sub-batches to save memory. However, some filters, like batch statistics calculations, need to operate over the entire batch to calculate a valid result, in this case, the mean and variance per channel over the set of images.

In such cases, the accumulated result is commonly stored in a MPSState containing a MTLBuffer. (MTLTextures may not be able to be read from and written to in the same filter on some devices.) -isResultStateReusedAcrossBatch is set to YES, so that the state is allocated once and passed in for each sub-batch and the filter accumulates its results into it, one sub-batch at a time. Note that sub-batches may frequently be as small as 1.

Default: NO

Source

pub unsafe fn destinationImageDescriptorForSourceImages_sourceStates( &self, source_images: &NSArray<MPSImage>, source_states: Option<&NSArray<MPSState>>, ) -> Retained<MPSImageDescriptor>

Available on crate features MPSNeuralNetwork and MPSImage and MPSState only.

Get a suggested destination image descriptor for a source image

Your application is certainly free to pass in any destinationImage it likes to encodeToCommandBuffer:sourceImage:destinationImage, within reason. This is the basic design for iOS 10. This method is therefore not required.

However, calculating the MPSImage size and MPSCNNBinaryKernel properties for each filter can be tedious and complicated work, so this method is made available to automate the process. The application may modify the properties of the descriptor before a MPSImage is made from it, so long as the choice is sensible for the kernel in question. Please see individual kernel descriptions for restrictions.

The expected timeline for use is as follows:

  1. This method is called: a) The default MPS padding calculation is applied. It uses the MPSNNPaddingMethod of the .padding property to provide a consistent addressing scheme over the graph. It creates the MPSImageDescriptor and adjusts the .offset property of the MPSNNKernel. When using a MPSNNGraph, the padding is set using the MPSNNFilterNode as a proxy.

b) This method may be overridden by MPSCNNBinaryKernel subclass to achieve any customization appropriate to the object type.

c) Source states are then applied in order. These may modify the descriptor and may update other object properties. See: -destinationImageDescriptorForSourceImages:sourceStates: forKernel:suggestedDescriptor: This is the typical way in which MPS may attempt to influence the operation of its kernels.

d) If the .padding property has a custom padding policy method of the same name, it is called. Similarly, it may also adjust the descriptor and any MPSCNNBinaryKernel properties. This is the typical way in which your application may attempt to influence the operation of the MPS kernels.

  1. A result is returned from this method and the caller may further adjust the descriptor and kernel properties directly.

  2. The caller uses the descriptor to make a new MPSImage to use as the destination image for the -encode call in step 5.

  3. The caller calls -resultStateForSourceImage:sourceStates:destinationImage: to make any result states needed for the kernel. If there isn’t one, it will return nil. A variant is available to return a temporary state instead.

  4. a -encode method is called to encode the kernel.

The entire process 1-5 is more simply achieved by just calling an -encode… method that returns a MPSImage out the left hand sid of the method. Simpler still, use the MPSNNGraph to coordinate the entire process from end to end. Opportunities to influence the process are of course reduced, as (2) is no longer possible with either method. Your application may opt to use the five step method if it requires greater customization as described, or if it would like to estimate storage in advance based on the sum of MPSImageDescriptors before processing a graph. Storage estimation is done by using the MPSImageDescriptor to create a MPSImage (without passing it a texture), and then call -resourceSize. As long as the MPSImage is not used in an encode call and the .texture property is not invoked, the underlying MTLTexture is not created.

No destination state or destination image is provided as an argument to this function because it is expected they will be made / configured after this is called. This method is expected to auto-configure important object properties that may be needed in the ensuing destination image and state creation steps.

Parameter sourceImages: A array of source images that will be passed into the -encode call Since MPSCNNBinaryKernel is a binary kernel, it is an array of length 2.

Parameter sourceStates: An optional array of source states that will be passed into the -encode call

Returns: an image descriptor allocated on the autorelease pool

Source

pub unsafe fn encodingStorageSizeForPrimaryImage_secondaryImage_sourceStates_destinationImage( &self, primary_image: &MPSImage, secondary_image: &MPSImage, source_states: Option<&NSArray<MPSState>>, destination_image: Option<&MPSImage>, ) -> NSUInteger

Available on crate features MPSNeuralNetwork and MPSImage and MPSState only.

The size of extra MPS heap storage allocated while the kernel is encoding

This is best effort and just describes things that are likely to end up on the MPS heap. It does not describe all allocation done by the -encode call. It is intended for use with high water calculations for MTLHeap sizing. Allocations are typically for temporary storage needed for multipass algorithms. This interface should not be used to detect multipass algorithms.

Source

pub unsafe fn batchEncodingStorageSizeForPrimaryImage_secondaryImage_sourceStates_destinationImage( &self, primary_image: &MPSImageBatch, secondary_image: &MPSImageBatch, source_states: Option<&NSArray<MPSStateBatch>>, destination_image: Option<&MPSImageBatch>, ) -> NSUInteger

Available on crate features MPSNeuralNetwork and MPSImage and MPSNDArray and MPSState only.

The size of extra MPS heap storage allocated while the kernel is encoding a batch

This is best effort and just describes things that are likely to end up on the MPS heap. It does not describe all allocation done by the -encode call. It is intended for use with high water calculations for MTLHeap sizing. Allocations are typically for temporary storage needed for multipass algorithms. This interface should not be used to detect multipass algorithms.

Methods from Deref<Target = MPSKernel>§

Source

pub unsafe fn options(&self) -> MPSKernelOptions

Available on crate feature MPSCoreTypes only.

The set of options used to run the kernel. subsubsection_options

Source

pub unsafe fn setOptions(&self, options: MPSKernelOptions)

Available on crate feature MPSCoreTypes only.

Setter for options.

Source

pub unsafe fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>

The device on which the kernel will be used

Source

pub unsafe fn label(&self) -> Option<Retained<NSString>>

A string to help identify this object.

Source

pub unsafe fn setLabel(&self, label: Option<&NSString>)

Setter for label.

This is copied when set.

Source

pub unsafe fn copyWithZone_device( &self, zone: *mut NSZone, device: Option<&ProtocolObject<dyn MTLDevice>>, ) -> Retained<Self>

Make a copy of this MPSKernel for a new device

-copyWithZone: will call this API to make a copy of the MPSKernel on the same device. This interface may also be called directly to make a copy of the MPSKernel on a new device. Typically, the same MPSKernels should not be used to encode kernels on multiple command buffers from multiple threads. Many MPSKernels have mutable properties that might be changed by the other thread while this one is trying to encode. If you need to use a MPSKernel from multiple threads make a copy of it for each additional thread using -copyWithZone: or -copyWithZone:device:

Parameter zone: The NSZone in which to allocate the object

Parameter device: The device for the new MPSKernel. If nil, then use self.device.

Returns: a pointer to a copy of this MPSKernel. This will fail, returning nil if the device is not supported. Devices must be MTLFeatureSet_iOS_GPUFamily2_v1 or later.

§Safety

zone must be a valid pointer or null.

Methods from Deref<Target = NSObject>§

Source

pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !

Handle messages the object doesn’t recognize.

See Apple’s documentation for details.

Methods from Deref<Target = AnyObject>§

Source

pub fn class(&self) -> &'static AnyClass

Dynamically find the class of this object.

§Panics

May panic if the object is invalid (which may be the case for objects returned from unavailable init/new methods).

§Example

Check that an instance of NSObject has the precise class NSObject.

use objc2::ClassType;
use objc2::runtime::NSObject;

let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Source

pub unsafe fn get_ivar<T>(&self, name: &str) -> &T
where T: Encode,

👎Deprecated: this is difficult to use correctly, use Ivar::load instead.

Use Ivar::load instead.

§Safety

The object must have an instance variable with the given name, and it must be of type T.

See Ivar::load_ptr for details surrounding this.

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: DowncastTarget,

Attempt to downcast the object to a class of type T.

This is the reference-variant. Use Retained::downcast if you want to convert a retained object to another type.

§Mutable classes

Some classes have immutable and mutable variants, such as NSString and NSMutableString.

When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.

So using this method to convert a NSString to a NSMutableString, while not unsound, is generally frowned upon unless you created the string yourself, or the API explicitly documents the string to be mutable.

See Apple’s documentation on mutability and on isKindOfClass: for more details.

§Generic classes

Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.

You can, however, safely downcast to generic collections where all the type-parameters are AnyObject.

§Panics

This works internally by calling isKindOfClass:. That means that the object must have the instance method of that name, and an exception will be thrown (if CoreFoundation is linked) or the process will abort if that is not the case. In the vast majority of cases, you don’t need to worry about this, since both root objects NSObject and NSProxy implement this method.

§Examples

Cast an NSString back and forth from NSObject.

use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};

let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();

Try (and fail) to cast an NSObject to an NSString.

use objc2_foundation::{NSObject, NSString};

let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());

Try to cast to an array of strings.

use objc2_foundation::{NSArray, NSObject, NSString};

let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();

This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.

Downcast when processing each element instead.

use objc2_foundation::{NSArray, NSObject, NSString};

let arr = NSArray::from_retained_slice(&[NSObject::new()]);

for elem in arr {
    if let Some(data) = elem.downcast_ref::<NSString>() {
        // handle `data`
    }
}

Trait Implementations§

Source§

impl AsRef<AnyObject> for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<MPSCNNBinaryKernel> for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn as_ref(&self) -> &MPSCNNBinaryKernel

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<MPSCNNDropoutGradient> for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<MPSCNNGradientKernel> for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn as_ref(&self) -> &MPSCNNGradientKernel

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<MPSKernel> for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn as_ref(&self) -> &MPSKernel

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<NSObject> for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn as_ref(&self) -> &NSObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<MPSCNNBinaryKernel> for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn borrow(&self) -> &MPSCNNBinaryKernel

Immutably borrows from an owned value. Read more
Source§

impl Borrow<MPSCNNGradientKernel> for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn borrow(&self) -> &MPSCNNGradientKernel

Immutably borrows from an owned value. Read more
Source§

impl Borrow<MPSKernel> for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn borrow(&self) -> &MPSKernel

Immutably borrows from an owned value. Read more
Source§

impl Borrow<NSObject> for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn borrow(&self) -> &NSObject

Immutably borrows from an owned value. Read more
Source§

impl ClassType for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

const NAME: &'static str = "MPSCNNDropoutGradient"

The name of the Objective-C class that this type represents. Read more
Source§

type Super = MPSCNNGradientKernel

The superclass of this class. Read more
Source§

type ThreadKind = <<MPSCNNDropoutGradient as ClassType>::Super as ClassType>::ThreadKind

Whether the type can be used from any thread, or from only the main thread. Read more
Source§

fn class() -> &'static AnyClass

Get a reference to the Objective-C class that this type represents. Read more
Source§

fn as_super(&self) -> &Self::Super

Get an immutable reference to the superclass.
Source§

impl CopyingHelper for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

type Result = MPSCNNDropoutGradient

The immutable counterpart of the type, or Self if the type has no immutable counterpart. Read more
Source§

impl Debug for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

type Target = MPSCNNGradientKernel

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Hash for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl NSCoding for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

unsafe fn encodeWithCoder(&self, coder: &NSCoder)
where Self: Sized + Message,

Safety Read more
Source§

unsafe fn initWithCoder( this: Allocated<Self>, coder: &NSCoder, ) -> Option<Retained<Self>>
where Self: Sized + Message,

Safety Read more
Source§

impl NSCopying for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn copy(&self) -> Retained<Self::Result>
where Self: Sized + Message + CopyingHelper,

Returns a new instance that’s a copy of the receiver. Read more
Source§

unsafe fn copyWithZone(&self, zone: *mut NSZone) -> Retained<Self::Result>
where Self: Sized + Message + CopyingHelper,

Returns a new instance that’s a copy of the receiver. Read more
Source§

impl NSObjectProtocol for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn isEqual(&self, other: Option<&AnyObject>) -> bool
where Self: Sized + Message,

Check whether the object is equal to an arbitrary other object. Read more
Source§

fn hash(&self) -> usize
where Self: Sized + Message,

An integer that can be used as a table address in a hash table structure. Read more
Source§

fn isKindOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of the class, or one of its subclasses. Read more
Source§

fn is_kind_of<T>(&self) -> bool
where T: ClassType, Self: Sized + Message,

👎Deprecated: use isKindOfClass directly, or cast your objects with AnyObject::downcast_ref
Check if the object is an instance of the class type, or one of its subclasses. Read more
Source§

fn isMemberOfClass(&self, cls: &AnyClass) -> bool
where Self: Sized + Message,

Check if the object is an instance of a specific class, without checking subclasses. Read more
Source§

fn respondsToSelector(&self, aSelector: Sel) -> bool
where Self: Sized + Message,

Check whether the object implements or inherits a method with the given selector. Read more
Source§

fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
where Self: Sized + Message,

Check whether the object conforms to a given protocol. Read more
Source§

fn description(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object. Read more
Source§

fn debugDescription(&self) -> Retained<NSObject>
where Self: Sized + Message,

A textual representation of the object to use when debugging. Read more
Source§

fn isProxy(&self) -> bool
where Self: Sized + Message,

Check whether the receiver is a subclass of the NSProxy root class instead of the usual NSObject. Read more
Source§

fn retainCount(&self) -> usize
where Self: Sized + Message,

The reference count of the object. Read more
Source§

impl NSSecureCoding for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

impl PartialEq for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

const ENCODING_REF: Encoding = <MPSCNNGradientKernel as ::objc2::RefEncode>::ENCODING_REF

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl DowncastTarget for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.
Source§

impl Eq for MPSCNNDropoutGradient

Available on crate feature MPSNeuralNetwork only.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T> AnyThread for T
where T: ClassType<ThreadKind = dyn AnyThread + 'a> + ?Sized,

Source§

fn alloc() -> Allocated<Self>
where Self: Sized + ClassType,

Allocate a new instance of the class. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,