Struct cv_convert::TensorFromMat[][src]

pub struct TensorFromMat { /* fields omitted */ }
Expand description

A Tensor which data reference borrows from a Mat. It can be dereferenced to a Tensor.

Implementations

Methods from Deref<Target = Tensor>

Returns a pointer to the underlying C++ tensor.

The caller must ensures that the Rust tensor object outlives this pointer.

Returns a mutable pointer to the underlying C++ tensor.

The caller must ensures that the Rust tensor object outlives this pointer.

Returns the number of dimension of the tensor.

Returns the shape of the input tensor.

Returns the tensor size for single dimension tensors.

Returns the tensor sizes for two dimension tensors.

Returns the tensor sizes for three dimension tensors.

Returns the tensor sizes for four dimension tensors.

Returns the tensor sizes for five dimension tensors.

Returns the tensor sizes for six dimension tensors.

Returns the stride of the input tensor.

Returns the tensor strides for single dimension tensors.

Returns the tensor strides for two dimension tensors.

Returns the tensor strides for three dimension tensors.

Returns the tensor strides for four dimension tensors.

Returns the tensor strides for five dimension tensors.

Returns the tensor strides for six dimension tensors.

Returns the kind of elements stored in the input tensor. Returns an error on undefined tensors and unsupported data types.

Returns the kind of elements stored in the input tensor. Panics an error on undefined tensors and unsupported data types.

Returns the device on which the input tensor is located.

Prints the input tensor.

Caution: this uses the C++ printer which prints the whole tensor even if it is very large.

Returns a double value on tensors holding a single element. An error is returned otherwise.

Returns an int value on tensors holding a single element. An error is returned otherwise.

Returns a double value on tensors holding a single element. Panics otherwise.

Returns an int value on tensors holding a single element. Panics otherwise.

Returns true if gradient are currently tracked for this tensor.

Returns the address of the first element of this tensor.

Returns true if the tensor is defined.

Returns true if the tensor is compatible with MKL-DNN (oneDNN).

Returns true if the tensor is sparse.

Zeroes the gradient tensor attached to this tensor if defined.

Runs the backward pass, populating the gradient tensors for tensors which gradients are tracked.

Gradients tracking can be turned on via set_requires_grad.

Runs the backward pass, populating the gradient tensors for tensors which gradients are tracked.

Gradients tracking can be turned on via set_requires_grad. Panics if the C++ api returns an exception.

Copies numel elements from self to dst.

Unscale tensor while checking for infinities.

found_inf is a singleton tensor that is used to record the presence of infinite values. inv_scale is a scalar containing the inverse scaling factor. This method is only available for CUDA tensors.

Unscale tensor while checking for infinities.

found_inf is a singleton tensor that is used to record the presence of infinite values. inv_scale is a scalar containing the inverse scaling factor. This method is only available for CUDA tensors.

Copies numel elements from self to dst.

Copies numel elements from self to dst.

Copies numel elements from self to dst.

Returns the total number of elements stored in a tensor.

Returns a new tensor that share storage with the input tensor.

Gets the sub-tensor at the given index.

Gets the sub-tensor at the given index.

Copies values from the argument tensor to the input tensor.

Copies values from the argument tensor to the input tensor.

Saves a tensor to a file.

The file format is the same as the one used by the PyTorch C++ API.

Returns a string representation for the tensor.

The representation will contain all the tensor element hence may be huge for large tensors.

Writes a tensor in the npy format so that it can be read using python.

Casts a tensor to a specified kind.

Computes the cross-entropy loss based on some logits and targets.

Returns the average accuracy for some given logits assuming that targets represent ground-truth.

Moves a tensor to a specified device.

Flattens a tensor.

This returns a flattened version of the given tensor. The first dimension is preserved as it is assumed to be the mini-batch dimension.

Converts a tensor to a one-hot encoded version.

If the input has a size [N1, N2, …, Nk], the returned tensor has a size [N1, …, Nk, labels]. The returned tensor uses float values. Elements of the input vector are expected to be between 0 and labels-1.

Copies a tensor to a newly allocated tensor using the same shape and device.

Re-initializes the tensor using the specified initialization.

Trait Implementations

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.