pub struct MPSGraph { /* private fields */ }
MPSGraph
and MPSGraphCore
only.Expand description
The optimized representation of a compute graph of operations and tensors.
An MPSGraph is a symbolic representation of operations to be utilized to execute compute graphs on a device.
See also Apple’s documentation
Implementations§
Source§impl MPSGraph
impl MPSGraph
Sourcepub unsafe fn options(&self) -> MPSGraphOptions
pub unsafe fn options(&self) -> MPSGraphOptions
Options for the graph.
The default value is MPSGraphOptionsDefault
.
Sourcepub unsafe fn setOptions(&self, options: MPSGraphOptions)
pub unsafe fn setOptions(&self, options: MPSGraphOptions)
Setter for options
.
Sourcepub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
Initialize an MPSGraph to insert nodes in.
Sourcepub unsafe fn placeholderTensors(&self) -> Retained<NSArray<MPSGraphTensor>>
Available on crate feature MPSGraphTensor
only.
pub unsafe fn placeholderTensors(&self) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphTensor
only.Array of all the placeholder tensors.
Sourcepub unsafe fn compileWithDevice_feeds_targetTensors_targetOperations_compilationDescriptor(
&self,
device: Option<&MPSGraphDevice>,
feeds: &MPSGraphTensorShapedTypeDictionary,
target_tensors: &NSArray<MPSGraphTensor>,
target_operations: Option<&NSArray<MPSGraphOperation>>,
compilation_descriptor: Option<&MPSGraphCompilationDescriptor>,
) -> Retained<MPSGraphExecutable>
Available on crate features MPSGraphDevice
and MPSGraphExecutable
and MPSGraphOperation
and MPSGraphTensor
only.
pub unsafe fn compileWithDevice_feeds_targetTensors_targetOperations_compilationDescriptor( &self, device: Option<&MPSGraphDevice>, feeds: &MPSGraphTensorShapedTypeDictionary, target_tensors: &NSArray<MPSGraphTensor>, target_operations: Option<&NSArray<MPSGraphOperation>>, compilation_descriptor: Option<&MPSGraphCompilationDescriptor>, ) -> Retained<MPSGraphExecutable>
MPSGraphDevice
and MPSGraphExecutable
and MPSGraphOperation
and MPSGraphTensor
only.Compiles the graph for the given feeds to returns the target tensor values, ensuring all target operations would be executed.
This call blocks until execution has completed. The compilation descriptor helps specialize the executable returned.
- Parameters:
- device: MPSGraph device to optimize for.
- feeds: Feeds dictionary for the placeholder tensors.
- targetTensors: Tensors for which the caller wishes MPSGraphTensorData to be returned.
- targetOperations: Operations to be completed at the end of the run.
- compilationDescriptor: compilation descriptor to set different compilation parameters.
- Returns: A valid MPSGraphExecutable object
Sourcepub unsafe fn runWithFeeds_targetTensors_targetOperations(
&self,
feeds: &MPSGraphTensorDataDictionary,
target_tensors: &NSArray<MPSGraphTensor>,
target_operations: Option<&NSArray<MPSGraphOperation>>,
) -> Retained<MPSGraphTensorDataDictionary>
Available on crate features MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
only.
pub unsafe fn runWithFeeds_targetTensors_targetOperations( &self, feeds: &MPSGraphTensorDataDictionary, target_tensors: &NSArray<MPSGraphTensor>, target_operations: Option<&NSArray<MPSGraphOperation>>, ) -> Retained<MPSGraphTensorDataDictionary>
MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
only.Runs the graph for the given feeds and returns the target tensor values, ensuring all target operations also executed.
This call blocks until execution has completed.
- Parameters:
- feeds: Feeds dictionary for the placeholder tensors.
- targetTensors: Tensors for which the caller wishes MPSGraphTensorData to be returned.
- targetOperations: Operations to be completed at the end of the run.
- Returns: A valid MPSGraphTensor : MPSGraphTensorData dictionary with results synchronized to the CPU memory.
Sourcepub unsafe fn runWithMTLCommandQueue_feeds_targetTensors_targetOperations(
&self,
command_queue: &ProtocolObject<dyn MTLCommandQueue>,
feeds: &MPSGraphTensorDataDictionary,
target_tensors: &NSArray<MPSGraphTensor>,
target_operations: Option<&NSArray<MPSGraphOperation>>,
) -> Retained<MPSGraphTensorDataDictionary>
Available on crate features MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
only.
pub unsafe fn runWithMTLCommandQueue_feeds_targetTensors_targetOperations( &self, command_queue: &ProtocolObject<dyn MTLCommandQueue>, feeds: &MPSGraphTensorDataDictionary, target_tensors: &NSArray<MPSGraphTensor>, target_operations: Option<&NSArray<MPSGraphOperation>>, ) -> Retained<MPSGraphTensorDataDictionary>
MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
only.Runs the graph for the given feeds and returns the target tensor values, ensuring all target operations also executed.
This call blocks until execution has completed.
- Parameters:
- commandQueue: CommandQueue passed to exectute the graph on.
- feeds: Feeds dictionary for the placeholder tensors.
- targetTensors: Tensors for which the caller wishes MPSGraphTensorData to be returned.
- targetOperations: Operations to be completed at the end of the run.
- Returns: A valid MPSGraphTensor : MPSGraphTensorData dictionary with results synchronized to the CPU memory.
Sourcepub unsafe fn runWithMTLCommandQueue_feeds_targetOperations_resultsDictionary(
&self,
command_queue: &ProtocolObject<dyn MTLCommandQueue>,
feeds: &MPSGraphTensorDataDictionary,
target_operations: Option<&NSArray<MPSGraphOperation>>,
results_dictionary: &MPSGraphTensorDataDictionary,
)
Available on crate features MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
only.
pub unsafe fn runWithMTLCommandQueue_feeds_targetOperations_resultsDictionary( &self, command_queue: &ProtocolObject<dyn MTLCommandQueue>, feeds: &MPSGraphTensorDataDictionary, target_operations: Option<&NSArray<MPSGraphOperation>>, results_dictionary: &MPSGraphTensorDataDictionary, )
MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
only.Runs the graph for the given feeds and returns the target tensor values in the results dictionary provided by the user.
It also ensures all target operations also executed. This call blocks until execution has completed.
- Parameters:
- commandQueue: CommandQueue passed to exectute the graph on.
- feeds: Feeds dictionary for the placeholder tensors.
- targetOperations: Operations to be completed at the end of the run.
- resultsDictionary: MPSGraphTensors dictionary passed by user, these will be filled with graph output data.
Sourcepub unsafe fn runAsyncWithFeeds_targetTensors_targetOperations_executionDescriptor(
&self,
feeds: &MPSGraphTensorDataDictionary,
target_tensors: &NSArray<MPSGraphTensor>,
target_operations: Option<&NSArray<MPSGraphOperation>>,
execution_descriptor: Option<&MPSGraphExecutionDescriptor>,
) -> Retained<MPSGraphTensorDataDictionary>
Available on crate features MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
only.
pub unsafe fn runAsyncWithFeeds_targetTensors_targetOperations_executionDescriptor( &self, feeds: &MPSGraphTensorDataDictionary, target_tensors: &NSArray<MPSGraphTensor>, target_operations: Option<&NSArray<MPSGraphOperation>>, execution_descriptor: Option<&MPSGraphExecutionDescriptor>, ) -> Retained<MPSGraphTensorDataDictionary>
MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
only.Runs the graph for the given feeds and returns the target tensor values, ensuring all target operations also executed.
This call is asynchronous and will return immediately if a completionHandler is set.
- Parameters:
- feeds: Feeds dictionary for the placeholder tensors.
- targetTensors: Tensors for which the caller wishes MPSGraphTensorData to be returned.
- targetOperations: Operations to be completed at the end of the run.
- executionDescriptor: ExecutionDescriptor to be passed in and used.
- Returns: A valid MPSGraphTensor : MPSGraphTensorData dictionary with results synchronized to the CPU memory.
Sourcepub unsafe fn runAsyncWithMTLCommandQueue_feeds_targetTensors_targetOperations_executionDescriptor(
&self,
command_queue: &ProtocolObject<dyn MTLCommandQueue>,
feeds: &MPSGraphTensorDataDictionary,
target_tensors: &NSArray<MPSGraphTensor>,
target_operations: Option<&NSArray<MPSGraphOperation>>,
execution_descriptor: Option<&MPSGraphExecutionDescriptor>,
) -> Retained<MPSGraphTensorDataDictionary>
Available on crate features MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
only.
pub unsafe fn runAsyncWithMTLCommandQueue_feeds_targetTensors_targetOperations_executionDescriptor( &self, command_queue: &ProtocolObject<dyn MTLCommandQueue>, feeds: &MPSGraphTensorDataDictionary, target_tensors: &NSArray<MPSGraphTensor>, target_operations: Option<&NSArray<MPSGraphOperation>>, execution_descriptor: Option<&MPSGraphExecutionDescriptor>, ) -> Retained<MPSGraphTensorDataDictionary>
MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
only.Runs the graph for the given feeds and returns the target tensor values, ensuring all target operations also executed.
This call is asynchronous and will return immediately if a completionHandler is set.
- Parameters:
- commandQueue: CommandQueue passed to exectute the graph on.
- feeds: Feeds dictionary for the placeholder tensors.
- targetTensors: Tensors for which the caller wishes MPSGraphTensorData to be returned.
- targetOperations: Operations to be completed at the end of the run.
- executionDescriptor: ExecutionDescriptor to be passed in and used.
- Returns: A valid MPSGraphTensor : MPSGraphTensorData dictionary with results synchronized to the CPU memory if MPSGraphOptionsSynchronizeResults set.
Sourcepub unsafe fn runAsyncWithMTLCommandQueue_feeds_targetOperations_resultsDictionary_executionDescriptor(
&self,
command_queue: &ProtocolObject<dyn MTLCommandQueue>,
feeds: &MPSGraphTensorDataDictionary,
target_operations: Option<&NSArray<MPSGraphOperation>>,
results_dictionary: &MPSGraphTensorDataDictionary,
execution_descriptor: Option<&MPSGraphExecutionDescriptor>,
)
Available on crate features MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
only.
pub unsafe fn runAsyncWithMTLCommandQueue_feeds_targetOperations_resultsDictionary_executionDescriptor( &self, command_queue: &ProtocolObject<dyn MTLCommandQueue>, feeds: &MPSGraphTensorDataDictionary, target_operations: Option<&NSArray<MPSGraphOperation>>, results_dictionary: &MPSGraphTensorDataDictionary, execution_descriptor: Option<&MPSGraphExecutionDescriptor>, )
MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
only.Encodes the graph for the given feeds to returns the target tensor values in the results dictionary provided by the user.
It ensures all target operations also executed. This call is asynchronous and will return immediately if a completionHandler is set.
- Parameters:
- commandQueue: CommandQueue passed to exectute the graph on.
- feeds: Feeds dictionary for the placeholder tensors.
- targetOperations: Operations to be completed at the end of the run.
- resultsDictionary: MPSGraphTensors dictionary passed by user, these will be filled with graph output data.
- executionDescriptor: ExecutionDescriptor to be passed in and used.
Sourcepub unsafe fn encodeToCommandBuffer_feeds_targetTensors_targetOperations_executionDescriptor(
&self,
command_buffer: &MPSCommandBuffer,
feeds: &MPSGraphTensorDataDictionary,
target_tensors: &NSArray<MPSGraphTensor>,
target_operations: Option<&NSArray<MPSGraphOperation>>,
execution_descriptor: Option<&MPSGraphExecutionDescriptor>,
) -> Retained<MPSGraphTensorDataDictionary>
Available on crate features MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
and objc2-metal-performance-shaders
only.
pub unsafe fn encodeToCommandBuffer_feeds_targetTensors_targetOperations_executionDescriptor( &self, command_buffer: &MPSCommandBuffer, feeds: &MPSGraphTensorDataDictionary, target_tensors: &NSArray<MPSGraphTensor>, target_operations: Option<&NSArray<MPSGraphOperation>>, execution_descriptor: Option<&MPSGraphExecutionDescriptor>, ) -> Retained<MPSGraphTensorDataDictionary>
MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
and objc2-metal-performance-shaders
only.Encodes the graph for the given feeds to returns the target tensor values, ensuring all target operations also executed.
This call is asynchronous and will return immediately if a completionHandler is set.
- Parameters:
- commandBuffer: commandBuffer passed to exectute the graph on, it is an MPSCommandBuffer, commitAndContinue might be called, please don’t rely on underlying MTLCommandBuffer to remain uncommitted.
- feeds: Feeds dictionary for the placeholder tensors.
- targetTensors: Tensors for which the caller wishes MPSGraphTensorData to be returned.
- targetOperations: Operations to be completed at the end of the run.
- executionDescriptor: ExecutionDescriptor to be passed in and used.
- Returns: A valid MPSGraphTensor : MPSGraphTensorData dictionary with results synchronized to the CPU memory if MPSGraphOptionsSynchronizeResults set.
Sourcepub unsafe fn encodeToCommandBuffer_feeds_targetOperations_resultsDictionary_executionDescriptor(
&self,
command_buffer: &MPSCommandBuffer,
feeds: &MPSGraphTensorDataDictionary,
target_operations: Option<&NSArray<MPSGraphOperation>>,
results_dictionary: &MPSGraphTensorDataDictionary,
execution_descriptor: Option<&MPSGraphExecutionDescriptor>,
)
Available on crate features MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
and objc2-metal-performance-shaders
only.
pub unsafe fn encodeToCommandBuffer_feeds_targetOperations_resultsDictionary_executionDescriptor( &self, command_buffer: &MPSCommandBuffer, feeds: &MPSGraphTensorDataDictionary, target_operations: Option<&NSArray<MPSGraphOperation>>, results_dictionary: &MPSGraphTensorDataDictionary, execution_descriptor: Option<&MPSGraphExecutionDescriptor>, )
MPSGraphOperation
and MPSGraphTensor
and MPSGraphTensorData
and objc2-metal-performance-shaders
only.Encodes the graph for the given feeds to returns the target tensor values in the results dictionary provided by the user.
It ensures all target operations also executed. This call is asynchronous and will return immediately if a completionHandler is set.
- Parameters:
- commandBuffer: commandBuffer passed to execute the graph on, commitAndContinue might be called, please don’t rely on underlying MTLCommandBuffer to remain uncommitted.
- feeds: Feeds dictionary for the placeholder tensors.
- targetOperations: Operations to be completed at the end of the run.
- resultsDictionary: MPSGraphTensors dictionary passed by user, these will be filled with graph output data.
- executionDescriptor: ExecutionDescriptor to be passed in and used.
Source§impl MPSGraph
MPSGraphActivationOps.
impl MPSGraph
MPSGraphActivationOps.
Sourcepub unsafe fn reLUWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphActivationOps
and MPSGraphTensor
only.
pub unsafe fn reLUWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphActivationOps
and MPSGraphTensor
only.Computes the ReLU (rectified linear activation unit) function with the input tensor.
The operation is: f(x) = max(x, 0).
- Parameters:
- tensor: The input tensor.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
object.
Sourcepub unsafe fn reLUGradientWithIncomingGradient_sourceTensor_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphActivationOps
and MPSGraphTensor
only.
pub unsafe fn reLUGradientWithIncomingGradient_sourceTensor_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphActivationOps
and MPSGraphTensor
only.Computes the gradient of the ReLU (rectified linear activation unit) function using the incoming gradient.
- Parameters:
- gradient: The incoming gradient tensor.
- source: The input tensor from forward pass.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
object.
Sourcepub unsafe fn sigmoidWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphActivationOps
and MPSGraphTensor
only.
pub unsafe fn sigmoidWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphActivationOps
and MPSGraphTensor
only.Computes the sigmoid operation on an input tensor.
- Parameters:
- tensor: The input tensor.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
object.
Sourcepub unsafe fn sigmoidGradientWithIncomingGradient_sourceTensor_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphActivationOps
and MPSGraphTensor
only.
pub unsafe fn sigmoidGradientWithIncomingGradient_sourceTensor_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphActivationOps
and MPSGraphTensor
only.Computes the gradient of the sigmoid function using the incoming gradient tensor.
- Parameters:
- gradient: The incoming gradient tensor.
- source: The input tensor.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
object
Sourcepub unsafe fn softMaxWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphActivationOps
and MPSGraphTensor
only.
pub unsafe fn softMaxWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphActivationOps
and MPSGraphTensor
only.Computes the softmax function on the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor.
- axis: The axis along which softmax is computed.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
object
Sourcepub unsafe fn softMaxGradientWithIncomingGradient_sourceTensor_axis_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphActivationOps
and MPSGraphTensor
only.
pub unsafe fn softMaxGradientWithIncomingGradient_sourceTensor_axis_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphActivationOps
and MPSGraphTensor
only.Computes the gradient of the softmax function along the specified axis using the incoming gradient tensor.
- Parameters:
- gradient: The incoming gradient tensor.
- source: The input tensor.
- axis: The axis along which softmax is computed.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
object
Sourcepub unsafe fn leakyReLUWithTensor_alpha_name(
&self,
tensor: &MPSGraphTensor,
alpha: c_double,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphActivationOps
and MPSGraphTensor
only.
pub unsafe fn leakyReLUWithTensor_alpha_name( &self, tensor: &MPSGraphTensor, alpha: c_double, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphActivationOps
and MPSGraphTensor
only.Computes the leaky rectified linear unit (ReLU) activation function on the input tensor.
The operation is: f(x) = max(x, alpha).
- Parameters:
- tensor: An input tensor.
- alpha: The scalar value alpha used by all elements in the input tensor.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
object
Sourcepub unsafe fn leakyReLUWithTensor_alphaTensor_name(
&self,
tensor: &MPSGraphTensor,
alpha_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphActivationOps
and MPSGraphTensor
only.
pub unsafe fn leakyReLUWithTensor_alphaTensor_name( &self, tensor: &MPSGraphTensor, alpha_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphActivationOps
and MPSGraphTensor
only.Computes the leaky rectified linear unit (ReLU) activation function on the input tensor.
The operation is: f(x) = max(x, alpha). This operation supports broadcasting with the alpha tensor.
- Parameters:
- tensor: The input tensor.
- alpha: The alpha tensor.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
object
Sourcepub unsafe fn leakyReLUGradientWithIncomingGradient_sourceTensor_alphaTensor_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
alpha_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphActivationOps
and MPSGraphTensor
only.
pub unsafe fn leakyReLUGradientWithIncomingGradient_sourceTensor_alphaTensor_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, alpha_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphActivationOps
and MPSGraphTensor
only.Computes the gradient of the leaky rectified linear unit (ReLU) activation.
This operation supports broadcasting with the alpha tensor.
- Parameters:
- gradient: The incoming gradient tensor.
- source: The input tensor in forward pass.
- alpha: The alpha tensor
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
object
Source§impl MPSGraph
MPSGraphArithmeticOps.
impl MPSGraph
MPSGraphArithmeticOps.
Sourcepub unsafe fn identityWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn identityWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Copies the input tensor values into the output, behaving as an identity operation.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object which is a copy of the input.
Sourcepub unsafe fn exponentWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn exponentWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the natural exponent to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn exponentBase2WithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn exponentBase2WithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies an exponent with base 2 to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn exponentBase10WithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn exponentBase10WithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies an exponent with base 10 to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn logarithmWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn logarithmWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Computes the natural logarithm to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn logarithmBase2WithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn logarithmBase2WithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Computes the logarithm with base 2 to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn logarithmBase10WithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn logarithmBase10WithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Computes the logarithm with base 10 to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn squareWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn squareWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the square operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn squareRootWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn squareRootWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the square root operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn reciprocalSquareRootWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn reciprocalSquareRootWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the reciprocal square root operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn reverseSquareRootWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
👎DeprecatedAvailable on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn reverseSquareRootWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the reverse square root operation to the input tensor elements.
The reverse square root operation is the reciprocal of the square root.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn reciprocalWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn reciprocalWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the reciprocal operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn absoluteWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn absoluteWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the absolute values of the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn absoluteSquareWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn absoluteSquareWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the absolute square of the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation..
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn negativeWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn negativeWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies negative to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn signWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn signWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the sign of the input tensor elements.
This operation returns 1.0 if the correspnding input element is greater than 0, -1.0 if it is lesser than 0, -0.0 if it is equal to -0.0, and +0.0 if it is equal to +0.0.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn signbitWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn signbitWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the sign bit of the input tensor elements.
This operation returns true
if the sign bit is set for the correspnding floating-point input element,
otherwise it returns false
.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn ceilWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn ceilWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the ceiling operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn floorWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn floorWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the floor operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn roundWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn roundWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Rounds the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn rintWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn rintWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Rounds the input tensor elements by rounding to nearest even.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn sinWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn sinWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the sine operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn cosWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn cosWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the cosine operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn tanWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn tanWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the tangent operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn sinhWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn sinhWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the hyperbolic sine operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn coshWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn coshWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the hyperbolic cosine operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn tanhWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn tanhWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the hyperbolic tangent operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn asinWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn asinWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the inverse sine operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn acosWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn acosWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the inverse cosine operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn atanWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn atanWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the inverse tangent operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn asinhWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn asinhWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the inverse hyperbolic sine operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn acoshWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn acoshWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the inverse hyperbolic cosine operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn atanhWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn atanhWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the inverse hyperbolic tangent operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn notWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn notWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the logical NOT operation to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn isInfiniteWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn isInfiniteWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Checks if the input tensor elements are infinite or not.
If the input tensor element is infinite, the operation returns true
, else it returns false
.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn isFiniteWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn isFiniteWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Checks if the input tensor elements are finite or not.
If the input tensor element is finite, the operation returns true
, else it returns false
.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn isNaNWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn isNaNWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Checks if the input tensor elements are NaN
or not.
If the input tensor element is NaN
, the operation returns true
, else it returns false
.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn erfWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn erfWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the error function to the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn truncateWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn truncateWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the truncate operation to the input tensor elements.
This operation applies the floor operation to positive inputs and ceiling operation to negative inputs.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn bitwiseNOTWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn bitwiseNOTWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Applies the bitwise NOT operation to the input tensor element.
This operation only accepts integer tensors.
- Parameters:
- tensor: The input tensor, which must be of integer type.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn bitwisePopulationCountWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn bitwisePopulationCountWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the population count of the input tensor elements.
This operation only accepts integer tensors, and returns the number of bits set in the input element.
- Parameters:
- tensor: The input tensor, which must be of integer type.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn conjugateWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn conjugateWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the complex conjugate of the input tensor elements.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation..
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn additionWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn additionWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Adds two input tensors.
This operation creates an add operation and returns the result tensor. It supports broadcasting as well.
resultTensor = primaryTensor + secondaryTensor
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn subtractionWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn subtractionWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Subtracts the second input tensor from the first.
This operation creates a subtract operation and returns the result tensor. It supports broadcasting as well.
resultTensor = primaryTensor - secondaryTensor
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn multiplicationWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn multiplicationWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Multiplies two input tensors.
This operation creates a multiply operation and returns the result tensor. It supports broadcasting as well.
resultTensor = primaryTensor * secondaryTensor
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn divisionWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn divisionWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Divides the first input tensor by the second.
This operation creates a divide operation and returns the result tensor. It supports broadcasting as well.
resultTensor = primaryTensor / secondaryTensor
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn moduloWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn moduloWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the remainder obtained by dividing the first input tensor by the second.
This operation creates a modulo operation and returns the result tensor. It supports broadcasting as well.
resultTensor = primaryTensor % secondaryTensor
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn powerWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn powerWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise result of raising the first tensor to the power of the second tensor.
This operation creates a power operation and returns the result tensor. It supports broadcasting as well.
resultTensor = pow(primaryTensor, secondaryTensor)
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn minimumWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn minimumWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise minimum of the input tensors.
This operation creates a minimum operation and returns the result tensor. It supports broadcasting as well.
resultTensor = min(primaryTensor, secondaryTensor)
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn maximumWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn maximumWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise maximum of the input tensors.
This operation creates a maximum operation and returns the result tensor. It supports broadcasting as well.
resultTensor = max(primaryTensor, secondaryTensor)
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn minimumWithNaNPropagationWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn minimumWithNaNPropagationWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise minimum of the input tensors, while propagating NaN
values.
This operation creates a minimum with NaN
propagation operation and returns the result tensor. This means that
if any of the elementwise operands is NaN
, the result is NaN
.
It supports broadcasting as well.
resultTensor = isNaN(primaryTensor) || isNan(secondaryTensor) ? NaN : min(primaryTensor, secondaryTensor)
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn maximumWithNaNPropagationWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn maximumWithNaNPropagationWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise maximum of the input tensors, while propagating NaN
values.
This operation creates a maximum with NaN
propagation operation and returns the result tensor. This means that
if any of the elementwise operands is NaN
, the result is NaN
.
It supports broadcasting as well.
resultTensor = isNaN(primaryTensor) || isNan(secondaryTensor) ? NaN : max(primaryTensor, secondaryTensor)
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn equalWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn equalWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise equality check of the input tensors.
This operation creates a equal operation and returns the result tensor. It supports broadcasting as well.
resultTensor = primaryTensor == secondaryTensor
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn notEqualWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn notEqualWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise inequality check of the input tensors.
This operation creates a not equal operation and returns the result tensor. It supports broadcasting as well.
resultTensor = primaryTensor != secondaryTensor
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn lessThanWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn lessThanWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Checks in an elementwise manner if the first input tensor is less than the second.
This operation creates a lessThan
operation and returns the result tensor. It supports broadcasting as well.
resultTensor = primaryTensor
<
secondaryTensor
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn lessThanOrEqualToWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn lessThanOrEqualToWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Checks in an elementwise manner if the first input tensor is less than or equal to the second.
This operation creates a lessThanOrEqualTo
operation and returns the result tensor. It supports broadcasting as well.
resultTensor = primaryTensor
<
= secondaryTensor
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn greaterThanWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn greaterThanWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Checks in an elementwise manner if the first input tensor is greater than the second.
This operation creates a greaterThan
operation and returns the result tensor. It supports broadcasting as well.
resultTensor = primaryTensor > secondaryTensor
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn greaterThanOrEqualToWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn greaterThanOrEqualToWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Checks in an elementwise manner if the first input tensor is greater than or equal to the second.
This operation creates a greaterThanOrEqual
operation and returns the result tensor. It supports broadcasting as well.
resultTensor = primaryTensor
<
secondaryTensor
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn logicalANDWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn logicalANDWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise logical AND of the input tensors.
This operation creates a logical AND operation and returns the result tensor. It supports broadcasting as well.
resultTensor = primaryTensor
&
&
secondaryTensor
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn logicalORWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn logicalORWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise logical OR of the input tensors.
This operation creates a logical OR operation and returns the result tensor. It supports broadcasting as well.
resultTensor = primaryTensor || secondaryTensor
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn logicalNANDWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn logicalNANDWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise logical NAND of the input tensors.
This operation creates a logical NAND operation and returns the result tensor. It supports broadcasting as well.
resultTensor = !(primaryTensor
&
&
secondaryTensor)
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn logicalNORWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn logicalNORWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise logical NOR of the input tensors.
This operation creates a logical NOR operation and returns the result tensor. It supports broadcasting as well.
resultTensor = !(primaryTensor || secondaryTensor)
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn logicalXORWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn logicalXORWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise logical XOR of the input tensors.
This operation creates a logical XOR operation and returns the result tensor. It supports broadcasting as well.
resultTensor = XOR(primaryTensor, secondaryTensor)
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn logicalXNORWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn logicalXNORWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise logical XNOR of the input tensors.
This operation creates a logical XNOR operation and returns the result tensor. It supports broadcasting as well.
resultTensor = XNOR(primaryTensor, secondaryTensor)
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn atan2WithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn atan2WithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise two-argument arctangent of the input tensors.
This operation creates a atan2
operation and returns the result tensor. It supports broadcasting as well.
Graph computes arc tangent of primaryTensor over secondaryTensor.
resultTensor = atan2(primaryTensor, secondaryTensor)
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn bitwiseANDWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn bitwiseANDWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise bitwise AND of binary representations of two integer tensors.
- Parameters:
- primaryTensor: The primary input tensor, must be of integer type.
- secondaryTensor: The secondary input tensor, must be of integer type.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn bitwiseORWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn bitwiseORWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise bitwise OR of binary representations of two integer tensors.
- Parameters:
- primaryTensor: The primary input tensor, must be of integer type.
- secondaryTensor: The secondary input tensor, must be of integer type.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn bitwiseXORWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn bitwiseXORWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise bitwise XOR of binary representations of two integer tensors.
- Parameters:
- primaryTensor: The primary input tensor, must be of integer type.
- secondaryTensor: The secondary input tensor, must be of integer type.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn bitwiseLeftShiftWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn bitwiseLeftShiftWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise left-shifted binary representations of the primary integer by the secondary tensor amount.
- Parameters:
- primaryTensor: The primary input tensor, must be of integer type.
- secondaryTensor: The secondary input tensor, must be of integer type.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn bitwiseRightShiftWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn bitwiseRightShiftWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the elementwise right-shifted binary representations of the primary integer by the secondary tensor amount.
- Parameters:
- primaryTensor: The primary input tensor, must be of integer type.
- secondaryTensor: The secondary input tensor, must be of integer type.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn selectWithPredicateTensor_truePredicateTensor_falsePredicateTensor_name(
&self,
predicate_tensor: &MPSGraphTensor,
true_predicate_tensor: &MPSGraphTensor,
false_select_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn selectWithPredicateTensor_truePredicateTensor_falsePredicateTensor_name( &self, predicate_tensor: &MPSGraphTensor, true_predicate_tensor: &MPSGraphTensor, false_select_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Selects values from either the true or false predicate tensor, depending on the values in the first input.
This operation creates a select operation and returns the result tensor. It supports broadcasting as well.
resultTensor = select(predicateTensor, truePredicateTensor, falseSelectTensor)
- Parameters:
- predicateTensor: The predicate tensor.
- truePredicateTensor: The tensor to select values from if predicate is true.
- falseSelectTensor: The tensor to select values from if predicate is false.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn clampWithTensor_minValueTensor_maxValueTensor_name(
&self,
tensor: &MPSGraphTensor,
min_value_tensor: &MPSGraphTensor,
max_value_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn clampWithTensor_minValueTensor_maxValueTensor_name( &self, tensor: &MPSGraphTensor, min_value_tensor: &MPSGraphTensor, max_value_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Clamps the values in the first tensor between the corresponding values in the minimum and maximum value tensor.
This operation creates a clamp operation and returns the result tensor. It supports broadcasting as well.
resultTensor = clamp(tensor, minValueTensor, maxValueTensor)
- Parameters:
- tensor: The tensor to be clamped.
- minValueTensor: The tensor with min values to clamp to.
- minValueTensor: The tensor with max values to clamp to.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn divisionNoNaNWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn divisionNoNaNWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Divides the first input tensor by the second, with the result being 0 if the denominator is 0.
resultTensor = select(secondaryTensor, primaryTensor / secondaryTensor, 0)
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn floorModuloWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn floorModuloWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the remainder of floor divison between the primary and secondary tensor.
Creates a floorModulo operation and returns the result tensor, it supports broadcasting as well, returns 0 if divisor is 0.
resultTensor = primaryTensor - (floor(primaryTensor / secondaryTensor) * secondaryTensor)
- Parameters:
- primaryTensor: The LHS tensor of the binary Op.
- secondaryTensor: The RHS tensor of the binary Op.
- name: An optional string which serves as an identifier for the operation.
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn realPartOfTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn realPartOfTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the real part of a tensor.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation..
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn imaginaryPartOfTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn imaginaryPartOfTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns the imaginary part of a tensor.
- Parameters:
- tensor: The input tensor.
- name: An optional string which serves as an identifier for the operation..
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Sourcepub unsafe fn complexTensorWithRealTensor_imaginaryTensor_name(
&self,
real_tensor: &MPSGraphTensor,
imaginary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphArithmeticOps
and MPSGraphTensor
only.
pub unsafe fn complexTensorWithRealTensor_imaginaryTensor_name( &self, real_tensor: &MPSGraphTensor, imaginary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphArithmeticOps
and MPSGraphTensor
only.Returns a complex tensor from the two input tensors.
- Parameters:
- realTensor: The real part of the complex tensor.
- imaginaryTensor: The imaginary part of the complex tensor.
- name: An optional string which serves as an identifier for the operation..
- Returns: A valid
MPSGraphTensor
object containing the elementwise result of the applied operation.
Source§impl MPSGraph
MPSGraphGradientOps.
impl MPSGraph
MPSGraphGradientOps.
Sourcepub unsafe fn gradientForPrimaryTensor_withTensors_name(
&self,
primary_tensor: &MPSGraphTensor,
tensors: &NSArray<MPSGraphTensor>,
name: Option<&NSString>,
) -> Retained<NSDictionary<MPSGraphTensor, MPSGraphTensor>>
Available on crate features MPSGraphAutomaticDifferentiation
and MPSGraphTensor
only.
pub unsafe fn gradientForPrimaryTensor_withTensors_name( &self, primary_tensor: &MPSGraphTensor, tensors: &NSArray<MPSGraphTensor>, name: Option<&NSString>, ) -> Retained<NSDictionary<MPSGraphTensor, MPSGraphTensor>>
MPSGraphAutomaticDifferentiation
and MPSGraphTensor
only.Calculates a partial derivative of primaryTensor with respect to the tensors.
- Parameters:
- primaryTensor: Tensor to be differentiated (numerator).
- tensors: Tensors to do the differentiation with (denominator).
- name: Name for the gradient operation.
- Returns: A valid MPSGraphTensor dictionary object containing partial derivative d(primaryTensor)/d(secondaryTensor) for each tensor as key.
Source§impl MPSGraph
CallOp.
impl MPSGraph
CallOp.
Sourcepub unsafe fn callSymbolName_inputTensors_outputTypes_name(
&self,
symbol_name: &NSString,
input_tensors: &NSArray<MPSGraphTensor>,
output_types: &NSArray<MPSGraphType>,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphCallOps
and MPSGraphTensor
only.
pub unsafe fn callSymbolName_inputTensors_outputTypes_name( &self, symbol_name: &NSString, input_tensors: &NSArray<MPSGraphTensor>, output_types: &NSArray<MPSGraphType>, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphCallOps
and MPSGraphTensor
only.Creates an operation which invokes another executable.
- Parameters:
- symbolName: The unique identifier used to find the executable in the
MPSGraphCompilationDescriptor.callables
directory. - inputTensors: The tensors which are passed as inputs to the executable being invoked.
- outputTypes: The expected return types of the executable being invoked.
- name: name of operation.
- Returns: An array of valid
MPSGraphTensor
objects representing the return tensors of the invoked executable.
Source§impl MPSGraph
MPSGraphControlFlowOps.
impl MPSGraph
MPSGraphControlFlowOps.
Sourcepub unsafe fn controlDependencyWithOperations_dependentBlock_name(
&self,
operations: &NSArray<MPSGraphOperation>,
dependent_block: MPSGraphControlFlowDependencyBlock,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphControlFlowOps
and MPSGraphOperation
and MPSGraphTensor
and block2
only.
pub unsafe fn controlDependencyWithOperations_dependentBlock_name( &self, operations: &NSArray<MPSGraphOperation>, dependent_block: MPSGraphControlFlowDependencyBlock, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphControlFlowOps
and MPSGraphOperation
and MPSGraphTensor
and block2
only.Runs the graph for the given feeds and returns the target tensor values, ensuring all target operations also executed.
This call blocks until execution has completed.
- Parameters:
- operations: Operations maked as control dependency for all ops created inside the dependent block
- dependentBlock: MPSGraphControlFlowDependencyBlock which is provided by caller to create dependent ops
- name: name of scope
- Returns: A valid MPSGraphTensor array with results returned from dependentBlock forwarded
§Safety
dependent_block
must be a valid pointer.
Sourcepub unsafe fn ifWithPredicateTensor_thenBlock_elseBlock_name(
&self,
predicate_tensor: &MPSGraphTensor,
then_block: MPSGraphIfThenElseBlock,
else_block: MPSGraphIfThenElseBlock,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphControlFlowOps
and MPSGraphTensor
and block2
only.
pub unsafe fn ifWithPredicateTensor_thenBlock_elseBlock_name( &self, predicate_tensor: &MPSGraphTensor, then_block: MPSGraphIfThenElseBlock, else_block: MPSGraphIfThenElseBlock, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphControlFlowOps
and MPSGraphTensor
and block2
only.Adds an if-then-else operation to the graph.
- Parameters:
- predicateTensor: Tensor must have a single scalar value, used to decide between then/else branches
- thenBlock: If predicate is true operations in this block are executed
- elseBlock: If predicate is false operations in this block are executed
- name: name of operation
- Returns: results If no error, the tensors returned by user. If not empty, user must define both then/else block, both should have same number of arguments and each corresponding argument should have same elementTypes.
§Safety
then_block
must be a valid pointer.else_block
must be a valid pointer or null.
Sourcepub unsafe fn whileWithInitialInputs_before_after_name(
&self,
initial_inputs: &NSArray<MPSGraphTensor>,
before: MPSGraphWhileBeforeBlock,
after: MPSGraphWhileAfterBlock,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphControlFlowOps
and MPSGraphTensor
and block2
only.
pub unsafe fn whileWithInitialInputs_before_after_name( &self, initial_inputs: &NSArray<MPSGraphTensor>, before: MPSGraphWhileBeforeBlock, after: MPSGraphWhileAfterBlock, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphControlFlowOps
and MPSGraphTensor
and block2
only.Adds a while loop operation.
- Parameters:
- initialInputs: inputTensors to the
beforeBlock
, for the 1st iteration will be same as initialInputs passed to the while loop. - before:
beforeBlock
, this will be run first and then call theafterBlock
with results or return results from the loop. - after:
afterBlock
, this will execute after the condition evaluation. - name: name of operation.
- Returns: A valid MPSGraphTensor array with results returned from the conditionBlock depending on the predicate tensor.
§Safety
before
must be a valid pointer.after
must be a valid pointer.
Sourcepub unsafe fn forLoopWithLowerBound_upperBound_step_initialBodyArguments_body_name(
&self,
lower_bound: &MPSGraphTensor,
upper_bound: &MPSGraphTensor,
step: &MPSGraphTensor,
initial_body_arguments: &NSArray<MPSGraphTensor>,
body: MPSGraphForLoopBodyBlock,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphControlFlowOps
and MPSGraphTensor
and block2
only.
pub unsafe fn forLoopWithLowerBound_upperBound_step_initialBodyArguments_body_name( &self, lower_bound: &MPSGraphTensor, upper_bound: &MPSGraphTensor, step: &MPSGraphTensor, initial_body_arguments: &NSArray<MPSGraphTensor>, body: MPSGraphForLoopBodyBlock, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphControlFlowOps
and MPSGraphTensor
and block2
only.Adds a for loop operation, The lower and upper bounds specify a half-open range: the range includes the lower bound but does not include the upper bound.
- Parameters:
- lowerBound: Lower bound value of the loop, this is a scalar tensor, this is the index the loop will start with.
- upperBound: Upper bound value of the loop, this is a scalar tensor.
- step: Step value of the loop, this is a scalar tensor and must be positive.
- initialBodyArguments: initial set of iteration arguments passed to the bodyBlock of the for loop.
- body: This block will execute the body of the for loop.
- name: name of operation.
- Returns: A valid
MPSGraphTensor
array with same count and corresponding element types asinitialIterationArguments
and return types of the for loop.
§Safety
body
must be a valid pointer.
Sourcepub unsafe fn forLoopWithNumberOfIterations_initialBodyArguments_body_name(
&self,
number_of_iterations: &MPSGraphTensor,
initial_body_arguments: &NSArray<MPSGraphTensor>,
body: MPSGraphForLoopBodyBlock,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphControlFlowOps
and MPSGraphTensor
and block2
only.
pub unsafe fn forLoopWithNumberOfIterations_initialBodyArguments_body_name( &self, number_of_iterations: &MPSGraphTensor, initial_body_arguments: &NSArray<MPSGraphTensor>, body: MPSGraphForLoopBodyBlock, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphControlFlowOps
and MPSGraphTensor
and block2
only.Adds a for loop operation, with a specific number of iterations.
- Parameters:
- numberOfIterations: tensor with number of iterations the loop will execute
- initialBodyArguments: initial set of iteration arguments passed to the bodyBlock of the for loop
- body: bodyBlock, this will execute the body of the for loop, index will go from 0 to numberOfIterations-1
- name: name of operation
- Returns: A valid MPSGraphTensor array with same count and corresponding elementTypes as initialIterationArguments and return types of the for loop
§Safety
body
must be a valid pointer.
Source§impl MPSGraph
MPSGraphConvolutionOps.
impl MPSGraph
MPSGraphConvolutionOps.
This is a category that defines the methods which can be used to add 2D-convolution operator to the graph with properties described by an instance of MPSGraphConvolution2DOpDescriptor
.
Sourcepub unsafe fn convolution2DWithSourceTensor_weightsTensor_descriptor_name(
&self,
source: &MPSGraphTensor,
weights: &MPSGraphTensor,
descriptor: &MPSGraphConvolution2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionOps
and MPSGraphTensor
only.
pub unsafe fn convolution2DWithSourceTensor_weightsTensor_descriptor_name( &self, source: &MPSGraphTensor, weights: &MPSGraphTensor, descriptor: &MPSGraphConvolution2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionOps
and MPSGraphTensor
only.Creates a 2D (forward) convolution operation and returns the result tensor.
- Parameters:
- source: source tensor - must be a rank 4 tensor. The layout is defined by
descriptor.dataLayout
. - weights: weights tensor, must be rank 4. The layout is defined by
descriptor.weightsLayout
. - descriptor: Specifies strides, dilation rates, paddings and layouts.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn convolution2DDataGradientWithIncomingGradientTensor_weightsTensor_outputShape_forwardConvolutionDescriptor_name(
&self,
incoming_gradient: &MPSGraphTensor,
weights: &MPSGraphTensor,
output_shape: &MPSShape,
forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn convolution2DDataGradientWithIncomingGradientTensor_weightsTensor_outputShape_forwardConvolutionDescriptor_name( &self, incoming_gradient: &MPSGraphTensor, weights: &MPSGraphTensor, output_shape: &MPSShape, forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a 2D convolution gradient operation with respect to the source tensor of the forward convolution.
If S
is source tensor to forward convolution, R
is the result/returned tensor from forward convolution,
and L
is the loss function, convolution2DDataGradientWithIncomingGradientTensor
returns tensor dL/dS = dL/dR * dR/dS
,
where dL/dR
is the incomingGradient parameter.
- Parameters:
- incomingGradient: Incoming loss gradient tensor
- weights: Forward pass weights tensor
- outputShape: Shape of the forward pass source tensor
- forwardConvolutionDescriptor: Forward convolution 2D op
descriptor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn convolution2DDataGradientWithIncomingGradientTensor_weightsTensor_outputShapeTensor_forwardConvolutionDescriptor_name(
&self,
gradient: &MPSGraphTensor,
weights: &MPSGraphTensor,
output_shape_tensor: &MPSGraphTensor,
forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionOps
and MPSGraphTensor
only.
pub unsafe fn convolution2DDataGradientWithIncomingGradientTensor_weightsTensor_outputShapeTensor_forwardConvolutionDescriptor_name( &self, gradient: &MPSGraphTensor, weights: &MPSGraphTensor, output_shape_tensor: &MPSGraphTensor, forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionOps
and MPSGraphTensor
only.Creates a 2D convolution gradient operation with respect to the source tensor of the forward convolution.
If S
is source tensor to forward convolution, R
is the result/returned tensor of forward convolution,
and L
is the loss function, convolution2DDataGradientWithIncomingGradientTensor returns tensor dL/dS = dL/dR * dR/dS
,
where dL/dR
is the incomingGradient parameter.
- Parameters:
- incomingGradient: Incoming loss gradient tensor
- weights: Forward pass weights tensor
- outputShapeTensor: 4D Int32 or Int64 tensor. Shape of the forward pass source tensor
- forwardConvolutionDescriptor: Forward convolution 2D op
descriptor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn convolution2DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShape_forwardConvolutionDescriptor_name(
&self,
incoming_gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
output_shape: &MPSShape,
forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn convolution2DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShape_forwardConvolutionDescriptor_name( &self, incoming_gradient: &MPSGraphTensor, source: &MPSGraphTensor, output_shape: &MPSShape, forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a 2D convolution gradient operation with respect to the weights tensor of the forward convolution.
If W
is weights tensor to forward convolution, R
is the result/returned tensor of forward convolution,
and L
is the loss function, convolution2DWeightsGradientWithIncomingGradientTensor returns tensor dL/dW = dL/dR * dR/dW
,
where dL/dR
is the incomingGradient parameter.
- Parameters:
- incomingGradient: Incoming loss gradient tensor
- weights: Forward pass weights tensor
- outputShape: Shape of the forward pass source tensor
- forwardConvolutionDescriptor: Forward convolution 2D op
descriptor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn convolution2DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShapeTensor_forwardConvolutionDescriptor_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
output_shape_tensor: &MPSGraphTensor,
forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionOps
and MPSGraphTensor
only.
pub unsafe fn convolution2DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShapeTensor_forwardConvolutionDescriptor_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, output_shape_tensor: &MPSGraphTensor, forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionOps
and MPSGraphTensor
only.Creates a 2D convolution gradient operation with respect to weights tensor of forward convolution.
If W
is weights tensor to forward convolution, R
is the result/returned tensor of forward convolution,
and L
is the loss function, convolution2DWeightsGradientWithIncomingGradientTensor returns tensor dL/dW = dL/dR * dR/dW
,
where dL/dR
is the incomingGradient parameter.
- Parameters:
- incomingGradient: Incoming loss gradient tensor
- weights: Forward pass weights tensor
- outputShapeTensor: 4D int32 or Int64 Tensor. Shape of the forward pass source tensor
- forwardConvolutionDescriptor: Forward convolution 2D op
descriptor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn convolution3DWithSourceTensor_weightsTensor_descriptor_name(
&self,
source: &MPSGraphTensor,
weights: &MPSGraphTensor,
descriptor: &MPSGraphConvolution3DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionOps
and MPSGraphTensor
only.
pub unsafe fn convolution3DWithSourceTensor_weightsTensor_descriptor_name( &self, source: &MPSGraphTensor, weights: &MPSGraphTensor, descriptor: &MPSGraphConvolution3DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionOps
and MPSGraphTensor
only.Creates a 3D forward convolution operation and returns the result tensor.
- Parameters:
- source: source tensor - must be of rank 5. The layout is defined by
descriptor.dataLayout
. - weights: weights tensor, must be rank 5. The layout is defined by
descriptor.weightsLayout
. - descriptor: Specifies strides, dilation rates, paddings and layouts.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn convolution3DDataGradientWithIncomingGradientTensor_weightsTensor_outputShape_forwardConvolutionDescriptor_name(
&self,
incoming_gradient: &MPSGraphTensor,
weights: &MPSGraphTensor,
output_shape: &MPSShape,
forward_convolution_descriptor: &MPSGraphConvolution3DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn convolution3DDataGradientWithIncomingGradientTensor_weightsTensor_outputShape_forwardConvolutionDescriptor_name( &self, incoming_gradient: &MPSGraphTensor, weights: &MPSGraphTensor, output_shape: &MPSShape, forward_convolution_descriptor: &MPSGraphConvolution3DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a 3D convolution gradient operation with respect to the source tensor of the forward convolution.
If S
is source tensor to forward convolution, R
is the result/returned tensor of forward convolution,
and L
is the loss function, convolution3DDataGradientWithIncomingGradientTensor returns tensor dL/dS = dL/dR * dR/dS
,
where dL/dR
is the incomingGradient parameter.
- Parameters:
- incomingGradient: Incoming loss gradient tensor
- weights: Forward pass weights tensor
- outputShape: Shape of the forward pass source tensor
- forwardConvolutionDescriptor: Forward convolution 2D op
descriptor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn convolution3DDataGradientWithIncomingGradientTensor_weightsTensor_outputShapeTensor_forwardConvolutionDescriptor_name(
&self,
gradient: &MPSGraphTensor,
weights: &MPSGraphTensor,
output_shape_tensor: &MPSGraphTensor,
forward_convolution_descriptor: &MPSGraphConvolution3DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionOps
and MPSGraphTensor
only.
pub unsafe fn convolution3DDataGradientWithIncomingGradientTensor_weightsTensor_outputShapeTensor_forwardConvolutionDescriptor_name( &self, gradient: &MPSGraphTensor, weights: &MPSGraphTensor, output_shape_tensor: &MPSGraphTensor, forward_convolution_descriptor: &MPSGraphConvolution3DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionOps
and MPSGraphTensor
only.Creates a 3D convolution gradient operation with respect to the source tensor of the forward convolution.
If S
is source tensor to forward convolution, R
is the result/returned tensor of forward convolution,
and L
is the loss function, convolution3DDataGradientWithIncomingGradientTensor returns tensor dL/dS = dL/dR * dR/dS
,
where dL/dR
is the incomingGradient parameter.
- Parameters:
- incomingGradient: Incoming loss gradient tensor
- weights: Forward pass weights tensor
- outputShapeTensor: 4D Int32 or Int64 tensor. Shape of the forward pass source tensor
- forwardConvolutionDescriptor: Forward convolution 2D op
descriptor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn convolution3DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShape_forwardConvolutionDescriptor_name(
&self,
incoming_gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
output_shape: &MPSShape,
forward_convolution_descriptor: &MPSGraphConvolution3DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn convolution3DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShape_forwardConvolutionDescriptor_name( &self, incoming_gradient: &MPSGraphTensor, source: &MPSGraphTensor, output_shape: &MPSShape, forward_convolution_descriptor: &MPSGraphConvolution3DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a 3D convolution gradient operation with respect to the weights tensor of the forward convolution.
If W
is weights tensor to forward convolution, R
is the result/returned tensor of forward convolution,
and L
is the loss function, convolution3DWeightsGradientWithIncomingGradientTensor returns tensor dL/dW = dL/dR * dR/dW
,
where dL/dR
is the incomingGradient parameter.
- Parameters:
- incomingGradient: Incoming loss gradient tensor
- weights: Forward pass weights tensor
- outputShape: Shape of the forward pass source tensor
- forwardConvolutionDescriptor: Forward convolution 2D op
descriptor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn convolution3DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShapeTensor_forwardConvolutionDescriptor_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
output_shape_tensor: &MPSGraphTensor,
forward_convolution_descriptor: &MPSGraphConvolution3DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionOps
and MPSGraphTensor
only.
pub unsafe fn convolution3DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShapeTensor_forwardConvolutionDescriptor_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, output_shape_tensor: &MPSGraphTensor, forward_convolution_descriptor: &MPSGraphConvolution3DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionOps
and MPSGraphTensor
only.Creates a 3D convolution gradient operation with respect to the weights tensor of the forward convolution.
If W
is weights tensor to forward convolution, R
is the result/returned tensor of forward convolution,
and L
is the loss function, convolution3DWeightsGradientWithIncomingGradientTensor returns tensor dL/dW = dL/dR * dR/dW
,
where dL/dR
is the incomingGradient parameter.
- Parameters:
- incomingGradient: Incoming loss gradient tensor
- weights: Forward pass weights tensor
- outputShapeTensor: 4D int32 or Int64 Tensor. Shape of the forward pass source tensor
- forwardConvolutionDescriptor: Forward convolution 2D op
descriptor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Source§impl MPSGraph
MPSGraphConvolutionTransposeOps.
impl MPSGraph
MPSGraphConvolutionTransposeOps.
This is a category that defines the methods which can be used to add 2D-convolution transpose operator to the graph with properties described by an instance of MPSGraphConvolution2DOpDescriptor
.
Sourcepub unsafe fn convolutionTranspose2DWithSourceTensor_weightsTensor_outputShape_descriptor_name(
&self,
source: &MPSGraphTensor,
weights: &MPSGraphTensor,
output_shape: &MPSShape,
descriptor: &MPSGraphConvolution2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionTransposeOps
and MPSGraphConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn convolutionTranspose2DWithSourceTensor_weightsTensor_outputShape_descriptor_name( &self, source: &MPSGraphTensor, weights: &MPSGraphTensor, output_shape: &MPSShape, descriptor: &MPSGraphConvolution2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionTransposeOps
and MPSGraphConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a convolution transpose operation and returns the result tensor.
Convolution Tranpose operation is exactly the same as convolution gradint with respect to input image convolution2DDataGradientWithIncomingGradient
.
Weights tensor and source tensors are interpreted as they are in convolution2DDataGradientWithIncomingGradient
.
Convolution with stride s
downsamples source tensor by factor s
in spatial dimensions whereas convolution tranpose with stride s
upsamples
source tensor by factor s
. Convolution transpose can map the same source size to multiple destination sizes. The relationship between the width of the
source and the width of the destination is (sourceWidth - 1)stride + 1 + (kernelWidth - 1)dilationRate < = destinationWidth + paddingLeft + paddingRight
so there are stride -1 values of the width of the destination that give same width of the source. In order to disambiguate, outputShape parameter is used.
- Parameters:
- source: input tensor
- weights: weights tensor
- outputShape: shape of the result tensor.
- descriptor: descriptor for the corresponding forward 2D-convolution operation
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn convolutionTranspose2DWithSourceTensor_weightsTensor_outputShapeTensor_descriptor_name(
&self,
source: &MPSGraphTensor,
weights: &MPSGraphTensor,
output_shape: &MPSGraphTensor,
descriptor: &MPSGraphConvolution2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionTransposeOps
and MPSGraphConvolutionOps
and MPSGraphTensor
only.
pub unsafe fn convolutionTranspose2DWithSourceTensor_weightsTensor_outputShapeTensor_descriptor_name( &self, source: &MPSGraphTensor, weights: &MPSGraphTensor, output_shape: &MPSGraphTensor, descriptor: &MPSGraphConvolution2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionTransposeOps
and MPSGraphConvolutionOps
and MPSGraphTensor
only.Creates a convolution transpose operation and returns the result tensor.
- Parameters:
- source: input tensor
- weights: weights tensor
- outputShape: 1D Int32 or Int64 tensor. shape of the result tensor.
- descriptor: descriptor for the corresponding forward Conv2D operation
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn convolutionTranspose2DDataGradientWithIncomingGradientTensor_weightsTensor_outputShape_forwardConvolutionDescriptor_name(
&self,
incoming_gradient: &MPSGraphTensor,
weights: &MPSGraphTensor,
output_shape: &MPSShape,
forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionTransposeOps
and MPSGraphConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn convolutionTranspose2DDataGradientWithIncomingGradientTensor_weightsTensor_outputShape_forwardConvolutionDescriptor_name( &self, incoming_gradient: &MPSGraphTensor, weights: &MPSGraphTensor, output_shape: &MPSShape, forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionTransposeOps
and MPSGraphConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a convolution transpose gradient operation with respect to the source tensor of convolution transpose operation and returns the result tensor.
Inserts an operation in graph to compute gradient of convolution transpose with respect to source tensor of the corresponding convolution transpose operation.
- Parameters:
- incomingGradient: Incoming gradient tensor
- weights: Forward pass weights tensor
- outputShape: Shape of the forward pass source tensor
- forwardConvolutionDescriptor: Forward pass op descriptor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn convolutionTranspose2DDataGradientWithIncomingGradientTensor_weightsTensor_outputShapeTensor_forwardConvolutionDescriptor_name(
&self,
incoming_gradient: &MPSGraphTensor,
weights: &MPSGraphTensor,
output_shape: &MPSGraphTensor,
forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionTransposeOps
and MPSGraphConvolutionOps
and MPSGraphTensor
only.
pub unsafe fn convolutionTranspose2DDataGradientWithIncomingGradientTensor_weightsTensor_outputShapeTensor_forwardConvolutionDescriptor_name( &self, incoming_gradient: &MPSGraphTensor, weights: &MPSGraphTensor, output_shape: &MPSGraphTensor, forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionTransposeOps
and MPSGraphConvolutionOps
and MPSGraphTensor
only.Creates a convolution transpose gradient operation with respect to the source tensor of convolution transpose operation and returns the result tensor.
Inserts an operation in graph to compute gradient of convolution transpose with respect to source tensor of the corresponding convolution transpose operation.
- Parameters:
- incomingGradient: Incoming gradient tensor
- weights: Forward pass weights tensor
- outputShape: 1D Int32 or Int64 Tensor. Shape of the forward pass source tensor
- forwardConvolutionDescriptor: Forward pass op descriptor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn convolutionTranspose2DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShape_forwardConvolutionDescriptor_name(
&self,
incoming_gradient_tensor: &MPSGraphTensor,
source: &MPSGraphTensor,
output_shape: &MPSShape,
forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionTransposeOps
and MPSGraphConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn convolutionTranspose2DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShape_forwardConvolutionDescriptor_name( &self, incoming_gradient_tensor: &MPSGraphTensor, source: &MPSGraphTensor, output_shape: &MPSShape, forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionTransposeOps
and MPSGraphConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a convolution transpose gradient operation with respect to the weights tensor of the convolution transpose operation and returns the result tensor.
Inserts an operation in graph to compute gradient of convolution transpose with respect to the weights tensor of the corresponding convolution transpose operation.
- Parameters:
- incomingGradientTensor: Incoming gradient tensor
- source: Forward pass source tensor
- outputShape: Shape of the forward pass source weights tensor
- forwardConvolutionDescriptor: Forward pass op descriptor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn convolutionTranspose2DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShapeTensor_forwardConvolutionDescriptor_name(
&self,
incoming_gradient_tensor: &MPSGraphTensor,
source: &MPSGraphTensor,
output_shape: &MPSGraphTensor,
forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphConvolutionTransposeOps
and MPSGraphConvolutionOps
and MPSGraphTensor
only.
pub unsafe fn convolutionTranspose2DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShapeTensor_forwardConvolutionDescriptor_name( &self, incoming_gradient_tensor: &MPSGraphTensor, source: &MPSGraphTensor, output_shape: &MPSGraphTensor, forward_convolution_descriptor: &MPSGraphConvolution2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphConvolutionTransposeOps
and MPSGraphConvolutionOps
and MPSGraphTensor
only.Creates a convolution transpose gradient operation with respect to the weights tensor of the convolution transpose operation and returns the result tensor.
Inserts an operation in graph to compute gradient of convolution transpose with respect to the weights tensor of the corresponding convolution transpose operation.
- Parameters:
- incomingGradientTensor: Incoming gradient tensor
- source: Forward pass source tensor
- outputShape: 1D Int32 or Int64 Tensor. Shape of the forward pass source weights tensor
- forwardConvolutionDescriptor: Forward pass op descriptor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Source§impl MPSGraph
MPSGraphCumulativeOps.
impl MPSGraph
MPSGraphCumulativeOps.
Sourcepub unsafe fn cumulativeSumWithTensor_axis_exclusive_reverse_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
exclusive: bool,
reverse: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeSumWithTensor_axis_exclusive_reverse_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, exclusive: bool, reverse: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative sum of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axis: The tensor dimension where you compute the cumulative operation
- exclusive: If true, perform the exclusive cumulative operation, and the first element will be equal to zero
- reverse: If true, reverse the direction of the cumulative operation along the specified axis
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeSumWithTensor_axisTensor_exclusive_reverse_name(
&self,
tensor: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
exclusive: bool,
reverse: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeSumWithTensor_axisTensor_exclusive_reverse_name( &self, tensor: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, exclusive: bool, reverse: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative sum of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axisTensor: The tensor dimension where you compute the cumulative operation
- exclusive: If true, perform the exclusive cumulative operation, and the first element will be equal to zero
- reverse: If true, reverse the direction of the cumulative operation along the specified axis
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeSumWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeSumWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative sum of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axis: The tensor dimension where you compute the cumulative operation
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeSumWithTensor_axisTensor_name(
&self,
tensor: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeSumWithTensor_axisTensor_name( &self, tensor: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative sum of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axisTensor: The tensor dimension where you compute the cumulative operation
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeProductWithTensor_axis_exclusive_reverse_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
exclusive: bool,
reverse: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeProductWithTensor_axis_exclusive_reverse_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, exclusive: bool, reverse: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative product of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axis: The tensor dimension where you compute the cumulative operation
- exclusive: If true, perform the exclusive cumulative operation, and the first element will be equal to one
- reverse: If true, reverse the direction of the cumulative operation along the specified axis
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeProductWithTensor_axisTensor_exclusive_reverse_name(
&self,
tensor: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
exclusive: bool,
reverse: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeProductWithTensor_axisTensor_exclusive_reverse_name( &self, tensor: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, exclusive: bool, reverse: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative product of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axisTensor: The tensor dimension where you compute the cumulative operation
- exclusive: If true, perform the exclusive cumulative operation, and the first element will be equal to one
- reverse: If true, reverse the direction of the cumulative operation along the specified axis
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeProductWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeProductWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative product of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axis: The tensor dimension where you compute the cumulative operation
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeProductWithTensor_axisTensor_name(
&self,
tensor: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeProductWithTensor_axisTensor_name( &self, tensor: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative product of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axisTensor: The tensor dimension where you compute the cumulative operation
- exclusive: If true, perform the exclusive cumulative operation, and the first element will be equal to one
- reverse: If true, reverse the direction of the cumulative operation along the specified axis
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeMinimumWithTensor_axis_exclusive_reverse_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
exclusive: bool,
reverse: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeMinimumWithTensor_axis_exclusive_reverse_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, exclusive: bool, reverse: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative minimum of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axis: The tensor dimension where you compute the cumulative operation
- exclusive: If true, perform the exclusive cumulative operation, and the first element will be equal to the largest value of the tensor data type
- reverse: If true, reverse the direction of the cumulative operation along the specified axis
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeMinimumWithTensor_axisTensor_exclusive_reverse_name(
&self,
tensor: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
exclusive: bool,
reverse: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeMinimumWithTensor_axisTensor_exclusive_reverse_name( &self, tensor: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, exclusive: bool, reverse: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative minimum of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axisTensor: The tensor dimension where you compute the cumulative operation
- exclusive: If true, perform the exclusive cumulative operation, and the first element will be equal to the largest value of the tensor data type
- reverse: If true, reverse the direction of the cumulative operation along the specified axis
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeMinimumWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeMinimumWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative minimum of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axis: The tensor dimension where you compute the cumulative operation
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeMinimumWithTensor_axisTensor_name(
&self,
tensor: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeMinimumWithTensor_axisTensor_name( &self, tensor: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative minimum of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axisTensor: The tensor dimension where you compute the cumulative operation
- exclusive: If true, perform the exclusive cumulative operation, and the first element will be equal to the largest value of the tensor data type
- reverse: If true, reverse the direction of the cumulative operation along the specified axis
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeMaximumWithTensor_axis_exclusive_reverse_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
exclusive: bool,
reverse: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeMaximumWithTensor_axis_exclusive_reverse_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, exclusive: bool, reverse: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative maximum of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axis: The tensor dimension where you compute the cumulative operation
- exclusive: If true, perform the exclusive cumulative operation, and the first element will be equal to the lowest value of the tensor data type
- reverse: If true, reverse the direction of the cumulative operation along the specified axis
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeMaximumWithTensor_axisTensor_exclusive_reverse_name(
&self,
tensor: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
exclusive: bool,
reverse: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeMaximumWithTensor_axisTensor_exclusive_reverse_name( &self, tensor: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, exclusive: bool, reverse: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative maximum of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axisTensor: The tensor dimension where you compute the cumulative operation
- exclusive: If true, perform the exclusive cumulative operation, and the first element will be equal to the lowest value of the tensor data type
- reverse: If true, reverse the direction of the cumulative operation along the specified axis
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeMaximumWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeMaximumWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative maximum of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axis: The tensor dimension where you compute the cumulative operation
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn cumulativeMaximumWithTensor_axisTensor_name(
&self,
tensor: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphCumulativeOps
and MPSGraphTensor
only.
pub unsafe fn cumulativeMaximumWithTensor_axisTensor_name( &self, tensor: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphCumulativeOps
and MPSGraphTensor
only.Computes the cumulative maximum of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axisTensor: The tensor dimension where you compute the cumulative operation
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Source§impl MPSGraph
MPSGraphDepthwiseConvolutionOps.
impl MPSGraph
MPSGraphDepthwiseConvolutionOps.
Sourcepub unsafe fn depthwiseConvolution2DWithSourceTensor_weightsTensor_descriptor_name(
&self,
source: &MPSGraphTensor,
weights: &MPSGraphTensor,
descriptor: &MPSGraphDepthwiseConvolution2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphDepthwiseConvolutionOps
and MPSGraphTensor
only.
pub unsafe fn depthwiseConvolution2DWithSourceTensor_weightsTensor_descriptor_name( &self, source: &MPSGraphTensor, weights: &MPSGraphTensor, descriptor: &MPSGraphDepthwiseConvolution2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphDepthwiseConvolutionOps
and MPSGraphTensor
only.Creates a 2D-depthwise convolution operation and returns the result tensor.
- Parameters:
- source: A 2D Image source as tensor - must be of rank=4. The layout is defined by
descriptor.dataLayout
. - weights: The weights tensor, must be rank=4. The layout is defined by
descriptor.weightsLayout
. - descriptor: The descriptor object that specifies strides, dilation rates, paddings and layouts.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn depthwiseConvolution2DDataGradientWithIncomingGradientTensor_weightsTensor_outputShape_descriptor_name(
&self,
incoming_gradient: &MPSGraphTensor,
weights: &MPSGraphTensor,
output_shape: &MPSShape,
descriptor: &MPSGraphDepthwiseConvolution2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphDepthwiseConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn depthwiseConvolution2DDataGradientWithIncomingGradientTensor_weightsTensor_outputShape_descriptor_name( &self, incoming_gradient: &MPSGraphTensor, weights: &MPSGraphTensor, output_shape: &MPSShape, descriptor: &MPSGraphDepthwiseConvolution2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphDepthwiseConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a 2D-depthwise convolution gradient for data operation and returns the result tensor.
- Parameters:
- incomingGradient: A 2D input gradient tensor - must be of rank=4. The layout is defined by
descriptor.dataLayout
. - weights: The weights tensor, must be rank=4. The layout is defined by
descriptor.weightsLayout
. - outputShape: The shape of the οutput tensor (and therefore input tensor of forward pass).
- descriptor: The descriptor object that specifies strides, dilation rates, paddings and layouts.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn depthwiseConvolution2DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShape_descriptor_name(
&self,
incoming_gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
output_shape: &MPSShape,
descriptor: &MPSGraphDepthwiseConvolution2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphDepthwiseConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn depthwiseConvolution2DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShape_descriptor_name( &self, incoming_gradient: &MPSGraphTensor, source: &MPSGraphTensor, output_shape: &MPSShape, descriptor: &MPSGraphDepthwiseConvolution2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphDepthwiseConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a 2D-depthwise convolution gradient for weights operation and returns the result tensor.
- Parameters:
- incomingGradient: A 2D input gradient tensor - must be of rank=4. The layout is defined by
descriptor.dataLayout
. - source: A 2D Image source as tensor - must be of rank=4. The layout is defined by
descriptor.dataLayout
. - outputShape: The shape of the οutput tensor (and therefore weight tensor of forward pass).
- descriptor: The descriptor object that specifies strides, dilation rates, paddings and layouts.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn depthwiseConvolution3DWithSourceTensor_weightsTensor_descriptor_name(
&self,
source: &MPSGraphTensor,
weights: &MPSGraphTensor,
descriptor: &MPSGraphDepthwiseConvolution3DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphDepthwiseConvolutionOps
and MPSGraphTensor
only.
pub unsafe fn depthwiseConvolution3DWithSourceTensor_weightsTensor_descriptor_name( &self, source: &MPSGraphTensor, weights: &MPSGraphTensor, descriptor: &MPSGraphDepthwiseConvolution3DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphDepthwiseConvolutionOps
and MPSGraphTensor
only.Creates a 3D depthwise convolution operation and returns the result tensor.
Works exactly like depthwise convolution2D, but in three dimensions. Supports different layouts with
the MPSGraphDepthwiseConvolution3DOpDescriptor/channelDimensionIndex
property.
If your weights need a different layout add a permute operation on them before this operation.
- Parameters:
- source: A 3D Image source as tensor - must be at least rank=4 (CDHW when channelDimensionIndex = -4).
- weights: The weights tensor, must be rank=4 - axes are interpreted as CDHW when channelDimensionIndex = -4 .
- descriptor: The descriptor object that specifies strides, dilation rates and paddings.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn depthwiseConvolution3DDataGradientWithIncomingGradientTensor_weightsTensor_outputShape_descriptor_name(
&self,
incoming_gradient: &MPSGraphTensor,
weights: &MPSGraphTensor,
output_shape: Option<&MPSShape>,
descriptor: &MPSGraphDepthwiseConvolution3DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphDepthwiseConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn depthwiseConvolution3DDataGradientWithIncomingGradientTensor_weightsTensor_outputShape_descriptor_name( &self, incoming_gradient: &MPSGraphTensor, weights: &MPSGraphTensor, output_shape: Option<&MPSShape>, descriptor: &MPSGraphDepthwiseConvolution3DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphDepthwiseConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a 3D depthwise convolution gradient for data operation and returns the result tensor.
- Parameters:
- incomingGradient: A 3D input gradient tensor - must be at least rank=4 (CDHW).
- weights: The weights tensor, must be rank=4 - axes are interpreted as CDHW.
- outputShape: The shape of the οutput tensor (and therefore input tensor of forward pass).
- descriptor: The descriptor object that specifies strides, dilation rates and paddings.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn depthwiseConvolution3DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShape_descriptor_name(
&self,
incoming_gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
output_shape: &MPSShape,
descriptor: &MPSGraphDepthwiseConvolution3DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphDepthwiseConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn depthwiseConvolution3DWeightsGradientWithIncomingGradientTensor_sourceTensor_outputShape_descriptor_name( &self, incoming_gradient: &MPSGraphTensor, source: &MPSGraphTensor, output_shape: &MPSShape, descriptor: &MPSGraphDepthwiseConvolution3DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphDepthwiseConvolutionOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a 3D depthwise convolution gradient for weights operation and returns the result tensor.
- Parameters:
- incomingGradient: A 3D input gradient tensor - must be at least rank=4 (NCDHW).
- source: The forward pass 3D Image source as tensor - must be at least rank=4 (NCDHW).
- outputShape: The shape of the οutput tensor (and therefore weight tensor of forward pass).
- descriptor: The descriptor object that specifies strides, dilation rates and paddings.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Source§impl MPSGraph
MPSGraphFourierTransformOps.
impl MPSGraph
MPSGraphFourierTransformOps.
Sourcepub unsafe fn fastFourierTransformWithTensor_axes_descriptor_name(
&self,
tensor: &MPSGraphTensor,
axes: &NSArray<NSNumber>,
descriptor: &MPSGraphFFTDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphFourierTransformOps
and MPSGraphTensor
only.
pub unsafe fn fastFourierTransformWithTensor_axes_descriptor_name( &self, tensor: &MPSGraphTensor, axes: &NSArray<NSNumber>, descriptor: &MPSGraphFFTDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphFourierTransformOps
and MPSGraphTensor
only.Creates a fast Fourier transform operation and returns the result tensor.
This operation computes the fast Fourier transform of the input tensor according to the following formulae.
output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) input[nu], where
scale = 1
for scaling_mode = none
,
scale = 1/V_f
for scaling_mode = size
,
scale = 1/sqrt(V_f)
for scaling_mode = unitary
, where
V_f
is the volume of the transformation defined by the dimensions included in axes
(V_f = prod_{i \in axes} shape(input)[i]
) (see MPSGraphFFTDescriptor/scalingMode
),
+
is selected in +/-
when inverse
is specified, otherwise -
is used
and the sum is done separately over each dimension in axes
and n
is the
dimension length of that axis.
Tip: Currently MPSGraph supports the transformation only within the last four dimensions of the input tensor. In case you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input with
MPSGraph/transposeTensor:permutation:name:
to be within that last four and then transpose the result tensor back with the inverse of the input transpose.
- Parameters:
- tensor: A complex or real-valued input tensor.
- axes: An array of numbers that specifies over which axes MPSGraph performs the Fourier transform - all axes must be contained within last four dimensions of the input tensor.
- descriptor: A descriptor that defines the parameters of the Fourier transform operation - see
MPSGraphFFTDescriptor
. - name: The name for the operation.
- Returns: A valid complex-valued MPSGraphTensor of the same shape as
tensor
.
Sourcepub unsafe fn fastFourierTransformWithTensor_axesTensor_descriptor_name(
&self,
tensor: &MPSGraphTensor,
axes_tensor: &MPSGraphTensor,
descriptor: &MPSGraphFFTDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphFourierTransformOps
and MPSGraphTensor
only.
pub unsafe fn fastFourierTransformWithTensor_axesTensor_descriptor_name( &self, tensor: &MPSGraphTensor, axes_tensor: &MPSGraphTensor, descriptor: &MPSGraphFFTDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphFourierTransformOps
and MPSGraphTensor
only.Creates a fast Fourier transform operation and returns the result tensor.
This operation computes the fast Fourier transform of the input tensor according to the following formulae.
output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) input[nu], where
scale = 1
for scaling_mode = none
,
scale = 1/V_f
for scaling_mode = size
,
scale = 1/sqrt(V_f)
for scaling_mode = unitary
, where
V_f
is the volume of the transformation defined by the dimensions included in axes
(V_f = prod_{i \in axes} shape(input)[i]
) (see MPSGraphFFTDescriptor/scalingMode
),
+
is selected in +/-
when inverse
is specified, otherwise -
is used
and the sum is done separately over each dimension in axes
and n
is the
dimension length of that axis.
Tip: Currently MPSGraph supports the transformation only within the last four dimensions of the input tensor. In case you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input with
MPSGraph/transposeTensor:permutation:name:
to be within that last four and then transpose the result tensor back with the inverse of the input transpose.
- Parameters:
- tensor: A complex or real-valued input tensor.
- axesTensor: A tensor of rank one containing the axes over which MPSGraph performs the transformation. See
MPSGraph/fastFourierTransformWithTensor:axes:descriptor:name:
. - descriptor: A descriptor that defines the parameters of the Fourier transform operation - see
MPSGraphFFTDescriptor
. - name: The name for the operation.
- Returns: A valid complex-valued MPSGraphTensor of the same shape as
tensor
.
Sourcepub unsafe fn realToHermiteanFFTWithTensor_axes_descriptor_name(
&self,
tensor: &MPSGraphTensor,
axes: &NSArray<NSNumber>,
descriptor: &MPSGraphFFTDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphFourierTransformOps
and MPSGraphTensor
only.
pub unsafe fn realToHermiteanFFTWithTensor_axes_descriptor_name( &self, tensor: &MPSGraphTensor, axes: &NSArray<NSNumber>, descriptor: &MPSGraphFFTDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphFourierTransformOps
and MPSGraphTensor
only.Creates a Real-to-Hermitean fast Fourier transform operation and returns the result tensor.
This operation computes the fast Fourier transform of a real-valued input tensor according to the following formulae.
output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) input[nu], where
scale = 1
for scaling_mode = none
,
scale = 1/V_f
for scaling_mode = size
,
scale = 1/sqrt(V_f)
for scaling_mode = unitary
, where
V_f
is the volume of the transformation defined by the dimensions included in axes
(V_f = prod_{i \in axes} shape(input)[i]
) (see MPSGraphFFTDescriptor/scalingMode
),
+
is selected in +/-
when inverse
is specified, otherwise -
is used
and the sum is done separately over each dimension in axes
and n
is the
dimension length of that axis. With this API MPSGraph writes out only the results for the unique
frequencies, resulting in a tensor which has size (n/2)+1
in the last dimension defined by axes
.
Tip: Currently MPSGraph supports the transformation only within the last four dimensions of the input tensor. In case you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input with
MPSGraph/transposeTensor:permutation:name:
to be within that last four and then transpose the result tensor back with the inverse of the input transpose.
- Parameters:
- tensor: A Real-valued input tensor. Must have datatype
MPSDataTypeFloat32
orMPSDatatypeFloat16
. - axes: An array of numbers that specifies over which axes MPSGraph performs the Fourier transform - all axes must be contained within last four dimensions of the input tensor.
- descriptor: A descriptor that defines the parameters of the Fourier transform operation - see
MPSGraphFFTDescriptor
. - name: The name for the operation.
- Returns: A valid MPSGraphTensor of type
MPSDataTypeComplexFloat32
orMPSDataTypeComplexFloat16
with reduced size (see Discussion).
Sourcepub unsafe fn realToHermiteanFFTWithTensor_axesTensor_descriptor_name(
&self,
tensor: &MPSGraphTensor,
axes_tensor: &MPSGraphTensor,
descriptor: &MPSGraphFFTDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphFourierTransformOps
and MPSGraphTensor
only.
pub unsafe fn realToHermiteanFFTWithTensor_axesTensor_descriptor_name( &self, tensor: &MPSGraphTensor, axes_tensor: &MPSGraphTensor, descriptor: &MPSGraphFFTDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphFourierTransformOps
and MPSGraphTensor
only.Creates a Real-to-Hermitean fast Fourier transform operation and returns the result tensor.
This operation computes the fast Fourier transform of a real-valued input tensor according to the following formulae.
output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) input[nu], where
scale = 1
for scaling_mode = none
,
scale = 1/V_f
for scaling_mode = size
,
scale = 1/sqrt(V_f)
for scaling_mode = unitary
, where
V_f
is the volume of the transformation defined by the dimensions included in axes
(V_f = prod_{i \in axes} shape(input)[i]
) (see MPSGraphFFTDescriptor/scalingMode
),
+
is selected in +/-
when inverse
is specified, otherwise -
is used
and the sum is done separately over each dimension in axes
and n
is the
dimension length of that axis. With this API MPSGraph writes out only the results for the unique
frequencies, resulting in a tensor which has size (n/2)+1
in the last dimension defined by axes
.
Tip: Currently MPSGraph supports the transformation only within the last four dimensions of the input tensor. In case you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input with
MPSGraph/transposeTensor:permutation:name:
to be within that last four and then transpose the result tensor back with the inverse of the input transpose.
- Parameters:
- tensor: A real-valued input tensor. Must have datatype
MPSDataTypeFloat32
orMPSDatatypeFloat16
. - axesTensor: A tensor of rank one containing the axes over which MPSGraph performs the transformation. See
MPSGraph/fastFourierTransformWithTensor:axes:descriptor:name:
. - descriptor: A descriptor that defines the parameters of the Fourier transform operation - see
MPSGraphFFTDescriptor
. - name: The name for the operation.
- Returns: A valid MPSGraphTensor of type
MPSDataTypeComplexFloat32
orMPSDataTypeComplexFloat16
with reduced size (see Discussion).
Sourcepub unsafe fn HermiteanToRealFFTWithTensor_axes_descriptor_name(
&self,
tensor: &MPSGraphTensor,
axes: &NSArray<NSNumber>,
descriptor: &MPSGraphFFTDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphFourierTransformOps
and MPSGraphTensor
only.
pub unsafe fn HermiteanToRealFFTWithTensor_axes_descriptor_name( &self, tensor: &MPSGraphTensor, axes: &NSArray<NSNumber>, descriptor: &MPSGraphFFTDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphFourierTransformOps
and MPSGraphTensor
only.Creates a Hermitean-to-real fast Fourier transform operation and returns the result tensor.
This operation computes the fast Fourier transform of a complex-valued input tensor according to the following formulae.
output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) in'[nu], where
in'[nu] = conjugate(in[n - nu])
, for the last dimension defined by axes
when nu
is out of range of the input dimension.
scale = 1
for scaling_mode = none
,
scale = 1/V_f
for scaling_mode = size
,
scale = 1/sqrt(V_f)
for scaling_mode = unitary
, where
V_f
is the volume of the transformation defined by the dimensions included in axes
(V_f = prod_{i \in axes} shape(input)[i]
) (see MPSGraphFFTDescriptor/scalingMode
),
+
is selected in +/-
when inverse
is specified, otherwise -
is used
and the sum is done separately over each dimension in axes
and n
is the
dimension length of that axis. With this API MPSGraph treats the input tensor to have only the unique
frequencies, which means that the resulting tensor has size (inSize-1)*2 + x
in the last dimension defined by axes
,
where inSize = shape(input)[axis] ( = (n/2)+1 )
is the size of the input tensor
in the last transformed dimension and
x = 1
when MPSGraphFFTDescriptor/roundToOddHermitean
= YES
and x = 0
otherwise.
Tip: Currently transformation is supported only within the last four dimensions of the input tensor. In case you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input with
MPSGraph/transposeTensor:permutation:name:
to be within that last four and then transpose the result tensor back with the inverse of the input transpose.
- Parameters:
- tensor: A complex-valued input tensor with reduced size (see Discussion). Must have datatype
MPSDataTypeComplexFloat32
orMPSDataTypeComplexFloat16
. - axes: An array of numbers that specifies over which axes MPSGraph performs the Fourier transform - all axes must be contained within last four dimensions of the input tensor.
- descriptor: A descriptor that defines the parameters of the Fourier transform operation - see
MPSGraphFFTDescriptor
. - name: The name for the operation.
- Returns: A valid MPSGraphTensor of type
MPSDataTypeFloat32
orMPSDataTypeFloat16
(full size).
Sourcepub unsafe fn HermiteanToRealFFTWithTensor_axesTensor_descriptor_name(
&self,
tensor: &MPSGraphTensor,
axes_tensor: &MPSGraphTensor,
descriptor: &MPSGraphFFTDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphFourierTransformOps
and MPSGraphTensor
only.
pub unsafe fn HermiteanToRealFFTWithTensor_axesTensor_descriptor_name( &self, tensor: &MPSGraphTensor, axes_tensor: &MPSGraphTensor, descriptor: &MPSGraphFFTDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphFourierTransformOps
and MPSGraphTensor
only.Creates a Hermitean-to-real fast Fourier transform operation and returns the result tensor.
This operation computes the fast Fourier transform of a complex-valued input tensor according to the following formulae.
output[mu] = scale * sum_nu exp( +/- i * 2Pi * mu * nu / n ) in'[nu], where
in'[nu] = conjugate(in[n - nu])
, for the last dimension defined by axes
when nu
is out of range of the input dimension.
scale = 1
for scaling_mode = none
,
scale = 1/V_f
for scaling_mode = size
,
scale = 1/sqrt(V_f)
for scaling_mode = unitary
, where
V_f
is the volume of the transformation defined by the dimensions included in axes
(V_f = prod_{i \in axes} shape(input)[i]
) (see MPSGraphFFTDescriptor/scalingMode
),
+
is selected in +/-
when inverse
is specified, otherwise -
is used
and the sum is done separately over each dimension in axes
and n
is the
dimension length of that axis. With this API MPSGraph treats the input tensor to have only the unique
frequencies, which means that the resulting tensor has size (inSize-1)*2 + x
in the last dimension defined by axes
,
where inSize = shape(input)[axis] ( = (n/2)+1 )
is the size of the input tensor
in the last transformed dimension and
x = 1
when MPSGraphFFTDescriptor/roundToOddHermitean
= YES
and x = 0
otherwise.
Tip: Currently MPSGraph supports the transformation only within the last four dimensions of the input tensor. In case you need to transform higher dimensions than the last four, you can tranpose the higher dimensions of the input with
MPSGraph/transposeTensor:permutation:name:
to be within that last four and then transpose the result tensor back with the inverse of the input transpose.
- Parameters:
- tensor: A complex-valued input tensor with reduced size (see Discussion). Must have datatype
MPSDataTypeComplexFloat32
orMPSDataTypeComplexFloat16
. - axesTensor: A tensor of rank one containing the axes over which MPSGraph performs the transformation. See
MPSGraph/fastFourierTransformWithTensor:axes:descriptor:name:
. - descriptor: A descriptor that defines the parameters of the Fourier transform operation - see
MPSGraphFFTDescriptor
. - name: The name for the operation.
- Returns: A valid MPSGraphTensor of type
MPSDataTypeFloat32
orMPSDataTypeFloat16
(full size).
Source§impl MPSGraph
GatherNDOps.
impl MPSGraph
GatherNDOps.
Sourcepub unsafe fn gatherNDWithUpdatesTensor_indicesTensor_batchDimensions_name(
&self,
updates_tensor: &MPSGraphTensor,
indices_tensor: &MPSGraphTensor,
batch_dimensions: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphGatherOps
and MPSGraphTensor
only.
pub unsafe fn gatherNDWithUpdatesTensor_indicesTensor_batchDimensions_name( &self, updates_tensor: &MPSGraphTensor, indices_tensor: &MPSGraphTensor, batch_dimensions: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphGatherOps
and MPSGraphTensor
only.Creates a GatherND operation and returns the result tensor.
Gathers the slices in updatesTensor to the result tensor along the indices in indicesTensor. The gather is defined as
B = batchDims
U = updates.rank - B
P = res.rank - B
Q = inds.rank - B
K = inds.shape[-1]
index_slice = indices[i_{b0},...,i_{bB},i_{0},..,i_{Q-1}]
res[i_{b0},...,i_{bB},i_{0},...,i_{Q-1}] = updates[i_{b0},...,i_{bB},index_slice[0],...,index_slice[K-1]]
The tensors have the following shape requirements
U > 0; P > 0; Q > 0
K
<
= U
P = (U-K) + Q-1
indices.shape[0:Q-1] = res.shape[0:Q-1]
res.shape[Q:P] = updates.shape[K:U]
- Parameters:
- updatesTensor: Tensor containing slices to be inserted into the result tensor.
- indicesTensor: Tensor containg the updates indices to read slices from
- batchDimensions: The number of batch dimensions
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Source§impl MPSGraph
GatherOps.
impl MPSGraph
GatherOps.
Sourcepub unsafe fn gatherWithUpdatesTensor_indicesTensor_axis_batchDimensions_name(
&self,
updates_tensor: &MPSGraphTensor,
indices_tensor: &MPSGraphTensor,
axis: NSUInteger,
batch_dimensions: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphGatherOps
and MPSGraphTensor
only.
pub unsafe fn gatherWithUpdatesTensor_indicesTensor_axis_batchDimensions_name( &self, updates_tensor: &MPSGraphTensor, indices_tensor: &MPSGraphTensor, axis: NSUInteger, batch_dimensions: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphGatherOps
and MPSGraphTensor
only.Creates a Gather operation and returns the result tensor.
Gathers the values in updatesTensor to the result tensor along the indices in indicesTensor. The gather is defined as
B = batchDims
U = updates.rank
P = res.rank
Q = inds.rank
res[p_{0},...p_{axis-1}, i_{B},...,i_{Q}, ...,p_{axis+1},...,p{U-1}] =
updates[p_{0},...p_{axis-1}, indices[p_{0},...,p_{B-1},i_{B},...,i_{Q}, ...,p_{axis+1},...,p{U-1}]
The tensors have the following shape requirements
P = Q-B + U-1
indices.shape[0:B] = updates.shape[0:B] = res.shape[0:B]
res.shape[0:axis] = updates.shape[0:axis]
res.shape[axis:axis+Q-B] = indices.shape[B:]
res.shape[axis+1+Q-B:] = updates.shape[axis+1:]
- Parameters:
- updatesTensor: Tensor containing slices to be inserted into the result tensor.
- indicesTensor: Tensor containg the updates indices to read slices from
- axis: The dimension on which to perform the gather
- batchDimensions: The number of batch dimensions
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Source§impl MPSGraph
MPSGraphGatherAlongAxisOps.
impl MPSGraph
MPSGraphGatherAlongAxisOps.
Sourcepub unsafe fn gatherAlongAxis_withUpdatesTensor_indicesTensor_name(
&self,
axis: NSInteger,
updates_tensor: &MPSGraphTensor,
indices_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphGatherOps
and MPSGraphTensor
only.
pub unsafe fn gatherAlongAxis_withUpdatesTensor_indicesTensor_name( &self, axis: NSInteger, updates_tensor: &MPSGraphTensor, indices_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphGatherOps
and MPSGraphTensor
only.Creates a GatherAlongAxis operation and returns the result tensor.
Gather values from updatesTensor
along the specified axis
at indices in indicesTensor
.
The shape of updatesTensor
and indicesTensor
must match except at axis
.
The shape of the result tensor is equal to the shape of indicesTensor
.
If an index is out of bounds of the updatesTensor
along axis
a 0 is inserted.
- Parameters:
- axis: The axis to gather from. Negative values wrap around
- updatesTensor: The input tensor to gather values from
- indicesTensor: Int32 or Int64 tensor used to index
updatesTensor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn gatherAlongAxisTensor_withUpdatesTensor_indicesTensor_name(
&self,
axis_tensor: &MPSGraphTensor,
updates_tensor: &MPSGraphTensor,
indices_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphGatherOps
and MPSGraphTensor
only.
pub unsafe fn gatherAlongAxisTensor_withUpdatesTensor_indicesTensor_name( &self, axis_tensor: &MPSGraphTensor, updates_tensor: &MPSGraphTensor, indices_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphGatherOps
and MPSGraphTensor
only.Creates a GatherAlongAxis operation and returns the result tensor.
Gather values from updatesTensor
along the specified axis
at indices in indicesTensor
.
The shape of updatesTensor
and indicesTensor
must match except at axis
.
The shape of the result tensor is equal to the shape of indicesTensor
.
If an index is out of bounds of the updatesTensor
along axis
a 0 is inserted.
- Parameters:
- axisTensor: Scalar Int32 tensor. The axis to gather from. Negative values wrap around
- updatesTensor: The input tensor to gather values from
- indicesTensor: Int32 or Int64 tensor used to index
updatesTensor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Source§impl MPSGraph
MPSGraphImToColOps.
impl MPSGraph
MPSGraphImToColOps.
Sourcepub unsafe fn imToColWithSourceTensor_descriptor_name(
&self,
source: &MPSGraphTensor,
descriptor: &MPSGraphImToColOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphImToColOps
and MPSGraphTensor
only.
pub unsafe fn imToColWithSourceTensor_descriptor_name( &self, source: &MPSGraphTensor, descriptor: &MPSGraphImToColOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphImToColOps
and MPSGraphTensor
only.Creates an imToCol operation and returns the result tensor.
- Parameters:
- source: The tensor containing the source data. Must be of rank 4. The layout is defined by
descriptor.dataLayout
. - descriptor: The descriptor object that specifies the parameters of the operation.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn colToImWithSourceTensor_outputShape_descriptor_name(
&self,
source: &MPSGraphTensor,
output_shape: &MPSShape,
descriptor: &MPSGraphImToColOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphImToColOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn colToImWithSourceTensor_outputShape_descriptor_name( &self, source: &MPSGraphTensor, output_shape: &MPSShape, descriptor: &MPSGraphImToColOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphImToColOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a column to image operation and returns the result tensor.
- Parameters:
- source: The tensor containing the source data. Must be of rank 4. The layout is defined by
descriptor.dataLayout
. - outputShape: The result tensor shape.
- descriptor: The descriptor object that specifies the parameters of the operation.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Source§impl MPSGraph
MPSGraphLinearAlgebraOps.
impl MPSGraph
MPSGraphLinearAlgebraOps.
Sourcepub unsafe fn bandPartWithTensor_numLower_numUpper_name(
&self,
input_tensor: &MPSGraphTensor,
num_lower: NSInteger,
num_upper: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphLinearAlgebraOps
and MPSGraphTensor
only.
pub unsafe fn bandPartWithTensor_numLower_numUpper_name( &self, input_tensor: &MPSGraphTensor, num_lower: NSInteger, num_upper: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphLinearAlgebraOps
and MPSGraphTensor
only.Computes the band part of an input tensor.
This operation copies a diagonal band of values from input tensor to a result tensor of the same size.
A coordinate [..., i, j]
is in the band if
(numLower
<
0 || (i-j)
<
= numLower)
&
&
(numUpper
<
0 || (j-i)
<
= numUpper)
The values outside of the band are set to 0.
- Parameters:
- inputTensor: input tensor
- numLower: the number of diagonals in the lower triangle to keep. If -1, the framework returns all sub diagnols.
- numUpper: the number of diagonals in the upper triangle to keep. If -1, the framework returns all super diagnols.
- name: name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn bandPartWithTensor_numLowerTensor_numUpperTensor_name(
&self,
input_tensor: &MPSGraphTensor,
num_lower_tensor: &MPSGraphTensor,
num_upper_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphLinearAlgebraOps
and MPSGraphTensor
only.
pub unsafe fn bandPartWithTensor_numLowerTensor_numUpperTensor_name( &self, input_tensor: &MPSGraphTensor, num_lower_tensor: &MPSGraphTensor, num_upper_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphLinearAlgebraOps
and MPSGraphTensor
only.Creates the band part operation and returns the result.
See above discussion of bandPartWithTensor: numLower: numUpper: name:
- Parameters:
- inputTensor: The source tensor to copy.
- numLowerTensor: Scalar Int32 tensor. The number of diagonals in the lower triangle to keep. If -1, keep all.
- numUpperTensor: Scalar Int32 tensor. The number of diagonals in the upper triangle to keep. If -1, keep all.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Source§impl MPSGraph
MPSGraphLossOps.
impl MPSGraph
MPSGraphLossOps.
Sourcepub unsafe fn softMaxCrossEntropyWithSourceTensor_labelsTensor_axis_reductionType_name(
&self,
source_tensor: &MPSGraphTensor,
labels_tensor: &MPSGraphTensor,
axis: NSInteger,
reduction_type: MPSGraphLossReductionType,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphLossOps
and MPSGraphTensor
only.
pub unsafe fn softMaxCrossEntropyWithSourceTensor_labelsTensor_axis_reductionType_name( &self, source_tensor: &MPSGraphTensor, labels_tensor: &MPSGraphTensor, axis: NSInteger, reduction_type: MPSGraphLossReductionType, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphLossOps
and MPSGraphTensor
only.Creates a softmax cross-entropy loss operation and returns the result tensor.
The softmax cross-entropy operation computes:
loss = reduction( - labels*ln( softmax(source) )), where
sotfmax(source) = exp(source) / sum( exp(source) ), and
the operation performs the reduction over the axis
dimension.
- Parameters:
- sourceTensor: The source tensor.
- labelsTensor: The labels tensor.
- axis: The axis over which the operation computes the softmax reduction.
- reductionType: The type of reduction MPSGraph uses to reduce across all other axes than
axis
. See:MPSGraphLossReductionType
. - name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn softMaxCrossEntropyGradientWithIncomingGradientTensor_sourceTensor_labelsTensor_axis_reductionType_name(
&self,
gradient_tensor: &MPSGraphTensor,
source_tensor: &MPSGraphTensor,
labels_tensor: &MPSGraphTensor,
axis: NSInteger,
reduction_type: MPSGraphLossReductionType,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphLossOps
and MPSGraphTensor
only.
pub unsafe fn softMaxCrossEntropyGradientWithIncomingGradientTensor_sourceTensor_labelsTensor_axis_reductionType_name( &self, gradient_tensor: &MPSGraphTensor, source_tensor: &MPSGraphTensor, labels_tensor: &MPSGraphTensor, axis: NSInteger, reduction_type: MPSGraphLossReductionType, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphLossOps
and MPSGraphTensor
only.Creates the gradient of a softmax cross-entropy loss operation and returns the result tensor.
- Parameters:
- gradientTensor: The input gradientTensor. Note: in most cases this is the initial gradient tensor, which is a constant tensor with value one.
- sourceTensor: The source tensor.
- labelsTensor: The labels tensor.
- axis: The axis over which the operation computes the softmax reduction.
- reductionType: The type of reduction MPSGraph uses to reduce across all other axes than
axis
. See:MPSGraphLossReductionType
. - name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Source§impl MPSGraph
MPSGraphMatrixInverseOps.
impl MPSGraph
MPSGraphMatrixInverseOps.
Sourcepub unsafe fn inverseOfTensor_name(
&self,
input_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMatrixInverseOps
and MPSGraphTensor
only.
pub unsafe fn inverseOfTensor_name( &self, input_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphMatrixInverseOps
and MPSGraphTensor
only.Computes the inverse of an input tensor.
The framework computes the inverse of a square matrix by calling LU decomposition and LU solver. All dimensions after the first 2 are treated as batch dimensions and the inverse for each batch is computed. Results are undefined for ill conditioned matrices.
- Parameters:
- inputTensor: The input tensor.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
object containing the inverse of the input tensor.
Source§impl MPSGraph
MPSGraphMatrixMultiplicationOps.
impl MPSGraph
MPSGraphMatrixMultiplicationOps.
Sourcepub unsafe fn matrixMultiplicationWithPrimaryTensor_secondaryTensor_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMatrixMultiplicationOps
and MPSGraphTensor
only.
pub unsafe fn matrixMultiplicationWithPrimaryTensor_secondaryTensor_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphMatrixMultiplicationOps
and MPSGraphTensor
only.Computes the matrix multiplication of 2 input tensors with support for broadcasting.
- Parameters:
- primaryTensor: The left-hand side tensor.
- secondaryTensor: The right-hand side tensor.
- name: The name for the operation.
- Returns: A valid tensor containing the product of the input matrices.
Sourcepub unsafe fn HammingDistanceWithPrimaryTensor_secondaryTensor_resultDataType_name(
&self,
primary_tensor: &MPSGraphTensor,
secondary_tensor: &MPSGraphTensor,
result_data_type: MPSDataType,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMatrixMultiplicationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn HammingDistanceWithPrimaryTensor_secondaryTensor_resultDataType_name( &self, primary_tensor: &MPSGraphTensor, secondary_tensor: &MPSGraphTensor, result_data_type: MPSDataType, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphMatrixMultiplicationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Computes the hamming distance of two input tensors with support for broadcasting.
The hamming distance is computed between 2 sets of vectors and the last dimension(s) of each input tensor is considered a vector.
- Parameters:
- primaryTensor: The first input tensor.
- secondaryTensor: The second input tensor.
- resultDataType: The datatype of the return MPSGraphTensor. Must be either
MPSDataTypeUInt32
orMPSDataTypeUInt16
. - name: The name for the operation.
- Returns: A valid tensor containing the hamming distance between the input tensors.
Sourcepub unsafe fn scaledDotProductAttentionWithQueryTensor_keyTensor_valueTensor_maskTensor_scale_name(
&self,
query_tensor: &MPSGraphTensor,
key_tensor: &MPSGraphTensor,
value_tensor: &MPSGraphTensor,
mask_tensor: Option<&MPSGraphTensor>,
scale: c_float,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMatrixMultiplicationOps
and MPSGraphTensor
only.
pub unsafe fn scaledDotProductAttentionWithQueryTensor_keyTensor_valueTensor_maskTensor_scale_name( &self, query_tensor: &MPSGraphTensor, key_tensor: &MPSGraphTensor, value_tensor: &MPSGraphTensor, mask_tensor: Option<&MPSGraphTensor>, scale: c_float, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphMatrixMultiplicationOps
and MPSGraphTensor
only.Creates a scaled dot product attention (SDPA) operation and returns the result tensor.
SDPA Op computes attention by computing softmax(scale * QK^T + M)V. queryTensor Q with shape [B, Hq, Nq, F] and keyTensor K with shape [B, Hq, Nkv, F], with Q’s H dimension expandable to satisfy matmul QK^T. maskTensor M’s shape should be broadcast compatible to satisfy (QK^T + M). valueTensor V with shape [B, Hv, Nkv, F] should satisfy the matmul (QK^T + M)V.
- Parameters:
- queryTensor: A tensor that represents the query projection.
- keyTensor: A tensor that represents the key projection.
- valueTensor: A tensor that represents the value projection.
- maskTensor: An optional tensor that contains a mask that is applied to the scaled, matrix multiplied query and value matrices. If mask tensor is nil, the QK^T is not element-wise masked.
- scale: A scale that is applied to the result of query and value matrix multiply.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn scaledDotProductAttentionWithQueryTensor_keyTensor_valueTensor_scale_name(
&self,
query_tensor: &MPSGraphTensor,
key_tensor: &MPSGraphTensor,
value_tensor: &MPSGraphTensor,
scale: c_float,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMatrixMultiplicationOps
and MPSGraphTensor
only.
pub unsafe fn scaledDotProductAttentionWithQueryTensor_keyTensor_valueTensor_scale_name( &self, query_tensor: &MPSGraphTensor, key_tensor: &MPSGraphTensor, value_tensor: &MPSGraphTensor, scale: c_float, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphMatrixMultiplicationOps
and MPSGraphTensor
only.Creates a scaled dot product attention (SDPA) operation (without a mask) and returns the result tensor.
- Parameters:
- queryTensor: A tensor that represents the query projection.
- keyTensor: A tensor that represents the key projection.
- valueTensor: A tensor that represents the value projection.
- scale: A scale that is applied on the result of query and value matrix multiply.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Source§impl MPSGraph
MemoryOps.
impl MPSGraph
MemoryOps.
Sourcepub unsafe fn placeholderWithShape_dataType_name(
&self,
shape: Option<&MPSShape>,
data_type: MPSDataType,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn placeholderWithShape_dataType_name( &self, shape: Option<&MPSShape>, data_type: MPSDataType, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a placeholder operation and returns the result tensor.
- Parameters:
- shape: The shape of the output tensor. A nil shape will result in an unranked tensor.
- dataType: The dataType of the placeholder tensor.
- name: The name for the placeholder operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn placeholderWithShape_name(
&self,
shape: Option<&MPSShape>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn placeholderWithShape_name( &self, shape: Option<&MPSShape>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a placeholder operation and returns the result tensor with the dataType of the placeholder tensor set to 32 bit float.
- Parameters:
- shape: The shape of the output tensor. A nil shape will result in an unranked tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn constantWithData_shape_dataType(
&self,
data: &NSData,
shape: &MPSShape,
data_type: MPSDataType,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn constantWithData_shape_dataType( &self, data: &NSData, shape: &MPSShape, data_type: MPSDataType, ) -> Retained<MPSGraphTensor>
MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a constant op with a given shape and data, and returns the result tensor.
- Parameters:
- data: The data for the tensor. The number of bytes should be sizeof(dataType)numberOfElements.
- shape: The shape of the output tensor. This has to be statically shaped.
- dataType: The dataType of theconstant tensor.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn constantWithScalar_dataType(
&self,
scalar: c_double,
data_type: MPSDataType,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn constantWithScalar_dataType( &self, scalar: c_double, data_type: MPSDataType, ) -> Retained<MPSGraphTensor>
MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a constant operation and returns the result tensor.
- Parameters:
- scalar: The scalar value to fill the entire tensor values with.
- dataType: The dataType of the constant tensor.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn constantWithScalar_shape_dataType(
&self,
scalar: c_double,
shape: &MPSShape,
data_type: MPSDataType,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn constantWithScalar_shape_dataType( &self, scalar: c_double, shape: &MPSShape, data_type: MPSDataType, ) -> Retained<MPSGraphTensor>
MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a constant op with a given shape and returns the result tensor.
- Parameters:
- scalar: The scalar value to fill the entire tensor values with.
- shape: The shape of the output tensor.
- dataType: The dataType of the constant tensor.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn constantWithRealPart_imaginaryPart(
&self,
real_part: c_double,
imaginary_part: c_double,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMemoryOps
and MPSGraphTensor
only.
pub unsafe fn constantWithRealPart_imaginaryPart( &self, real_part: c_double, imaginary_part: c_double, ) -> Retained<MPSGraphTensor>
MPSGraphMemoryOps
and MPSGraphTensor
only.Creates a complex constant op with the MPSDataTypeComplexFloat32 data type and returns the result tensor.
- Parameters:
- realPart: The real part of the complex scalar to fill the entire tensor values with.
- imaginaryPart: The imaginary part of the complex scalar to fill the entire tensor values with.
- dataType: The dataType of the constant tensor.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn constantWithRealPart_imaginaryPart_dataType(
&self,
real_part: c_double,
imaginary_part: c_double,
data_type: MPSDataType,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn constantWithRealPart_imaginaryPart_dataType( &self, real_part: c_double, imaginary_part: c_double, data_type: MPSDataType, ) -> Retained<MPSGraphTensor>
MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a complex constant operation and returns the result tensor.
- Parameters:
- realPart: The real part of the complex scalar to fill the entire tensor values with.
- imaginaryPart: The imaginary part of the complex scalar to fill the entire tensor values with.
- dataType: The dataType of the constant tensor.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn constantWithRealPart_imaginaryPart_shape_dataType(
&self,
real_part: c_double,
imaginary_part: c_double,
shape: &MPSShape,
data_type: MPSDataType,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn constantWithRealPart_imaginaryPart_shape_dataType( &self, real_part: c_double, imaginary_part: c_double, shape: &MPSShape, data_type: MPSDataType, ) -> Retained<MPSGraphTensor>
MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a complex constant op with a given shape and returns the result tensor.
- Parameters:
- realPart: The real part of the complex scalar to fill the entire tensor values with.
- imaginaryPart: The imaginary part of the complex scalar to fill the entire tensor values with.
- shape: The shape of the output tensor. This has to be statically shaped.
- dataType: The dataType of the constant tensor.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn variableWithData_shape_dataType_name(
&self,
data: &NSData,
shape: &MPSShape,
data_type: MPSDataType,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn variableWithData_shape_dataType_name( &self, data: &NSData, shape: &MPSShape, data_type: MPSDataType, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphMemoryOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a variable operation and returns the result tensor.
- Parameters:
- data: The data for the tensor. The number of bytes should be sizeof(dataType)numberOfElements.
- shape: The shape of the output tensor. This has to be statically shaped.
- dataType: The dataType of the constant tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn variableFromTensorWithTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMemoryOps
and MPSGraphTensor
only.
pub unsafe fn variableFromTensorWithTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphMemoryOps
and MPSGraphTensor
only.Creates a variable from an input tensor.
- Parameters:
- tensor: The tensor from which to form the variable.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn readVariable_name(
&self,
variable: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphMemoryOps
and MPSGraphTensor
only.
pub unsafe fn readVariable_name( &self, variable: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphMemoryOps
and MPSGraphTensor
only.Creates a read op which reads at this point of execution of the graph and returns the result tensor.
- Parameters:
- variable: The variable resource tensor to read from.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn assignVariable_withValueOfTensor_name(
&self,
variable: &MPSGraphTensor,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphOperation>
Available on crate features MPSGraphMemoryOps
and MPSGraphOperation
and MPSGraphTensor
only.
pub unsafe fn assignVariable_withValueOfTensor_name( &self, variable: &MPSGraphTensor, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphOperation>
MPSGraphMemoryOps
and MPSGraphOperation
and MPSGraphTensor
only.Creates an assign operation which writes at this point of execution of the graph.
- Parameters:
- variable: The variable resource tensor to assign to.
- tensor: The tensor to assign to the variable.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Source§impl MPSGraph
MPSGraphNonMaximumSuppressionOps.
impl MPSGraph
MPSGraphNonMaximumSuppressionOps.
Sourcepub unsafe fn nonMaximumSuppressionWithBoxesTensor_scoresTensor_IOUThreshold_scoreThreshold_perClassSuppression_coordinateMode_name(
&self,
boxes_tensor: &MPSGraphTensor,
scores_tensor: &MPSGraphTensor,
iou_threshold: c_float,
score_threshold: c_float,
per_class_suppression: bool,
coordinate_mode: MPSGraphNonMaximumSuppressionCoordinateMode,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphNonMaximumSuppressionOps
and MPSGraphTensor
only.
pub unsafe fn nonMaximumSuppressionWithBoxesTensor_scoresTensor_IOUThreshold_scoreThreshold_perClassSuppression_coordinateMode_name( &self, boxes_tensor: &MPSGraphTensor, scores_tensor: &MPSGraphTensor, iou_threshold: c_float, score_threshold: c_float, per_class_suppression: bool, coordinate_mode: MPSGraphNonMaximumSuppressionCoordinateMode, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphNonMaximumSuppressionOps
and MPSGraphTensor
only.Creates a nonMaximumumSuppression operation and returns the result tensor.
- Parameters:
- boxesTensor: A tensor containing the coordinates of the input boxes. Must be a rank 3 tensor of shape [N,B,4] of type
MPSDataTypeFloat32
- scoresTensor: A tensor containing the scores of the input boxes. Must be a rank 3 tensor of shape [N,B,K] of type
MPSDataTypeFloat32
- IOUThreshold: The threshold for when to reject boxes based on their Intersection Over Union. Valid range is [0,1].
- scoreThreshold: The threshold for when to reject boxes based on their score, before IOU suppression.
- perClassSuppression: When this is specified a box will only suppress another box if they have the same class.
- coordinateMode: The coordinate mode the box coordinates are provided in.
- name: The name for the operation.
Sourcepub unsafe fn nonMaximumSuppressionWithBoxesTensor_scoresTensor_classIndicesTensor_IOUThreshold_scoreThreshold_perClassSuppression_coordinateMode_name(
&self,
boxes_tensor: &MPSGraphTensor,
scores_tensor: &MPSGraphTensor,
class_indices_tensor: &MPSGraphTensor,
iou_threshold: c_float,
score_threshold: c_float,
per_class_suppression: bool,
coordinate_mode: MPSGraphNonMaximumSuppressionCoordinateMode,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphNonMaximumSuppressionOps
and MPSGraphTensor
only.
pub unsafe fn nonMaximumSuppressionWithBoxesTensor_scoresTensor_classIndicesTensor_IOUThreshold_scoreThreshold_perClassSuppression_coordinateMode_name( &self, boxes_tensor: &MPSGraphTensor, scores_tensor: &MPSGraphTensor, class_indices_tensor: &MPSGraphTensor, iou_threshold: c_float, score_threshold: c_float, per_class_suppression: bool, coordinate_mode: MPSGraphNonMaximumSuppressionCoordinateMode, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphNonMaximumSuppressionOps
and MPSGraphTensor
only.Creates a nonMaximumumSuppression operation and returns the result tensor.
- Parameters:
- boxesTensor: A tensor containing the coordinates of the input boxes. Must be a rank 3 tensor of shape [N,B,4] of type
MPSDataTypeFloat32
- scoresTensor: A tensor containing the scores of the input boxes. Must be a rank 3 tensor of shape [N,B,1] of type
MPSDataTypeFloat32
- classIndicesTensor: A tensor containing the class indices of the input boxes. Must be a rank 2 tensor of shape [N,B] of type
MPSDataTypeInt32
- IOUThreshold: The threshold for when to reject boxes based on their Intersection Over Union. Valid range is [0,1].
- scoreThreshold: The threshold for when to reject boxes based on their score, before IOU suppression.
- perClassSuppression: When this is specified a box will only suppress another box if they have the same class.
- coordinateMode: The coordinate mode the box coordinates are provided in.
- name: The name for the operation.
Source§impl MPSGraph
NonZeroOps.
impl MPSGraph
NonZeroOps.
Sourcepub unsafe fn nonZeroIndicesOfTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphNonZeroOps
and MPSGraphTensor
only.
pub unsafe fn nonZeroIndicesOfTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphNonZeroOps
and MPSGraphTensor
only.Computes the indices of the non-zero elements of the input tensor.
The indices are returned as a two-dimensional tensor of size [number_of_nonzeros, input_rank]
.
Each row in the result contains indices of a nonzero elements in input.
For example:
tensor = [[ 1, 0, 3],
[ 0, 10, 0]]
indices = [[ 0, 0],
[ 0, 2],
[ 1, 1]]
- Parameters:
- tensor: An MPSGraphTensor of which to compute the non-zero indices.
- Returns: A valid MPSGraphTensor containing indices in signed int32 data type.
Source§impl MPSGraph
MPSGraphNormalizationOps.
impl MPSGraph
MPSGraphNormalizationOps.
Sourcepub unsafe fn meanOfTensor_axes_name(
&self,
tensor: &MPSGraphTensor,
axes: &NSArray<NSNumber>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphNormalizationOps
and MPSGraphTensor
only.
pub unsafe fn meanOfTensor_axes_name( &self, tensor: &MPSGraphTensor, axes: &NSArray<NSNumber>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphNormalizationOps
and MPSGraphTensor
only.Returns the mean of the first input along the specified axes.
- Parameters:
- axes: A list of axes over which to perform the reduction. The order of dimensions goes from the slowest moving at axis=0 to the fastest moving dimension.
- name: An optional name for the operation.
- Returns: A valid
MPSGraphTensor
object.
Sourcepub unsafe fn varianceOfTensor_meanTensor_axes_name(
&self,
tensor: &MPSGraphTensor,
mean_tensor: &MPSGraphTensor,
axes: &NSArray<NSNumber>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphNormalizationOps
and MPSGraphTensor
only.
pub unsafe fn varianceOfTensor_meanTensor_axes_name( &self, tensor: &MPSGraphTensor, mean_tensor: &MPSGraphTensor, axes: &NSArray<NSNumber>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphNormalizationOps
and MPSGraphTensor
only.Returns the variance of the first input along the specified axes when the mean has been precomputed.
- Parameters:
- axes: A list of axes over which to perform the reduction such that the order of dimensions goes from the slowest moving at axis=0 to the fastest moving dimension.
- name: An optional name for the operation.
- Returns: A valid
MPSGraphTensor
object.
Sourcepub unsafe fn varianceOfTensor_axes_name(
&self,
tensor: &MPSGraphTensor,
axes: &NSArray<NSNumber>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphNormalizationOps
and MPSGraphTensor
only.
pub unsafe fn varianceOfTensor_axes_name( &self, tensor: &MPSGraphTensor, axes: &NSArray<NSNumber>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphNormalizationOps
and MPSGraphTensor
only.Returns the variance of the first input along the specified axes.
- Parameters:
- axes: A list of axes over which to perform the reduction. Tthe order of dimensions goes from the slowest moving at axis=0 to the fastest moving dimension.
- name: An optional name for the operation.
- Returns: A valid
MPSGraphTensor
object.
Sourcepub unsafe fn normalizationWithTensor_meanTensor_varianceTensor_gammaTensor_betaTensor_epsilon_name(
&self,
tensor: &MPSGraphTensor,
mean: &MPSGraphTensor,
variance: &MPSGraphTensor,
gamma: Option<&MPSGraphTensor>,
beta: Option<&MPSGraphTensor>,
epsilon: c_float,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphNormalizationOps
and MPSGraphTensor
only.
pub unsafe fn normalizationWithTensor_meanTensor_varianceTensor_gammaTensor_betaTensor_epsilon_name( &self, tensor: &MPSGraphTensor, mean: &MPSGraphTensor, variance: &MPSGraphTensor, gamma: Option<&MPSGraphTensor>, beta: Option<&MPSGraphTensor>, epsilon: c_float, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphNormalizationOps
and MPSGraphTensor
only.Creates a batch normalization operation and returns the result tensor.
The mean and variance tensors should be outputs of meanWithTensor:axes:name
and varianceWithTensor:meanTensor:axes:name
.
Use the axes parameter to achieve different types of normalizations.
For example (assuming your data is in NxHxWxC format)
Batch normalization: axes = [0, 1, 2]
Instance normalization: axes = [1, 2]
Shapes for gamma and beta must match the input data along at least one dimension and will be broadcast along the rest.
For batch normalization, gamma and beta would typically be 1x1x1xC i.e. one value per channel.
- Parameters:
- tensor: The input tensor.
- mean: The mean tensor.
- variance: The variance tensor.
- gamma: The tensor used to scale the normalized result.
- beta: The tensor used to bias the normalized result.
- epsilon: A small value to add to the variance when normalizing the inputs.
- name: An optional name for the operation.
- Returns: A valid
MPSGraphTensor
object.
Sourcepub unsafe fn normalizationGammaGradientWithIncomingGradientTensor_sourceTensor_meanTensor_varianceTensor_reductionAxes_epsilon_name(
&self,
incoming_gradient_tensor: &MPSGraphTensor,
source_tensor: &MPSGraphTensor,
mean_tensor: &MPSGraphTensor,
variance_tensor: &MPSGraphTensor,
axes: &NSArray<NSNumber>,
epsilon: c_float,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphNormalizationOps
and MPSGraphTensor
only.
pub unsafe fn normalizationGammaGradientWithIncomingGradientTensor_sourceTensor_meanTensor_varianceTensor_reductionAxes_epsilon_name( &self, incoming_gradient_tensor: &MPSGraphTensor, source_tensor: &MPSGraphTensor, mean_tensor: &MPSGraphTensor, variance_tensor: &MPSGraphTensor, axes: &NSArray<NSNumber>, epsilon: c_float, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphNormalizationOps
and MPSGraphTensor
only.Creates a normalization gamma-gradient operation and returns the result tensor.
The mean and variance tensors should be outputs of meanWithTensor:axes:name
and varianceWithTensor:meanTensor:axes:name
.
Use the axes parameter to achieve different types of normalizations.
For example (assuming your data is in NxHxWxC
format)
Batch normalization: axes = [0, 1, 2]
Instance normalization: axes = [1, 2]
- Parameters:
- incomingGradientTensor: The incoming original
resultTensor
gradient. - sourceTensor: The original input source in forward direction.
- meanTensor: The mean tensor.
- varianceTensor: The variance tensor.
- axes: The axes of normalization.
- epsilon: A small value to add to the variance when normalizing the inputs.
- name: An optional name for the operation.
- Returns: A valid
MPSGraphTensor
object.
Sourcepub unsafe fn normalizationBetaGradientWithIncomingGradientTensor_sourceTensor_reductionAxes_name(
&self,
incoming_gradient_tensor: &MPSGraphTensor,
source_tensor: &MPSGraphTensor,
axes: &NSArray<NSNumber>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphNormalizationOps
and MPSGraphTensor
only.
pub unsafe fn normalizationBetaGradientWithIncomingGradientTensor_sourceTensor_reductionAxes_name( &self, incoming_gradient_tensor: &MPSGraphTensor, source_tensor: &MPSGraphTensor, axes: &NSArray<NSNumber>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphNormalizationOps
and MPSGraphTensor
only.Creates a normalization beta-gradient operation and returns the result tensor.
The mean and variance tensors should be outputs of meanWithTensor:axes:name
and varianceWithTensor:meanTensor:axes:name
.
Use the axes parameter to achieve different types of normalizations.
For example (assuming your data is in NxHxWxC
format)
Batch normalization: axes = [0, 1, 2]
Instance normalization: axes = [1, 2]
- Parameters:
- incomingGradientTensor: The incoming original
resultTensor
gradient. - sourceTensor: The original input source in forward direction.
- axes: The axes of normalization.
- name: An optional name for the operation.
- Returns: A valid
MPSGraphTensor
object.
Sourcepub unsafe fn normalizationGradientWithIncomingGradientTensor_sourceTensor_meanTensor_varianceTensor_gammaTensor_gammaGradientTensor_betaGradientTensor_reductionAxes_epsilon_name(
&self,
incoming_gradient_tensor: &MPSGraphTensor,
source_tensor: &MPSGraphTensor,
mean_tensor: &MPSGraphTensor,
variance_tensor: &MPSGraphTensor,
gamma: Option<&MPSGraphTensor>,
gamma_gradient: Option<&MPSGraphTensor>,
beta_gradient: Option<&MPSGraphTensor>,
axes: &NSArray<NSNumber>,
epsilon: c_float,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphNormalizationOps
and MPSGraphTensor
only.
pub unsafe fn normalizationGradientWithIncomingGradientTensor_sourceTensor_meanTensor_varianceTensor_gammaTensor_gammaGradientTensor_betaGradientTensor_reductionAxes_epsilon_name( &self, incoming_gradient_tensor: &MPSGraphTensor, source_tensor: &MPSGraphTensor, mean_tensor: &MPSGraphTensor, variance_tensor: &MPSGraphTensor, gamma: Option<&MPSGraphTensor>, gamma_gradient: Option<&MPSGraphTensor>, beta_gradient: Option<&MPSGraphTensor>, axes: &NSArray<NSNumber>, epsilon: c_float, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphNormalizationOps
and MPSGraphTensor
only.Creates a normalization input gradient operation and returns the result tensor.
The mean and variance tensors should be outputs of meanWithTensor:axes:name
and varianceWithTensor:meanTensor:axes:name
.
Use the axes parameter to achieve different types of normalizations.
For example (assuming your data is in NxHxWxC
format)
Batch normalization: axes = [0, 1, 2]
Instance normalization: axes = [1, 2]
- Parameters:
- incomingGradientTensor: The incoming original
resultTensor
gradient. - sourceTensor: The original input source in forward direction.
- meanTensor: The mean tensor.
- varianceTensor: The variance tensor.
- gamma: The gamma tensor.
- gammaGradient: The
gammaGradient
tensor. - betaGradient: The
betaGradient
tensor - axes: The axes of normalization.
- epsilon: A small value to add to the variance when normalizing the inputs.
- name: An optional name for the operation.
Source§impl MPSGraph
MPSGraphOneHotOps.
impl MPSGraph
MPSGraphOneHotOps.
Sourcepub unsafe fn oneHotWithIndicesTensor_depth_axis_dataType_onValue_offValue_name(
&self,
indices_tensor: &MPSGraphTensor,
depth: NSUInteger,
axis: NSUInteger,
data_type: MPSDataType,
on_value: c_double,
off_value: c_double,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphOneHotOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn oneHotWithIndicesTensor_depth_axis_dataType_onValue_offValue_name( &self, indices_tensor: &MPSGraphTensor, depth: NSUInteger, axis: NSUInteger, data_type: MPSDataType, on_value: c_double, off_value: c_double, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphOneHotOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a oneHot operation and returns the result tensor.
Creates a tensor of rank equal to the indicesTensor rank + 1. Inserts a new axis at the axis specified, or the minor axis if axis is -1. The values at the indices in the indicesTensor will have the onValue, and all other values will be set to the offValue.
- Parameters:
- indicesTensor: Tensor of indices for on values
- depth: Depth of the oneHot vector along the axis
- axis: The axis to insert the new oneHot vector at. Defaults to -1, the minor axis
- dataType: MPSDataType of the result tensor Defaults to MPSDataTypeFloat
- onValue: The value for indices designated by the indicesTensor. This value must match the specified data type. Defaults to 1.0f
- offValue: The value for indices not designated by the indicesTensor. This value must match the specified data type. Defaults to 0.0f
- name: Name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn oneHotWithIndicesTensor_depth_dataType_onValue_offValue_name(
&self,
indices_tensor: &MPSGraphTensor,
depth: NSUInteger,
data_type: MPSDataType,
on_value: c_double,
off_value: c_double,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphOneHotOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn oneHotWithIndicesTensor_depth_dataType_onValue_offValue_name( &self, indices_tensor: &MPSGraphTensor, depth: NSUInteger, data_type: MPSDataType, on_value: c_double, off_value: c_double, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphOneHotOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a oneHot operation and returns the result tensor.
Creates a tensor of rank equal to the rank of indicesTensor
+ 1.
Inserts a new axis at the minor dimension.
The values at the indices in the indicesTensor will have the onValue,
and all other values will be set to the offValue.
- Parameters:
- indicesTensor: Tensor of indices for on values
- depth: Depth of the oneHot vector along the axis
- dataType: MPSDataType of the result tensor.
- onValue: The value for indices designated by the indicesTensor. This value must match the specified data type.
- offValue: The value for indices not designated by the indicesTensor. This value must match the specified data type.
- name: Name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn oneHotWithIndicesTensor_depth_axis_dataType_name(
&self,
indices_tensor: &MPSGraphTensor,
depth: NSUInteger,
axis: NSUInteger,
data_type: MPSDataType,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphOneHotOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn oneHotWithIndicesTensor_depth_axis_dataType_name( &self, indices_tensor: &MPSGraphTensor, depth: NSUInteger, axis: NSUInteger, data_type: MPSDataType, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphOneHotOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a oneHot operation and returns the result tensor.
Creates a tensor of rank equal to the rank of indicesTensor
+ 1.
Inserts a new axis at the axis specified, or the minor axis if axis
is -1.
The values at the indices in the indicesTensor will be set to 1,
and all other values will be set to 0.
- Parameters:
- indicesTensor: Tensor of indices for on values
- depth: Depth of the oneHot vector along the axis
- axis: The axis to insert the new oneHot vector at
- dataType: MPSDataType of the result tensor.
- name: Name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn oneHotWithIndicesTensor_depth_axis_name(
&self,
indices_tensor: &MPSGraphTensor,
depth: NSUInteger,
axis: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphOneHotOps
and MPSGraphTensor
only.
pub unsafe fn oneHotWithIndicesTensor_depth_axis_name( &self, indices_tensor: &MPSGraphTensor, depth: NSUInteger, axis: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphOneHotOps
and MPSGraphTensor
only.Creates a oneHot operation and returns the result tensor.
Creates a tensor of rank equal to the rank of indicesTensor
+ 1, of type MPSDataTypeFloat32.
Inserts a new axis at the axis specified, or the minor axis if axis
is -1.
The values at the indices in the indicesTensor will be set to 1,
and all other values will be set to 0.
- Parameters:
- indicesTensor: Tensor of indices for on values
- depth: Depth of the oneHot vector along the axis
- axis: The axis to insert the new oneHot vector at
- name: Name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn oneHotWithIndicesTensor_depth_dataType_name(
&self,
indices_tensor: &MPSGraphTensor,
depth: NSUInteger,
data_type: MPSDataType,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphOneHotOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn oneHotWithIndicesTensor_depth_dataType_name( &self, indices_tensor: &MPSGraphTensor, depth: NSUInteger, data_type: MPSDataType, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphOneHotOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a oneHot operation and returns the result tensor.
Creates a tensor of rank equal to the rank of indicesTensor
+ 1.
Inserts a new axis at the minor dimension.
The values at the indices in the indicesTensor will be set to 1,
and all other values will be set to 0.
- Parameters:
- indicesTensor: Tensor of indices for on values
- depth: Depth of the oneHot vector along the axis
- dataType: MPSDataType of the result tensor.
- name: Name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn oneHotWithIndicesTensor_depth_name(
&self,
indices_tensor: &MPSGraphTensor,
depth: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphOneHotOps
and MPSGraphTensor
only.
pub unsafe fn oneHotWithIndicesTensor_depth_name( &self, indices_tensor: &MPSGraphTensor, depth: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphOneHotOps
and MPSGraphTensor
only.Creates a oneHot operation and returns the result tensor.
Creates a tensor of rank equal to the rank of indicesTensor
+ 1, of type MPSDataTypeFloat32.
Inserts a new axis at the minor dimension.
The values at the indices in the indicesTensor will be set to 1,
and all other values will be set to 0.
- Parameters:
- indicesTensor: Tensor of indices for on values
- depth: Depth of the oneHot vector along the axis
- name: Name for the operation
- Returns: A valid MPSGraphTensor object.
Source§impl MPSGraph
MPSGraphOptimizerOps.
impl MPSGraph
MPSGraphOptimizerOps.
Sourcepub unsafe fn stochasticGradientDescentWithLearningRateTensor_valuesTensor_gradientTensor_name(
&self,
learning_rate_tensor: &MPSGraphTensor,
values_tensor: &MPSGraphTensor,
gradient_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphOptimizerOps
and MPSGraphTensor
only.
pub unsafe fn stochasticGradientDescentWithLearningRateTensor_valuesTensor_gradientTensor_name( &self, learning_rate_tensor: &MPSGraphTensor, values_tensor: &MPSGraphTensor, gradient_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphOptimizerOps
and MPSGraphTensor
only.The Stochastic gradient descent performs a gradient descent.
variable = variable - (learningRate * g)
where,
g
is gradient of error wrt variable
- Parameters:
- learningRateTensor: scalar tensor which indicates the learning rate to use with the optimizer
- valuesTensor: values tensor, usually representing the trainable parameters
- gradientTensor: partial gradient of the trainable parameters with respect to loss
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn applyStochasticGradientDescentWithLearningRateTensor_variable_gradientTensor_name(
&self,
learning_rate_tensor: &MPSGraphTensor,
variable: &MPSGraphVariableOp,
gradient_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphOperation>
Available on crate features MPSGraphOptimizerOps
and MPSGraphMemoryOps
and MPSGraphOperation
and MPSGraphTensor
only.
pub unsafe fn applyStochasticGradientDescentWithLearningRateTensor_variable_gradientTensor_name( &self, learning_rate_tensor: &MPSGraphTensor, variable: &MPSGraphVariableOp, gradient_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphOperation>
MPSGraphOptimizerOps
and MPSGraphMemoryOps
and MPSGraphOperation
and MPSGraphTensor
only.The Stochastic gradient descent performs a gradient descent
variable = variable - (learningRate * g)
where,
g
is gradient of error wrt variable
this op directly writes to the variable
- Parameters:
- learningRateTensor: scalar tensor which indicates the learning rate to use with the optimizer
- variable: variable operation with trainable parameters
- gradientTensor: partial gradient of the trainable parameters with respect to loss
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn adamWithLearningRateTensor_beta1Tensor_beta2Tensor_epsilonTensor_beta1PowerTensor_beta2PowerTensor_valuesTensor_momentumTensor_velocityTensor_maximumVelocityTensor_gradientTensor_name(
&self,
learning_rate_tensor: &MPSGraphTensor,
beta1_tensor: &MPSGraphTensor,
beta2_tensor: &MPSGraphTensor,
epsilon_tensor: &MPSGraphTensor,
beta1_power_tensor: &MPSGraphTensor,
beta2_power_tensor: &MPSGraphTensor,
values_tensor: &MPSGraphTensor,
momentum_tensor: &MPSGraphTensor,
velocity_tensor: &MPSGraphTensor,
maximum_velocity_tensor: Option<&MPSGraphTensor>,
gradient_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphOptimizerOps
and MPSGraphTensor
only.
pub unsafe fn adamWithLearningRateTensor_beta1Tensor_beta2Tensor_epsilonTensor_beta1PowerTensor_beta2PowerTensor_valuesTensor_momentumTensor_velocityTensor_maximumVelocityTensor_gradientTensor_name( &self, learning_rate_tensor: &MPSGraphTensor, beta1_tensor: &MPSGraphTensor, beta2_tensor: &MPSGraphTensor, epsilon_tensor: &MPSGraphTensor, beta1_power_tensor: &MPSGraphTensor, beta2_power_tensor: &MPSGraphTensor, values_tensor: &MPSGraphTensor, momentum_tensor: &MPSGraphTensor, velocity_tensor: &MPSGraphTensor, maximum_velocity_tensor: Option<&MPSGraphTensor>, gradient_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphOptimizerOps
and MPSGraphTensor
only.Creates operations to apply Adam optimization.
The adam update ops are added current learning rate:
lr[t] = learningRate * sqrt(1 - beta2^t) / (1 - beta1^t)
m[t] = beta1 * m[t-1] + (1 - beta1) * g
v[t] = beta2 * v[t-1] + (1 - beta2) * (g ^ 2)
maxVel[t] = max(maxVel[t-1], v[t])
variable = variable - lr[t] * m[t] / (sqrt(maxVel) + epsilon)
- Parameters:
- learningRateTensor: scalar tensor which indicates the learning rate to use with the optimizer
- beta1Tensor: beta1Tensor
- beta2Tensor: beta2Tensor
- beta1PowerTensor:
beta1^t
beta1 power tensor - beta2PowerTensor:
beta2^t
beta2 power tensor - valuesTensor: values to update with optimization
- momentumTensor: momentum tensor
- velocityTensor: velocity tensor
- maximumVelocityTensor: optional maximum velocity tensor
- gradientTensor: partial gradient of the trainable parameters with respect to loss
- name: name for the operation
- Returns: if maximumVelocity is nil array of 3 tensors (update, newMomentum, newVelocity) else array of 4 tensors (update, newMomentum, newVelocity, newMaximumVelocity)
Sourcepub unsafe fn adamWithCurrentLearningRateTensor_beta1Tensor_beta2Tensor_epsilonTensor_valuesTensor_momentumTensor_velocityTensor_maximumVelocityTensor_gradientTensor_name(
&self,
current_learning_rate_tensor: &MPSGraphTensor,
beta1_tensor: &MPSGraphTensor,
beta2_tensor: &MPSGraphTensor,
epsilon_tensor: &MPSGraphTensor,
values_tensor: &MPSGraphTensor,
momentum_tensor: &MPSGraphTensor,
velocity_tensor: &MPSGraphTensor,
maximum_velocity_tensor: Option<&MPSGraphTensor>,
gradient_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphOptimizerOps
and MPSGraphTensor
only.
pub unsafe fn adamWithCurrentLearningRateTensor_beta1Tensor_beta2Tensor_epsilonTensor_valuesTensor_momentumTensor_velocityTensor_maximumVelocityTensor_gradientTensor_name( &self, current_learning_rate_tensor: &MPSGraphTensor, beta1_tensor: &MPSGraphTensor, beta2_tensor: &MPSGraphTensor, epsilon_tensor: &MPSGraphTensor, values_tensor: &MPSGraphTensor, momentum_tensor: &MPSGraphTensor, velocity_tensor: &MPSGraphTensor, maximum_velocity_tensor: Option<&MPSGraphTensor>, gradient_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphOptimizerOps
and MPSGraphTensor
only.Creates operations to apply Adam optimization.
The adam update ops are added
m[t] = beta1m[t-1] + (1 - beta1) * g
v[t] = beta2v[t-1] + (1 - beta2) * (g ^ 2)
maxVel[t] = max(maxVel[t-1],v[t])
variable = variable - lr[t] * m[t] / (sqrt(maxVel) + epsilon)
- Parameters:
- learningRateTensor: scalar tensor which indicates the learning rate to use with the optimizer
- beta1Tensor: beta1Tensor
- beta2Tensor: beta2Tensor
- epsilonTensor: epsilon tensor
- valuesTensor: values to update with optimization
- momentumTensor: momentum tensor
- velocityTensor: velocity tensor
- maximumVelocityTensor: optional maximum velocity tensor
- gradientTensor: partial gradient of the trainable parameters with respect to loss
- name: name for the operation
- Returns: if maximumVelocity is nil array of 3 tensors (update, newMomentum, newVelocity) else array of 4 tensors (update, newMomentum, newVelocity, newMaximumVelocity)
Source§impl MPSGraph
MPSGraphPoolingOps.
impl MPSGraph
MPSGraphPoolingOps.
Sourcepub unsafe fn maxPooling2DWithSourceTensor_descriptor_name(
&self,
source: &MPSGraphTensor,
descriptor: &MPSGraphPooling2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
only.
pub unsafe fn maxPooling2DWithSourceTensor_descriptor_name( &self, source: &MPSGraphTensor, descriptor: &MPSGraphPooling2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphPoolingOps
and MPSGraphTensor
only.Creates a 2D max-pooling operation and returns the result tensor.
- Parameters:
- source: A 2D Image source as tensor - must be of rank=4. The layout is defined by
descriptor.dataLayout
. - descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates, paddings and layouts.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn maxPooling2DReturnIndicesWithSourceTensor_descriptor_name(
&self,
source: &MPSGraphTensor,
descriptor: &MPSGraphPooling2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
only.
pub unsafe fn maxPooling2DReturnIndicesWithSourceTensor_descriptor_name( &self, source: &MPSGraphTensor, descriptor: &MPSGraphPooling2DOpDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphPoolingOps
and MPSGraphTensor
only.Creates a 2D max-pooling operation and returns the result tensor and the corresponding indices tensor.
In order to Computes the indices, returnIndicesMode
of the descriptor must be set. The datatype of indices tensor can be set
using returnIndicesDataType
.
If returnIndicesMode = MPSGraphPoolingReturnIndicesNone
then only the first result
MPSGraph returns will be valid and using the second result will assert.
- Parameters:
- source: A 2D Image source as tensor - must be of rank=4. The layout is defined by
descriptor.dataLayout
. - descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates, paddings and layouts.
- name: The name for the operation.
- Returns: An array of two MPSGraphTensors. The first tensor holds the result of max pool and the second tensor holds the corresponding indices
Sourcepub unsafe fn maxPooling2DGradientWithGradientTensor_sourceTensor_descriptor_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
descriptor: &MPSGraphPooling2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
only.
pub unsafe fn maxPooling2DGradientWithGradientTensor_sourceTensor_descriptor_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, descriptor: &MPSGraphPooling2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphPoolingOps
and MPSGraphTensor
only.Creates a max-pooling gradient operation and returns the result tensor.
- Parameters:
- gradient: A 2D input gradient tensor - must be of rank=4. The layout is defined by
descriptor.dataLayout
. - source: The input tensor for the forward pass.
- descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates, paddings and layouts.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn maxPooling2DGradientWithGradientTensor_indicesTensor_outputShape_descriptor_name(
&self,
gradient: &MPSGraphTensor,
indices: &MPSGraphTensor,
output_shape: &MPSShape,
descriptor: &MPSGraphPooling2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn maxPooling2DGradientWithGradientTensor_indicesTensor_outputShape_descriptor_name( &self, gradient: &MPSGraphTensor, indices: &MPSGraphTensor, output_shape: &MPSShape, descriptor: &MPSGraphPooling2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphPoolingOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a max-pooling gradient operation and returns the result tensor.
With this API MPSGraph computes the max-pooling gradient efficiently by reusing the indices from the forward API instead of recomputing them.
The descriptor must set returnIndicesMode
and returnIndicesDataType
to the same value as that set by the forward pass.
- Parameters:
- gradient: A 2D input gradient tensor - must be of rank=4. The layout is defined by
descriptor.dataLayout
. - indices: The indices tensor returned from
MPSGraph/maxPooling2DReturnIndicesWithSourceTensor:descriptor:name:
. - outputShape: The shape of the destination gradient.
- descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates, paddings and layouts.
- name: The name for the operation.
- Returns: Destination gradient tensor.
Sourcepub unsafe fn maxPooling2DGradientWithGradientTensor_indicesTensor_outputShapeTensor_descriptor_name(
&self,
gradient: &MPSGraphTensor,
indices: &MPSGraphTensor,
output_shape: &MPSGraphTensor,
descriptor: &MPSGraphPooling2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
only.
pub unsafe fn maxPooling2DGradientWithGradientTensor_indicesTensor_outputShapeTensor_descriptor_name( &self, gradient: &MPSGraphTensor, indices: &MPSGraphTensor, output_shape: &MPSGraphTensor, descriptor: &MPSGraphPooling2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphPoolingOps
and MPSGraphTensor
only.Creates a max-pooling gradient operation and returns the result tensor.
With this API MPSGraph computes the max-pooling gradient efficiently by reusing the indices from the forward API instead of recomputing them.
The descriptor must set returnIndicesMode
and returnIndicesDataType
to the same value as that set by the forward pass.
- Parameters:
- gradient: A 2D input gradient tensor - must be of rank=4. The layout is defined by
descriptor.dataLayout
. - indices: The indices tensor returned from
MPSGraph/maxPooling2DReturnIndicesWithSourceTensor:descriptor:name:
. - outputShape: A tensor containing the shape of the destination gradient.
- descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates, paddings and layouts.
- name: The name for the operation.
- Returns: Destination gradient tensor.
Sourcepub unsafe fn avgPooling2DWithSourceTensor_descriptor_name(
&self,
source: &MPSGraphTensor,
descriptor: &MPSGraphPooling2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
only.
pub unsafe fn avgPooling2DWithSourceTensor_descriptor_name( &self, source: &MPSGraphTensor, descriptor: &MPSGraphPooling2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphPoolingOps
and MPSGraphTensor
only.Creates a 2D average-pooling operation and returns the result tensor.
- Parameters:
- source: A 2D Image source as tensor - must be of rank=4. The layout is defined by
descriptor.dataLayout
. - descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates, paddings and layouts.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn avgPooling2DGradientWithGradientTensor_sourceTensor_descriptor_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
descriptor: &MPSGraphPooling2DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
only.
pub unsafe fn avgPooling2DGradientWithGradientTensor_sourceTensor_descriptor_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, descriptor: &MPSGraphPooling2DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphPoolingOps
and MPSGraphTensor
only.Creates a 2D average pooling gradient operation and returns the result tensor.
- Parameters:
- gradient: A 2D input gradient tensor - must be of rank=4. The layout is defined by
descriptor.dataLayout
. - source: The input tensor for the forward pass.
- descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates, paddings and layouts.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn maxPooling4DWithSourceTensor_descriptor_name(
&self,
source: &MPSGraphTensor,
descriptor: &MPSGraphPooling4DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
only.
pub unsafe fn maxPooling4DWithSourceTensor_descriptor_name( &self, source: &MPSGraphTensor, descriptor: &MPSGraphPooling4DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphPoolingOps
and MPSGraphTensor
only.Creates a 4D max-pooling operation and returns the result tensor.
- Parameters:
- source: A source tensor.
- descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates and paddings.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn maxPooling4DReturnIndicesWithSourceTensor_descriptor_name(
&self,
source: &MPSGraphTensor,
descriptor: &MPSGraphPooling4DOpDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
only.
pub unsafe fn maxPooling4DReturnIndicesWithSourceTensor_descriptor_name( &self, source: &MPSGraphTensor, descriptor: &MPSGraphPooling4DOpDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphPoolingOps
and MPSGraphTensor
only.Creates a 4D max-pooling operation and returns the result tensor and the corresponding indices tensor.
In order to Computes the indices, returnIndicesMode
of the descriptor must be set. The datatype of indices tensor can be set
using returnIndicesDataType
.
If returnIndicesMode = MPSGraphPoolingReturnIndicesNone
then only the first result
MPSGraph returns will be valid and using the second result will assert.
- Parameters:
- source: The source tensor on which pooling will be performed.
- descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates and paddings.
- name: The name for the operation.
- Returns: An array of two MPSGraphTensors. The first tensor holds the result of max pool and the second tensor holds the corresponding indices.
Sourcepub unsafe fn maxPooling4DGradientWithGradientTensor_sourceTensor_descriptor_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
descriptor: &MPSGraphPooling4DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
only.
pub unsafe fn maxPooling4DGradientWithGradientTensor_sourceTensor_descriptor_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, descriptor: &MPSGraphPooling4DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphPoolingOps
and MPSGraphTensor
only.Creates a max-pooling gradient operation and returns the result tensor.
- Parameters:
- gradient: An input gradient tensor.
- source: The input tensor for the forward pass.
- descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates and paddings.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn maxPooling4DGradientWithGradientTensor_indicesTensor_outputShape_descriptor_name(
&self,
gradient: &MPSGraphTensor,
indices: &MPSGraphTensor,
output_shape: &MPSShape,
descriptor: &MPSGraphPooling4DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn maxPooling4DGradientWithGradientTensor_indicesTensor_outputShape_descriptor_name( &self, gradient: &MPSGraphTensor, indices: &MPSGraphTensor, output_shape: &MPSShape, descriptor: &MPSGraphPooling4DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphPoolingOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a max-pooling gradient operation and returns the result tensor.
With this API MPSGraph computes the max-pooling gradient efficiently by reusing the indices from the forward API instead of recomputing them.
The descriptor must set returnIndicesMode
and returnIndicesDataType
to the same value as that set by the forward pass.
- Parameters:
- gradient: An input gradient tensor.
- indices: Indices tensor returned from
MPSGraph/maxPooling4DReturnIndicesWithSourceTensor:descriptor:name:
. - outputShape: The shape of the destination gradient.
- descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates, paddings and layouts.
- name: The name for the operation.
- Returns: Destination gradient tensor.
Sourcepub unsafe fn maxPooling4DGradientWithGradientTensor_indicesTensor_outputShapeTensor_descriptor_name(
&self,
gradient: &MPSGraphTensor,
indices: &MPSGraphTensor,
output_shape: &MPSGraphTensor,
descriptor: &MPSGraphPooling4DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
only.
pub unsafe fn maxPooling4DGradientWithGradientTensor_indicesTensor_outputShapeTensor_descriptor_name( &self, gradient: &MPSGraphTensor, indices: &MPSGraphTensor, output_shape: &MPSGraphTensor, descriptor: &MPSGraphPooling4DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphPoolingOps
and MPSGraphTensor
only.Creates a max-pooling gradient operation and returns the result tensor.
With this API MPSGraph computes the max-pooling gradient efficiently by reusing the indices from the forward API instead of recomputing them.
The descriptor must set returnIndicesMode
and returnIndicesDataType
to the same value as that set by the forward pass.
- Parameters:
- gradient: An input gradient tensor.
- indices: The indices tensor returned from
MPSGraph/maxPooling4DReturnIndicesWithSourceTensor:descriptor:name:
. - outputShape: A tensor containing the shape of the destination gradient.
- descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates, paddings and layouts.
- name: The name for the operation.
- Returns: Destination gradient tensor.
Sourcepub unsafe fn avgPooling4DWithSourceTensor_descriptor_name(
&self,
source: &MPSGraphTensor,
descriptor: &MPSGraphPooling4DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
only.
pub unsafe fn avgPooling4DWithSourceTensor_descriptor_name( &self, source: &MPSGraphTensor, descriptor: &MPSGraphPooling4DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphPoolingOps
and MPSGraphTensor
only.Creates a 4D average pooling operation and returns the result tensor.
- Parameters:
- source: A source tensor.
- descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates and paddings.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn avgPooling4DGradientWithGradientTensor_sourceTensor_descriptor_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
descriptor: &MPSGraphPooling4DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
only.
pub unsafe fn avgPooling4DGradientWithGradientTensor_sourceTensor_descriptor_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, descriptor: &MPSGraphPooling4DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphPoolingOps
and MPSGraphTensor
only.Creates an average pooling gradient operation and returns the result tensor.
- Parameters:
- gradient: An input gradient tensor.
- source: The input tensor for the forward pass.
- descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates and paddings.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn L2NormPooling4DWithSourceTensor_descriptor_name(
&self,
source: &MPSGraphTensor,
descriptor: &MPSGraphPooling4DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
only.
pub unsafe fn L2NormPooling4DWithSourceTensor_descriptor_name( &self, source: &MPSGraphTensor, descriptor: &MPSGraphPooling4DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphPoolingOps
and MPSGraphTensor
only.Creates a 4D L2-norm pooling operation and returns the result tensor.
- Parameters:
- source: A source tensor.
- descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates and paddings.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn L2NormPooling4DGradientWithGradientTensor_sourceTensor_descriptor_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
descriptor: &MPSGraphPooling4DOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphPoolingOps
and MPSGraphTensor
only.
pub unsafe fn L2NormPooling4DGradientWithGradientTensor_sourceTensor_descriptor_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, descriptor: &MPSGraphPooling4DOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphPoolingOps
and MPSGraphTensor
only.Creates a L2-Norm pooling gradient operation and returns the result tensor.
- Parameters:
- gradient: An input gradient tensor.
- source: The input tensor for the forward pass.
- descriptor: A pooling operation descriptor that specifies pooling window sizes, strides, dilation rates and paddings.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Source§impl MPSGraph
MPSGraphQuantizationOps.
impl MPSGraph
MPSGraphQuantizationOps.
Sourcepub unsafe fn quantizeTensor_scale_zeroPoint_dataType_name(
&self,
tensor: &MPSGraphTensor,
scale: c_double,
zero_point: c_double,
data_type: MPSDataType,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn quantizeTensor_scale_zeroPoint_dataType_name( &self, tensor: &MPSGraphTensor, scale: c_double, zero_point: c_double, data_type: MPSDataType, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a Quantize operation and returns the result tensor.
Convert the float tensor
to an i8 or u8 tensor by applying a scale + bias transform:
result = (tensor / scale) + zeroPoint
- Parameters:
- tensor: Input tensor to be quantized
- scale: Scale scalar parameter
- zeroPoint: Bias scalar parameter (converted to dataType of resultTensor)
- dataType: Integer data type of the result tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of datatype dataType
Sourcepub unsafe fn dequantizeTensor_scale_zeroPoint_dataType_name(
&self,
tensor: &MPSGraphTensor,
scale: c_double,
zero_point: c_double,
data_type: MPSDataType,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn dequantizeTensor_scale_zeroPoint_dataType_name( &self, tensor: &MPSGraphTensor, scale: c_double, zero_point: c_double, data_type: MPSDataType, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates Dequantize operation and returns the result tensor.
Convert the i8 or u8 tensor
to a float tensor by applying a scale + bias transform:
result = scale(tensor - zeroPoint)
- Parameters:
- tensor: Input tensor to be dequantized
- scale: Scale scalar parameter
- zeroPoint: Bias scalar parameter (converted to dataType of tensor)
- dataType: Float data type of the result tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of datatype dataType
Sourcepub unsafe fn quantizeTensor_scaleTensor_zeroPoint_dataType_axis_name(
&self,
tensor: &MPSGraphTensor,
scale_tensor: &MPSGraphTensor,
zero_point: c_double,
data_type: MPSDataType,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn quantizeTensor_scaleTensor_zeroPoint_dataType_axis_name( &self, tensor: &MPSGraphTensor, scale_tensor: &MPSGraphTensor, zero_point: c_double, data_type: MPSDataType, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a Quantize operation and returns the result tensor.
Convert the float tensor
to an i8 or u8 tensor by applying a scale + bias transform:
result = (tensor / scaleTensor) + zeroPoint
- Parameters:
- tensor: Input tensor to be quantized
- scaleTensor: Scale 1D Tensor parameter with size == tensor.shape[axis]
- zeroPoint: Bias scalar parameter (converted to dataType of resultTensor)
- dataType: Integer data type of the result tensor.
- axis: Axis on which the scale 1D value is being broadcasted
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of datatype dataType
Sourcepub unsafe fn dequantizeTensor_scaleTensor_zeroPoint_dataType_axis_name(
&self,
tensor: &MPSGraphTensor,
scale_tensor: &MPSGraphTensor,
zero_point: c_double,
data_type: MPSDataType,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn dequantizeTensor_scaleTensor_zeroPoint_dataType_axis_name( &self, tensor: &MPSGraphTensor, scale_tensor: &MPSGraphTensor, zero_point: c_double, data_type: MPSDataType, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates Dequantize operation and returns the result tensor.
Convert the i8 or u8 tensor
to a float tensor by applying a scale + bias transform:
result = scaleTensor(tensor - zeroPoint)
- Parameters:
- tensor: Input tensor to be dequantized
- scaleTensor: Scale scalar or 1D Tensor parameter with size == tensor.shape[axis]
- zeroPoint: Bias scalar parameter (converted to dataType of tensor)
- dataType: Float data type of the result tensor.
- axis: Axis on which the scale 1D value is being broadcasted
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of datatype dataType
Sourcepub unsafe fn quantizeTensor_scaleTensor_zeroPointTensor_dataType_axis_name(
&self,
tensor: &MPSGraphTensor,
scale_tensor: &MPSGraphTensor,
zero_point_tensor: &MPSGraphTensor,
data_type: MPSDataType,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn quantizeTensor_scaleTensor_zeroPointTensor_dataType_axis_name( &self, tensor: &MPSGraphTensor, scale_tensor: &MPSGraphTensor, zero_point_tensor: &MPSGraphTensor, data_type: MPSDataType, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a Quantize operation and returns the result tensor.
Convert the float tensor
to an i8 or u8 tensor by applying a scale + bias transform:
result = (tensor / scaleTensor) + zeroPointTensor
- Parameters:
- tensor: Input tensor to be quantized
- scaleTensor: Scale scalar or 1D Tensor parameter with size == tensor.shape[axis]
- zeroPointTensor: Bias scalar or 1D Tensor parameter with size == tensor.shape[axis]
- dataType: Integer data type of the result tensor.
- axis: Axis on which the scale 1D value is being broadcasted
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of datatype dataType
Sourcepub unsafe fn dequantizeTensor_scaleTensor_zeroPointTensor_dataType_axis_name(
&self,
tensor: &MPSGraphTensor,
scale_tensor: &MPSGraphTensor,
zero_point_tensor: &MPSGraphTensor,
data_type: MPSDataType,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn dequantizeTensor_scaleTensor_zeroPointTensor_dataType_axis_name( &self, tensor: &MPSGraphTensor, scale_tensor: &MPSGraphTensor, zero_point_tensor: &MPSGraphTensor, data_type: MPSDataType, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a dequantize operation and returns the result tensor.
Convert the i8 or u8 tensor
to a float tensor by applying a scale + bias transform:
result = scaleTensor(tensor - zeroPointTensor)
- Parameters:
- tensor: Input tensor to be dequantized
- scaleTensor: Scale scalar or 1D Tensor parameter with size == tensor.shape[axis]
- zeroPointTensor: Bias scalar or 1D Tensor parameter with size == tensor.shape[axis]
- dataType: Float data type of the result tensor.
- axis: Axis on which the scale 1D value is being broadcasted
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of datatype dataType
Sourcepub unsafe fn dequantizeTensor_scaleTensor_zeroPointTensor_dataType_name(
&self,
tensor: &MPSGraphTensor,
scale_tensor: &MPSGraphTensor,
zero_point_tensor: &MPSGraphTensor,
data_type: MPSDataType,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn dequantizeTensor_scaleTensor_zeroPointTensor_dataType_name( &self, tensor: &MPSGraphTensor, scale_tensor: &MPSGraphTensor, zero_point_tensor: &MPSGraphTensor, data_type: MPSDataType, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a dequantize operation and returns the result tensor.
Convert the i8, u8, i4 or u4 tensor
to a float tensor by applying a scale and bias transform:
result = scaleTensor(tensor - zeroPointTensor).
- Parameters:
- tensor: Input tensor to be dequantized.
- scaleTensor: The scale tensor with groups support.
- zeroPointTensor: The bias tensor with groups support.
- dataType: Float data type of the result tensor.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array of datatypedataType
.
Sourcepub unsafe fn dequantizeTensor_scaleTensor_dataType_name(
&self,
tensor: &MPSGraphTensor,
scale_tensor: &MPSGraphTensor,
data_type: MPSDataType,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn dequantizeTensor_scaleTensor_dataType_name( &self, tensor: &MPSGraphTensor, scale_tensor: &MPSGraphTensor, data_type: MPSDataType, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphQuantizationOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a dequantize operation and returns the result tensor.
Converts the i8, u8, i4 or u4 tensor
to a float tensor by applying a scale and bias transform:
result = scaleTensor * tensor.
- Parameters:
- tensor: Input tensor to be dequantized.
- scaleTensor: Scale Tensor parameter with groups support.
- dataType: Float data type of the result tensor.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array of datatypedataType
.
Sourcepub unsafe fn dequantizeTensor_LUTTensor_name(
&self,
tensor: &MPSGraphTensor,
lut_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphQuantizationOps
and MPSGraphTensor
only.
pub unsafe fn dequantizeTensor_LUTTensor_name( &self, tensor: &MPSGraphTensor, lut_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphQuantizationOps
and MPSGraphTensor
only.Creates a lookup-table based quantization operation and returns the result tensor.
Converts a u8 or u4 tensor
to a float tensor by applying a lookup operation:
result[i1,...,in] = LUTTensor[i1',...,in',tensor[i1,...,in]].
Note: The operation supports LUT groups up to the last 3 dimensions for tensor
.
- Parameters:
- tensor: Input tensor to be dequantized.
- LUTTensor: The lookup table to use - for u4 the last dimension should have 16 elements, and for u8 256 elements.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
object.
Sourcepub unsafe fn dequantizeTensor_LUTTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
lut_tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphQuantizationOps
and MPSGraphTensor
only.
pub unsafe fn dequantizeTensor_LUTTensor_axis_name( &self, tensor: &MPSGraphTensor, lut_tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphQuantizationOps
and MPSGraphTensor
only.Creates a vector lookup-table based quantization operation and returns the result tensor.
Converts a u8 or u4 tensor
to a float tensor by applying a lookup operation, where each
input index defines a vector of values. The operation reads the vector values from the last dimension of the lookup table
tensor and stores them into the dimension defined by axis
on the result tensor.
result[i1, ... , i_axis, ..., in] = LUTTensor[i1', ..., in', tensor[i1, ..., in], i_axis]
Note: The operation supports LUT groups up to the last 2 dimensions for tensor
.
- Parameters:
- tensor: Input tensor to be dequantized.
- LUTTensor: The lookup table to use - for u4 the second to last dimension should have 16 elements, and for u8 256 elements.
- axis: Axis on which the scale 1D value is being broadcasted.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
object.
Source§impl MPSGraph
MPSGraphRNNOps.
impl MPSGraph
MPSGraphRNNOps.
Sourcepub unsafe fn singleGateRNNWithSourceTensor_recurrentWeight_inputWeight_bias_initState_mask_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
init_state: Option<&MPSGraphTensor>,
mask: Option<&MPSGraphTensor>,
descriptor: &MPSGraphSingleGateRNNDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn singleGateRNNWithSourceTensor_recurrentWeight_inputWeight_bias_initState_mask_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, init_state: Option<&MPSGraphTensor>, mask: Option<&MPSGraphTensor>, descriptor: &MPSGraphSingleGateRNNDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates a single-gate RNN operation and returns the value and optionally the training state tensor.
This operation returns tensors h
and optionally z
that are defined recursively as follows:
for t = 0 to T-1
z[t] = x[t] W^T + (h[t-1]m) R^T + b
h[t] = activation( z[t] ), where
W
is optional inputWeight
, R
is recurrentWeight
, b
is bias
, m
is optional mask
,
x[t]
is source
h[t]
is the first output, z[t]
is the second output (optional) and h[-1]
is initState
.
See MPSGraphSingleGateRNNDescriptor
for different activation
options.
- Parameters:
- source: A tensor that contains the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,2H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,H,H] and otherwise it is [H,H]. - inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [2H,I] and otherwise it is [H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [2H] and otherwise it is [H]. - initState: The initial internal state of the RNN
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - mask: A tensor containing the mask
m
- optional, if missing the operation assumes ones. This is useful for dropout support. - descriptor: A descriptor that defines the parameters for the RNN operation.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of size 1 or 2, depending on value of
descriptor.training
. The layout of the both outputs is [T,N,H] or [T,N,2H] for bidirectional.
Sourcepub unsafe fn singleGateRNNWithSourceTensor_recurrentWeight_inputWeight_bias_initState_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
init_state: Option<&MPSGraphTensor>,
descriptor: &MPSGraphSingleGateRNNDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn singleGateRNNWithSourceTensor_recurrentWeight_inputWeight_bias_initState_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, init_state: Option<&MPSGraphTensor>, descriptor: &MPSGraphSingleGateRNNDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates a single-gate RNN operation and returns the value and optionally the training state tensor.
This operation returns tensors h
and optionally z
that are defined recursively as follows:
for t = 0 to T-1
z[t] = x[t] W^T + (h[t-1]m) R^T + b
h[t] = activation( z[t] ), where
W
is optional inputWeight
, R
is recurrentWeight
, b
is bias
, m
is optional mask
,
x[t]
is source
h[t]
is the first output, z[t]
is the second output (optional) and h[-1]
is initState
.
See MPSGraphSingleGateRNNDescriptor
for different activation
options.
- Parameters:
- source: A tensor that contains the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,2H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,H,H] and otherwise it is [H,H]. - inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [2H,I] and otherwise it is [H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [2H] and otherwise it is [H]. - initState: The initial internal state of the RNN
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - descriptor: A descriptor that defines the parameters for the RNN operation.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of size 1 or 2, depending on value of
descriptor.training
. The layout of the both outputs is [T,N,H] or [T,N,2H] for bidirectional.
Sourcepub unsafe fn singleGateRNNWithSourceTensor_recurrentWeight_initState_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
init_state: Option<&MPSGraphTensor>,
descriptor: &MPSGraphSingleGateRNNDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn singleGateRNNWithSourceTensor_recurrentWeight_initState_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, init_state: Option<&MPSGraphTensor>, descriptor: &MPSGraphSingleGateRNNDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates a single-gate RNN operation and returns the value and optionally the training state tensor.
This operation returns tensors h
and optionally z
that are defined recursively as follows:
for t = 0 to T-1
z[t] = x[t] W^T + (h[t-1]m) R^T + b
h[t] = activation( z[t] ), where
W
is optional inputWeight
, R
is recurrentWeight
, b
is bias
, m
is optional mask
,
x[t]
is source
h[t]
is the first output, z[t]
is the second output (optional) and h[-1]
is initState
.
See MPSGraphSingleGateRNNDescriptor
for different activation
options.
- Parameters:
- source: A tensor that contains the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,2H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,H,H] and otherwise it is [H,H]. - initState: The initial internal state of the RNN
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - descriptor: A descriptor that defines the parameters for the RNN operation.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of size 1 or 2, depending on value of
descriptor.training
. The layout of the both outputs is [T,N,H] or [T,N,2H] for bidirectional.
Sourcepub unsafe fn singleGateRNNGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_stateGradient_inputWeight_bias_initState_mask_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
source_gradient: &MPSGraphTensor,
z_state: &MPSGraphTensor,
state_gradient: Option<&MPSGraphTensor>,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
init_state: Option<&MPSGraphTensor>,
mask: Option<&MPSGraphTensor>,
descriptor: &MPSGraphSingleGateRNNDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn singleGateRNNGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_stateGradient_inputWeight_bias_initState_mask_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, source_gradient: &MPSGraphTensor, z_state: &MPSGraphTensor, state_gradient: Option<&MPSGraphTensor>, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, init_state: Option<&MPSGraphTensor>, mask: Option<&MPSGraphTensor>, descriptor: &MPSGraphSingleGateRNNDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates a single-gate RNN gradient operation and returns the gradient tensor values.
For details of this operation and parameters, refer to documentation of
MPSGraph/singleGateRNNWithSourceTensor:recurrentWeight:inputWeight:bias:initState:mask:descriptor:name:
.
- Parameters:
- source: A tensor that contains the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,2H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,H,H] and otherwise it is [H,H]. Note: Forbidirectional
this tensor must have a static shape. - sourceGradient: The input gradient, that is the gradient of a tensor with respect to the first output of the forward pass.
- zState: The second output of
MPSGraph/singleGateRNNWithSourceTensor:recurrentWeight:inputWeight:bias:initState:mask:descriptor:name:
withdescriptor.training = YES
. - stateGradient: The input gradient coming from the future timestep - optional, if missing the operation assumes zeroes.
- inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [2H,I] and otherwise it is [H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [2H] and otherwise it is [H]. - initState: The initial internal state of the RNN
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - mask: A tensor containing the mask
m
- optional, if missing the operation assumes ones. This is useful for dropout support. - descriptor: A descriptor that defines the parameters for the RNN operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array containing gradients for each input tensor, except forsourceGradient
andmask
. In case an input isnil
, no gradient will be returned for it. The order of the gradients will be: forsource
, forrecurrentWeight
, forinputWeight
, forbias
and finally forinitState
.
Sourcepub unsafe fn singleGateRNNGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_inputWeight_bias_initState_mask_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
source_gradient: &MPSGraphTensor,
z_state: &MPSGraphTensor,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
init_state: Option<&MPSGraphTensor>,
mask: Option<&MPSGraphTensor>,
descriptor: &MPSGraphSingleGateRNNDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn singleGateRNNGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_inputWeight_bias_initState_mask_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, source_gradient: &MPSGraphTensor, z_state: &MPSGraphTensor, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, init_state: Option<&MPSGraphTensor>, mask: Option<&MPSGraphTensor>, descriptor: &MPSGraphSingleGateRNNDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates a single-gate RNN gradient operation and returns the gradient tensor values.
For details of this operation and parameters, refer to documentation of
MPSGraph/singleGateRNNWithSourceTensor:recurrentWeight:inputWeight:bias:initState:mask:descriptor:name:
.
- Parameters:
- source: A tensor that contains the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,2H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,H,H] and otherwise it is [H,H]. Note: Forbidirectional
this tensor must have a static shape. - sourceGradient: The input gradient, that is the gradient of a tensor with respect to the first output of the forward pass.
- zState: The second output of
MPSGraph/singleGateRNNWithSourceTensor:recurrentWeight:inputWeight:bias:initState:mask:descriptor:name:
withdescriptor.training = YES
. - inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [2H,I] and otherwise it is [H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [2H] and otherwise it is [H]. - initState: The initial internal state of the RNN
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - mask: A tensor containing the mask
m
- optional, if missing the operation assumes ones. This is useful for dropout support. - descriptor: A descriptor that defines the parameters for the RNN operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array containing gradients for each input tensor, except forsourceGradient
andmask
. In case an input isnil
, no gradient will be returned for it. The order of the gradients will be: forsource
, forrecurrentWeight
, forinputWeight
, forbias
and finally forinitState
.
Sourcepub unsafe fn singleGateRNNGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_inputWeight_bias_initState_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
source_gradient: &MPSGraphTensor,
z_state: &MPSGraphTensor,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
init_state: Option<&MPSGraphTensor>,
descriptor: &MPSGraphSingleGateRNNDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn singleGateRNNGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_inputWeight_bias_initState_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, source_gradient: &MPSGraphTensor, z_state: &MPSGraphTensor, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, init_state: Option<&MPSGraphTensor>, descriptor: &MPSGraphSingleGateRNNDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates a single-gate RNN gradient operation and returns the gradient tensor values.
For details of this operation and parameters, refer to documentation of
MPSGraph/singleGateRNNWithSourceTensor:recurrentWeight:inputWeight:bias:initState:mask:descriptor:name:
.
- Parameters:
- source: A tensor that contains the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,2H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,H,H] and otherwise it is [H,H]. Note: Forbidirectional
this tensor must have a static shape. - sourceGradient: The input gradient, that is the gradient of a tensor with respect to the first output of the forward pass.
- zState: The second output of
MPSGraph/singleGateRNNWithSourceTensor:recurrentWeight:inputWeight:bias:initState:mask:descriptor:name:
withdescriptor.training = YES
. - inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [2H,I] and otherwise it is [H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [2H] and otherwise it is [H]. - initState: The initial internal state of the RNN
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - descriptor: A descriptor that defines the parameters for the RNN operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array containing gradients for each input tensor, except forsourceGradient
andmask
. In case an input isnil
, no gradient will be returned for it. The order of the gradients will be: forsource
, forrecurrentWeight
, forinputWeight
, forbias
and finally forinitState
.
Sourcepub unsafe fn singleGateRNNGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_initState_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
source_gradient: &MPSGraphTensor,
z_state: &MPSGraphTensor,
init_state: Option<&MPSGraphTensor>,
descriptor: &MPSGraphSingleGateRNNDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn singleGateRNNGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_initState_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, source_gradient: &MPSGraphTensor, z_state: &MPSGraphTensor, init_state: Option<&MPSGraphTensor>, descriptor: &MPSGraphSingleGateRNNDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates a single-gate RNN gradient operation and returns the gradient tensor values.
For details of this operation and parameters, refer to documentation of
MPSGraph/singleGateRNNWithSourceTensor:recurrentWeight:inputWeight:bias:initState:mask:descriptor:name:
.
- Parameters:
- source: A tensor that contains the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,2H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,H,H] and otherwise it is [H,H]. Note: Forbidirectional
this tensor must have a static shape. - sourceGradient: The input gradient, that is the gradient of a tensor with respect to the first output of the forward pass.
- zState: The second output of
MPSGraph/singleGateRNNWithSourceTensor:recurrentWeight:inputWeight:bias:initState:mask:descriptor:name:
withdescriptor.training = YES
. - initState: The initial internal state of the RNN
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - descriptor: A descriptor that defines the parameters for the RNN operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array containing gradients for each input tensor, except forsourceGradient
andmask
. In case an input isnil
, no gradient will be returned for it. The order of the gradients will be: forsource
, forrecurrentWeight
, forinputWeight
, forbias
and finally forinitState
.
Sourcepub unsafe fn LSTMWithSourceTensor_recurrentWeight_inputWeight_bias_initState_initCell_mask_peephole_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
init_state: Option<&MPSGraphTensor>,
init_cell: Option<&MPSGraphTensor>,
mask: Option<&MPSGraphTensor>,
peephole: Option<&MPSGraphTensor>,
descriptor: &MPSGraphLSTMDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn LSTMWithSourceTensor_recurrentWeight_inputWeight_bias_initState_initCell_mask_peephole_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, init_state: Option<&MPSGraphTensor>, init_cell: Option<&MPSGraphTensor>, mask: Option<&MPSGraphTensor>, peephole: Option<&MPSGraphTensor>, descriptor: &MPSGraphLSTMDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates an LSTM operation and returns the value tensor and optionally the cell state tensor and the training state tensor.
This operation returns tensors h
and optionally c
and optionally z
that are defined recursively as follows:
for t = 0 to T-1
z[t] = [i, f, z, o][t] = f( (h[t-1] m) R^T + x'[t] + p c[t-1] )
x'[t] = x[t] W^T + b
c[t] = f[t]c[t-1] + i[t]z[t]
h[t] = o[t]g(c[t]), where
W
is optional inputWeight
, R
is recurrentWeight
, b
is optional bias
, m
is optional mask
,
x[t]
is source
h[t]
is the first output, c[t]
is the second output (optional),
z[t]
is either the second or third output (optional), h[-1]
is initCell
. and h[-1]
is initState
.
p
is an optional peephole vector.
See MPSGraphLSTMDescriptor
for different activation
options for f()
and g()
.
- Parameters:
- source: A tensor containing the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,4H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,8H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,4H,H] and otherwise it is [4H,H]. - inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [8H,I] and otherwise it is [4H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [8H] and otherwise it is [4H]. - initState: The initial internal state of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - initCell: The initial internal cell of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - mask: A tensor containing the mask
m
- optional, if missing the operation assumes ones. Useful for dropout. - peephole: A tensor containing the peephole vector
v
- optional, if missing the operation assumes zeroes. Shape is [4H], ie. a vector for each gate, or [2,4H] for bidirectional. - descriptor: A descriptor that defines the parameters for the LSTM operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array of size 1 or 2 or 3, depending on values ofdescriptor.produceCell
anddescriptor.training
. The layout of the both state and cell outputs are [T,N,H] or [T,N,2H] for bidirectional, and the layout of the trainingState output is [T,N,4H] or [T,N,8H] for bidirectional.
Sourcepub unsafe fn LSTMWithSourceTensor_recurrentWeight_inputWeight_bias_initState_initCell_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
init_state: Option<&MPSGraphTensor>,
init_cell: Option<&MPSGraphTensor>,
descriptor: &MPSGraphLSTMDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn LSTMWithSourceTensor_recurrentWeight_inputWeight_bias_initState_initCell_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, init_state: Option<&MPSGraphTensor>, init_cell: Option<&MPSGraphTensor>, descriptor: &MPSGraphLSTMDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates an LSTM operation and returns the value tensor and optionally the cell state tensor and the training state tensor.
This operation returns tensors h
and optionally c
and optionally z
that are defined recursively as follows:
for t = 0 to T-1
z[t] = [i, f, z, o][t] = f( (h[t-1] m) R^T + x'[t] + p c[t-1] )
x'[t] = x[t] W^T + b
c[t] = f[t]c[t-1] + i[t]z[t]
h[t] = o[t]g(c[t]), where
W
is optional inputWeight
, R
is recurrentWeight
, b
is optional bias
, m
is optional mask
,
x[t]
is source
h[t]
is the first output, c[t]
is the second output (optional),
z[t]
is either the second or third output (optional), h[-1]
is initCell
. and h[-1]
is initState
.
p
is an optional peephole vector.
See MPSGraphLSTMDescriptor
for different activation
options for f()
and g()
.
- Parameters:
- source: A tensor containing the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,4H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,8H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,4H,H] and otherwise it is [4H,H]. - inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [8H,I] and otherwise it is [4H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [8H] and otherwise it is [4H]. - initState: The initial internal state of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - initCell: The initial internal cell of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - descriptor: A descriptor that defines the parameters for the LSTM operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array of size 1 or 2 or 3, depending on values ofdescriptor.produceCell
anddescriptor.training
. The layout of the both state and cell outputs are [T,N,H] or [T,N,2H] for bidirectional, and the layout of the trainingState output is [T,N,4H] or [T,N,8H] for bidirectional.
Sourcepub unsafe fn LSTMWithSourceTensor_recurrentWeight_initState_initCell_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
init_state: Option<&MPSGraphTensor>,
init_cell: Option<&MPSGraphTensor>,
descriptor: &MPSGraphLSTMDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn LSTMWithSourceTensor_recurrentWeight_initState_initCell_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, init_state: Option<&MPSGraphTensor>, init_cell: Option<&MPSGraphTensor>, descriptor: &MPSGraphLSTMDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates an LSTM operation and returns the value tensor and optionally the cell state tensor and the training state tensor.
This operation returns tensors h
and optionally c
and optionally z
that are defined recursively as follows:
for t = 0 to T-1
z[t] = [i, f, z, o][t] = f( (h[t-1] m) R^T + x'[t] + p c[t-1] )
x'[t] = x[t] W^T + b
c[t] = f[t]c[t-1] + i[t]z[t]
h[t] = o[t]g(c[t]), where
W
is optional inputWeight
, R
is recurrentWeight
, b
is optional bias
, m
is optional mask
,
x[t]
is source
h[t]
is the first output, c[t]
is the second output (optional),
z[t]
is either the second or third output (optional), h[-1]
is initCell
. and h[-1]
is initState
.
p
is an optional peephole vector.
See MPSGraphLSTMDescriptor
for different activation
options for f()
and g()
.
- Parameters:
- source: A tensor containing the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,4H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,8H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,4H,H] and otherwise it is [4H,H]. - initState: The initial internal state of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - initCell: The initial internal cell of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - descriptor: A descriptor that defines the parameters for the LSTM operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array of size 1 or 2 or 3, depending on values ofdescriptor.produceCell
anddescriptor.training
. The layout of the both state and cell outputs are [T,N,H] or [T,N,2H] for bidirectional, and the layout of the trainingState output is [T,N,4H] or [T,N,8H] for bidirectional.
Sourcepub unsafe fn LSTMGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_cellOutputFwd_stateGradient_cellGradient_inputWeight_bias_initState_initCell_mask_peephole_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
source_gradient: &MPSGraphTensor,
z_state: &MPSGraphTensor,
cell_output_fwd: &MPSGraphTensor,
state_gradient: Option<&MPSGraphTensor>,
cell_gradient: Option<&MPSGraphTensor>,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
init_state: Option<&MPSGraphTensor>,
init_cell: Option<&MPSGraphTensor>,
mask: Option<&MPSGraphTensor>,
peephole: Option<&MPSGraphTensor>,
descriptor: &MPSGraphLSTMDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn LSTMGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_cellOutputFwd_stateGradient_cellGradient_inputWeight_bias_initState_initCell_mask_peephole_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, source_gradient: &MPSGraphTensor, z_state: &MPSGraphTensor, cell_output_fwd: &MPSGraphTensor, state_gradient: Option<&MPSGraphTensor>, cell_gradient: Option<&MPSGraphTensor>, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, init_state: Option<&MPSGraphTensor>, init_cell: Option<&MPSGraphTensor>, mask: Option<&MPSGraphTensor>, peephole: Option<&MPSGraphTensor>, descriptor: &MPSGraphLSTMDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates an LSTM gradient operation and returns the gradient tensor values.
For details of this operation and parameters, refer to documentation of
MPSGraph/LSTMWithSourceTensor:recurrentWeight:inputWeight:bias:initState:initCell:mask:peephole:descriptor:name:
.
- Parameters:
- source: A tensor containing the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,4H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,8H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,4H,H] and otherwise it is [4H,H]. - sourceGradient: The input gradient, that is the gradient of a tensor with respect to the first output of the forward pass.
- zState: The third output of
MPSGraph/LSTMWithSourceTensor:recurrentWeight:inputWeight:bias:initState:initCell:descriptor:name:
withdescriptor.training = YES
. - cellOutputFwd: The second output of
MPSGraph/LSTMWithSourceTensor:recurrentWeight:inputWeight:bias:initState:initCell:descriptor:name:
withdescriptor.training = YES
ordescriptor.produceCell = YES
. - stateGradient: The input gradient for state coming from the future timestep - optional, if missing the operation assumes zeroes.
- cellGradient: Input gradient for cell coming from the future timestep - optional, if missing the operation assumes zeroes.
- inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [8H,I] and otherwise it is [4H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [8H] and otherwise it is [4H]. - initState: The initial internal state of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - initCell: The initial internal cell of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - mask: A tensor containing the mask
m
- optional, if missing the operation assumes ones. Useful for dropout. - peephole: A tensor containing the peephole vector
v
- optional, if missing the operation assumes zeroes. Shape is [4H], ie. a vector for each gate, or [2,4H] for bidirectional. - descriptor: A descriptor that defines the parameters for the LSTM operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array containing gradients for each input tensor, except forsourceGradient
andmask
. In case an input is nil, no gradient will be returned for it. The order of the gradients will be: forsource
, forrecurrentWeight
, forinputWeight
, forbias
, forpeephole
, forinitState
and forinitCell
.
Sourcepub unsafe fn LSTMGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_cellOutputFwd_inputWeight_bias_initState_initCell_mask_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
source_gradient: &MPSGraphTensor,
z_state: &MPSGraphTensor,
cell_output_fwd: &MPSGraphTensor,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
init_state: Option<&MPSGraphTensor>,
init_cell: Option<&MPSGraphTensor>,
mask: Option<&MPSGraphTensor>,
descriptor: &MPSGraphLSTMDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn LSTMGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_cellOutputFwd_inputWeight_bias_initState_initCell_mask_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, source_gradient: &MPSGraphTensor, z_state: &MPSGraphTensor, cell_output_fwd: &MPSGraphTensor, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, init_state: Option<&MPSGraphTensor>, init_cell: Option<&MPSGraphTensor>, mask: Option<&MPSGraphTensor>, descriptor: &MPSGraphLSTMDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates an LSTM gradient operation and returns the gradient tensor values.
For details of this operation and parameters, refer to documentation of
MPSGraph/LSTMWithSourceTensor:recurrentWeight:inputWeight:bias:initState:initCell:mask:peephole:descriptor:name:
.
- Parameters:
- source: A tensor containing the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,4H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,8H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,4H,H] and otherwise it is [4H,H]. - sourceGradient: The input gradient, that is the gradient of a tensor with respect to the first output of the forward pass.
- zState: The third output of
MPSGraph/LSTMWithSourceTensor:recurrentWeight:inputWeight:bias:initState:initCell:descriptor:name:
withdescriptor.training = YES
. - cellOutputFwd: The second output of
MPSGraph/LSTMWithSourceTensor:recurrentWeight:inputWeight:bias:initState:initCell:descriptor:name:
withdescriptor.training = YES
ordescriptor.produceCell = YES
. - inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [8H,I] and otherwise it is [4H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [8H] and otherwise it is [4H]. - initState: The initial internal state of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - initCell: The initial internal cell of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - mask: A tensor containing the mask
m
- optional, if missing the operation assumes ones. Useful for dropout. - descriptor: A descriptor that defines the parameters for the LSTM operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array containing gradients for each input tensor, except forsourceGradient
andmask
. In case an input is nil, no gradient will be returned for it. The order of the gradients will be: forsource
, forrecurrentWeight
, forinputWeight
, forbias
, forpeephole
, forinitState
and forinitCell
.
Sourcepub unsafe fn LSTMGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_cellOutputFwd_inputWeight_bias_initState_initCell_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
source_gradient: &MPSGraphTensor,
z_state: &MPSGraphTensor,
cell_output_fwd: &MPSGraphTensor,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
init_state: Option<&MPSGraphTensor>,
init_cell: Option<&MPSGraphTensor>,
descriptor: &MPSGraphLSTMDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn LSTMGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_cellOutputFwd_inputWeight_bias_initState_initCell_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, source_gradient: &MPSGraphTensor, z_state: &MPSGraphTensor, cell_output_fwd: &MPSGraphTensor, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, init_state: Option<&MPSGraphTensor>, init_cell: Option<&MPSGraphTensor>, descriptor: &MPSGraphLSTMDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates an LSTM gradient operation and returns the gradient tensor values.
For details of this operation and parameters, refer to documentation of
MPSGraph/LSTMWithSourceTensor:recurrentWeight:inputWeight:bias:initState:initCell:mask:peephole:descriptor:name:
.
- Parameters:
- source: A tensor containing the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,4H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,8H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,4H,H] and otherwise it is [4H,H]. - sourceGradient: The input gradient, that is the gradient of a tensor with respect to the first output of the forward pass.
- zState: The third output of
MPSGraph/LSTMWithSourceTensor:recurrentWeight:inputWeight:bias:initState:initCell:descriptor:name:
withdescriptor.training = YES
. - cellOutputFwd: The second output of
MPSGraph/LSTMWithSourceTensor:recurrentWeight:inputWeight:bias:initState:initCell:descriptor:name:
withdescriptor.training = YES
ordescriptor.produceCell = YES
. - inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [8H,I] and otherwise it is [4H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [8H] and otherwise it is [4H]. - initState: The initial internal state of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - initCell: The initial internal cell of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - descriptor: A descriptor that defines the parameters for the LSTM operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array containing gradients for each input tensor, except forsourceGradient
andmask
. In case an input is nil, no gradient will be returned for it. The order of the gradients will be: forsource
, forrecurrentWeight
, forinputWeight
, forbias
, forinitState
and forinitCell
.
Sourcepub unsafe fn LSTMGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_cellOutputFwd_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
source_gradient: &MPSGraphTensor,
z_state: &MPSGraphTensor,
cell_output_fwd: &MPSGraphTensor,
descriptor: &MPSGraphLSTMDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn LSTMGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_cellOutputFwd_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, source_gradient: &MPSGraphTensor, z_state: &MPSGraphTensor, cell_output_fwd: &MPSGraphTensor, descriptor: &MPSGraphLSTMDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates an LSTM gradient operation and returns the gradient tensor values.
For details of this operation and parameters, refer to documentation of
MPSGraph/LSTMWithSourceTensor:recurrentWeight:inputWeight:bias:initState:initCell:mask:peephole:descriptor:name:
.
- Parameters:
- source: A tensor containing the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,4H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,8H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,4H,H] and otherwise it is [4H,H]. - sourceGradient: The input gradient, that is the gradient of a tensor with respect to the first output of the forward pass.
- zState: The third output of
MPSGraph/LSTMWithSourceTensor:recurrentWeight:inputWeight:bias:initState:initCell:descriptor:name:
withdescriptor.training = YES
. - cellOutputFwd: The second output of
MPSGraph/LSTMWithSourceTensor:recurrentWeight:inputWeight:bias:initState:initCell:descriptor:name:
withdescriptor.training = YES
ordescriptor.produceCell = YES
. - descriptor: A descriptor that defines the parameters for the LSTM operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array containing gradients for each input tensor, except forsourceGradient
andmask
. In case an input is nil, no gradient will be returned for it. The order of the gradients will be: forsource
, forrecurrentWeight
, forinputWeight
, forbias
, forinitState
and forinitCell
.
Sourcepub unsafe fn GRUWithSourceTensor_recurrentWeight_inputWeight_bias_initState_mask_secondaryBias_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
init_state: Option<&MPSGraphTensor>,
mask: Option<&MPSGraphTensor>,
secondary_bias: Option<&MPSGraphTensor>,
descriptor: &MPSGraphGRUDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn GRUWithSourceTensor_recurrentWeight_inputWeight_bias_initState_mask_secondaryBias_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, init_state: Option<&MPSGraphTensor>, mask: Option<&MPSGraphTensor>, secondary_bias: Option<&MPSGraphTensor>, descriptor: &MPSGraphGRUDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates a GRU operation and returns the value and optionally the training state tensor.
This operation returns tensors h
and optionally z
that are defined recursively as follows:
for t = 0 to T-1
z[t] = fz( (h[t-1] m) R^T + x[t] W^T + b ),
r[t] = fr( (h[t-1] m) R^T + x[t] W^T + b ),
c[t] = (h[t-1] r[t] m) R^T
o[t] = fo( c[t] + x[t] W^T + b )
h[t] = z[t]h[t-1] + (1-z[t])o[t]
If resetAfter = YES
then c[t]
is replaced by
c[t] = ( (h[t-1] m) R^T + b2 ) r[t]
If flipZ = YES
then h[t]
is replaced by
h[t] = (1-z[t])h[t-1] + z[t]o[t].
W
is optional inputWeight
, R
is recurrentWeight
, b
is optional bias
, m
is optional mask
,
x[t]
is source
h[t]
is the first output, z[t]
is the second output (optional) and h[-1]
is initState
.
b2
is an optional resetBias
vector, only used when resetAfter = YES
.
See MPSGraphGRUDescriptor
for different activation
options for f()
.
- Parameters:
- source: A tensor containing the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,3H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,6H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,3H,H] and otherwise it is [3H,H]. - inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [6H,I] and otherwise it is [3H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [6H] and otherwise it is [3H]. - initState: The initial internal state of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - mask: A tensor containing the mask
m
- optional, if missing the operation assumes ones. Useful for dropout. - secondaryBias: A tensor containing the secondary bias vector
b2
- optional, if missing the operation assumes zeroes. Only used withreset_after = YES
. Shape is [H], ie. a vector for each gate, or [2H] for bidirectional. - descriptor: A descriptor that defines the parameters for the GRU operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array of size 1 or 2 depending on value ofdescriptor.training
. The layout of the state output is [T,N,H] or [T,N,2H] for bidirectional, and the layout of thetrainingState
output is [T,N,3H] or [T,N,6H] for bidirectional.
Sourcepub unsafe fn GRUWithSourceTensor_recurrentWeight_inputWeight_bias_initState_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
init_state: Option<&MPSGraphTensor>,
descriptor: &MPSGraphGRUDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn GRUWithSourceTensor_recurrentWeight_inputWeight_bias_initState_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, init_state: Option<&MPSGraphTensor>, descriptor: &MPSGraphGRUDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates a GRU operation and returns the value and optionally the training state tensor.
This operation returns tensors h
and optionally z
that are defined recursively as follows:
for t = 0 to T-1
z[t] = fz( (h[t-1] m) R^T + x[t] W^T + b ),
r[t] = fr( (h[t-1] m) R^T + x[t] W^T + b ),
c[t] = (h[t-1] r[t] m) R^T
o[t] = fo( c[t] + x[t] W^T + b )
h[t] = z[t]h[t-1] + (1-z[t])o[t]
If resetAfter = YES
then c[t]
is replaced by
c[t] = ( (h[t-1] m) R^T + b2 ) r[t]
If flipZ = YES
then h[t]
is replaced by
h[t] = (1-z[t])h[t-1] + z[t]o[t].
W
is optional inputWeight
, R
is recurrentWeight
, b
is optional bias
, m
is optional mask
,
x[t]
is source
h[t]
is the first output, z[t]
is the second output (optional) and h[-1]
is initState
.
b2
is an optional resetBias
vector, only used when resetAfter = YES
.
See MPSGraphGRUDescriptor
for different activation
options for f()
.
- Parameters:
- source: A tensor containing the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,3H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,6H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,3H,H] and otherwise it is [3H,H]. - inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [6H,I] and otherwise it is [3H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [6H] and otherwise it is [3H]. - initState: The initial internal state of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - descriptor: A descriptor that defines the parameters for the GRU operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array of size 1 or 2 depending on value ofdescriptor.training
. The layout of the state output is [T,N,H] or [T,N,2H] for bidirectional, and the layout of thetrainingState
output is [T,N,3H] or [T,N,6H] for bidirectional.
Sourcepub unsafe fn GRUWithSourceTensor_recurrentWeight_inputWeight_bias_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
descriptor: &MPSGraphGRUDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn GRUWithSourceTensor_recurrentWeight_inputWeight_bias_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, descriptor: &MPSGraphGRUDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates a GRU operation and returns the value and optionally the training state tensor.
This operation returns tensors h
and optionally z
that are defined recursively as follows:
for t = 0 to T-1
z[t] = fz( (h[t-1] m) R^T + x[t] W^T + b ),
r[t] = fr( (h[t-1] m) R^T + x[t] W^T + b ),
c[t] = (h[t-1] r[t] m) R^T
o[t] = fo( c[t] + x[t] W^T + b )
h[t] = z[t]h[t-1] + (1-z[t])o[t]
If resetAfter = YES
then c[t]
is replaced by
c[t] = ( (h[t-1] m) R^T + b2 ) r[t]
If flipZ = YES
then h[t]
is replaced by
h[t] = (1-z[t])h[t-1] + z[t]o[t].
W
is optional inputWeight
, R
is recurrentWeight
, b
is optional bias
, m
is optional mask
,
x[t]
is source
h[t]
is the first output, z[t]
is the second output (optional) and h[-1]
is initState
.
b2
is an optional resetBias
vector, only used when resetAfter = YES
.
See MPSGraphGRUDescriptor
for different activation
options for f()
.
- Parameters:
- source: A tensor containing the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,3H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,6H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,3H,H] and otherwise it is [3H,H]. - inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [6H,I] and otherwise it is [3H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [6H] and otherwise it is [3H]. - descriptor: A descriptor that defines the parameters for the GRU operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array of size 1 or 2 depending on value ofdescriptor.training
. The layout of the state output is [T,N,H] or [T,N,2H] for bidirectional, and the layout of thetrainingState
output is [T,N,3H] or [T,N,6H] for bidirectional.
Sourcepub unsafe fn GRUGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_outputFwd_stateGradient_inputWeight_bias_initState_mask_secondaryBias_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
source_gradient: &MPSGraphTensor,
z_state: &MPSGraphTensor,
output_fwd: &MPSGraphTensor,
state_gradient: Option<&MPSGraphTensor>,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
init_state: Option<&MPSGraphTensor>,
mask: Option<&MPSGraphTensor>,
secondary_bias: Option<&MPSGraphTensor>,
descriptor: &MPSGraphGRUDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn GRUGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_outputFwd_stateGradient_inputWeight_bias_initState_mask_secondaryBias_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, source_gradient: &MPSGraphTensor, z_state: &MPSGraphTensor, output_fwd: &MPSGraphTensor, state_gradient: Option<&MPSGraphTensor>, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, init_state: Option<&MPSGraphTensor>, mask: Option<&MPSGraphTensor>, secondary_bias: Option<&MPSGraphTensor>, descriptor: &MPSGraphGRUDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates a GRU gradient operation and returns the gradient tensor values.
For details of this operation and parameters, refer to documentation of
MPSGraph/GRUWithSourceTensor:recurrentWeight:inputWeight:bias:initState:mask:secondaryBias:descriptor:name:
.
- Parameters:
- source: A tensor containing the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,3H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,6H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,3H,H] and otherwise it is [3H,H]. - sourceGradient: The input gradient, that is the gradient of a tensor with respect to the first output of the forward pass.
- zState: The second output of
MPSGraph/GRUWithSourceTensor:recurrentWeight:inputWeight:bias:initState:descriptor:name:
withdescriptor.training = YES
. - outputFwd: The first output of
MPSGraph/GRUWithSourceTensor:recurrentWeight:inputWeight:bias:initState:descriptor:name:
withdescriptor.training = YES
. - stateGradient: The input gradient for state coming from the future timestep - optional, if missing the operation assumes zeroes.
- inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [6H,I] and otherwise it is [3H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [6H] and otherwise it is [3H]. - initState: The initial internal state of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - mask: A tensor containing the mask
m
- optional, if missing the operation assumes ones. Useful for dropout. - secondaryBias: A tensor containing the secondary bias vector
b2
- optional, if missing the operation assumes zeroes. Only used withreset_after = YES
. Shape is [H], ie. a vector for each gate, or [2H] for bidirectional. - descriptor: A descriptor that defines the parameters for the GRU operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array containing gradients for each input tensor, except forsourceGradient
andmask
. In case an input is nil, no gradient will be returned for it. The order of the gradients will be: forsource
, forrecurrentWeight
, forinputWeight
, forbias
, forinitState
and forsecondaryBias
.
Sourcepub unsafe fn GRUGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_outputFwd_inputWeight_bias_initState_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
source_gradient: &MPSGraphTensor,
z_state: &MPSGraphTensor,
output_fwd: &MPSGraphTensor,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
init_state: Option<&MPSGraphTensor>,
descriptor: &MPSGraphGRUDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn GRUGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_outputFwd_inputWeight_bias_initState_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, source_gradient: &MPSGraphTensor, z_state: &MPSGraphTensor, output_fwd: &MPSGraphTensor, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, init_state: Option<&MPSGraphTensor>, descriptor: &MPSGraphGRUDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates a GRU gradient operation and returns the gradient tensor values.
For details of this operation and parameters, refer to documentation of
MPSGraph/GRUWithSourceTensor:recurrentWeight:inputWeight:bias:initState:mask:secondaryBias:descriptor:name:
.
- Parameters:
- source: A tensor containing the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,3H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,6H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,3H,H] and otherwise it is [3H,H]. - sourceGradient: The input gradient, that is the gradient of a tensor with respect to the first output of the forward pass.
- zState: The second output of
MPSGraph/GRUWithSourceTensor:recurrentWeight:inputWeight:bias:initState:descriptor:name:
withdescriptor.training = YES
. - outputFwd: The first output of
MPSGraph/GRUWithSourceTensor:recurrentWeight:inputWeight:bias:initState:descriptor:name:
withdescriptor.training = YES
. - inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [6H,I] and otherwise it is [3H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [6H] and otherwise it is [3H]. - initState: The initial internal state of the LSTM
h[-1]
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [N,2H] and otherwise it is [N,H]. - descriptor: A descriptor that defines the parameters for the GRU operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array containing gradients for each input tensor, except forsourceGradient
andmask
. In case an input is nil, no gradient will be returned for it. The order of the gradients will be: forsource
, forrecurrentWeight
, forinputWeight
, forbias
and forinitState
.
Sourcepub unsafe fn GRUGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_outputFwd_inputWeight_bias_descriptor_name(
&self,
source: &MPSGraphTensor,
recurrent_weight: &MPSGraphTensor,
source_gradient: &MPSGraphTensor,
z_state: &MPSGraphTensor,
output_fwd: &MPSGraphTensor,
input_weight: Option<&MPSGraphTensor>,
bias: Option<&MPSGraphTensor>,
descriptor: &MPSGraphGRUDescriptor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRNNOps
and MPSGraphTensor
only.
pub unsafe fn GRUGradientsWithSourceTensor_recurrentWeight_sourceGradient_zState_outputFwd_inputWeight_bias_descriptor_name( &self, source: &MPSGraphTensor, recurrent_weight: &MPSGraphTensor, source_gradient: &MPSGraphTensor, z_state: &MPSGraphTensor, output_fwd: &MPSGraphTensor, input_weight: Option<&MPSGraphTensor>, bias: Option<&MPSGraphTensor>, descriptor: &MPSGraphGRUDescriptor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRNNOps
and MPSGraphTensor
only.Creates a GRU gradient operation and returns the gradient tensor values.
For details of this operation and parameters, refer to documentation of
MPSGraph/GRUWithSourceTensor:recurrentWeight:inputWeight:bias:initState:mask:secondaryBias:descriptor:name:
.
- Parameters:
- source: A tensor containing the source data
x[t]
with the data layout [T,N,I]. In caseinputWeight = nil
andbidirectional = NO
then the layout is [T,N,3H] and forinputWeight = nil
andbidirectional = YES
the layout is [T,N,6H]. - recurrentWeight: A tensor containing the recurrent weights
R
. Forbidirectional
the layout is [2,3H,H] and otherwise it is [3H,H]. - sourceGradient: The input gradient, that is the gradient of a tensor with respect to the first output of the forward pass.
- zState: The second output of
MPSGraph/GRUWithSourceTensor:recurrentWeight:inputWeight:bias:initState:descriptor:name:
withdescriptor.training = YES
. - outputFwd: The first output of
MPSGraph/GRUWithSourceTensor:recurrentWeight:inputWeight:bias:initState:descriptor:name:
withdescriptor.training = YES
. - inputWeight: A tensor containing the input weights matrix
W
- optional, if missing the operation assumes a diagonal unit-matrix. Forbidirectional
the layout is [6H,I] and otherwise it is [3H,I]. - bias: A tensor containing the bias
b
- optional, if missing the operation assumes zeroes. Forbidirectional
the layout is [6H] and otherwise it is [3H]. - descriptor: A descriptor that defines the parameters for the GRU operation.
- name: The name for the operation.
- Returns: A valid
MPSGraphTensor
array containing gradients for each input tensor, except forsourceGradient
andmask
. In case an input is nil, no gradient will be returned for it. The order of the gradients will be: forsource
, forrecurrentWeight
, forinputWeight
and forbias
.
Source§impl MPSGraph
MPSGraphRandomOps.
impl MPSGraph
MPSGraphRandomOps.
Sourcepub unsafe fn randomPhiloxStateTensorWithSeed_name(
&self,
seed: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
only.
pub unsafe fn randomPhiloxStateTensorWithSeed_name( &self, seed: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphRandomOps
and MPSGraphTensor
only.Creates a tensor representing state using the Philox algorithm with given counter and key values.
Generates random numbers using the Philox counter-based algorithm, for further details see: John K. Salmon, Mark A. Moraes, Ron O. Dror, and David E. Shaw. Parallel Random Numbers: As Easy as 1, 2, 3. A stateTensor generated with this API can be used in MPSGraph Random APIs which accept a stateTensor. The updated stateTensor is returned alongside the random values, and can be fed to the following random layer. In most use cases, a stateTensor should only need to be initialized once at the start of the graph. A stateTensor can be set as a target tensor of an MPSGraph execution to obtain a stateTensor serialized as an NDArray. This can be used as input to a placeholder in the graph to avoid ever needing to have a state intilization layer in an MPSGraph. This can allow for a continued stream through multiple executions of a single MPSGraph by having the final stateTensor as a target tensor passed into the following MPSGraph execution as a placeholder input. This may be helpful for training graphs in particular.
MPSGraph *graph = [MPSGraph new];
MPSGraphTensor *stateTensor = [graph randomPhiloxStateTensorWithSeed: seed name: nil];
NSArray
<MPSGraphTensor
*> *resultTensors0 = [graph randomUniformTensorWithShape:
- Parameters:
- seed: Initial counter and key values will be generated using seed.
- name: Name for the operation
- Returns: An MPSGraphTensor representing a random state, to be passed as an input to a random op.
Sourcepub unsafe fn randomPhiloxStateTensorWithCounterLow_counterHigh_key_name(
&self,
counter_low: NSUInteger,
counter_high: NSUInteger,
key: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
only.
pub unsafe fn randomPhiloxStateTensorWithCounterLow_counterHigh_key_name( &self, counter_low: NSUInteger, counter_high: NSUInteger, key: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphRandomOps
and MPSGraphTensor
only.Creates a tensor representing state using the Philox algorithm with given counter and key values.
See randomPhiloxStateTensorWithSeed.
- Parameters:
- counterLow: The value to initilaize lower 64 bits of counter to. Philox utilizes a 128 bit counter
- counterHigh: The value to initilaize upper 64 bits of counter to. Philox utilizes a 128 bit counter
- key: The value to initialize the key to in Philox algorithm.
- name: Name for the operation
- Returns: An MPSGraphTensor representing a random state, to be passed as an input to a random op.
Sourcepub unsafe fn randomTensorWithShape_descriptor_name(
&self,
shape: &MPSShape,
descriptor: &MPSGraphRandomOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn randomTensorWithShape_descriptor_name( &self, shape: &MPSShape, descriptor: &MPSGraphRandomOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphRandomOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a Random op of type matching distribution in descriptor and returns random values.
Returns a tensor of provided shape of random values in the distribution specified. Uses a random seed value to initalize state. No state is preserved, and subsequent calls are not guaranteed to result in a unique stream of random values.
- Parameters:
- shape: The shape of the tensor generated
- descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
- name: The name for the operation.
- Returns: An MPSGraphTensor of shape containing random values in the defined range.
Sourcepub unsafe fn randomTensorWithShapeTensor_descriptor_name(
&self,
shape_tensor: &MPSGraphTensor,
descriptor: &MPSGraphRandomOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
only.
pub unsafe fn randomTensorWithShapeTensor_descriptor_name( &self, shape_tensor: &MPSGraphTensor, descriptor: &MPSGraphRandomOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphRandomOps
and MPSGraphTensor
only.Creates a Random op of type matching distribution in descriptor and returns random values.
Returns a tensor of provided shape of random values in the distribution specified. Uses a random seed value to initalize state. No state is preserved, and subsequent calls are not guaranteed to result in a unique stream of random values.
- Parameters:
- shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
- descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
- name: The name for the operation.
- Returns: An MPSGraphTensor of shape containing random values in the defined range.
Sourcepub unsafe fn randomTensorWithShape_descriptor_seed_name(
&self,
shape: &MPSShape,
descriptor: &MPSGraphRandomOpDescriptor,
seed: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn randomTensorWithShape_descriptor_seed_name( &self, shape: &MPSShape, descriptor: &MPSGraphRandomOpDescriptor, seed: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphRandomOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a Random op of type matching distribution in descriptor and returns random values.
Returns a tensor of provided shape of random values in the distribution specified. Uses the provided seed value to initalize state. No state is preserved, and all calls with equal seed yield an identical stream of random values.
- Parameters:
- shape: The shape of the tensor generated
- descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
- seed: The seed to use to initialize state. All calls with equal seed yield an identical stream of random values.
- name: The name for the operation.
- Returns: An MPSGraphTensor of shape containing random values in the defined range.
Sourcepub unsafe fn randomTensorWithShapeTensor_descriptor_seed_name(
&self,
shape_tensor: &MPSGraphTensor,
descriptor: &MPSGraphRandomOpDescriptor,
seed: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
only.
pub unsafe fn randomTensorWithShapeTensor_descriptor_seed_name( &self, shape_tensor: &MPSGraphTensor, descriptor: &MPSGraphRandomOpDescriptor, seed: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphRandomOps
and MPSGraphTensor
only.Creates a Random op of type matching distribution in descriptor and returns random values.
Returns a tensor of provided shape of random values in the distribution specified. Uses the provided seed value to initalize state. No state is preserved, and all calls with equal seed yield an identical stream of random values.
- Parameters:
- shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
- descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
- seed: The seed to use to initialize state. All calls with equal seed yield an identical stream of random values.
- name: The name for the operation.
- Returns: An MPSGraphTensor of shape containing random values in the defined range.
Sourcepub unsafe fn randomTensorWithShape_descriptor_stateTensor_name(
&self,
shape: &MPSShape,
descriptor: &MPSGraphRandomOpDescriptor,
state: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn randomTensorWithShape_descriptor_stateTensor_name( &self, shape: &MPSShape, descriptor: &MPSGraphRandomOpDescriptor, state: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRandomOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a Random op of type matching distribution in descriptor, and returns random values and updated state.
Returns an array of 2 tensors, where the first is of provided shape of random values in the distribution specified, and the second is the updated state tensor. Uses the provided state to define a stream of random values. No state is preserved, and all calls with equal state yield an identical stream of random values. The initial stateTensor provided should be created using the MPSGraph randomPhiloxStateTensor APIs. The resulting stateTensor from this op can be passed as an argument to the following random calls to continue sampling from the stream.
- Parameters:
- shape: The shape of the tensor generated
- descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
- state: The state to define a stream of random values. All calls with equal state yield an identical stream of random values.
- name: The name for the operation.
- Returns: An array of MPSGraphTensor of size 2. The first MPSGraphTensor is of shape containing random values in the defined range. The second MPSGraphTensor is the updated state tensor.
Sourcepub unsafe fn randomTensorWithShapeTensor_descriptor_stateTensor_name(
&self,
shape_tensor: &MPSGraphTensor,
descriptor: &MPSGraphRandomOpDescriptor,
state: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
only.
pub unsafe fn randomTensorWithShapeTensor_descriptor_stateTensor_name( &self, shape_tensor: &MPSGraphTensor, descriptor: &MPSGraphRandomOpDescriptor, state: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRandomOps
and MPSGraphTensor
only.Creates a Random op of type matching distribution in descriptor, and returns random values and updated state.
Returns an array of 2 tensors, where the first is of provided shape of random values in the distribution specified, and the second is the updated state tensor. Uses the provided state to define a stream of random values. No state is preserved, and all calls with equal state yield an identical stream of random values. The initial stateTensor provided should be created using the MPSGraph randomPhiloxStateTensor APIs. The resulting stateTensor from this op can be passed as an argument to the following random calls to continue sampling from the stream.
- Parameters:
- shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated.
- descriptor: The descriptor of the distribution. See MPSGraphRandomOpDescriptor.
- state: The state to define a stream of random values. All calls with equal state yield an identical stream of random values.
- name: The name for the operation.
- Returns: An array of MPSGraphTensor of size 2. The first MPSGraphTensor is of shape containing random values in the defined range. The second MPSGraphTensor is the updated state tensor.
Sourcepub unsafe fn randomUniformTensorWithShape_name(
&self,
shape: &MPSShape,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn randomUniformTensorWithShape_name( &self, shape: &MPSShape, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphRandomOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a RandomUniform operation and returns random uniform values
Returns a tensor of provided shape of random uniform values in the range [0.0, 1.0). Uses a random seed value to initalize state. No state is preserved, and subsequent calls are not guaranteed to result in a unique stream of random values.
- Parameters:
- shape: The shape of the tensor generated
- name: The name for the operation.
- Returns: An MPSGraphTensor of shape containing random values in the defined range.
Sourcepub unsafe fn randomUniformTensorWithShapeTensor_name(
&self,
shape_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
only.
pub unsafe fn randomUniformTensorWithShapeTensor_name( &self, shape_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphRandomOps
and MPSGraphTensor
only.Creates a RandomUniform operation and returns random uniform values
Returns a tensor of provided shape of random uniform values in the range [0.0, 1.0). Uses a random seed value to initalize state. No state is preserved, and subsequent calls are not guaranteed to result in a unique stream of random values.
- Parameters:
- shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
- name: The name for the operation.
- Returns: An MPSGraphTensor of shape containing random values in the defined range.
Sourcepub unsafe fn randomUniformTensorWithShape_seed_name(
&self,
shape: &MPSShape,
seed: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn randomUniformTensorWithShape_seed_name( &self, shape: &MPSShape, seed: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphRandomOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a RandomUniform operation and returns random uniform values
Returns a tensor of provided shape of random uniform values in the range [0.0, 1.0). Uses the provided seed value to initalize state. No state is preserved, and all calls with equal seed yield an identical stream of random values.
- Parameters:
- shape: The shape of the tensor generated
- seed: The seed to use to initialize state. All calls with equal seed yield an identical stream of random values.
- name: The name for the operation.
- Returns: An MPSGraphTensor of shape containing random values in the defined range.
Sourcepub unsafe fn randomUniformTensorWithShapeTensor_seed_name(
&self,
shape_tensor: &MPSGraphTensor,
seed: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
only.
pub unsafe fn randomUniformTensorWithShapeTensor_seed_name( &self, shape_tensor: &MPSGraphTensor, seed: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphRandomOps
and MPSGraphTensor
only.Creates a RandomUniform operation and returns random uniform values
Returns a tensor of provided shape of random uniform values in the range [0.0, 1.0). Uses the provided seed value to initalize state. No state is preserved, and all calls with equal seed yield an identical stream of random values.
- Parameters:
- shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
- seed: The seed to use to initialize state. All calls with equal seed yield an identical stream of random values.
- name: The name for the operation.
- Returns: An MPSGraphTensor of shape containing random values in the defined range.
Sourcepub unsafe fn randomUniformTensorWithShape_stateTensor_name(
&self,
shape: &MPSShape,
state: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn randomUniformTensorWithShape_stateTensor_name( &self, shape: &MPSShape, state: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRandomOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a RandomUniform operation and returns random uniform values and updated state
Returns an array of 2 tensors, where the first is a tensor of provided shape of random uniform values in the range [0.0, 1.0), and the second is the updated state tensor. The provided state is used to define a stream of random values. No state is preserved, and all calls with equal state yield an identical stream of random values. The initial stateTensor provided should be created using the MPSGraph randomPhiloxStateTensor APIs. The resulting stateTensor from this op can be passed as an argument to the following random calls to continue sampling from the stream.
- Parameters:
- shape: The shape of the tensor generated
- state: The state to define a stream of random values. All calls with equal state yield an identical stream of random values.
- name: The name for the operation.
- Returns: An array of MPSGraphTensor of size 2. The first MPSGraphTensor is of shape containing random values in the defined range. The second MPSGraphTensor is the updated state tensor.
Sourcepub unsafe fn randomUniformTensorWithShapeTensor_stateTensor_name(
&self,
shape_tensor: &MPSGraphTensor,
state: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
only.
pub unsafe fn randomUniformTensorWithShapeTensor_stateTensor_name( &self, shape_tensor: &MPSGraphTensor, state: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphRandomOps
and MPSGraphTensor
only.Creates a RandomUniform operation and returns random uniform values and updated state
Returns an array of 2 tensors, where the first is a tensor of provided shape of random uniform values in the range [0.0, 1.0), and the second is the updated state tensor. The provided state is used to define a stream of random values. No state is preserved, and all calls with equal state yield an identical stream of random values. The initial stateTensor provided should be created using the MPSGraph randomPhiloxStateTensor APIs. The resulting stateTensor from this op can be passed as an argument to the following random calls to continue sampling from the stream.
- Parameters:
- shapeTensor: 1D Int32 or Int64 tensor. The shape of the tensor generated
- state: The state to define a stream of random values. All calls with equal state yield an identical stream of random values.
- name: The name for the operation.
- Returns: An array of MPSGraphTensor of size 2. The first MPSGraphTensor is of shape containing random values in the defined range. The second MPSGraphTensor is the updated state tensor.
Sourcepub unsafe fn dropoutTensor_rate_name(
&self,
tensor: &MPSGraphTensor,
rate: c_double,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
only.
pub unsafe fn dropoutTensor_rate_name( &self, tensor: &MPSGraphTensor, rate: c_double, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphRandomOps
and MPSGraphTensor
only.Creates a dropout operation and returns the result
Removes values in the tensor
with a percentage chance equal to rate
. Removed values are set to 0
- Parameters:
- tensor: Input tensor
- rate: The rate of values to be set to 0
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn dropoutTensor_rateTensor_name(
&self,
tensor: &MPSGraphTensor,
rate: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphRandomOps
and MPSGraphTensor
only.
pub unsafe fn dropoutTensor_rateTensor_name( &self, tensor: &MPSGraphTensor, rate: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphRandomOps
and MPSGraphTensor
only.Creates a dropout operation and returns the result
Removes values in the tensor
with a percentage chance equal to rate
. Removed values are set to 0
- Parameters:
- tensor: Input tensor
- rate: The rate of values to be set to 0
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Source§impl MPSGraph
MPSGraphReductionOps.
impl MPSGraph
MPSGraphReductionOps.
Sourcepub unsafe fn reductionSumWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionSumWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction sum operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axis: axis of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionSumWithTensor_axes_name(
&self,
tensor: &MPSGraphTensor,
axes: Option<&NSArray<NSNumber>>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionSumWithTensor_axes_name( &self, tensor: &MPSGraphTensor, axes: Option<&NSArray<NSNumber>>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction sum operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axes: axes of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionMaximumWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionMaximumWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction max operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axis: axis of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionMaximumWithTensor_axes_name(
&self,
tensor: &MPSGraphTensor,
axes: Option<&NSArray<NSNumber>>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionMaximumWithTensor_axes_name( &self, tensor: &MPSGraphTensor, axes: Option<&NSArray<NSNumber>>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction max operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axes: axes of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionMinimumWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionMinimumWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction minimum operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axis: axis of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionMinimumWithTensor_axes_name(
&self,
tensor: &MPSGraphTensor,
axes: Option<&NSArray<NSNumber>>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionMinimumWithTensor_axes_name( &self, tensor: &MPSGraphTensor, axes: Option<&NSArray<NSNumber>>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction min operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axes: axes of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionMaximumPropagateNaNWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionMaximumPropagateNaNWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction max propagate NaN operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axis: axis of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionMaximumPropagateNaNWithTensor_axes_name(
&self,
tensor: &MPSGraphTensor,
axes: Option<&NSArray<NSNumber>>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionMaximumPropagateNaNWithTensor_axes_name( &self, tensor: &MPSGraphTensor, axes: Option<&NSArray<NSNumber>>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction max propagate NaN operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axes: axes of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionMinimumPropagateNaNWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionMinimumPropagateNaNWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction min propagate NaN operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axis: axis of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionMinimumPropagateNaNWithTensor_axes_name(
&self,
tensor: &MPSGraphTensor,
axes: Option<&NSArray<NSNumber>>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionMinimumPropagateNaNWithTensor_axes_name( &self, tensor: &MPSGraphTensor, axes: Option<&NSArray<NSNumber>>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction min propagate NaN operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axes: axes of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionProductWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionProductWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction product operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axis: axis of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionProductWithTensor_axes_name(
&self,
tensor: &MPSGraphTensor,
axes: Option<&NSArray<NSNumber>>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionProductWithTensor_axes_name( &self, tensor: &MPSGraphTensor, axes: Option<&NSArray<NSNumber>>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction product operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axes: axes of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionArgMaximumWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionArgMaximumWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction argMax operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axis: axis of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionArgMinimumWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionArgMinimumWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction argMin operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axis: axis of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionAndWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionAndWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction and operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axis: axis of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionAndWithTensor_axes_name(
&self,
tensor: &MPSGraphTensor,
axes: Option<&NSArray<NSNumber>>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionAndWithTensor_axes_name( &self, tensor: &MPSGraphTensor, axes: Option<&NSArray<NSNumber>>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction and operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axes: axes of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionOrWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionOrWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction or operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axis: axis of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reductionOrWithTensor_axes_name(
&self,
tensor: &MPSGraphTensor,
axes: Option<&NSArray<NSNumber>>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphReductionOps
and MPSGraphTensor
only.
pub unsafe fn reductionOrWithTensor_axes_name( &self, tensor: &MPSGraphTensor, axes: Option<&NSArray<NSNumber>>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphReductionOps
and MPSGraphTensor
only.Creates a reduction or operation and returns the result tensor.
- Parameters:
- tensor: input tensor
- axes: axes of reduction
- name: name for the operation
- Returns: A valid MPSGraphTensor object.
Source§impl MPSGraph
MPSGraphResizeOps.
impl MPSGraph
MPSGraphResizeOps.
Sourcepub unsafe fn resizeTensor_size_mode_centerResult_alignCorners_layout_name(
&self,
images_tensor: &MPSGraphTensor,
size: &MPSShape,
mode: MPSGraphResizeMode,
center_result: bool,
align_corners: bool,
layout: MPSGraphTensorNamedDataLayout,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn resizeTensor_size_mode_centerResult_alignCorners_layout_name( &self, images_tensor: &MPSGraphTensor, size: &MPSShape, mode: MPSGraphResizeMode, center_result: bool, align_corners: bool, layout: MPSGraphTensorNamedDataLayout, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a Resize operation and returns the result tensor.
Resamples input images to given size. Result images will be distorted if size is of different aspect ratio. Resize supports the following modes: Nearest Neighbor - values are interpolated using the closest neighbor pixel Bilinear - values are computed using bilinear interpolation of 4 neighboring pixels Destination indices are computed using direct index scaling by default, with no offset added. If the centerResult parameter is true, the destination indices will be scaled and shifted to be centered on the input image. If the alignCorners parameter is true, the corners of the result images will match the input images. Scaling will be modified to a factor of (size - 1) / (inputSize - 1). When alignCorners is true, the centerResult parameter does nothing. In order to achieve the same behavior as OpenCV’s resize and TensorFlowV2’s resize,
centerResult = YES;
alginCorners = NO;
To achieve the same behavior as TensorFlowV1 resize
centerResult = NO;
- Parameters:
- imagesTensor: Tensor containing input images.
- size: A 2-element shape as [newHeight, newWidth]
- mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
- centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
- alignCorners: When YES, the result image will have the same value as the input image in the corners
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeTensor_sizeTensor_mode_centerResult_alignCorners_layout_name(
&self,
images_tensor: &MPSGraphTensor,
size: &MPSGraphTensor,
mode: MPSGraphResizeMode,
center_result: bool,
align_corners: bool,
layout: MPSGraphTensorNamedDataLayout,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeTensor_sizeTensor_mode_centerResult_alignCorners_layout_name( &self, images_tensor: &MPSGraphTensor, size: &MPSGraphTensor, mode: MPSGraphResizeMode, center_result: bool, align_corners: bool, layout: MPSGraphTensorNamedDataLayout, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize operation and returns the result tensor.
Resamples input images to given size. Result images will be distorted if size is of different aspect ratio. Resize supports the following modes: Nearest Neighbor - values are interpolated using the closest neighbor pixel Bilinear - values are computed using bilinear interpolation of 4 neighboring pixels Destination indices are computed using direct index scaling by default, with no offset added. If the centerResult parameter is true, the destination indices will be scaled and shifted to be centered on the input image. If the alignCorners parameter is true, the corners of the result images will match the input images. Scaling will be modified to a factor of (size - 1) / (inputSize - 1). When alignCorners is true, the centerResult parameter does nothing. In order to achieve the same behavior as OpenCV’s resize and TensorFlowV2’s resize,
centerResult = YES;
alginCorners = NO;
To achieve the same behavior as TensorFlowV1 resize
centerResult = NO;
- Parameters:
- imagesTensor: Tensor containing input images.
- size: 1D Int32 or Int64 tensor. A 2-element shape as [newHeight, newWidth]
- mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
- centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
- alignCorners: When YES, the result image will have the same value as the input image in the corners
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeTensor_sizeTensor_mode_centerResult_alignCorners_name(
&self,
images_tensor: &MPSGraphTensor,
size: &MPSGraphTensor,
mode: MPSGraphResizeMode,
center_result: bool,
align_corners: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeTensor_sizeTensor_mode_centerResult_alignCorners_name( &self, images_tensor: &MPSGraphTensor, size: &MPSGraphTensor, mode: MPSGraphResizeMode, center_result: bool, align_corners: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize operation and returns the result tensor.
Resamples input images to given size. Result images will be distorted if size is of different aspect ratio. Resize supports the following modes: Nearest Neighbor - values are interpolated using the closest neighbor pixel Bilinear - values are computed using bilinear interpolation of 4 neighboring pixels Destination indices are computed using direct index scaling by default, with no offset added. If the centerResult parameter is true, the destination indices will be scaled and shifted to be centered on the input image. If the alignCorners parameter is true, the corners of the result images will match the input images. Scaling will be modified to a factor of (size - 1) / (inputSize - 1). When alignCorners is true, the centerResult parameter does nothing. In order to achieve the same behavior as OpenCV’s resize and TensorFlowV2’s resize,
centerResult = YES;
alginCorners = NO;
To achieve the same behavior as TensorFlowV1 resize
centerResult = NO;
- Parameters:
- imagesTensor: Tensor containing input images.
- size: The target size of the result tensor. 1D Int32 or Int64 tensor of size equal to rank of input.
- mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
- centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
- alignCorners: When YES, the result image will have the same value as the input image in the corners
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeNearestWithTensor_sizeTensor_nearestRoundingMode_centerResult_alignCorners_layout_name(
&self,
images_tensor: &MPSGraphTensor,
size: &MPSGraphTensor,
nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
center_result: bool,
align_corners: bool,
layout: MPSGraphTensorNamedDataLayout,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeNearestWithTensor_sizeTensor_nearestRoundingMode_centerResult_alignCorners_layout_name( &self, images_tensor: &MPSGraphTensor, size: &MPSGraphTensor, nearest_rounding_mode: MPSGraphResizeNearestRoundingMode, center_result: bool, align_corners: bool, layout: MPSGraphTensorNamedDataLayout, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Resamples input images to given size using nearest neighbor sampling.
This API allows for the rounding mode to be specified. Resamples input images to given size. Result images will be distorted if size is of different aspect ratio. Resize supports the following modes: Nearest Neighbor - values are interpolated using the closest neighbor pixel Bilinear - values are computed using bilinear interpolation of 4 neighboring pixels Destination indices are computed using direct index scaling by default, with no offset added. If the centerResult parameter is true, the destination indices will be scaled and shifted to be centered on the input image. If the alignCorners parameter is true, the corners of the result images will match the input images. Scaling will be modified to a factor of (size - 1) / (inputSize - 1). When alignCorners is true, the centerResult parameter does nothing. In order to achieve the same behavior as OpenCV’s resize and TensorFlowV2’s resize,
centerResult = YES;
alginCorners = NO;
To achieve the same behavior as TensorFlowV1 resize
centerResult = NO;
- Parameters:
- imagesTensor: Tensor containing input images.
- size: 1D Int32 or Int64 tensor. A 2-element shape as [newHeight, newWidth]
- nearestRoundingMode: The rounding mode to use when using nearest resampling. Default is roundPreferCeil.
- centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
- alignCorners: When YES, the result image will have the same value as the input image in the corners
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeNearestWithTensor_sizeTensor_nearestRoundingMode_centerResult_alignCorners_name(
&self,
images_tensor: &MPSGraphTensor,
size: &MPSGraphTensor,
nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
center_result: bool,
align_corners: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeNearestWithTensor_sizeTensor_nearestRoundingMode_centerResult_alignCorners_name( &self, images_tensor: &MPSGraphTensor, size: &MPSGraphTensor, nearest_rounding_mode: MPSGraphResizeNearestRoundingMode, center_result: bool, align_corners: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize operation and returns the result tensor.
Resamples input images to given size using nearest neighbor sampling. Result images will be distorted if size is of different aspect ratio. Destination indices are computed using direct index scaling by default, with no offset added. If the centerResult parameter is true, the destination indices will be scaled and shifted to be centered on the input image. If the alignCorners parameter is true, the corners of the result images will match the input images. Scaling will be modified to a factor of (size - 1) / (inputSize - 1). When alignCorners is true, the centerResult parameter does nothing. In order to achieve the same behavior as OpenCV’s resize and TensorFlowV2’s resize,
centerResult = YES;
alginCorners = NO;
To achieve the same behavior as TensorFlowV1 resize
centerResult = NO;
- Parameters:
- imagesTensor: Tensor containing input images.
- size: The target size of the result tensor. 1D Int32 or Int64 tensor of size equal to rank of input.
- nearestRoundingMode: The rounding mode to use when using nearest resampling. Default is roundPreferCeil.
- centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
- alignCorners: When YES, the result image will have the same value as the input image in the corners
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeBilinearWithTensor_sizeTensor_centerResult_alignCorners_layout_name(
&self,
images_tensor: &MPSGraphTensor,
size: &MPSGraphTensor,
center_result: bool,
align_corners: bool,
layout: MPSGraphTensorNamedDataLayout,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeBilinearWithTensor_sizeTensor_centerResult_alignCorners_layout_name( &self, images_tensor: &MPSGraphTensor, size: &MPSGraphTensor, center_result: bool, align_corners: bool, layout: MPSGraphTensorNamedDataLayout, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Resamples input images to given size using bilinear sampling.
Resamples input images to given size using nearest neighbor sampling. Result images will be distorted if size is of different aspect ratio. Destination indices are computed using direct index scaling by default, with no offset added. If the centerResult parameter is true, the destination indices will be scaled and shifted to be centered on the input image. If the alignCorners parameter is true, the corners of the result images will match the input images. Scaling will be modified to a factor of (size - 1) / (inputSize - 1). When alignCorners is true, the centerResult parameter does nothing. In order to achieve the same behavior as OpenCV’s resize and TensorFlowV2’s resize,
centerResult = YES;
alginCorners = NO;
To achieve the same behavior as TensorFlowV1 resize
centerResult = NO;
- Parameters:
- imagesTensor: Tensor containing input images.
- size: 1D Int32 or Int64 tensor. A 2-element shape as [newHeight, newWidth]
- centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
- alignCorners: When YES, the result image will have the same value as the input image in the corners
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeBilinearWithTensor_sizeTensor_centerResult_alignCorners_name(
&self,
images_tensor: &MPSGraphTensor,
size: &MPSGraphTensor,
center_result: bool,
align_corners: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeBilinearWithTensor_sizeTensor_centerResult_alignCorners_name( &self, images_tensor: &MPSGraphTensor, size: &MPSGraphTensor, center_result: bool, align_corners: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize operation and returns the result tensor.
Resamples input images to given size using bilinear sampling. Result images will be distorted if size is of different aspect ratio. Destination indices are computed using direct index scaling by default, with no offset added. If the centerResult parameter is true, the destination indices will be scaled and shifted to be centered on the input image. If the alignCorners parameter is true, the corners of the result images will match the input images. Scaling will be modified to a factor of (size - 1) / (inputSize - 1). When alignCorners is true, the centerResult parameter does nothing. In order to achieve the same behavior as OpenCV’s resize and TensorFlowV2’s resize,
centerResult = YES;
alginCorners = NO;
To achieve the same behavior as TensorFlowV1 resize
centerResult = NO;
- Parameters:
- imagesTensor: Tensor containing input images.
- size: The target size of the result tensor. 1D Int32 or Int64 tensor of size equal to rank of input.
- centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
- alignCorners: When YES, the result image will have the same value as the input image in the corners
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeTensor_sizeTensor_scaleOffsetTensor_mode_layout_name(
&self,
images_tensor: &MPSGraphTensor,
size: &MPSGraphTensor,
scale_offset: &MPSGraphTensor,
mode: MPSGraphResizeMode,
layout: MPSGraphTensorNamedDataLayout,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeTensor_sizeTensor_scaleOffsetTensor_mode_layout_name( &self, images_tensor: &MPSGraphTensor, size: &MPSGraphTensor, scale_offset: &MPSGraphTensor, mode: MPSGraphResizeMode, layout: MPSGraphTensorNamedDataLayout, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Resamples input images to given size using the provided scale and offset. Destination indices are computed using
dst_indices = (src_indicesscale) + offset
For most use cases passing the scale and offset directly is unnecessary, and it is preferable to use the API specifying centerResult and alignCorners.
- Parameters:
- imagesTensor: Tensor containing input images.
- size: 1D Int32 or Int64 tensor. A 2-element shape as [newHeight, newWidth]
- scaleOffset: 1D float tensor. A 4-element shape as [scaleY, scaleX, offsetY, offsetX]
- mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeTensor_sizeTensor_scaleTensor_offsetTensor_mode_name(
&self,
images_tensor: &MPSGraphTensor,
size: &MPSGraphTensor,
scale: &MPSGraphTensor,
offset: &MPSGraphTensor,
mode: MPSGraphResizeMode,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeTensor_sizeTensor_scaleTensor_offsetTensor_mode_name( &self, images_tensor: &MPSGraphTensor, size: &MPSGraphTensor, scale: &MPSGraphTensor, offset: &MPSGraphTensor, mode: MPSGraphResizeMode, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize operation and returns the result tensor.
Resamples input images to given size using the provided scale and offset. Destination indices are computed using
dst_indices = (src_indices * scale) + offset
For most use cases passing the scale and offset directly is unnecessary, and it is preferable to use the API specifying centerResult and alignCorners.
- Parameters:
- imagesTensor: Tensor containing input images.
- size: The target size of the result tensor. 1D Int32 or Int64 tensor of size equal to rank of input.
- scale: 1D float tensor of size equal to rank of input.
- offset: 1D float tensor of size equal to rank of input.
- mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeNearestWithTensor_sizeTensor_scaleOffsetTensor_nearestRoundingMode_layout_name(
&self,
images_tensor: &MPSGraphTensor,
size: &MPSGraphTensor,
scale_offset: &MPSGraphTensor,
nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
layout: MPSGraphTensorNamedDataLayout,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeNearestWithTensor_sizeTensor_scaleOffsetTensor_nearestRoundingMode_layout_name( &self, images_tensor: &MPSGraphTensor, size: &MPSGraphTensor, scale_offset: &MPSGraphTensor, nearest_rounding_mode: MPSGraphResizeNearestRoundingMode, layout: MPSGraphTensorNamedDataLayout, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Resamples input images to given size using the provided scale and offset and nearest neighbor sampling See above discussion for more details.
- Parameters:
- imagesTensor: Tensor containing input images.
- size: 1D Int32 or Int64 tensor. A 2-element shape as [newHeight, newWidth]
- scaleOffset: 1D float tensor. A 4-element shape as [scaleY, scaleX, offsetY, offsetX]
- nearestRoundingMode: The rounding mode to use when using nearest resampling.
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeNearestWithTensor_sizeTensor_scaleTensor_offsetTensor_nearestRoundingMode_name(
&self,
images_tensor: &MPSGraphTensor,
size: &MPSGraphTensor,
scale: &MPSGraphTensor,
offset: &MPSGraphTensor,
nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeNearestWithTensor_sizeTensor_scaleTensor_offsetTensor_nearestRoundingMode_name( &self, images_tensor: &MPSGraphTensor, size: &MPSGraphTensor, scale: &MPSGraphTensor, offset: &MPSGraphTensor, nearest_rounding_mode: MPSGraphResizeNearestRoundingMode, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize operation and returns the result tensor.
Resamples input images to given size using the provided scale and offset and nearest neighbor sampling. Destination indices are computed using
dst_indices = (src_indices * scale) + offset
For most use cases passing the scale and offset directly is unnecessary, and it is preferable to use the API specifying centerResult and alignCorners.
- Parameters:
- imagesTensor: Tensor containing input images.
- size: The target size of the result tensor. 1D Int32 or Int64 tensor of size equal to rank of input.
- scale: 1D float tensor of size equal to rank of input.
- offset: 1D float tensor of size equal to rank of input.
- nearestRoundingMode: The rounding mode to use when using nearest resampling. Default is roundPreferCeil.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeBilinearWithTensor_sizeTensor_scaleOffsetTensor_layout_name(
&self,
images_tensor: &MPSGraphTensor,
size: &MPSGraphTensor,
scale_offset: &MPSGraphTensor,
layout: MPSGraphTensorNamedDataLayout,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeBilinearWithTensor_sizeTensor_scaleOffsetTensor_layout_name( &self, images_tensor: &MPSGraphTensor, size: &MPSGraphTensor, scale_offset: &MPSGraphTensor, layout: MPSGraphTensorNamedDataLayout, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Resamples input images to given size using the provided scale and offset and bilinear sampling See above discussion for more details.
- Parameters:
- imagesTensor: Tensor containing input images.
- size: 1D Int32 or Int64 tensor. A 2-element shape as [newHeight, newWidth]
- scaleOffset: 1D float tensor. A 4-element shape as [scaleY, scaleX, offsetY, offsetX]
- nearestRoundingMode: The rounding mode to use when using nearest resampling.
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeBilinearWithTensor_sizeTensor_scaleTensor_offsetTensor_name(
&self,
images_tensor: &MPSGraphTensor,
size: &MPSGraphTensor,
scale: &MPSGraphTensor,
offset: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeBilinearWithTensor_sizeTensor_scaleTensor_offsetTensor_name( &self, images_tensor: &MPSGraphTensor, size: &MPSGraphTensor, scale: &MPSGraphTensor, offset: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize operation and returns the result tensor.
Resamples input images to given size using the provided scale and offset and bilinear sampling. Destination indices are computed using
dst_indices = (src_indices * scale) + offset
For most use cases passing the scale and offset directly is unnecessary, and it is preferable to use the API specifying centerResult and alignCorners.
- Parameters:
- imagesTensor: Tensor containing input images.
- size: The target size of the result tensor. 1D Int32 or Int64 tensor of size equal to rank of input.
- scale: 1D float tensor of size equal to rank of input.
- offset: 1D float tensor of size equal to rank of input.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeWithGradientTensor_input_mode_centerResult_alignCorners_layout_name(
&self,
gradient: &MPSGraphTensor,
input: &MPSGraphTensor,
mode: MPSGraphResizeMode,
center_result: bool,
align_corners: bool,
layout: MPSGraphTensorNamedDataLayout,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeWithGradientTensor_input_mode_centerResult_alignCorners_layout_name( &self, gradient: &MPSGraphTensor, input: &MPSGraphTensor, mode: MPSGraphResizeMode, center_result: bool, align_corners: bool, layout: MPSGraphTensorNamedDataLayout, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize gradient operation and returns the result tensor.
Computes the gradient for the forward pass Resize op with identical parameters. See discussion of resizeTensor for more in depth description of resize paramters.
- Parameters:
- gradient: Incoming gradient tensor
- input: Forward pass input tensor
- mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
- centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
- alignCorners: When YES, the result image will have the same value as the input image in the corners
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeNearestWithGradientTensor_input_nearestRoundingMode_centerResult_alignCorners_layout_name(
&self,
gradient: &MPSGraphTensor,
input: &MPSGraphTensor,
nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
center_result: bool,
align_corners: bool,
layout: MPSGraphTensorNamedDataLayout,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeNearestWithGradientTensor_input_nearestRoundingMode_centerResult_alignCorners_layout_name( &self, gradient: &MPSGraphTensor, input: &MPSGraphTensor, nearest_rounding_mode: MPSGraphResizeNearestRoundingMode, center_result: bool, align_corners: bool, layout: MPSGraphTensorNamedDataLayout, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize gradient operation and returns the result tensor.
Computes the gradient for the forward pass Resize op with identical parameters. See discussion of resizeTensor for more in depth description of resize paramters.
- Parameters:
- gradient: Incoming gradient tensor
- input: Forward pass input tensor
- nearestRoundingMode: The rounding mode to use when using nearest resampling.
- centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
- alignCorners: When YES, the result image will have the same value as the input image in the corners
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeBilinearWithGradientTensor_input_centerResult_alignCorners_layout_name(
&self,
gradient: &MPSGraphTensor,
input: &MPSGraphTensor,
center_result: bool,
align_corners: bool,
layout: MPSGraphTensorNamedDataLayout,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeBilinearWithGradientTensor_input_centerResult_alignCorners_layout_name( &self, gradient: &MPSGraphTensor, input: &MPSGraphTensor, center_result: bool, align_corners: bool, layout: MPSGraphTensorNamedDataLayout, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize gradient operation and returns the result tensor.
Computes the gradient for the forward pass Resize op with identical parameters. See discussion of resizeTensor for more in depth description of resize paramters.
- Parameters:
- gradient: Incoming gradient tensor
- input: Forward pass input tensor
- centerResult: Controls if the result image is centered on the input image. When NO, the result will have the top left corner aligned
- alignCorners: When YES, the result image will have the same value as the input image in the corners
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeWithGradientTensor_input_scaleOffsetTensor_mode_layout_name(
&self,
gradient: &MPSGraphTensor,
input: &MPSGraphTensor,
scale_offset: &MPSGraphTensor,
mode: MPSGraphResizeMode,
layout: MPSGraphTensorNamedDataLayout,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeWithGradientTensor_input_scaleOffsetTensor_mode_layout_name( &self, gradient: &MPSGraphTensor, input: &MPSGraphTensor, scale_offset: &MPSGraphTensor, mode: MPSGraphResizeMode, layout: MPSGraphTensorNamedDataLayout, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize gradient operation and returns the result tensor.
Computes the gradient for the forward pass Resize op with identical parameters. See discussion of resizeTensor for more in depth description of resize paramters.
- Parameters:
- gradient: Incoming gradient tensor
- input: Forward pass input tensor
- scaleOffset: 1D float tensor. A 4-element shape as [scaleY, scaleX, offsetY, offsetX]
- mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeWithGradientTensor_input_scaleTensor_offsetTensor_mode_name(
&self,
gradient: &MPSGraphTensor,
input: &MPSGraphTensor,
scale: &MPSGraphTensor,
offset: &MPSGraphTensor,
mode: MPSGraphResizeMode,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeWithGradientTensor_input_scaleTensor_offsetTensor_mode_name( &self, gradient: &MPSGraphTensor, input: &MPSGraphTensor, scale: &MPSGraphTensor, offset: &MPSGraphTensor, mode: MPSGraphResizeMode, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize gradient operation and returns the result tensor.
Computes the gradient for the forward pass Resize op with identical parameters. See discussion of resizeTensor for more in depth description of resize paramters.
- Parameters:
- gradient: Incoming gradient tensor
- input: Forward pass input tensor
- scale: 1D float tensor of size equal to rank of input.
- offset: 1D float tensor of size equal to rank of input.
- mode: The resampling mode to use. If nearest sampling is specifed, RoundPreferCeil mode will be used.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeNearestWithGradientTensor_input_scaleOffsetTensor_nearestRoundingMode_layout_name(
&self,
gradient: &MPSGraphTensor,
input: &MPSGraphTensor,
scale_offset: &MPSGraphTensor,
nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
layout: MPSGraphTensorNamedDataLayout,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeNearestWithGradientTensor_input_scaleOffsetTensor_nearestRoundingMode_layout_name( &self, gradient: &MPSGraphTensor, input: &MPSGraphTensor, scale_offset: &MPSGraphTensor, nearest_rounding_mode: MPSGraphResizeNearestRoundingMode, layout: MPSGraphTensorNamedDataLayout, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize gradient operation and returns the result tensor.
Computes the gradient for the forward pass Resize op with identical parameters. See discussion of resizeTensor for more in depth description of resize paramters.
- Parameters:
- gradient: Incoming gradient tensor
- input: Forward pass input tensor
- scaleOffset: 1D float tensor. A 4-element shape as [scaleY, scaleX, offsetY, offsetX]
- nearestRoundingMode: The rounding mode to use when using nearest resampling.
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeNearestWithGradientTensor_input_scaleTensor_offsetTensor_nearestRoundingMode_name(
&self,
gradient: &MPSGraphTensor,
input: &MPSGraphTensor,
scale: &MPSGraphTensor,
offset: &MPSGraphTensor,
nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeNearestWithGradientTensor_input_scaleTensor_offsetTensor_nearestRoundingMode_name( &self, gradient: &MPSGraphTensor, input: &MPSGraphTensor, scale: &MPSGraphTensor, offset: &MPSGraphTensor, nearest_rounding_mode: MPSGraphResizeNearestRoundingMode, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize gradient operation and returns the result tensor.
Computes the gradient for the forward pass Resize op with nearest neighbor sampling and identical parameters. See discussion of resizeTensor for more in depth description of resize paramters.
- Parameters:
- gradient: Incoming gradient tensor
- input: Forward pass input tensor
- scale: 1D float tensor of size equal to rank of input.
- offset: 1D float tensor of size equal to rank of input.
- nearestRoundingMode: The rounding mode to use when using nearest resampling. Default is roundPreferCeil.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeBilinearWithGradientTensor_input_scaleOffsetTensor_layout_name(
&self,
gradient: &MPSGraphTensor,
input: &MPSGraphTensor,
scale_offset: &MPSGraphTensor,
layout: MPSGraphTensorNamedDataLayout,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeBilinearWithGradientTensor_input_scaleOffsetTensor_layout_name( &self, gradient: &MPSGraphTensor, input: &MPSGraphTensor, scale_offset: &MPSGraphTensor, layout: MPSGraphTensorNamedDataLayout, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize gradient operation and returns the result tensor.
Computes the gradient for the forward pass Resize op with bilinear sampling and identical parameters. See discussion of resizeTensor for more in depth description of resize paramters.
- Parameters:
- gradient: Incoming gradient tensor
- input: Forward pass input tensor
- scaleOffset: 1D float tensor. A 4-element shape as [scaleY, scaleX, offsetY, offsetX]
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC, NCHW, HWC, CHW, and HW.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn resizeBilinearWithGradientTensor_input_scaleTensor_offsetTensor_name(
&self,
gradient: &MPSGraphTensor,
input: &MPSGraphTensor,
scale: &MPSGraphTensor,
offset: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn resizeBilinearWithGradientTensor_input_scaleTensor_offsetTensor_name( &self, gradient: &MPSGraphTensor, input: &MPSGraphTensor, scale: &MPSGraphTensor, offset: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphResizeOps
and MPSGraphTensor
only.Creates a Resize gradient operation and returns the result tensor.
Computes the gradient for the forward pass Resize op with bilinear sampling and identical parameters.
- Parameters:
- gradient: Incoming gradient tensor
- input: Forward pass input tensor
- scale: 1D float tensor of size equal to rank of input.
- offset: 1D float tensor of size equal to rank of input.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Source§impl MPSGraph
MPSGraphSampleGrid.
impl MPSGraph
MPSGraphSampleGrid.
Sourcepub unsafe fn sampleGridWithSourceTensor_coordinateTensor_layout_normalizeCoordinates_relativeCoordinates_alignCorners_paddingMode_samplingMode_constantValue_name(
&self,
source: &MPSGraphTensor,
coordinates: &MPSGraphTensor,
layout: MPSGraphTensorNamedDataLayout,
normalize_coordinates: bool,
relative_coordinates: bool,
align_corners: bool,
padding_mode: MPSGraphPaddingMode,
sampling_mode: MPSGraphResizeMode,
constant_value: c_double,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphSampleGridOps
and MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn sampleGridWithSourceTensor_coordinateTensor_layout_normalizeCoordinates_relativeCoordinates_alignCorners_paddingMode_samplingMode_constantValue_name( &self, source: &MPSGraphTensor, coordinates: &MPSGraphTensor, layout: MPSGraphTensorNamedDataLayout, normalize_coordinates: bool, relative_coordinates: bool, align_corners: bool, padding_mode: MPSGraphPaddingMode, sampling_mode: MPSGraphResizeMode, constant_value: c_double, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphSampleGridOps
and MPSGraphResizeOps
and MPSGraphTensor
only.Samples a tensor using the coordinates provided.
Given an input tensor (N, H1, W1, C) or (N, C, H1, W1) and coordinates tensor (N, H2, W2, 2) this operation outputs a tensor of size (N, H2, W2, C) or (N, C, H2, W2) by sampling the input tensor at the coordinates provided by the coordinates tensor.
- Parameters:
- source: Tensor containing source data
- coordinates: a tensor (N, Hout, Wout, 2) that contains the coordinates of the samples in the source tensor that constitute the output tensor.
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC and NCHW.
- normalizeCoordinates: If true, coordinates are within [-1, 1] x [-1, 1] otherwise they are in pixels in the input tensor.
- relativeCoordinates: If true, coordinates are relative to the postion of the pixel in the output tensor and scaled back to the input tensor size
- alignCorners: If true, coordinate extrema are equal to the center of edge pixels, otherwise extrema are equal to outer edge of edge pixels
- paddingMode: determines how samples outside the inputTensor are evaluated (only constant, reflect, symmetric and clampToEdge are supported)
- samplingMode: Can be either MPSGraphResizeNearest or MPSGraphResizeBilinear. Nearest sampling will use roundPreferCeil.
- constantValue: If paddingMode is MPSGraphPaddingModeConstant, then this constant is used for samples outside the input tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn sampleGridWithSourceTensor_coordinateTensor_layout_normalizeCoordinates_relativeCoordinates_alignCorners_paddingMode_nearestRoundingMode_constantValue_name(
&self,
source: &MPSGraphTensor,
coordinates: &MPSGraphTensor,
layout: MPSGraphTensorNamedDataLayout,
normalize_coordinates: bool,
relative_coordinates: bool,
align_corners: bool,
padding_mode: MPSGraphPaddingMode,
nearest_rounding_mode: MPSGraphResizeNearestRoundingMode,
constant_value: c_double,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphSampleGridOps
and MPSGraphResizeOps
and MPSGraphTensor
only.
pub unsafe fn sampleGridWithSourceTensor_coordinateTensor_layout_normalizeCoordinates_relativeCoordinates_alignCorners_paddingMode_nearestRoundingMode_constantValue_name( &self, source: &MPSGraphTensor, coordinates: &MPSGraphTensor, layout: MPSGraphTensorNamedDataLayout, normalize_coordinates: bool, relative_coordinates: bool, align_corners: bool, padding_mode: MPSGraphPaddingMode, nearest_rounding_mode: MPSGraphResizeNearestRoundingMode, constant_value: c_double, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphSampleGridOps
and MPSGraphResizeOps
and MPSGraphTensor
only.Samples a tensor using the coordinates provided, using nearest neighbor sampling with specified rounding mode.
Given an input tensor (N, H1, W1, C) or (N, C, H1, W1) and coordinates tensor (N, H2, W2, 2) this operation outputs a tensor of size (N, H2, W2, C) or (N, C, H2, W2) by sampling the input tensor at the coordinates provided by the coordinates tensor.
- Parameters:
- source: Tensor containing source data
- coordinates: a tensor (N, Hout, Wout, 2) that contains the coordinates of the samples in the source tensor that constitute the output tensor.
- layout: Specifies what layout the provided tensor is in. The returned tensor will follow the same layout. Valid layouts are NHWC and NCHW.
- normalizeCoordinates: If true, coordinates are within [-1, 1] x [-1, 1] otherwise they are in pixels in the input tensor.
- relativeCoordinates: If true, coordinates are relative to the postion of the pixel in the output tensor and scaled back to the input tensor size
- alignCorners: If true, coordinate extrema are equal to the center of edge pixels, otherwise extrema are equal to outer edge of edge pixels
- paddingMode: determines how samples outside the inputTensor are evaluated (only constant, reflect, symmetric and clampToEdge are supported)
- nearestRoundingMode: The rounding mode to use for determining the nearest neighbor. Valid modes are roundPreferCeil, roundPreferFloor, ceil, and floor.
- constantValue: If paddingMode is MPSGraphPaddingModeConstant, then this constant is used for samples outside the input tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Source§impl MPSGraph
ScatterNDOps.
impl MPSGraph
ScatterNDOps.
Sourcepub unsafe fn scatterNDWithUpdatesTensor_indicesTensor_shape_batchDimensions_mode_name(
&self,
updates_tensor: &MPSGraphTensor,
indices_tensor: &MPSGraphTensor,
shape: &MPSShape,
batch_dimensions: NSUInteger,
mode: MPSGraphScatterMode,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphScatterNDOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn scatterNDWithUpdatesTensor_indicesTensor_shape_batchDimensions_mode_name( &self, updates_tensor: &MPSGraphTensor, indices_tensor: &MPSGraphTensor, shape: &MPSShape, batch_dimensions: NSUInteger, mode: MPSGraphScatterMode, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphScatterNDOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a ScatterND operation and returns the result tensor.
Scatters the slices in updatesTensor to the result tensor along the indices in indicesTensor. The scatter is defined as
B = batchDims
U = updates.rank - B
P = res.rank - B
Q = inds.rank - B
K = inds.shape[-1]
index_slice = indices[i_{b0},...,i_{bB},i_{0},..,i_{Q-1}]
res[i_{b0},...,i_{bB},index_slice[0],...,index_slice[K-1]] = updates[i_{b0},...,i_{bB},i_{0},...,i_{Q-1}]
Collisions will be summed, and slices not set by indices are set to 0. The tensors have the following shape requirements
K
<
= P
U = (P-K) + Q-1
indices.shape[0:Q-1] = updates.shape[0:Q-1]
updates.shape[Q:U] = res.shape[K:P]
- Parameters:
- updatesTensor: Tensor containing slices to be inserted into the result tensor.
- indicesTensor: Tensor containg the result indices to insert slices at
- shape: The shape of the result tensor.
- batchDimensions: The number of batch dimensions
- mode: The type of update to use on the destination
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn scatterNDWithUpdatesTensor_indicesTensor_shape_batchDimensions_name(
&self,
updates_tensor: &MPSGraphTensor,
indices_tensor: &MPSGraphTensor,
shape: &MPSShape,
batch_dimensions: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphScatterNDOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn scatterNDWithUpdatesTensor_indicesTensor_shape_batchDimensions_name( &self, updates_tensor: &MPSGraphTensor, indices_tensor: &MPSGraphTensor, shape: &MPSShape, batch_dimensions: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphScatterNDOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a ScatterND operation and returns the result tensor.
Scatters the slices in updatesTensor to the result tensor along the indices in indicesTensor. The scatter is defined as
B = batchDims
U = updates.rank - B
P = res.rank - B
Q = inds.rank - B
K = inds.shape[-1]
index_slice = indices[i_{b0},...,i_{bB},i_{0},..,i_{Q-1}]
res[i_{b0},...,i_{bB},index_slice[0],...,index_slice[K-1]] = updates[i_{b0},...,i_{bB},i_{0},...,i_{Q-1}]
Collisions will be summed, and slices not set by indices are set to 0. The tensors have the following shape requirements
K
<
= P
U = (P-K) + Q-1
indices.shape[0:Q-1] = updates.shape[0:Q-1]
updates.shape[Q:U] = res.shape[K:P]
- Parameters:
- updatesTensor: Tensor containing slices to be inserted into the result tensor.
- indicesTensor: Tensor containg the result indices to insert slices at
- shape: The shape of the result tensor.
- batchDimensions: The number of batch dimensions
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn scatterNDWithDataTensor_updatesTensor_indicesTensor_batchDimensions_mode_name(
&self,
data_tensor: &MPSGraphTensor,
updates_tensor: &MPSGraphTensor,
indices_tensor: &MPSGraphTensor,
batch_dimensions: NSUInteger,
mode: MPSGraphScatterMode,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphScatterNDOps
and MPSGraphTensor
only.
pub unsafe fn scatterNDWithDataTensor_updatesTensor_indicesTensor_batchDimensions_mode_name( &self, data_tensor: &MPSGraphTensor, updates_tensor: &MPSGraphTensor, indices_tensor: &MPSGraphTensor, batch_dimensions: NSUInteger, mode: MPSGraphScatterMode, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphScatterNDOps
and MPSGraphTensor
only.Creates a ScatterND operation and returns the result tensor.
Scatters the slices in updatesTensor to the result tensor along the indices in indicesTensor, on top of dataTensor. The scatter is defined as
B = batchDims
U = updates.rank - B
P = res.rank - B
Q = inds.rank - B
K = inds.shape[-1]
index_slice = indices[i_{b0},...,i_{bB},i_{0},..,i_{Q-1}]
res[...] = data[...]
res[i_{b0},...,i_{bB},index_slice[0],...,index_slice[K-1]] += updates[i_{b0},...,i_{bB},i_{0},...,i_{Q-1}] // Note += is used but this depends on mode
Collisions will be updated according to mode, and slices not set by indices are set to 0. The tensors have the following shape requirements
K
<
= P
U = (P-K) + Q-1
data.shape = res.shape
indices.shape[0:Q-1] = updates.shape[0:Q-1]
updates.shape[Q:U] = res.shape[K:P]
- Parameters:
- dataTensor: Tensor containing inital values of same shape as result tensor
- updatesTensor: Tensor containing slices to be inserted into the result tensor.
- indicesTensor: Tensor containg the result indices to insert slices at
- batchDimensions: The number of batch dimensions
- mode: The type of update to use on the destination
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Source§impl MPSGraph
MPSGraphScatterOps.
impl MPSGraph
MPSGraphScatterOps.
Sourcepub unsafe fn scatterWithUpdatesTensor_indicesTensor_shape_axis_mode_name(
&self,
updates_tensor: &MPSGraphTensor,
indices_tensor: &MPSGraphTensor,
shape: &MPSShape,
axis: NSInteger,
mode: MPSGraphScatterMode,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphScatterNDOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn scatterWithUpdatesTensor_indicesTensor_shape_axis_mode_name( &self, updates_tensor: &MPSGraphTensor, indices_tensor: &MPSGraphTensor, shape: &MPSShape, axis: NSInteger, mode: MPSGraphScatterMode, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphScatterNDOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a Scatter operation and returns the result tensor.
Scatters the slices in updatesTensor to the result tensor along the indices in indicesTensor. The scatter is defined as
U = updates.rank
P = res.rank
res[i_{0},...,i_{axis-1},indices[i_{axis}],i_{axis+1},...,i_{U-1}] = updates[i_{0},...,i_{axis-1},i_{axis},i_{axis+1},...,i_{U-1}]
Collisions will be updated according to mode. The tensors have the following shape requirements
U = P
indices.rank = 1
updates.shape[0:axis-1] = res.shape[0:axis-1]
updates.shape[axis] = indices.shape[0]
updates.shape[axis+1:U] = res.shape[0:P]
- Parameters:
- updatesTensor: Tensor containing values to be inserted into the result tensor.
- indicesTensor: Tensor containg the result indices to insert values at.
- shape: The shape of the result tensor.
- axis: The axis of the result tensor to scatter values along.
- mode: The type of update to use on the destination.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn scatterWithDataTensor_updatesTensor_indicesTensor_axis_mode_name(
&self,
data_tensor: &MPSGraphTensor,
updates_tensor: &MPSGraphTensor,
indices_tensor: &MPSGraphTensor,
axis: NSInteger,
mode: MPSGraphScatterMode,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphScatterNDOps
and MPSGraphTensor
only.
pub unsafe fn scatterWithDataTensor_updatesTensor_indicesTensor_axis_mode_name( &self, data_tensor: &MPSGraphTensor, updates_tensor: &MPSGraphTensor, indices_tensor: &MPSGraphTensor, axis: NSInteger, mode: MPSGraphScatterMode, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphScatterNDOps
and MPSGraphTensor
only.Creates a Scatter operation and returns the result tensor.
Scatters the slices in updatesTensor to the result tensor along the indices in indicesTensor, on top of dataTensor. The scatter is defined as
U = updates.rank
P = res.rank
res[...] = data[...]
res[i_{0},...,i_{axis-1},indices[i_{axis}],i_{axis+1},...,i_{U-1}] += updates[i_{0},...,i_{axis-1},i_{axis},i_{axis+1},...,i_{U-1}] // Note += is used but this depends on mode
Collisions will be updated according to mode. The tensors have the following shape requirements
U = P
indices.rank = 1
data.shape = res.shape
updates.shape[0:axis-1] = res.shape[0:axis-1]
updates.shape[axis] = indices.shape[0]
updates.shape[axis+1:U] = res.shape[0:P]
- Parameters:
- dataTensor: Tensor containing inital values of same shape as result tensor
- updatesTensor: Tensor containing values to be inserted into the result tensor.
- indicesTensor: Tensor containg the result indices to insert values at
- axis: The axis of the result tensor to scatter values along
- mode: The type of update to use on the destination
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Source§impl MPSGraph
MPSGraphScatterAlongAxisOps.
impl MPSGraph
MPSGraphScatterAlongAxisOps.
Sourcepub unsafe fn scatterAlongAxis_withUpdatesTensor_indicesTensor_shape_mode_name(
&self,
axis: NSInteger,
updates_tensor: &MPSGraphTensor,
indices_tensor: &MPSGraphTensor,
shape: &MPSShape,
mode: MPSGraphScatterMode,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphScatterNDOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn scatterAlongAxis_withUpdatesTensor_indicesTensor_shape_mode_name( &self, axis: NSInteger, updates_tensor: &MPSGraphTensor, indices_tensor: &MPSGraphTensor, shape: &MPSShape, mode: MPSGraphScatterMode, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphScatterNDOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a ScatterAlongAxis operation and returns the result tensor.
Scatter values from updatesTensor
along the specified axis
at indices in indicesTensor
into a result tensor.
Values are updated following mode
. See MPSGraphScatterMode.
The shape of updatesTensor
and indicesTensor
must match. shape
must match except at axis
.
The shape of the result tensor is equal to shape
and initialized with an initial value corresponding to mode
.
If an index is out of bounds of shape
along axis
the update value is skipped.
- Parameters:
- axis: The axis to scatter to. Negative values wrap around
- updatesTensor: The input tensor to scatter values from
- indicesTensor: Int32 or Int64 tensor used to index the result tensor.
- mode: The type of update to use
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn scatterAlongAxisTensor_withUpdatesTensor_indicesTensor_shape_mode_name(
&self,
axis_tensor: &MPSGraphTensor,
updates_tensor: &MPSGraphTensor,
indices_tensor: &MPSGraphTensor,
shape: &MPSShape,
mode: MPSGraphScatterMode,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphScatterNDOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn scatterAlongAxisTensor_withUpdatesTensor_indicesTensor_shape_mode_name( &self, axis_tensor: &MPSGraphTensor, updates_tensor: &MPSGraphTensor, indices_tensor: &MPSGraphTensor, shape: &MPSShape, mode: MPSGraphScatterMode, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphScatterNDOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a ScatterAlongAxis operation and returns the result tensor.
Scatter values from updatesTensor
along the specified axis
at indices in indicesTensor
into a result tensor.
Values are updated following mode
. See MPSGraphScatterMode.
The shape of updatesTensor
and indicesTensor
must match. shape
must match except at axis
.
The shape of the result tensor is equal to shape
and initialized with an initial value corresponding to mode
.
If an index is out of bounds of shape
along axis
the update value is skipped.
- Parameters:
- axisTensor: Scalar Int32 tensor. The axis to scatter to. Negative values wrap around
- updatesTensor: The input tensor to scatter values from
- indicesTensor: Int32 or Int64 tensor used to index the result tensor.
- mode: The type of update to use
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn scatterAlongAxis_withDataTensor_updatesTensor_indicesTensor_mode_name(
&self,
axis: NSInteger,
data_tensor: &MPSGraphTensor,
updates_tensor: &MPSGraphTensor,
indices_tensor: &MPSGraphTensor,
mode: MPSGraphScatterMode,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphScatterNDOps
and MPSGraphTensor
only.
pub unsafe fn scatterAlongAxis_withDataTensor_updatesTensor_indicesTensor_mode_name( &self, axis: NSInteger, data_tensor: &MPSGraphTensor, updates_tensor: &MPSGraphTensor, indices_tensor: &MPSGraphTensor, mode: MPSGraphScatterMode, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphScatterNDOps
and MPSGraphTensor
only.Creates a ScatterAlongAxis operation and returns the result tensor.
Scatter values from updatesTensor
along the specified axis
at indices in indicesTensor
onto dataTensor
.
Values in dataTensor
are updated following mode
. See MPSGraphScatterMode.
The shape of updatesTensor
and indicesTensor
must match. The shape of dataTensor
must match except at axis
.
If an index is out of bounds of shape
along axis
the update value is skipped.
For example,
data = [ [0, 0, 0],
[1, 1, 1],
[2, 2, 2],
[3, 3, 3] ]
updates = [ [1, 2, 3],
[4, 5, 6] ]
indices = [ [2, 1, 0],
[1, 3, 2] ]
axis = 0
result = scatterAlongAxis(axis, data, updates, indices, MPSGraphScatterModeAdd, "scatter")
result = [ [0, 0, 3],
[5, 3, 1],
[3, 2, 8],
[3, 8, 3] ]
- Parameters:
- axis: The axis to scatter to. Negative values wrap around
- dataTensor: The input tensor to scatter values onto
- updatesTensor: The input tensor to scatter values from
- indicesTensor: Int32 or Int64 tensor used to index the result tensor.
- mode: The type of update to use
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn scatterAlongAxisTensor_withDataTensor_updatesTensor_indicesTensor_mode_name(
&self,
axis_tensor: &MPSGraphTensor,
data_tensor: &MPSGraphTensor,
updates_tensor: &MPSGraphTensor,
indices_tensor: &MPSGraphTensor,
mode: MPSGraphScatterMode,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphScatterNDOps
and MPSGraphTensor
only.
pub unsafe fn scatterAlongAxisTensor_withDataTensor_updatesTensor_indicesTensor_mode_name( &self, axis_tensor: &MPSGraphTensor, data_tensor: &MPSGraphTensor, updates_tensor: &MPSGraphTensor, indices_tensor: &MPSGraphTensor, mode: MPSGraphScatterMode, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphScatterNDOps
and MPSGraphTensor
only.Creates a ScatterAlongAxis operation and returns the result tensor.
Scatter values from updatesTensor
along the specified axis
at indices in indicesTensor
onto dataTensor
.
Values in dataTensor
are updated following mode
. See MPSGraphScatterMode.
The shape of updatesTensor
and indicesTensor
must match. The shape of dataTensor
must match except at axis
.
If an index is out of bounds of shape
along axis
the update value is skipped.
For example,
data = [ [0, 0, 0],
[1, 1, 1],
[2, 2, 2],
[3, 3, 3] ]
updates = [ [1, 2, 3],
[4, 5, 6] ]
indices = [ [2, 1, 0],
[1, 3, 2] ]
axis = 0
result = scatterAlongAxis(axis, data, updates, indices, MPSGraphScatterModeAdd, "scatter")
result = [ [0, 0, 3],
[5, 3, 1],
[3, 2, 8],
[3, 8, 3] ]
- Parameters:
- axisTensor: Scalar Int32 tensor. The axis to scatter to. Negative values wrap around
- dataTensor: The input tensor to scatter values onto
- updatesTensor: The input tensor to scatter values from
- indicesTensor: Int32 or Int64 tensor used to index the result tensor.
- mode: The type of update to use
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Source§impl MPSGraph
MPSGraphSortOps.
impl MPSGraph
MPSGraphSortOps.
Sourcepub unsafe fn sortWithTensor_axis_descending_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
descending: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphSortOps
and MPSGraphTensor
only.
pub unsafe fn sortWithTensor_axis_descending_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, descending: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphSortOps
and MPSGraphTensor
only.Sorts the elements of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axis: The tensor dimension over which you sort the tensor
- descending: If true, reverse the sort direction
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn sortWithTensor_axisTensor_descending_name(
&self,
tensor: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
descending: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphSortOps
and MPSGraphTensor
only.
pub unsafe fn sortWithTensor_axisTensor_descending_name( &self, tensor: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, descending: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphSortOps
and MPSGraphTensor
only.Sorts the elements of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axisTensor: The tensor dimension over which you sort the tensor
- descending: If true, reverse the sort direction
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn sortWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphSortOps
and MPSGraphTensor
only.
pub unsafe fn sortWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphSortOps
and MPSGraphTensor
only.Sorts the elements of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axis: The tensor dimension over which you sort the tensor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn sortWithTensor_axisTensor_name(
&self,
tensor: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphSortOps
and MPSGraphTensor
only.
pub unsafe fn sortWithTensor_axisTensor_name( &self, tensor: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphSortOps
and MPSGraphTensor
only.Sorts the elements of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axisTensor: The tensor dimension over which you sort the tensor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn argSortWithTensor_axis_descending_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
descending: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphSortOps
and MPSGraphTensor
only.
pub unsafe fn argSortWithTensor_axis_descending_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, descending: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphSortOps
and MPSGraphTensor
only.Computes the indices that sort the elements of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axis: The tensor dimension over which you sort the tensor
- descending: If true, reverse the sort direction
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object with 32-bit integer data type
Sourcepub unsafe fn argSortWithTensor_axisTensor_descending_name(
&self,
tensor: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
descending: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphSortOps
and MPSGraphTensor
only.
pub unsafe fn argSortWithTensor_axisTensor_descending_name( &self, tensor: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, descending: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphSortOps
and MPSGraphTensor
only.Computes the indices that sort the elements of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axisTensor: The tensor dimension over which you sort the tensor
- descending: If true, reverse the sort direction
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object with 32-bit integer data type
Sourcepub unsafe fn argSortWithTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphSortOps
and MPSGraphTensor
only.
pub unsafe fn argSortWithTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphSortOps
and MPSGraphTensor
only.Computes the indices that sort the elements of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axis: The tensor dimension over which you sort the tensor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object with 32-bit integer data type
Sourcepub unsafe fn argSortWithTensor_axisTensor_name(
&self,
tensor: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphSortOps
and MPSGraphTensor
only.
pub unsafe fn argSortWithTensor_axisTensor_name( &self, tensor: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphSortOps
and MPSGraphTensor
only.Computes the indices that sort the elements of the input tensor along the specified axis.
- Parameters:
- tensor: The input tensor
- axisTensor: The tensor dimension over which you sort the tensor
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object with 32-bit integer data type
Source§impl MPSGraph
MPSGraphSparseOps.
impl MPSGraph
MPSGraphSparseOps.
Sourcepub unsafe fn sparseTensorWithType_tensors_shape_dataType_name(
&self,
sparse_storage_type: MPSGraphSparseStorageType,
input_tensor_array: &NSArray<MPSGraphTensor>,
shape: &MPSShape,
data_type: MPSDataType,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphSparseOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn sparseTensorWithType_tensors_shape_dataType_name( &self, sparse_storage_type: MPSGraphSparseStorageType, input_tensor_array: &NSArray<MPSGraphTensor>, shape: &MPSShape, data_type: MPSDataType, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphSparseOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a sparse tensor representation.
sparseVals corresponds to non zero values in matrix. indexTensor0 and indexTensor1 are indices used for indexing into sparse data structure. For COO, indexTensor0 is x index and indexTensor1 is y index. For CSC, indexTensor0 and indexTensor1 correspond to rowIndex and colStarts respectively. For CSR, indexTensor0 and indexTensor1 correspond to colIndex and rowStarts respectively. You must set input tensors appropriately for each sparse storage type.
- Parameters:
- sparseStorageType: A sparseStorageType.
- inputTensorArray: An array of input tensors as [sparseVals, indexTensor0, indexTensor1].
- shape: The shape of the sparse tensor.
- dataType: The dataType of the sparse tensor.
- name: A name for the operation.
- Returns: A valid
MPSGraphTensor
object.
Sourcepub unsafe fn sparseTensorWithDescriptor_tensors_shape_name(
&self,
sparse_descriptor: &MPSGraphCreateSparseOpDescriptor,
input_tensor_array: &NSArray<MPSGraphTensor>,
shape: &MPSShape,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphSparseOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn sparseTensorWithDescriptor_tensors_shape_name( &self, sparse_descriptor: &MPSGraphCreateSparseOpDescriptor, input_tensor_array: &NSArray<MPSGraphTensor>, shape: &MPSShape, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphSparseOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a sparse tensor representation.
sparseVals corresponds to non zero values in matrix. indexTensor0 and indexTensor1 are indices used for indexing into sparse data structure. For COO, indexTensor0 is x index and indexTensor1 is y index . For CSC, indexTensor0 and indexTensor1 correspond to rowIndex and colStarts respectively. For CSR, indexTensor0 and indexTensor1 correspond to colIndex and rowStarts respectively. You must set input tensors appropriately for each sparse storage type.
- Parameters:
- sparseDescriptor: A sparseDescriptor.
- inputTensorArray: An array of input tensors as [sparseVals, indexTensor0, indexTensor1].
- shape: The shape of the sparse tensor.
- name: A name for the operation.
- Returns: A valid
MPSGraphTensor
object
Source§impl MPSGraph
MPSGraphStencilOps.
impl MPSGraph
MPSGraphStencilOps.
Sourcepub unsafe fn stencilWithSourceTensor_weightsTensor_descriptor_name(
&self,
source: &MPSGraphTensor,
weights: &MPSGraphTensor,
descriptor: &MPSGraphStencilOpDescriptor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphStencilOps
and MPSGraphTensor
only.
pub unsafe fn stencilWithSourceTensor_weightsTensor_descriptor_name( &self, source: &MPSGraphTensor, weights: &MPSGraphTensor, descriptor: &MPSGraphStencilOpDescriptor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphStencilOps
and MPSGraphTensor
only.Creates a stencil operation and returns the result tensor.
Performs a weighted reduction operation (See MPSGraphStencilOpDescriptor/reductionMode
) on the last 4 dimensions of the source
over the window determined by weights
, according to the value defined in descriptor
.
y[i] = reduction{j
\in w} ( x[ i + j ]w[j] )
- Parameters:
- source: The tensor containing the source data. Must be of rank 4 or greater.
- weights: A 4-D tensor containing the weights data.
- descriptor: The descriptor object that specifies the parameters for the stencil operation.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Source§impl MPSGraph
MPSGraphTensorShapeOps.
impl MPSGraph
MPSGraphTensorShapeOps.
Sourcepub unsafe fn reshapeTensor_withShape_name(
&self,
tensor: &MPSGraphTensor,
shape: &MPSShape,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn reshapeTensor_withShape_name( &self, tensor: &MPSGraphTensor, shape: &MPSShape, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a reshape operation and returns the result tensor.
This operation reshapes the input tensor to the target shape. The shape must be compatible with the input tensor shape, specifically the volume of the input tensor has to match the volume defined by the shape. The shape is allowed to contain dynamic dimensions (-1) when the result type can be inferred unambiguously.
- Parameters:
- tensor: The tensor to be reshaped.
- shape: The result tensor shape.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reshapeTensor_withShapeTensor_name(
&self,
tensor: &MPSGraphTensor,
shape_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn reshapeTensor_withShapeTensor_name( &self, tensor: &MPSGraphTensor, shape_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a reshape operation and returns the result tensor.
This operation reshapes the input tensor to the target shape. The shape tensor must be compatible with the input tensor shape, specifically the volume of the input tensor has to match the volume defined by the shape tensor. The shape tensor is allowed to contain dynamic dimensions (-1) when the result type can be inferred unambiguously.
- Parameters:
- tensor: The tensor to be reshaped.
- shapeTensor: A 1D tensor of type
MPSDataTypeInt32
orMPSDataTypeInt64
, that contains the target shape values. - name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn transposeTensor_dimension_withDimension_name(
&self,
tensor: &MPSGraphTensor,
dimension_index: NSUInteger,
dimension_index2: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn transposeTensor_dimension_withDimension_name( &self, tensor: &MPSGraphTensor, dimension_index: NSUInteger, dimension_index2: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a transpose operation and returns the result tensor.
Transposes the dimensions dimensionIndex
and dimensionIndex2
of the input tensor.
- Parameters:
- tensor: The tensor to be transposed.
- dimensionIndex: The first dimension index to be transposed.
- dimensionIndex2: The second dimension index to be transposed.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn transposeTensor_permutation_name(
&self,
tensor: &MPSGraphTensor,
permutation: &NSArray<NSNumber>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn transposeTensor_permutation_name( &self, tensor: &MPSGraphTensor, permutation: &NSArray<NSNumber>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a permutation operation and returns the result tensor.
Permutes the dimensions of the input tensor according to values in permutation
.
- Parameters:
- tensor: The tensor to be permuted.
- permutation: An array of numbers defining the permutation, must be of length
rank(tensor)
and define a valid permutation. - name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn sliceTensor_dimension_start_length_name(
&self,
tensor: &MPSGraphTensor,
dimension_index: NSUInteger,
start: NSInteger,
length: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn sliceTensor_dimension_start_length_name( &self, tensor: &MPSGraphTensor, dimension_index: NSUInteger, start: NSInteger, length: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a slice operation and returns the result tensor.
- Parameters:
- tensor: The tensor to be sliced.
- dimensionIndex: The dimension to slice.
- start: The starting index of the slice, can be negative to count from the end of the tensor dimension.
- length: The length of the slice.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn sliceTensor_starts_ends_strides_name(
&self,
tensor: &MPSGraphTensor,
starts: &NSArray<NSNumber>,
ends: &NSArray<NSNumber>,
strides: &NSArray<NSNumber>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn sliceTensor_starts_ends_strides_name( &self, tensor: &MPSGraphTensor, starts: &NSArray<NSNumber>, ends: &NSArray<NSNumber>, strides: &NSArray<NSNumber>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a strided-slice operation and returns the result tensor.
Slices a tensor starting from starts
, stopping short before ends
stepping
strides
paces between each value. Semantics based on
TensorFlow Strided Slice Op.
- Parameters:
- tensor: The tensor to be sliced.
- starts: An array of numbers that specify the starting points for each dimension.
- ends: An array of numbers that specify the ending points for each dimension.
- strides: An array of numbers that specify the strides for each dimension.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn sliceTensor_starts_ends_strides_startMask_endMask_squeezeMask_name(
&self,
tensor: &MPSGraphTensor,
starts: &NSArray<NSNumber>,
ends: &NSArray<NSNumber>,
strides: &NSArray<NSNumber>,
start_mask: u32,
end_mask: u32,
squeeze_mask: u32,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn sliceTensor_starts_ends_strides_startMask_endMask_squeezeMask_name( &self, tensor: &MPSGraphTensor, starts: &NSArray<NSNumber>, ends: &NSArray<NSNumber>, strides: &NSArray<NSNumber>, start_mask: u32, end_mask: u32, squeeze_mask: u32, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a strided-slice operation and returns the result tensor.
Slices a tensor starting from starts
, stopping short before ends
stepping
strides
paces between each value. Semantics based on
TensorFlow Strided Slice Op.
- Parameters:
- tensor: The Tensor to be sliced.
- starts: An array of numbers that specify the starting points for each dimension.
- ends: An array of numbers that specify the ending points for each dimension.
- strides: An array of numbers that specify the strides for each dimension.
- startMask: A bitmask that indicates dimensions whose
starts
values the operation should ignore. - endMask: A bitmask that indicates dimensions whose
ends
values the operation should ignore. - squeezeMask: A bitmask that indicates dimensions the operation will squeeze out from the result.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn sliceTensor_startTensor_endTensor_strideTensor_startMask_endMask_squeezeMask_name(
&self,
tensor: &MPSGraphTensor,
start_tensor: &MPSGraphTensor,
end_tensor: &MPSGraphTensor,
stride_tensor: &MPSGraphTensor,
start_mask: u32,
end_mask: u32,
squeeze_mask: u32,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn sliceTensor_startTensor_endTensor_strideTensor_startMask_endMask_squeezeMask_name( &self, tensor: &MPSGraphTensor, start_tensor: &MPSGraphTensor, end_tensor: &MPSGraphTensor, stride_tensor: &MPSGraphTensor, start_mask: u32, end_mask: u32, squeeze_mask: u32, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a strided-slice operation and returns the result tensor.
Slices a tensor starting from startTensor
, stopping short before endTensor
stepping
strideTensor
paces between each value. Semantics based on
TensorFlow Strided Slice Op.
- Parameters:
- tensor: The Tensor to be sliced.
- startTensor: The tensor that specifies the starting points for each dimension.
- endTensor: The tensor that specifies the ending points for each dimension.
- strideTensor: The tensor that specifies the strides for each dimension.
- startMask: A bitmask that indicates dimensions whose
starts
values the operation should ignore. - endMask: A bitmask that indicates dimensions whose
ends
values the operation should ignore. - squeezeMask: A bitmask that indicates dimensions the operation will squeeze out from the result.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn sliceTensor_startTensor_sizeTensor_squeezeMask_name(
&self,
tensor: &MPSGraphTensor,
start_tensor: &MPSGraphTensor,
size_tensor: &MPSGraphTensor,
squeeze_mask: u32,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn sliceTensor_startTensor_sizeTensor_squeezeMask_name( &self, tensor: &MPSGraphTensor, start_tensor: &MPSGraphTensor, size_tensor: &MPSGraphTensor, squeeze_mask: u32, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a slice operation and returns the result tensor.
Slices a tensor starting from startTensor
, stopping short before startTensor + endTensor
stepping
a single pace between each value. Semantics based on
TensorFlow Strided Slice Op.
- Parameters:
- tensor: The Tensor to be sliced.
- startTensor: The tensor that specifies the starting points for each dimension.
- sizeTensor: The tensor that specifies the size of the result for each dimension.
- squeezeMask: A bitmask that indicates dimensions the operation will squeeze out from the result.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn sliceGradientTensor_fwdInShapeTensor_starts_ends_strides_name(
&self,
input_gradient_tensor: &MPSGraphTensor,
fwd_in_shape_tensor: &MPSGraphTensor,
starts: &NSArray<NSNumber>,
ends: &NSArray<NSNumber>,
strides: &NSArray<NSNumber>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn sliceGradientTensor_fwdInShapeTensor_starts_ends_strides_name( &self, input_gradient_tensor: &MPSGraphTensor, fwd_in_shape_tensor: &MPSGraphTensor, starts: &NSArray<NSNumber>, ends: &NSArray<NSNumber>, strides: &NSArray<NSNumber>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a strided-slice gradient operation and returns the result tensor.
- Parameters:
- inputGradientTensor: The input gradient.
- fwdInShapeTensor: The shape of the forward pass input, that is the shape of the gradient output.
- starts: An array of numbers that specify the starting points for each dimension.
- ends: An array of numbers that specify the ending points for each dimension.
- strides: An array of numbers that specify the strides for each dimension.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn sliceGradientTensor_fwdInShapeTensor_startTensor_endTensor_strideTensor_startMask_endMask_squeezeMask_name(
&self,
input_gradient_tensor: &MPSGraphTensor,
fwd_in_shape_tensor: &MPSGraphTensor,
start_tensor: &MPSGraphTensor,
end_tensor: &MPSGraphTensor,
stride_tensor: &MPSGraphTensor,
start_mask: u32,
end_mask: u32,
squeeze_mask: u32,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn sliceGradientTensor_fwdInShapeTensor_startTensor_endTensor_strideTensor_startMask_endMask_squeezeMask_name( &self, input_gradient_tensor: &MPSGraphTensor, fwd_in_shape_tensor: &MPSGraphTensor, start_tensor: &MPSGraphTensor, end_tensor: &MPSGraphTensor, stride_tensor: &MPSGraphTensor, start_mask: u32, end_mask: u32, squeeze_mask: u32, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a strided-slice gradient operation and returns the result tensor.
- Parameters:
- inputGradientTensor: The input gradient.
- fwdInShapeTensor: The shape of the forward pass input, that is the shape of the gradient output.
- startTensor: The tensor that specifies the starting points for each dimension.
- endTensor: The tensor that specifies the ending points for each dimension.
- strideTensor: The tensor that specifies the strides for each dimension.
- startMask: A bitmask that indicates dimensions whose
starts
values the operation should ignore. - endMask: A bitmask that indicates dimensions whose
ends
values the operation should ignore. - squeezeMask: A bitmask that indicates dimensions the operation will squeeze out from the result.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn sliceGradientTensor_fwdInShapeTensor_startTensor_sizeTensor_squeezeMask_name(
&self,
input_gradient_tensor: &MPSGraphTensor,
fwd_in_shape_tensor: &MPSGraphTensor,
start_tensor: &MPSGraphTensor,
size_tensor: &MPSGraphTensor,
squeeze_mask: u32,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn sliceGradientTensor_fwdInShapeTensor_startTensor_sizeTensor_squeezeMask_name( &self, input_gradient_tensor: &MPSGraphTensor, fwd_in_shape_tensor: &MPSGraphTensor, start_tensor: &MPSGraphTensor, size_tensor: &MPSGraphTensor, squeeze_mask: u32, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a slice gradient operation and returns the result tensor.
- Parameters:
- inputGradientTensor: The input gradient.
- fwdInShapeTensor: The shape of the forward pass input, that is the shape of the gradient output.
- startTensor: The tensor that specifies the starting points for each dimension.
- sizeTensor: The tensor that specifies the size of the forward result for each dimension.
- squeezeMask: A bitmask that indicates dimensions the operation will squeeze out from the result.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn sliceGradientTensor_fwdInShapeTensor_starts_ends_strides_startMask_endMask_squeezeMask_name(
&self,
input_gradient_tensor: &MPSGraphTensor,
fwd_in_shape_tensor: &MPSGraphTensor,
starts: &NSArray<NSNumber>,
ends: &NSArray<NSNumber>,
strides: &NSArray<NSNumber>,
start_mask: u32,
end_mask: u32,
squeeze_mask: u32,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn sliceGradientTensor_fwdInShapeTensor_starts_ends_strides_startMask_endMask_squeezeMask_name( &self, input_gradient_tensor: &MPSGraphTensor, fwd_in_shape_tensor: &MPSGraphTensor, starts: &NSArray<NSNumber>, ends: &NSArray<NSNumber>, strides: &NSArray<NSNumber>, start_mask: u32, end_mask: u32, squeeze_mask: u32, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a strided-slice gradient operation and returns the result tensor.
- Parameters:
- inputGradientTensor: The input gradient.
- fwdInShapeTensor: The shape of the forward pass input, that is the shape of the gradient output.
- starts: An array of numbers that specify the starting points for each dimension.
- ends: An array of numbers that specify the ending points for each dimension.
- strides: An array of numbers that specify the strides for each dimension.
- startMask: A bitmask that indicates dimensions whose
starts
values the operation should ignore. - endMask: A bitmask that indicates dimensions whose
ends
values the operation should ignore. - squeezeMask: A bitmask that indicates dimensions the operation will squeeze out from the result.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn sliceUpdateDataTensor_updateTensor_startsTensor_endsTensor_stridesTensor_startMask_endMask_squeezeMask_name(
&self,
data_tensor: &MPSGraphTensor,
update_tensor: &MPSGraphTensor,
starts_tensor: &MPSGraphTensor,
ends_tensor: &MPSGraphTensor,
strides_tensor: &MPSGraphTensor,
start_mask: u32,
end_mask: u32,
squeeze_mask: u32,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn sliceUpdateDataTensor_updateTensor_startsTensor_endsTensor_stridesTensor_startMask_endMask_squeezeMask_name( &self, data_tensor: &MPSGraphTensor, update_tensor: &MPSGraphTensor, starts_tensor: &MPSGraphTensor, ends_tensor: &MPSGraphTensor, strides_tensor: &MPSGraphTensor, start_mask: u32, end_mask: u32, squeeze_mask: u32, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a strided-slice update operation and returns the result tensor.
- Parameters:
- dataTensor: The large tensor that will receive the update.
- updateTensor: The tensor with the new values that will replace values in the dataTensor.
- startsTensor: A Tensor that contains an array of numbers that specify the starting points for each dimension.
- endsTensor: A Tensor that contains an array of numbers that specify the ending points for each dimension.
- stridesTensor: A Tensor that contains an array of numbers that specify the strides for each dimension.
- startMask: A bitmask that indicates dimensions whose
starts
values the operation should ignore. - endMask: A bitmask that indicates dimensions whose
ends
values the operation should ignore. - squeezeMask: A bitmask that indicates dimensions the operation will squeeze out from the result.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn sliceUpdateDataTensor_updateTensor_starts_ends_strides_startMask_endMask_squeezeMask_name(
&self,
data_tensor: &MPSGraphTensor,
update_tensor: &MPSGraphTensor,
starts: &NSArray<NSNumber>,
ends: &NSArray<NSNumber>,
strides: &NSArray<NSNumber>,
start_mask: u32,
end_mask: u32,
squeeze_mask: u32,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn sliceUpdateDataTensor_updateTensor_starts_ends_strides_startMask_endMask_squeezeMask_name( &self, data_tensor: &MPSGraphTensor, update_tensor: &MPSGraphTensor, starts: &NSArray<NSNumber>, ends: &NSArray<NSNumber>, strides: &NSArray<NSNumber>, start_mask: u32, end_mask: u32, squeeze_mask: u32, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a strided-slice update operation and returns the result tensor.
- Parameters:
- dataTensor: The large tensor that will receive the update.
- updateTensor: The tensor with the new values that will replace values in the dataTensor.
- starts: An array of numbers that specify the starting points for each dimension.
- ends: An array of numbers that specify the ending points for each dimension.
- strides: An array of numbers that specify the strides for each dimension.
- startMask: A bitmask that indicates dimensions whose
starts
values the operation should ignore. - endMask: A bitmask that indicates dimensions whose
ends
values the operation should ignore. - squeezeMask: A bitmask that indicates dimensions the operation will squeeze out from the result.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn sliceUpdateDataTensor_updateTensor_startsTensor_endsTensor_stridesTensor_name(
&self,
data_tensor: &MPSGraphTensor,
update_tensor: &MPSGraphTensor,
starts_tensor: &MPSGraphTensor,
ends_tensor: &MPSGraphTensor,
strides_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn sliceUpdateDataTensor_updateTensor_startsTensor_endsTensor_stridesTensor_name( &self, data_tensor: &MPSGraphTensor, update_tensor: &MPSGraphTensor, starts_tensor: &MPSGraphTensor, ends_tensor: &MPSGraphTensor, strides_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a strided-slice update operation with zero masks and returns the result tensor.
- Parameters:
- dataTensor: The large tensor that will receive the update.
- updateTensor: The tensor with the new values that will replace values in the dataTensor.
- startsTensor: A Tensor that contains an array of numbers that specify the starting points for each dimension.
- endsTensor: A Tensor that contains an array of numbers that specify the ending points for each dimension.
- stridesTensor: A Tensor that contains an array of numbers that specify the strides for each dimension.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn sliceUpdateDataTensor_updateTensor_starts_ends_strides_name(
&self,
data_tensor: &MPSGraphTensor,
update_tensor: &MPSGraphTensor,
starts: &NSArray<NSNumber>,
ends: &NSArray<NSNumber>,
strides: &NSArray<NSNumber>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn sliceUpdateDataTensor_updateTensor_starts_ends_strides_name( &self, data_tensor: &MPSGraphTensor, update_tensor: &MPSGraphTensor, starts: &NSArray<NSNumber>, ends: &NSArray<NSNumber>, strides: &NSArray<NSNumber>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a strided-slice update operation with zero masks and returns the result tensor.
- Parameters:
- dataTensor: The large tensor that will receive the update.
- updateTensor: The tensor with the new values that will replace values in the dataTensor.
- starts: An array of numbers that specify the starting points for each dimension.
- ends: An array of numbers that specify the ending points for each dimension.
- strides: An array of numbers that specify the strides for each dimension.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn concatTensor_withTensor_dimension_name(
&self,
tensor: &MPSGraphTensor,
tensor2: &MPSGraphTensor,
dimension_index: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn concatTensor_withTensor_dimension_name( &self, tensor: &MPSGraphTensor, tensor2: &MPSGraphTensor, dimension_index: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a concatenation operation and returns the result tensor.
Concatenates two input tensors along the specified dimension. Tensors must be broadcast compatible along all other dimensions, and have the same datatype.
- Parameters:
- tensor: The first tensor to concatenate.
- tensor2: The second tensor to concatenate.
- dimensionIndex: The dimension to concatenate across, must be in range:
-rank < = dimension < rank
. - name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn concatTensors_dimension_name(
&self,
tensors: &NSArray<MPSGraphTensor>,
dimension_index: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn concatTensors_dimension_name( &self, tensors: &NSArray<MPSGraphTensor>, dimension_index: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a concatenation operation and returns the result tensor.
Concatenates all input tensors along the specified dimension. All inputs must be broadcast compatible along all other dimensions, and have the same datatype.
- Parameters:
- tensors: The tensors to concatenate.
- dimensionIndex: The dimension to concatenate across, must be in range:
-rank < = dimension < rank
. - name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn concatTensors_dimension_interleave_name(
&self,
tensors: &NSArray<MPSGraphTensor>,
dimension_index: NSInteger,
interleave: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn concatTensors_dimension_interleave_name( &self, tensors: &NSArray<MPSGraphTensor>, dimension_index: NSInteger, interleave: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a concatenation operation and returns the result tensor.
Concatenates all input tensors along specified dimension. All inputs must be broadcast compatible along all other dimensions, and have the same type. When interleave is specified, all tensors will be interleaved. To interleave, make sure to provide broadcast compatible inputs along the specified dimension as well. For example:
operand0 = [1, 2, 3]
operand1 = [4, 5, 6]
concat([operand0, operand1], axis = 0, interleave = YES) = [1, 4, 2, 5, 3, 6]
- Parameters:
- tensors: The tensors to concatenate.
- dimensionIndex: The dimension to concatenate across, must be in range:
-rank < = dimension < rank
. - interleave: A boolean value that specifies whether the operation interleaves input tensors.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn tileTensor_withMultiplier_name(
&self,
tensor: &MPSGraphTensor,
multiplier: &MPSShape,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn tileTensor_withMultiplier_name( &self, tensor: &MPSGraphTensor, multiplier: &MPSShape, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a tile operation and returns the result tensor.
Creates a tensor which contains multiple copies of the input tensor along each dimension of the tensor.
- Parameters:
- tensor: The input tensor
- multiplier: An array of numbers that specifies how many copies per dimension MPSGraph produces.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn tileGradientWithIncomingGradientTensor_sourceTensor_withMultiplier_name(
&self,
incoming_gradient_tensor: &MPSGraphTensor,
source_tensor: &MPSGraphTensor,
multiplier: &MPSShape,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn tileGradientWithIncomingGradientTensor_sourceTensor_withMultiplier_name( &self, incoming_gradient_tensor: &MPSGraphTensor, source_tensor: &MPSGraphTensor, multiplier: &MPSShape, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a tile gradient operation and returns the result tensor.
- Parameters:
- incomingGradientTensor: The input gradient tensor.
- sourceTensor: The input tensor of the forward pass.
- multiplier: An array of numbers that specifies how many copies per dimension MPSGraph produced in the forward pass.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn padTensor_withPaddingMode_leftPadding_rightPadding_constantValue_name(
&self,
tensor: &MPSGraphTensor,
padding_mode: MPSGraphPaddingMode,
left_padding: &MPSShape,
right_padding: &MPSShape,
constant_value: c_double,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn padTensor_withPaddingMode_leftPadding_rightPadding_constantValue_name( &self, tensor: &MPSGraphTensor, padding_mode: MPSGraphPaddingMode, left_padding: &MPSShape, right_padding: &MPSShape, constant_value: c_double, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a padding operation and returns the result tensor.
- Parameters:
- tensor: The input tensor.
- paddingMode: The parameter that defines the padding mode.
- leftPadding: The parameter that defines how much padding the operation applies to the input tensor before each dimension - must be of size
rank(tensor)
. - rightPadding: The parameter that defines how much padding the operation applies to the input tensor after each dimension - must be of size
rank(tensor)
. - constantValue: The constant value the operation uses when
paddingMode = MPSGraphPaddingModeConstant
. - name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn padGradientWithIncomingGradientTensor_sourceTensor_paddingMode_leftPadding_rightPadding_name(
&self,
incoming_gradient_tensor: &MPSGraphTensor,
source_tensor: &MPSGraphTensor,
padding_mode: MPSGraphPaddingMode,
left_padding: &MPSShape,
right_padding: &MPSShape,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn padGradientWithIncomingGradientTensor_sourceTensor_paddingMode_leftPadding_rightPadding_name( &self, incoming_gradient_tensor: &MPSGraphTensor, source_tensor: &MPSGraphTensor, padding_mode: MPSGraphPaddingMode, left_padding: &MPSShape, right_padding: &MPSShape, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a padding gradient operation and returns the result tensor.
- Parameters:
- incomingGradientTensor: The input gradient tensor.
- sourceTensor: The input tensor of the forward pass.
- paddingMode: The parameter that defines the padding mode.
- leftPadding: The parameter that defines how much padding the operation applies to the input tensor before each dimension - must be of size
rank(tensor)
. - rightPadding: The parameter that defines how much padding the operation applies to the input tensor after each dimension - must be of size
rank(tensor)
. - name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn spaceToDepth2DTensor_widthAxis_heightAxis_depthAxis_blockSize_usePixelShuffleOrder_name(
&self,
tensor: &MPSGraphTensor,
width_axis: NSUInteger,
height_axis: NSUInteger,
depth_axis: NSUInteger,
block_size: NSUInteger,
use_pixel_shuffle_order: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn spaceToDepth2DTensor_widthAxis_heightAxis_depthAxis_blockSize_usePixelShuffleOrder_name( &self, tensor: &MPSGraphTensor, width_axis: NSUInteger, height_axis: NSUInteger, depth_axis: NSUInteger, block_size: NSUInteger, use_pixel_shuffle_order: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a space-to-depth2D operation and returns the result tensor.
This operation outputs a copy of the input
tensor, where values from the
widthAxis
and heightAxis
dimensions are moved in spatial blocks of size
blockSize
to the depthAxis
dimension. Use the usePixelShuffleOrder
parameter
to control how the data within spatial blocks is ordered in the
depthAxis
dimension: with usePixelShuffleOrder=YES
MPSGraph stores the
values of the spatial blocks contiguosly within the depthAxis
dimension, whereas
otherwise they are stored interleaved with existing values in the depthAxis
dimension.
This operation is the inverse of MPSGraph/depthToSpace2DTensor:widthAxis:heightAxis:depthAxis:blockSize:usePixelShuffleOrder:name:
.
- Parameters:
- tensor: The input tensor.
- widthAxis: The axis that defines the fastest running dimension within the block.
- heightAxis: The axis that defines the 2nd fastest running dimension within the block.
- depthAxis: The axis that defines the destination dimension, where to copy the blocks.
- blockSize: The size of the square spatial sub-block.
- usePixelShuffleOrder: A parameter that controls the layout of the sub-blocks within the depth dimension.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn spaceToDepth2DTensor_widthAxisTensor_heightAxisTensor_depthAxisTensor_blockSize_usePixelShuffleOrder_name(
&self,
tensor: &MPSGraphTensor,
width_axis_tensor: &MPSGraphTensor,
height_axis_tensor: &MPSGraphTensor,
depth_axis_tensor: &MPSGraphTensor,
block_size: NSUInteger,
use_pixel_shuffle_order: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn spaceToDepth2DTensor_widthAxisTensor_heightAxisTensor_depthAxisTensor_blockSize_usePixelShuffleOrder_name( &self, tensor: &MPSGraphTensor, width_axis_tensor: &MPSGraphTensor, height_axis_tensor: &MPSGraphTensor, depth_axis_tensor: &MPSGraphTensor, block_size: NSUInteger, use_pixel_shuffle_order: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a space-to-depth2D operation and returns the result tensor.
This operation outputs a copy of the input
tensor, where values from the
widthAxisTensor
and heightAxisTensor
dimensions are moved in spatial blocks of size
blockSize
to the depthAxisTensor
dimension. Use the usePixelShuffleOrder
parameter
to control how the data within spatial blocks is ordered in the
depthAxisTensor
dimension: with usePixelShuffleOrder=YES
MPSGraph stores the
values of the spatial blocks contiguosly within the depthAxisTensor
dimension, whereas
otherwise they are stored interleaved with existing values in the depthAxisTensor
dimension.
This operation is the inverse of MPSGraph/depthToSpace2DTensor:widthAxisTensor:heightAxisTensor:depthAxisTensor:blockSize:usePixelShuffleOrder:name:
.
- Parameters:
- tensor: The input tensor.
- widthAxisTensor: A scalar tensor that contains the axis that defines the fastest running dimension within the block.
- heightAxisTensor: A scalar tensor that contains the axis that defines the 2nd fastest running dimension within the block.
- depthAxisTensor: A scalar tensor that contains the axis that defines the destination dimension, where to copy the blocks.
- blockSize: The size of the square spatial sub-block.
- usePixelShuffleOrder: A parameter that controls the layout of the sub-blocks within the depth dimension.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn depthToSpace2DTensor_widthAxis_heightAxis_depthAxis_blockSize_usePixelShuffleOrder_name(
&self,
tensor: &MPSGraphTensor,
width_axis: NSUInteger,
height_axis: NSUInteger,
depth_axis: NSUInteger,
block_size: NSUInteger,
use_pixel_shuffle_order: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn depthToSpace2DTensor_widthAxis_heightAxis_depthAxis_blockSize_usePixelShuffleOrder_name( &self, tensor: &MPSGraphTensor, width_axis: NSUInteger, height_axis: NSUInteger, depth_axis: NSUInteger, block_size: NSUInteger, use_pixel_shuffle_order: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a depth-to-space2D operation and returns the result tensor.
This operation outputs a copy of the input tensor, where values from the
depthAxis
dimension are moved in spatial blocks of size blockSize
to the
heightAxis
and widthAxis
dimensions. Use the usePixelShuffleOrder
parameter
to control how the data within spatial blocks is ordered in the
depthAxis
dimension: with usePixelShuffleOrder = YES
MPSGraph stores the values
of the spatial block contiguosly within the depthAxis
dimension, whereas
without it they are stored interleaved with existing values in the depthAxisTensor
dimension.
This operation is the inverse of
MPSGraph/spaceToDepth2DTensor:widthAxis:heightAxis:depthAxis:blockSize:usePixelShuffleOrder:name:
.
- Parameters:
- tensor: The input tensor.
- widthAxis: The axis that defines the fastest running dimension within the block.
- heightAxis: The axis that defines the 2nd fastest running dimension within the block.
- depthAxis: The axis that defines the destination dimension, where to copy the blocks.
- blockSize: The size of the square spatial sub-block.
- usePixelShuffleOrder: A parameter that controls the layout of the sub-blocks within the depth dimension.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn depthToSpace2DTensor_widthAxisTensor_heightAxisTensor_depthAxisTensor_blockSize_usePixelShuffleOrder_name(
&self,
tensor: &MPSGraphTensor,
width_axis_tensor: &MPSGraphTensor,
height_axis_tensor: &MPSGraphTensor,
depth_axis_tensor: &MPSGraphTensor,
block_size: NSUInteger,
use_pixel_shuffle_order: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn depthToSpace2DTensor_widthAxisTensor_heightAxisTensor_depthAxisTensor_blockSize_usePixelShuffleOrder_name( &self, tensor: &MPSGraphTensor, width_axis_tensor: &MPSGraphTensor, height_axis_tensor: &MPSGraphTensor, depth_axis_tensor: &MPSGraphTensor, block_size: NSUInteger, use_pixel_shuffle_order: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a depth-to-space2D operation and returns the result tensor.
This operation outputs a copy of the input tensor, where values from the
depthAxisTensor
dimension are moved in spatial blocks of size blockSize
to the
heightAxisTensor
and widthAxisTensor
dimensions. Use the usePixelShuffleOrder
parameter
to control how the data within spatial blocks is ordered in the
depthAxisTensor
dimension: with usePixelShuffleOrder = YES
MPSGraph stores the values
of the spatial block contiguosly within the depthAxisTensor
dimension, whereas
without it they are stored interleaved with existing values in the depthAxisTensor
dimension.
This operation is the inverse of MPSGraph/spaceToDepth2DTensor:widthAxisTensor:heightAxisTensor:depthAxisTensor:blockSize:usePixelShuffleOrder:name:
.
- Parameters:
- tensor: The input tensor.
- widthAxisTensor: A scalar tensor that contains the axis that defines the fastest running dimension within the block.
- heightAxisTensor: A scalar tensor that contains the axis that defines the 2nd fastest running dimension within the block.
- depthAxisTensor: A scalar tensor that contains the axis that defines the destination dimension, where to copy the blocks.
- blockSize: The size of the square spatial sub-block.
- usePixelShuffleOrder: A parameter that controls the layout of the sub-blocks within the depth dimension.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn spaceToBatchTensor_spatialAxes_batchAxis_blockDimensions_usePixelShuffleOrder_name(
&self,
tensor: &MPSGraphTensor,
spatial_axes: &NSArray<NSNumber>,
batch_axis: NSInteger,
block_dimensions: &NSArray<NSNumber>,
use_pixel_shuffle_order: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn spaceToBatchTensor_spatialAxes_batchAxis_blockDimensions_usePixelShuffleOrder_name( &self, tensor: &MPSGraphTensor, spatial_axes: &NSArray<NSNumber>, batch_axis: NSInteger, block_dimensions: &NSArray<NSNumber>, use_pixel_shuffle_order: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a space-to-batch operation and returns the result tensor.
This operation outputs a copy of the input
tensor, where values from the
spatialAxes
(for usePixelShuffleOrder=YES
1,2 or 3 axes supported, otherwise
limited only by MPSNDArray
rank limitations) dimensions are moved in spatial blocks with
rectangular size defined by blockDimensions
to the batchAxis
dimension.
Use the usePixelShuffleOrder
parameter to control how the data within spatial blocks is ordered
in the batchAxis
dimension: with usePixelShuffleOrder=YES
MPSGraph stores
the values of the spatial blocks contiguosly within the batchAxis
dimension, whereas
otherwise they are stored interleaved with existing values in the batchAxis
dimension.
Note: This operation is the inverse of
MPSGraph/batchToSpaceTensor:spatialAxes:batchAxis:blockDimensions:usePixelShuffleOrder:name:
.
Note: This operation is a generalization of
MPSGraph/spaceToDepth2DTensor:widthAxis:heightAxis:depthAxis:blockSize:usePixelShuffleOrder:name:
.
- Parameters:
- tensor: The input tensor.
- spatialAxes: The axes that define the dimensions containing the spatial blocks.
- batchAxis: The axis that defines the destination dimension, where to copy the blocks.
- blockDimensions: An array of numbers that defines the size of the rectangular spatial sub-block.
- usePixelShuffleOrder: A parameter that controls layout of the sub-blocks within the batch dimension.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn spaceToBatchTensor_spatialAxesTensor_batchAxisTensor_blockDimensionsTensor_usePixelShuffleOrder_name(
&self,
tensor: &MPSGraphTensor,
spatial_axes_tensor: &MPSGraphTensor,
batch_axis_tensor: &MPSGraphTensor,
block_dimensions_tensor: &MPSGraphTensor,
use_pixel_shuffle_order: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn spaceToBatchTensor_spatialAxesTensor_batchAxisTensor_blockDimensionsTensor_usePixelShuffleOrder_name( &self, tensor: &MPSGraphTensor, spatial_axes_tensor: &MPSGraphTensor, batch_axis_tensor: &MPSGraphTensor, block_dimensions_tensor: &MPSGraphTensor, use_pixel_shuffle_order: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a space-to-batch operation and returns the result tensor.
This operation outputs a copy of the input
tensor, where values from the
spatialAxesTensor
(for usePixelShuffleOrder=YES
1,2 or 3 axes supported, otherwise
limited only by MPSNDArray
rank limitations) dimensions are moved in spatial blocks with
rectangular size defined by blockDimensionsTensor
to the batchAxisTensor
dimension.
Use the usePixelShuffleOrder
parameter to control how the data within spatial blocks is ordered
in the batchAxisTensor
dimension: with usePixelShuffleOrder=YES
MPSGraph stores
the values of the spatial blocks contiguosly within the batchAxisTensor
dimension, whereas
otherwise they are stored interleaved with existing values in the batchAxisTensor
dimension.
Note: This operation is the inverse of
MPSGraph/batchToSpaceTensor:spatialAxesTensor:batchAxisTensor:blockDimensionsTensor:usePixelShuffleOrder:name:
.
Note: This operation is a generalization of
MPSGraph/spaceToDepth2DTensor:widthAxisTensor:heightAxisTensor:depthAxisTensor:blockSize:usePixelShuffleOrder:name:
.
- Parameters:
- tensor: The input tensor.
- spatialAxesTensor: A tensor that contains the axes that define the dimensions containing the spatial blocks.
- batchAxisTensor: A tensor that contains the axis that defines the destination dimension, where to copy the blocks.
- blockDimensionsTensor: A tensor that defines the size of the rectangular spatial sub-block.
- usePixelShuffleOrder: A parameter that controls layout of the sub-blocks within the batch dimension.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn batchToSpaceTensor_spatialAxes_batchAxis_blockDimensions_usePixelShuffleOrder_name(
&self,
tensor: &MPSGraphTensor,
spatial_axes: &NSArray<NSNumber>,
batch_axis: NSInteger,
block_dimensions: &NSArray<NSNumber>,
use_pixel_shuffle_order: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn batchToSpaceTensor_spatialAxes_batchAxis_blockDimensions_usePixelShuffleOrder_name( &self, tensor: &MPSGraphTensor, spatial_axes: &NSArray<NSNumber>, batch_axis: NSInteger, block_dimensions: &NSArray<NSNumber>, use_pixel_shuffle_order: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a batch-to-space operation and returns the result tensor.
This operation outputs a copy of the input tensor, where values from the
batchAxis
dimension are moved in spatial blocks of size blockDimensions
to the
spatialAxes
dimensions (for usePixelShuffleOrder=YES
1,2 or 3 axes supported,
otherwise limited only by MPSNDArray
rank limitations). Use the usePixelShuffleOrder
parameter
to control how the data within spatial blocks is ordered in the
batchAxis
dimension: with usePixelShuffleOrder = YES
MPSGraph stores
the values of the spatial block contiguosly within the batchAxis
dimension whereas
without it they are stored interleaved with existing values in the batchAxis
dimension.
Note: This operation is the inverse of
MPSGraph/spaceToBatchTensor:spatialAxes:batchAxis:blockDimensions:usePixelShuffleOrder:name:
.
Note: This operation is a generalization of
MPSGraph/depthToSpace2DTensor:widthAxis:heightAxis:depthAxis:blockSize:usePixelShuffleOrder:name:
.
- Parameters:
- tensor: The input tensor.
- spatialAxes: The axes that define the dimensions containing the spatial blocks.
- batchAxis: The axis that defines the destination dimension, where to copy the blocks.
- blockDimensions: An array of numbers that defines the size of the rectangular spatial sub-block.
- usePixelShuffleOrder: A parameter that controls layout of the sub-blocks within the batch dimension.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn batchToSpaceTensor_spatialAxesTensor_batchAxisTensor_blockDimensionsTensor_usePixelShuffleOrder_name(
&self,
tensor: &MPSGraphTensor,
spatial_axes_tensor: &MPSGraphTensor,
batch_axis_tensor: &MPSGraphTensor,
block_dimensions_tensor: &MPSGraphTensor,
use_pixel_shuffle_order: bool,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn batchToSpaceTensor_spatialAxesTensor_batchAxisTensor_blockDimensionsTensor_usePixelShuffleOrder_name( &self, tensor: &MPSGraphTensor, spatial_axes_tensor: &MPSGraphTensor, batch_axis_tensor: &MPSGraphTensor, block_dimensions_tensor: &MPSGraphTensor, use_pixel_shuffle_order: bool, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a batch-to-space operation and returns the result tensor.
This operation outputs a copy of the input tensor, where values from the
batchAxisTensor
dimension are moved in spatial blocks of size blockDimensionsTensor
to the
spatialAxesTensor
dimensions (for usePixelShuffleOrder=YES
1,2 or 3 axes supported,
otherwise limited only by MPSNDArray
rank limitations). Use the usePixelShuffleOrder
parameter
to control how the data within spatial blocks is ordered in the
batchAxisTensor
dimension: with usePixelShuffleOrder = YES
MPSGraph stores
the values of the spatial block contiguosly within the batchAxisTensor
dimension whereas
without it they are stored interleaved with existing values in the batchAxisTensor
dimension.
Note: This operation is the inverse of
MPSGraph/spaceToBatchTensor:spatialAxesTensor:batchAxisTensor:blockDimensionsTensor:usePixelShuffleOrder:name:
.
Note: This operation is a generalization of
MPSGraph/depthToSpace2DTensor:widthAxisTensor:heightAxisTensor:depthAxisTensor:blockSize:usePixelShuffleOrder:name:
.
- Parameters:
- tensor: The input tensor.
- spatialAxesTensor: A tensor that contains the axes that define the dimensions containing the spatial blocks.
- batchAxisTensor: A tensor that contains the axis that defines the destination dimension, where to copy the blocks.
- blockDimensionsTensor: A tensor that defines the size of the rectangular spatial sub-block.
- usePixelShuffleOrder: A parameter that controls layout of the sub-blocks within the batch dimension.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reverseTensor_axesTensor_name(
&self,
tensor: &MPSGraphTensor,
axes_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn reverseTensor_axesTensor_name( &self, tensor: &MPSGraphTensor, axes_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a reverse operation and returns the result tensor.
Reverses a tensor on given axes. Semantics based on TensorFlow reverse op.
- Parameters:
- tensor: The tensor to be reversed.
- axesTensor: A tensor that specifies axes to be reversed (Axes must be unique and within normal axis range).
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reverseTensor_axes_name(
&self,
tensor: &MPSGraphTensor,
axes: &NSArray<NSNumber>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn reverseTensor_axes_name( &self, tensor: &MPSGraphTensor, axes: &NSArray<NSNumber>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a reverse operation and returns the result tensor.
Reverses a tensor on given axes. Semantics based on TensorFlow reverse op.
- Parameters:
- tensor: The tensor to be reversed.
- axes: A tensor that specifies axes to be reversed (Axes must be unique and within normal axis range).
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reverseTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn reverseTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a reverse operation and returns the result tensor.
Reverses a tensor on all axes. Semantics based on TensorFlow reverse op.
- Parameters:
- tensor: The tensor to be reversed.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn flatten2DTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn flatten2DTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a flatten2D operation and returns the result tensor.
Flattens dimensions before axis
to result[0]
and dimensions starting
from axis
to result[1]
and returns a rank-2 tensor as result.
- Parameters:
- tensor: The tensor to be flattened.
- axis: The axis around which to flatten.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn flatten2DTensor_axisTensor_name(
&self,
tensor: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn flatten2DTensor_axisTensor_name( &self, tensor: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a flatten2D operation and returns the result tensor.
Flattens dimensions before axis
to result[0]
and dimensions starting
from axis
to result[1]
and returns a rank-2 tensor as result.
- Parameters:
- tensor: The tensor to be flattened.
- axisTensor: A scalar tensor that contains the axis around which to flatten.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn broadcastTensor_toShape_name(
&self,
tensor: &MPSGraphTensor,
shape: &MPSShape,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn broadcastTensor_toShape_name( &self, tensor: &MPSGraphTensor, shape: &MPSShape, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a broadcast operation and returns the result tensor.
Broadcasts values inside the tensor, starting from the trailing dimensions, to give it the correct shape. This is equivalent to the broadcasting for arithmetic operations when operands have different shapes.
- Parameters:
- tensor: The tensor to be broadcasted
- shape: The shape of the result tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn broadcastTensor_toShapeTensor_name(
&self,
tensor: &MPSGraphTensor,
shape_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn broadcastTensor_toShapeTensor_name( &self, tensor: &MPSGraphTensor, shape_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a broadcast operation and returns the result tensor.
Broadcasts values inside the tensor, starting from the trailing dimensions, to give it the correct shape. This is equivalent to the broadcasting for arithmetic operations when operands have different shapes.
- Parameters:
- tensor: The Tensor to be broadcasted.
- shapeTensor: A rank-1 tensor of type
MPSDataTypeInt32
orMPSDataTypeInt64
that defines the shape of the result tensor. - name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn shapeOfTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn shapeOfTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a shape-of operation and returns the result tensor.
Returns a rank-1 tensor of type MPSDataTypeInt32
with the values of the static shape of the input tensor.
- Parameters:
- tensor: The input tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn castTensor_toType_name(
&self,
tensor: &MPSGraphTensor,
type: MPSDataType,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn castTensor_toType_name( &self, tensor: &MPSGraphTensor, type: MPSDataType, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a cast operation and returns the result tensor.
Returns the input tensor casted to the specied data type.
- Parameters:
- tensor: The input tensor.
- type: The datatype to which MPSGraph casts the input.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn reinterpretCastTensor_toType_name(
&self,
tensor: &MPSGraphTensor,
type: MPSDataType,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn reinterpretCastTensor_toType_name( &self, tensor: &MPSGraphTensor, type: MPSDataType, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a reinterpret cast operation and returns the result tensor.
Returns input tensor (with element type tensor_type
) reinterpreted to element type
passed in with the last dimension scaled by sizeof(tensor_type) / sizeof(type)
.
This operation is endianness agnostic and MPSGraph reinterprets the data with the endianness of the
system.
- Parameters:
- tensor: The input tensor.
- type: The element type of the returned tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn stackTensors_axis_name(
&self,
input_tensors: &NSArray<MPSGraphTensor>,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn stackTensors_axis_name( &self, input_tensors: &NSArray<MPSGraphTensor>, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a stack operation and returns the result tensor.
Stacks all input tensors along axis
into a result tensor of rank + 1
. Tensors must be broadcast
compatible along all dimensions except axis
, and have the same type.
- Parameters:
- inputTensors: The input tensors.
- axis: The dimension to stack tensors into result. Must be in range:
-rank + 1 < = dimension < rank + 1
. - name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn splitTensor_splitSizes_axis_name(
&self,
tensor: &MPSGraphTensor,
split_sizes: &NSArray<NSNumber>,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn splitTensor_splitSizes_axis_name( &self, tensor: &MPSGraphTensor, split_sizes: &NSArray<NSNumber>, axis: NSInteger, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a split operation and returns the result tensor.
Splits the input tensor along axis
into multiple result tensors of size determined by splitSizes
.
Requires that the sum of splitSizes
is equal to the lenth of the input along axis
.
- Parameters:
- tensor: The input tensor.
- splitSizes: The lengths of the result tensors along the split axis.
- axis: The dimension along which MPSGraph splits the input tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn splitTensor_splitSizesTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
split_sizes_tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn splitTensor_splitSizesTensor_axis_name( &self, tensor: &MPSGraphTensor, split_sizes_tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a split operation and returns the result tensor.
Splits the input tensor along axis
into multiple result tensors of size determined by splitSizesTensor
.
Requires that the sum of the elements of splitSizesTensor
is equal to the lenth of the input along axis
.
- Parameters:
- tensor: The input tensor
- splitSizesTensor: The lengths of the result tensors along the split axis.
- axis: The dimension along which MPSGraph splits the input tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn splitTensor_numSplits_axis_name(
&self,
tensor: &MPSGraphTensor,
num_splits: NSUInteger,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn splitTensor_numSplits_axis_name( &self, tensor: &MPSGraphTensor, num_splits: NSUInteger, axis: NSInteger, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a split operation and returns the result tensor.
Splits the input tensor along axis
into numsplits
result tensors of equal size.
Requires that the lenth of the input along axis
is divisible by numSplits
.
- Parameters:
- tensor: The input tensor.
- numSplits: The number of result tensors to split to.
- axis: The dimension along which MPSGraph splits the input tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn squeezeTensor_name(
&self,
tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn squeezeTensor_name( &self, tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a squeeze operation and returns the result tensor.
Squeezes the tensor, removing all dimensions with size 1.
- Parameters:
- tensor: The input tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn squeezeTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn squeezeTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a squeeze operation and returns the result tensor.
Squeezes the tensor, removing a dimension with size 1 at the specified axis. The size of the input tensor must be 1 at the specified axis.
- Parameters:
- tensor: The input tensor.
- axis: The axis to squeeze.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn squeezeTensor_axes_name(
&self,
tensor: &MPSGraphTensor,
axes: &NSArray<NSNumber>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn squeezeTensor_axes_name( &self, tensor: &MPSGraphTensor, axes: &NSArray<NSNumber>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a squeeze operation and returns the result tensor.
Squeezes the tensor, removing dimensions with size 1 at specified axes. The size of the input tensor must be 1 at all specified axes.
- Parameters:
- tensor: The input tensor.
- axes: The axes to squeeze.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn squeezeTensor_axesTensor_name(
&self,
tensor: &MPSGraphTensor,
axes_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn squeezeTensor_axesTensor_name( &self, tensor: &MPSGraphTensor, axes_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a squeeze operation and returns the result tensor.
Squeezes the tensor, removing dimensions with size 1 at specified axes. The size of the input tensor must be 1 at all specified axes.
- Parameters:
- tensor: The input tensor.
- axesTensor: The tensor containing the axes to squeeze.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object
Sourcepub unsafe fn expandDimsOfTensor_axis_name(
&self,
tensor: &MPSGraphTensor,
axis: NSInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn expandDimsOfTensor_axis_name( &self, tensor: &MPSGraphTensor, axis: NSInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates an expand-dimensions operation and returns the result tensor.
Expands the tensor, inserting a dimension with size 1 at the specified axis.
- Parameters:
- tensor: The input tensor.
- axis: The axis to expand.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn expandDimsOfTensor_axes_name(
&self,
tensor: &MPSGraphTensor,
axes: &NSArray<NSNumber>,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn expandDimsOfTensor_axes_name( &self, tensor: &MPSGraphTensor, axes: &NSArray<NSNumber>, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates an expand-dimensions operation and returns the result tensor.
Expands the tensor, inserting dimensions with size 1 at specified axes.
- Parameters:
- tensor: The input tensor.
- axes: The axes to expand.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn expandDimsOfTensor_axesTensor_name(
&self,
tensor: &MPSGraphTensor,
axes_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn expandDimsOfTensor_axesTensor_name( &self, tensor: &MPSGraphTensor, axes_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates an expand-dimensions operation and returns the result tensor.
Expands the tensor, inserting dimensions with size 1 at specified axes.
- Parameters:
- tensor: The input tensor.
- axesTensor: The tensor containing the axes to expand.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn coordinateAlongAxis_withShape_name(
&self,
axis: NSInteger,
shape: &MPSShape,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn coordinateAlongAxis_withShape_name( &self, axis: NSInteger, shape: &MPSShape, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a get-coordindate operation and returns the result tensor.
Creates a tensor of specified shape with value at index [i_0, i_1, ... , i_N] = i_axis
For example,
coordinateAlongAxis(0, withShape=[5]) = [0, 1, 2, 3, 4]
coordinateAlongAxis(0, withShape=[3,2]) = [[0, 0],
[1, 1],
[2, 2]]
- Parameters:
- axis: The coordinate axis an element’s value is set to. Negative values wrap around.
- shape: The shape of the result tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn coordinateAlongAxisTensor_withShape_name(
&self,
axis_tensor: &MPSGraphTensor,
shape: &MPSShape,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.
pub unsafe fn coordinateAlongAxisTensor_withShape_name( &self, axis_tensor: &MPSGraphTensor, shape: &MPSShape, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
and objc2-metal-performance-shaders
only.Creates a get-coordindate operation and returns the result tensor.
See MPSGraph/coordinateAlongAxis:withShape:name:
.
- Parameters:
- axisTensor: A Scalar tensor of type
MPSDataTypeInt32
, that specifies the coordinate axis an element’s value is set to. Negative values wrap around. - shape: The shape of the result tensor.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn coordinateAlongAxis_withShapeTensor_name(
&self,
axis: NSInteger,
shape_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn coordinateAlongAxis_withShapeTensor_name( &self, axis: NSInteger, shape_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a get-coordindate operation and returns the result tensor.
See coordinateAlongAxis:withShape:name:
.
- Parameters:
- axis: The coordinate axis an element’s value is set to. Negative values wrap around.
- shapeTensor: A rank-1 tensor of type
MPSDataTypeInt32
orMPSDataTypeInt64
that defines the shape of the result tensor. - name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn coordinateAlongAxisTensor_withShapeTensor_name(
&self,
axis_tensor: &MPSGraphTensor,
shape_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTensorShapeOps
and MPSGraphTensor
only.
pub unsafe fn coordinateAlongAxisTensor_withShapeTensor_name( &self, axis_tensor: &MPSGraphTensor, shape_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTensorShapeOps
and MPSGraphTensor
only.Creates a get-coordindate operation and returns the result tensor.
See coordinateAlongAxis:withShape:name:
.
- Parameters:
- axisTensor: A Scalar tensor of type
MPSDataTypeInt32
, that specifies the coordinate axis an element’s value is set to. Negative values wrap around. - shapeTensor: A rank-1 tensor of type
MPSDataTypeInt32
orMPSDataTypeInt64
that defines the shape of the result tensor. - name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Source§impl MPSGraph
MPSGraphTopKOps.
impl MPSGraph
MPSGraphTopKOps.
Sourcepub unsafe fn topKWithSourceTensor_k_name(
&self,
source: &MPSGraphTensor,
k: NSUInteger,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphTopKOps
and MPSGraphTensor
only.
pub unsafe fn topKWithSourceTensor_k_name( &self, source: &MPSGraphTensor, k: NSUInteger, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphTopKOps
and MPSGraphTensor
only.Creates a TopK operation and returns the value and indices tensors
Finds the k largest values along the minor dimension of the input. The source must have at least k elements along its minor dimension. The first element of the result array corresponds to the top values, and the second element of the result array corresponds to the indices of the top values.
- Parameters:
- source: Tensor containing source data
- k: The number of largest values to return
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of size 2
Sourcepub unsafe fn topKWithSourceTensor_kTensor_name(
&self,
source: &MPSGraphTensor,
k_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphTopKOps
and MPSGraphTensor
only.
pub unsafe fn topKWithSourceTensor_kTensor_name( &self, source: &MPSGraphTensor, k_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphTopKOps
and MPSGraphTensor
only.Creates a TopK operation and returns the result tensor.
Finds the k largest values along the minor dimension of the input. The source must have at least k elements along its minor dimension. The first element of the result array corresponds to the top values, and the second element of the result array corresponds to the indices of the top values.
- Parameters:
- source: Tensor containing source data.
- kTensor: Tensor of the number of largest values to return.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of size 2.
Sourcepub unsafe fn topKWithSourceTensor_axis_k_name(
&self,
source: &MPSGraphTensor,
axis: NSInteger,
k: NSUInteger,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphTopKOps
and MPSGraphTensor
only.
pub unsafe fn topKWithSourceTensor_axis_k_name( &self, source: &MPSGraphTensor, axis: NSInteger, k: NSUInteger, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphTopKOps
and MPSGraphTensor
only.Creates a TopK operation and returns the value and indices tensors.
Finds the k largest values along the minor dimension of the input. The source must have at least k elements along its minor dimension. The first element of the result array corresponds to the top values, and the second array corresponds to the indices of the top values.
- Parameters:
- source: Tensor containing source data.
- axis: The dimension along which to compute the TopK values.
- k: The number of largest values to return.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of size 2.
Sourcepub unsafe fn bottomKWithSourceTensor_axis_k_name(
&self,
source: &MPSGraphTensor,
axis: NSInteger,
k: NSUInteger,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphTopKOps
and MPSGraphTensor
only.
pub unsafe fn bottomKWithSourceTensor_axis_k_name( &self, source: &MPSGraphTensor, axis: NSInteger, k: NSUInteger, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphTopKOps
and MPSGraphTensor
only.Creates a BottomK operation and returns the value and indices tensors.
Finds the k smallest values along the minor dimension of the input. The source must have at least k elements along its minor dimension. The first element of the result array corresponds to the bottom values, and the second array corresponds to the indices of the bottom values.
- Parameters:
- source: Tensor containing source data.
- axis: The dimension along which to compute the BottomK values.
- k: The number of largest values to return.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of size 2.
Sourcepub unsafe fn topKWithSourceTensor_axisTensor_kTensor_name(
&self,
source: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
k_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphTopKOps
and MPSGraphTensor
only.
pub unsafe fn topKWithSourceTensor_axisTensor_kTensor_name( &self, source: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, k_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphTopKOps
and MPSGraphTensor
only.Creates a TopK operation and returns the result tensor.
Finds the k largest values along the minor dimension of the input. The source must have at least k elements along its minor dimension. The first element of the result array corresponds to the top values, and the second array corresponds to the indices of the top values.
- Parameters:
- source: Tensor containing source data.
- axisTensor: Tensor containing the dimension along which to compute the TopK values.
- kTensor: Tensor of the number of largest values to return.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of size 2.
Sourcepub unsafe fn bottomKWithSourceTensor_axisTensor_kTensor_name(
&self,
source: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
k_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<NSArray<MPSGraphTensor>>
Available on crate features MPSGraphTopKOps
and MPSGraphTensor
only.
pub unsafe fn bottomKWithSourceTensor_axisTensor_kTensor_name( &self, source: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, k_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<NSArray<MPSGraphTensor>>
MPSGraphTopKOps
and MPSGraphTensor
only.Creates a BottomK operation and returns the result tensor.
Finds the k smallest values along the minor dimension of the input. The source must have at least k elements along its minor dimension. The first element of the result array corresponds to the bottom values, and the second array corresponds to the indices of the bottom values.
- Parameters:
- source: Tensor containing source data.
- axisTensor: Tensor containing the dimension along which to compute the BottomK values.
- kTensor: Tensor of the number of largest values to return.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor array of size 2.
Source§impl MPSGraph
MPSGraphTopKGradientOps.
impl MPSGraph
MPSGraphTopKGradientOps.
Sourcepub unsafe fn topKWithGradientTensor_source_k_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
k: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTopKOps
and MPSGraphTensor
only.
pub unsafe fn topKWithGradientTensor_source_k_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, k: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTopKOps
and MPSGraphTensor
only.Creates a TopKGradient operation and returns the result tensor.
Finds the K largest values along the minor dimension of the input. The input must have at least K elements along its minor dimension.
- Parameters:
- gradient: Tensor containing the incoming gradient.
- source: Tensor containing source data.
- k: The number of largest values to return.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn topKWithGradientTensor_source_axis_k_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
axis: NSInteger,
k: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTopKOps
and MPSGraphTensor
only.
pub unsafe fn topKWithGradientTensor_source_axis_k_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, axis: NSInteger, k: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTopKOps
and MPSGraphTensor
only.Creates a TopKGradient operation and returns the result tensor.
Finds the K largest values along the minor dimension of the input. The input must have at least K elements along its minor dimension.
- Parameters:
- gradient: Tensor containing the incoming gradient.
- source: Tensor containing source data.
- axis: The dimension along which to compute the TopK values..
- k: The number of largest values to return.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn bottomKWithGradientTensor_source_axis_k_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
axis: NSInteger,
k: NSUInteger,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTopKOps
and MPSGraphTensor
only.
pub unsafe fn bottomKWithGradientTensor_source_axis_k_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, axis: NSInteger, k: NSUInteger, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTopKOps
and MPSGraphTensor
only.Creates a BottomKGradient operation and returns the result tensor.
Finds the K smallest values along the minor dimension of the input. The input must have at least K elements along its minor dimension.
- Parameters:
- gradient: Tensor containing the incoming gradient.
- source: Tensor containing source data.
- axis: The dimension along which to compute the BottomK values.
- k: The number of largest values to return.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn topKWithGradientTensor_source_kTensor_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
k_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTopKOps
and MPSGraphTensor
only.
pub unsafe fn topKWithGradientTensor_source_kTensor_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, k_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTopKOps
and MPSGraphTensor
only.Creates a TopKGradient operation and returns the result tensor.
Finds the K largest values along the minor dimension of the input. The input must have at least K elements along its minor dimension.
- Parameters:
- gradient: Tensor containing the incoming gradient.
- source: Tensor containing source data.
- kTensor: Tensor of the number of largest values to return.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn topKWithGradientTensor_source_axisTensor_kTensor_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
k_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTopKOps
and MPSGraphTensor
only.
pub unsafe fn topKWithGradientTensor_source_axisTensor_kTensor_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, k_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTopKOps
and MPSGraphTensor
only.Creates a TopKGradient operation and returns the result tensor.
Finds the K largest values along the minor dimension of the input. The input must have at least K elements along its minor dimension.
- Parameters:
- gradient: Tensor containing the incoming gradient.
- source: Tensor containing source data.
- axisTensor: Tensor containing the dimension along which to compute the TopK values.
- kTensor: Tensor of the number of largest values to return.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Sourcepub unsafe fn bottomKWithGradientTensor_source_axisTensor_kTensor_name(
&self,
gradient: &MPSGraphTensor,
source: &MPSGraphTensor,
axis_tensor: &MPSGraphTensor,
k_tensor: &MPSGraphTensor,
name: Option<&NSString>,
) -> Retained<MPSGraphTensor>
Available on crate features MPSGraphTopKOps
and MPSGraphTensor
only.
pub unsafe fn bottomKWithGradientTensor_source_axisTensor_kTensor_name( &self, gradient: &MPSGraphTensor, source: &MPSGraphTensor, axis_tensor: &MPSGraphTensor, k_tensor: &MPSGraphTensor, name: Option<&NSString>, ) -> Retained<MPSGraphTensor>
MPSGraphTopKOps
and MPSGraphTensor
only.Creates a BottomKGradient operation and returns the result tensor.
Finds the K smallest values along the minor dimension of the input. The input must have at least K elements along its minor dimension.
- Parameters:
- gradient: Tensor containing the incoming gradient.
- source: Tensor containing source data.
- axisTensor: Tensor containing the dimension along which to compute the BottomK values.
- kTensor: Tensor of the number of largest values to return.
- name: The name for the operation.
- Returns: A valid MPSGraphTensor object.
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
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());
Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
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.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
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<MPSGraphObject> for MPSGraph
impl AsRef<MPSGraphObject> for MPSGraph
Source§fn as_ref(&self) -> &MPSGraphObject
fn as_ref(&self) -> &MPSGraphObject
Source§impl Borrow<MPSGraphObject> for MPSGraph
impl Borrow<MPSGraphObject> for MPSGraph
Source§fn borrow(&self) -> &MPSGraphObject
fn borrow(&self) -> &MPSGraphObject
Source§impl ClassType for MPSGraph
impl ClassType for MPSGraph
Source§const NAME: &'static str = "MPSGraph"
const NAME: &'static str = "MPSGraph"
Source§type Super = MPSGraphObject
type Super = MPSGraphObject
Source§type ThreadKind = <<MPSGraph as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<MPSGraph as ClassType>::Super as ClassType>::ThreadKind
Source§impl NSObjectProtocol for MPSGraph
impl NSObjectProtocol for MPSGraph
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass
directly, or cast your objects with AnyObject::downcast_ref