docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
sdfg::types::Tensor Class Reference

#include <sdfg/types/tensor.h>

Inheritance diagram for sdfg::types::Tensor:
[legend]

Public Member Functions

 Tensor (const Scalar &element_type, const symbolic::MultiExpression &shape)
 Tensor (const Scalar &element_type, const math::tensor::TensorLayout &layout)
 Tensor (const Scalar &element_type, const symbolic::MultiExpression &shape, const symbolic::MultiExpression &strides, const symbolic::Expression &offset=symbolic::zero())
 Tensor (StorageType storage_type, size_t alignment, const std::string &initializer, const Scalar &element_type, const math::tensor::TensorLayout &layout)
 Tensor (StorageType storage_type, size_t alignment, const std::string &initializer, const Scalar &element_type, const symbolic::MultiExpression &shape, const symbolic::MultiExpression &strides, const symbolic::Expression &offset=symbolic::zero())
virtual PrimitiveType primitive_type () const override
 Returns the primitive type for this type.
virtual TypeID type_id () const override
 Returns the TypeID for runtime type identification.
virtual bool is_symbol () const override
 Checks if this type represents a symbolic/integer type.
bool is_pointer_like () const override
 Checks if this is a pointer or a structure behaves like a pointer.
const Scalar & element_type () const
const math::tensor::TensorLayout & layout () const
const symbolic::MultiExpression & shape () const
const symbolic::MultiExpression & strides () const
const symbolic::Expression & offset () const
symbolic::Expression total_elements () const
symbolic::Expression total_size () const
bool is_scalar () const
bool is_contiguous () const
bool is_tight () const
virtual bool operator== (const IType &other) const override
 Compares two types for equality.
virtual std::unique_ptr< IType > clone () const override
 Creates a deep copy of this type.
virtual std::string print () const override
 Returns a string representation of this type.
std::unique_ptr< Tensor > newaxis (size_t axis) const
std::unique_ptr< Tensor > flip (size_t axis) const
std::unique_ptr< Tensor > unsqueeze (size_t axis) const
std::unique_ptr< Tensor > squeeze (size_t axis) const
std::unique_ptr< Tensor > squeeze () const
std::unique_ptr< Tensor > reshape (const symbolic::MultiExpression &new_shape) const
std::unique_ptr< Tensor > broadcast (const symbolic::MultiExpression &ref_shape) const
 Broadcast this tensor to a bigger shape with strides correctly set.
virtual void replace_symbols (const symbolic::Expression old_expression, const symbolic::Expression new_expression) override
 Replace symbolic expressions on this type.
virtual void replace_symbols (const symbolic::ExpressionMapping &replacements) override
Public Member Functions inherited from sdfg::types::IType
 IType (StorageType storage_type=StorageType::CPU_Stack(), size_t alignment=0, const std::string &initializer="")
 Constructs an IType with optional storage, alignment, and initializer.
virtual ~IType ()=default
 Virtual destructor for proper cleanup of derived classes.
StorageType storage_type () const
 Gets the storage type (const version).
StorageType & storage_type ()
 Gets the storage type (mutable reference).
void storage_type (const StorageType &storage_type)
 Sets the storage type.
size_t alignment () const
 Gets the alignment requirement in bytes.
void alignment (size_t alignment)
 Sets the alignment requirement in bytes.
std::string initializer () const
 Gets the initializer expression.
void initializer (const std::string &initializer)
 Sets the initializer expression.

Static Public Member Functions

static symbolic::MultiExpression strides_from_shape (const symbolic::MultiExpression &shape)

Additional Inherited Members

Protected Attributes inherited from sdfg::types::IType
StorageType storage_type_
 Where and how the data is stored.
size_t alignment_
 Memory alignment requirement in bytes.
std::string initializer_
 Optional initializer expression.

Constructor & Destructor Documentation

◆ Tensor() [1/5]

sdfg::types::Tensor::Tensor ( const Scalar & element_type,
const symbolic::MultiExpression & shape )
Deprecated
use TensorLayout

◆ Tensor() [2/5]

sdfg::types::Tensor::Tensor ( const Scalar & element_type,
const math::tensor::TensorLayout & layout )

◆ Tensor() [3/5]

sdfg::types::Tensor::Tensor ( const Scalar & element_type,
const symbolic::MultiExpression & shape,
const symbolic::MultiExpression & strides,
const symbolic::Expression & offset = symbolic::zero() )
Deprecated
use TensorLayout

◆ Tensor() [4/5]

sdfg::types::Tensor::Tensor ( StorageType storage_type,
size_t alignment,
const std::string & initializer,
const Scalar & element_type,
const math::tensor::TensorLayout & layout )

◆ Tensor() [5/5]

sdfg::types::Tensor::Tensor ( StorageType storage_type,
size_t alignment,
const std::string & initializer,
const Scalar & element_type,
const symbolic::MultiExpression & shape,
const symbolic::MultiExpression & strides,
const symbolic::Expression & offset = symbolic::zero() )
Deprecated
use TensorLayout

