Skip to main content

M_newTensorSpec

Function M_newTensorSpec 

Source
pub unsafe extern "C" fn M_newTensorSpec(
    shape: *const i64,
    rankSize: i64,
    dtype: M_Dtype,
    tensorName: *const c_char,
    device: *const M_Device,
) -> *mut M_TensorSpec
Expand description

Creates a tensor specification.

You need this in order to set the input tensors with M_borrowTensorInto().

When storing tensor data in memory, we always use a diminishing stride size. That is, earlier dimensions in the shape have larger strides than later dimensions. For example, a C array declared as int arr[1][2][3] would have a shape specified as {1, 2, 3}.

@param shape The shape of the tensor. @param rankSize The rank size of the tensor. @param dtype The datatype for the tensor. @param tensorName The name for the tensor. This string gets copied as part of the operation of M_newTensorSpec, so your original string need not remain valid after the completion of this call. @param device The device on which the tensor resides.

@returns A pointer to the tensor spec. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling M_freeTensorSpec().