Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
DEMO
Loading...
Searching...
No Matches
signet::forge::OwnedTensor Class Reference

An owning tensor that manages its own memory via a std::vector<uint8_t> buffer. More...

#include <tensor_bridge.hpp>

Public Member Functions

 OwnedTensor ()=default
 Default constructor: creates an invalid (empty) tensor.
 
 OwnedTensor (TensorShape shape, TensorDataType dtype)
 Allocate an uninitialized tensor with the given shape and type.
 
 OwnedTensor (const void *data, TensorShape shape, TensorDataType dtype)
 Allocate and copy data into the tensor.
 
 OwnedTensor (OwnedTensor &&) noexcept=default
 
OwnedTensoroperator= (OwnedTensor &&) noexcept=default
 
 OwnedTensor (const OwnedTensor &)=delete
 
OwnedTensoroperator= (const OwnedTensor &)=delete
 
OwnedTensor clone () const
 Deep-copy this tensor.
 
TensorView view ()
 Get a mutable non-owning view.
 
TensorView view () const
 Get a const non-owning view.
 
void * data () noexcept
 Raw mutable pointer to the tensor buffer.
 
const void * data () const noexcept
 Raw const pointer to the tensor buffer.
 
template<typename T >
T * typed_data () noexcept
 Typed mutable pointer to the tensor buffer.
 
template<typename T >
const T * typed_data () const noexcept
 Typed const pointer to the tensor buffer.
 
const TensorShapeshape () const noexcept
 The shape of this tensor.
 
TensorDataType dtype () const noexcept
 The element data type.
 
size_t byte_size () const noexcept
 Total byte size of the tensor buffer.
 
int64_t num_elements () const noexcept
 Total number of elements.
 
bool is_valid () const noexcept
 True if the tensor has been allocated (non-empty buffer).
 

Detailed Description

An owning tensor that manages its own memory via a std::vector<uint8_t> buffer.

Move-only; use clone() for explicit deep copies.

Provides the same access interface as TensorView. Obtain a non-owning view via view() for passing to functions that accept TensorView.

Definition at line 531 of file tensor_bridge.hpp.

Constructor & Destructor Documentation

◆ OwnedTensor() [1/5]

signet::forge::OwnedTensor::OwnedTensor ( )
default

Default constructor: creates an invalid (empty) tensor.

◆ OwnedTensor() [2/5]

signet::forge::OwnedTensor::OwnedTensor ( TensorShape  shape,
TensorDataType  dtype 
)
inline

Allocate an uninitialized tensor with the given shape and type.

Definition at line 537 of file tensor_bridge.hpp.

◆ OwnedTensor() [3/5]

signet::forge::OwnedTensor::OwnedTensor ( const void *  data,
TensorShape  shape,
TensorDataType  dtype 
)
inline

Allocate and copy data into the tensor.

Parameters
dataPointer to source data (must contain at least shape.num_elements() * tensor_element_size(dtype) bytes).
shapeShape of the tensor.
dtypeElement type.

Definition at line 556 of file tensor_bridge.hpp.

◆ OwnedTensor() [4/5]

signet::forge::OwnedTensor::OwnedTensor ( OwnedTensor &&  )
defaultnoexcept

◆ OwnedTensor() [5/5]

signet::forge::OwnedTensor::OwnedTensor ( const OwnedTensor )
delete

Member Function Documentation

◆ byte_size()

size_t signet::forge::OwnedTensor::byte_size ( ) const
inlinenoexcept

Total byte size of the tensor buffer.

Definition at line 628 of file tensor_bridge.hpp.

◆ clone()

OwnedTensor signet::forge::OwnedTensor::clone ( ) const
inline

Deep-copy this tensor.

Definition at line 580 of file tensor_bridge.hpp.

◆ data() [1/2]

const void * signet::forge::OwnedTensor::data ( ) const
inlinenoexcept

Raw const pointer to the tensor buffer.

Definition at line 606 of file tensor_bridge.hpp.

◆ data() [2/2]

void * signet::forge::OwnedTensor::data ( )
inlinenoexcept

Raw mutable pointer to the tensor buffer.

Definition at line 604 of file tensor_bridge.hpp.

◆ dtype()

TensorDataType signet::forge::OwnedTensor::dtype ( ) const
inlinenoexcept

The element data type.

Definition at line 625 of file tensor_bridge.hpp.

◆ is_valid()

bool signet::forge::OwnedTensor::is_valid ( ) const
inlinenoexcept

True if the tensor has been allocated (non-empty buffer).

Definition at line 636 of file tensor_bridge.hpp.

◆ num_elements()

int64_t signet::forge::OwnedTensor::num_elements ( ) const
inlinenoexcept

Total number of elements.

Definition at line 631 of file tensor_bridge.hpp.

◆ operator=() [1/2]

OwnedTensor & signet::forge::OwnedTensor::operator= ( const OwnedTensor )
delete

◆ operator=() [2/2]

OwnedTensor & signet::forge::OwnedTensor::operator= ( OwnedTensor &&  )
defaultnoexcept

◆ shape()

const TensorShape & signet::forge::OwnedTensor::shape ( ) const
inlinenoexcept

The shape of this tensor.

Definition at line 623 of file tensor_bridge.hpp.

◆ typed_data() [1/2]

template<typename T >
const T * signet::forge::OwnedTensor::typed_data ( ) const
inlinenoexcept

Typed const pointer to the tensor buffer.

Template Parameters
TElement type (must match dtype()).

Definition at line 618 of file tensor_bridge.hpp.

◆ typed_data() [2/2]

template<typename T >
T * signet::forge::OwnedTensor::typed_data ( )
inlinenoexcept

Typed mutable pointer to the tensor buffer.

Template Parameters
TElement type (must match dtype()).

Definition at line 611 of file tensor_bridge.hpp.

◆ view() [1/2]

TensorView signet::forge::OwnedTensor::view ( )
inline

Get a mutable non-owning view.

Definition at line 591 of file tensor_bridge.hpp.

◆ view() [2/2]

TensorView signet::forge::OwnedTensor::view ( ) const
inline

Get a const non-owning view.

Definition at line 596 of file tensor_bridge.hpp.


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