Member Function Documentation

◆ broadcast()

std::unique_ptr< Tensor > sdfg::types::Tensor::broadcast ( const symbolic::MultiExpression & ref_shape) const

Broadcast this tensor to a bigger shape with strides correctly set.

◆ clone()

virtual std::unique_ptr< IType > sdfg::types::Tensor::clone ( ) const
overridevirtual

Creates a deep copy of this type.

Returns
A unique pointer to a new type object with the same properties

Implements sdfg::types::IType.

◆ element_type()

const Scalar & sdfg::types::Tensor::element_type ( ) const

◆ flip()

std::unique_ptr< Tensor > sdfg::types::Tensor::flip ( size_t axis) const

◆ is_contiguous()

bool sdfg::types::Tensor::is_contiguous ( ) const
Returns
True iff the strides are basic strides

◆ is_pointer_like()

bool sdfg::types::Tensor::is_pointer_like ( ) const
inlineoverridevirtual

Checks if this is a pointer or a structure behaves like a pointer.

Some structures may have pointer-like semantics in certain contexts.

Implements sdfg::types::IType.

◆ is_scalar()

bool sdfg::types::Tensor::is_scalar ( ) const

◆ is_symbol()

virtual bool sdfg::types::Tensor::is_symbol ( ) const
overridevirtual

Checks if this type represents a symbolic/integer type.

Symbolic types are integer types that can be used in symbolic expressions and loop bounds.

Returns
true if this is a symbolic integer type, false otherwise

Implements sdfg::types::IType.

◆ is_tight()

bool sdfg::types::Tensor::is_tight ( ) const
Returns
True iff contiguous and offset is zero

◆ layout()

const math::tensor::TensorLayout & sdfg::types::Tensor::layout ( ) const

◆ newaxis()

std::unique_ptr< Tensor > sdfg::types::Tensor::newaxis ( size_t axis) const

◆ offset()

const symbolic::Expression & sdfg::types::Tensor::offset ( ) const
Deprecated
use TensorLayout

◆ operator==()

virtual bool sdfg::types::Tensor::operator== ( const IType & other) const
overridevirtual

Compares two types for equality.

Parameters
otherThe type to compare with
Returns
true if the types are equal, false otherwise

Implements sdfg::types::IType.

◆ primitive_type()

virtual PrimitiveType sdfg::types::Tensor::primitive_type ( ) const
overridevirtual

Returns the primitive type for this type.

For scalar types, this returns the actual primitive type. For composite types (arrays, pointers, etc.), this returns the primitive type of the innermost element.

Returns
The primitive type

Implements sdfg::types::IType.

◆ print()

virtual std::string sdfg::types::Tensor::print ( ) const
overridevirtual

Returns a string representation of this type.

Returns
A human-readable string describing this type

Implements sdfg::types::IType.

◆ replace_symbols() [1/2]

virtual void sdfg::types::Tensor::replace_symbols ( const symbolic::Expression old_expression,
const symbolic::Expression new_expression )
overridevirtual

Replace symbolic expressions on this type.

Parameters
old_expressionExpression to replace
new_expressionReplacement expression

Replaces occurrences of symbolic expressions on the type.

Implements sdfg::types::IType.

◆ replace_symbols() [2/2]

virtual void sdfg::types::Tensor::replace_symbols ( const symbolic::ExpressionMapping & replacements)
overridevirtual

Implements sdfg::types::IType.

◆ reshape()

std::unique_ptr< Tensor > sdfg::types::Tensor::reshape ( const symbolic::MultiExpression & new_shape) const

◆ shape()

const symbolic::MultiExpression & sdfg::types::Tensor::shape ( ) const
Deprecated
use TensorLayout

◆ squeeze() [1/2]

std::unique_ptr< Tensor > sdfg::types::Tensor::squeeze ( ) const

◆ squeeze() [2/2]

std::unique_ptr< Tensor > sdfg::types::Tensor::squeeze ( size_t axis) const

◆ strides()

const symbolic::MultiExpression & sdfg::types::Tensor::strides ( ) const
Deprecated
use TensorLayout

◆ strides_from_shape()

symbolic::MultiExpression sdfg::types::Tensor::strides_from_shape ( const symbolic::MultiExpression & shape)
static

◆ total_elements()

symbolic::Expression sdfg::types::Tensor::total_elements ( ) const

◆ total_size()

symbolic::Expression sdfg::types::Tensor::total_size ( ) const

◆ type_id()

virtual TypeID sdfg::types::Tensor::type_id ( ) const
overridevirtual

Returns the TypeID for runtime type identification.

Returns
The TypeID enum value for this type

Implements sdfg::types::IType.

◆ unsqueeze()

std::unique_ptr< Tensor > sdfg::types::Tensor::unsqueeze ( size_t axis) const

The documentation for this class was generated from the following file: