Function deepviewrt_sys::nn_tensor_offset
source · pub unsafe extern "C" fn nn_tensor_offset(
tensor: *const NNTensor,
n_dims: i32,
shape: *const i32
) -> c_intExpand description
Returns the offset of a given tensor. This function can be used to calculate the index across numerous dimensions.
@note Avoid using this function as part of inner loops as it requires a multiply and add for each dimenions. Instead it can be used in an outer loop to get the starting index then increment this index in the inner loop, possibly using the tensor strides.
@param tensor the tensor object used in the operation @param n_dims the number of dimensions provided in the @p shape @param shape the multi-dimensional index used to calculate the linear index
@return the element index into the tensor based on the muliple dimenional indices provided.
@public @memberof NNTensor @since 2.0