NEML2 2.1.0
Loading...
Searching...
No Matches

#include <Tensor.h>

Inheritance diagram for Tensor:

Public Member Functions

 Tensor ()=default
 Special member functions.
 Tensor (const ATensor &tensor, Size dynamic_dim, Size intmd_dim=0)
 Construct from another ATensor with inferred dynamic shape.
 Tensor (const ATensor &tensor, const TraceableTensorShape &dynamic_shape, Size intmd_dim=0)
 Construct from another ATensor with given dynamic shape.
template<class Derived>
 Tensor (const TensorBase< Derived > &tensor)
 Copy from TensorBase.
Public Member Functions inherited from TensorBase< Tensor >
 TensorBase ()=default
 Default constructor.
Tensor variable_data () const
 Variable data without function graph.
Tensor contiguous () const
Tensor clone () const
 Clone (take ownership).
Tensor detach () const
 Discard function graph.
Tensor to (const TensorOptions &options) const
 Change tensor options.
Tensor operator- () const
 Negation.
Size batch_dim () const
Size base_dim () const
Size dynamic_dim () const
Size static_dim () const
Size intmd_dim () const
TraceableTensorShape batch_sizes () const
TensorShapeRef base_sizes () const
const TraceableTensorShapedynamic_sizes () const
TensorShapeRef static_sizes () const
TensorShapeRef intmd_sizes () const
TraceableSize batch_size (Size i) const
Size base_size (Size i) const
const TraceableSizedynamic_size (Size i) const
Size static_size (Size i) const
Size intmd_size (Size i) const
Tensor dynamic_index (indexing::TensorIndicesRef indices) const
Tensor intmd_index (indexing::TensorIndicesRef indices) const
neml2::Tensor base_index (indexing::TensorIndicesRef indices) const
Tensor batch_index (indexing::TensorIndicesRef indices) const
Tensor dynamic_slice (Size d, const indexing::Slice &index) const
Tensor intmd_slice (Size d, const indexing::Slice &index) const
neml2::Tensor base_slice (Size d, const indexing::Slice &index) const
Tensor batch_slice (Size d, const indexing::Slice &index) const
void dynamic_index_put_ (indexing::TensorIndicesRef indices, const ATensor &other)
void intmd_index_put_ (indexing::TensorIndicesRef indices, const ATensor &other)
void base_index_put_ (indexing::TensorIndicesRef indices, const ATensor &other)
void batch_index_put_ (indexing::TensorIndicesRef indices, const ATensor &other)
Tensor dynamic_expand (const TraceableTensorShape &shape) const
Tensor intmd_expand (TensorShapeRef shape) const
neml2::Tensor base_expand (TensorShapeRef shape) const
Tensor batch_expand (const TraceableTensorShape &dynamic_shape, TensorShapeRef intmd_shape={}) const
neml2::Tensor static_expand (TensorShapeRef intmd_shape, TensorShapeRef base_shape) const
Tensor dynamic_expand_as (const neml2::Tensor &other) const
Tensor intmd_expand_as (const neml2::Tensor &other) const
neml2::Tensor base_expand_as (const neml2::Tensor &other) const
Tensor batch_expand_as (const neml2::Tensor &other) const
neml2::Tensor static_expand_as (const neml2::Tensor &other) const
Tensor dynamic_reshape (const TraceableTensorShape &shape) const
Tensor intmd_reshape (TensorShapeRef shape) const
neml2::Tensor base_reshape (TensorShapeRef shape) const
Tensor batch_reshape (const TraceableTensorShape &dynamic_shape, TensorShapeRef intmd_shape={}) const
neml2::Tensor static_reshape (TensorShapeRef intmd_shape, TensorShapeRef base_shape) const
Tensor dynamic_squeeze (Size d) const
Tensor intmd_squeeze (Size d) const
neml2::Tensor base_squeeze (Size d) const
Tensor batch_squeeze (Size d) const
Tensor dynamic_unsqueeze (Size d, Size n=1) const
Tensor intmd_unsqueeze (Size d, Size n=1) const
neml2::Tensor base_unsqueeze (Size d, Size n=1) const
Tensor batch_unsqueeze (Size d, Size n=1) const
Tensor dynamic_transpose (Size d1, Size d2) const
Tensor intmd_transpose (Size d1, Size d2) const
neml2::Tensor base_transpose (Size d1, Size d2) const
Tensor batch_transpose (Size d1, Size d2) const
Tensor dynamic_movedim (Size old_dim, Size new_dim) const
Tensor intmd_movedim (Size old_dim, Size new_dim) const
neml2::Tensor base_movedim (Size old_dim, Size new_dim) const
Tensor batch_movedim (Size old_dim, Size new_dim) const
Tensor dynamic_flatten (Size start_dim=0, Size end_dim=-1) const
Tensor intmd_flatten (Size start_dim=0, Size end_dim=-1) const
neml2::Tensor base_flatten (Size start_dim=0, Size end_dim=-1) const
Tensor batch_flatten () const
 Flatten batch dimensions.
neml2::Tensor static_flatten () const
 Flatten static dimensions.

Static Public Member Functions

static Tensor create (const TensorDataContainer &data, const TensorOptions &options=default_tensor_options())
 Arbitrary (unbatched) tensor from a nested container.
static Tensor create (const TensorDataContainer &data, Size dynamic_dim, Size intmd_dim=0, const TensorOptions &options=default_tensor_options())
 Arbitrary tensor from a nested container.
static Tensor identity (Size n, const TensorOptions &options=default_tensor_options())
 Identity tensor.
