tensor.h#
Defines
-
define_data(type, field)#
-
namespace ONNX_LIGHT_NAMESPACE
Functions
-
struct Tensor#
- #include <tensor.h>
Stores an in-memory tensor payload and metadata.
Represents the ONNX tensor fields used by the lightweight parser, including dimensions, element type, typed repeated values, raw bytes, optional segment information, and external-data metadata.
Public Functions
-
inline int64_t elem_num() const#
Returns the total number of elements.
-
inline int64_t size_from_dim(int dim) const#
Returns the number of elements from a given dimension to the end.
- Parameters:
dim – Dimension index, supports negative indexing from the back.
-
inline int32_t elem_type() const#
Returns the ONNX element type.
-
inline int32_t &elem_type()#
Returns mutable access to the ONNX element type.
-
inline void set_raw_data(std::string raw_data)#
Sets raw tensor bytes and marks the tensor as raw-backed.
- Parameters:
raw_data – Raw tensor payload.
-
template<typename T>
T *data()# Returns a mutable pointer to typed tensor data.
- Template Parameters:
T – Element type to access.
-
template<typename T>
const T *data() const# Returns a const pointer to typed tensor data.
- Template Parameters:
T – Element type to access.
-
inline bool is_segment() const#
Returns whether a segment is defined.
-
inline int64_t segment_begin() const#
Returns the inclusive segment begin index.
-
inline int64_t segment_end() const#
Returns the exclusive segment end index.
-
inline void set_segment_begin_and_end(int64_t begin, int64_t end)#
Sets segment bounds and marks the segment as present.
- Parameters:
begin – Inclusive begin index.
end – Exclusive end index.
-
inline bool hasName() const#
Returns whether the tensor name is set.
-
inline bool is_raw_data() const#
Returns whether tensor values are stored as raw bytes.
-
inline const std::vector<std::pair<std::string, std::string>> &external_data() const#
Returns external-data entries.
-
inline std::vector<std::pair<std::string, std::string>> &external_data()#
Returns mutable external-data entries.
-
inline bool has_data_location() const#
Returns whether the data location differs from the default.
-
inline const ONNX_LIGHT_NAMESPACE::TensorProto::DataLocation &data_location() const#
Returns the tensor data location.
-
inline ONNX_LIGHT_NAMESPACE::TensorProto::DataLocation &data_location()#
Returns mutable access to the tensor data location.
-
template<>
inline float *data()# doc
-
template<>
inline const float *data() const#
-
template<>
inline double *data()# doc
-
template<>
inline const double *data() const#
-
template<>
inline int32_t *data()# doc
-
template<>
inline const int32_t *data() const#
-
template<>
inline int64_t *data()# doc
-
template<>
inline const int64_t *data() const#
-
template<>
inline uint64_t *data()# doc
-
template<>
inline const uint64_t *data() const#
Private Members
-
bool is_segment_ = {false}#
-
int64_t segment_begin_ = {0}#
-
int64_t segment_end_ = {0}#
-
bool has_name_ = {false}#
-
int32_t elem_type_ = {static_cast<int32_t>(ONNX_LIGHT_NAMESPACE::TensorProto::DataType::UNDEFINED)}#
-
bool is_raw_data_ = {false}#
-
ONNX_LIGHT_NAMESPACE::TensorProto::DataLocation data_location_{ONNX_LIGHT_NAMESPACE::TensorProto::DEFAULT}#
-
inline int64_t elem_num() const#
-
struct Tensor#