Macro rten_tensor::tensor
source · macro_rules! tensor { [[$($elem:expr),*]] => { ... }; [[$($elem:expr),*,]] => { ... }; (($($dim:expr),+); [$($elem:expr),*]) => { ... }; (($($dim:expr),+); [$($elem:expr),*,]) => { ... }; ($elem:expr) => { ... }; }
Expand description
Construct a Tensor.
use rten_tensor::tensor;
// Create a scalar (0D tensor)
tensor!(2.);
// Create a vector (1D tensor)
tensor!([1, 2, 3]);
// Create a 3D tensor with shape [1, 2, 2] and elements [1, 2, 3, 4].
tensor!((1, 2, 2); [1, 2, 3, 4]);