static Tensor empty (TensorShapeRef base_shape, const TensorOptions &options=default_tensor_options())
static Tensor empty (const TraceableTensorShape &dynamic_shape, TensorShapeRef intmd_shape, TensorShapeRef base_shape, const TensorOptions &options=default_tensor_options())
static Tensor zeros (TensorShapeRef base_shape, const TensorOptions &options=default_tensor_options())
static Tensor zeros (const TraceableTensorShape &dynamic_shape, TensorShapeRef intmd_shape, TensorShapeRef base_shape, const TensorOptions &options=default_tensor_options())
static Tensor ones (TensorShapeRef base_shape, const TensorOptions &options=default_tensor_options())
static Tensor ones (const TraceableTensorShape &dynamic_shape, TensorShapeRef intmd_shape, TensorShapeRef base_shape, const TensorOptions &options=default_tensor_options())
static Tensor full (TensorShapeRef base_shape, const CScalar &init, const TensorOptions &options=default_tensor_options())
static Tensor full (const TraceableTensorShape &dynamic_shape, TensorShapeRef intmd_shape, TensorShapeRef base_shape, const CScalar &init, const TensorOptions &options=default_tensor_options())
static Tensor rand (TensorShapeRef base_shape, const TensorOptions &options=default_tensor_options())
static Tensor rand (const TraceableTensorShape &dynamic_shape, TensorShapeRef intmd_shape, TensorShapeRef base_shape, const TensorOptions &options=default_tensor_options())
Static Public Member Functions inherited from TensorBase< Tensor >
static Tensor empty_like (const Tensor &other)
static Tensor zeros_like (const Tensor &other)
 Zero tensor like another, i.e. same batch and base shapes, same tensor options, etc.
static Tensor ones_like (const Tensor &other)
 Unit tensor like another, i.e. same batch and base shapes, same tensor options, etc.
static Tensor full_like (const Tensor &other, const CScalar &init)
static Tensor rand_like (const Tensor &other)

Additional Inherited Members

Protected Member Functions inherited from TensorBase< Tensor >
void validate_shapes_and_dims () const
 Validate shapes and dimensions.

Constructor & Destructor Documentation

◆ Tensor() [1/4]

Tensor ( )
default

Special member functions.

◆ Tensor() [2/4]

Tensor ( const ATensor & tensor,
Size dynamic_dim,
Size intmd_dim = 0 )

Construct from another ATensor with inferred dynamic shape.

◆ Tensor() [3/4]

Tensor ( const ATensor & tensor,
const TraceableTensorShape & dynamic_shape,
Size intmd_dim = 0 )

Construct from another ATensor with given dynamic shape.

◆ Tensor() [4/4]

template<class Derived>
Tensor ( const TensorBase< Derived > & tensor)
inline

Copy from TensorBase.

Member Function Documentation

◆ create() [1/2]

Tensor create ( const TensorDataContainer & data,
const TensorOptions & options = default_tensor_options() )
staticnodiscard

Arbitrary (unbatched) tensor from a nested container.

◆ create() [2/2]

Tensor create ( const TensorDataContainer & data,
Size dynamic_dim,
Size intmd_dim = 0,
const TensorOptions & options = default_tensor_options() )
staticnodiscard

Arbitrary tensor from a nested container.

◆ empty() [1/2]

Tensor empty ( const TraceableTensorShape & dynamic_shape,
TensorShapeRef intmd_shape,
TensorShapeRef base_shape,
const TensorOptions & options = default_tensor_options() )
staticnodiscard

◆ empty() [2/2]

Tensor empty ( TensorShapeRef base_shape,
const TensorOptions & options = default_tensor_options() )
staticnodiscard

Empty tensor filled with undefined values

◆ full() [1/2]

Tensor full ( const TraceableTensorShape & dynamic_shape,
TensorShapeRef intmd_shape,
TensorShapeRef base_shape,
const CScalar & init,
const TensorOptions & options = default_tensor_options() )
staticnodiscard

◆ full() [2/2]

Tensor full ( TensorShapeRef base_shape,
const CScalar & init,
const TensorOptions & options = default_tensor_options() )
staticnodiscard

Tensor filled with a given value

◆ identity()

Tensor identity ( Size n,
const TensorOptions & options = default_tensor_options() )
staticnodiscard

Identity tensor.

◆ ones() [1/2]

Tensor ones ( const TraceableTensorShape & dynamic_shape,
TensorShapeRef intmd_shape,
TensorShapeRef base_shape,
const TensorOptions & options = default_tensor_options() )
staticnodiscard

◆ ones() [2/2]

Tensor ones ( TensorShapeRef base_shape,
const TensorOptions & options = default_tensor_options() )
staticnodiscard

Tensor filled with ones

◆ rand() [1/2]

Tensor rand ( const TraceableTensorShape & dynamic_shape,
TensorShapeRef intmd_shape,
TensorShapeRef base_shape,
const TensorOptions & options = default_tensor_options() )
staticnodiscard

◆ rand() [2/2]

Tensor rand ( TensorShapeRef base_shape,
const TensorOptions & options = default_tensor_options() )
staticnodiscard

Tensor filled with random values from a uniform distribution [0, 1)

◆ zeros() [1/2]

Tensor zeros ( const TraceableTensorShape & dynamic_shape,
TensorShapeRef intmd_shape,
TensorShapeRef base_shape,
const TensorOptions & options = default_tensor_options() )
staticnodiscard

◆ zeros() [2/2]

Tensor zeros ( TensorShapeRef base_shape,
const TensorOptions & options = default_tensor_options() )
staticnodiscard

Tensor filled with zeros