ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnkit::support::onnx::TensorSet Class Referencefinal

#include <TensorSet.h>

Public Member Functions

 TensorSet (Allocator *allocator, size_t nums)
 
 ~TensorSet (void)
 
void set (size_t index, const std::string &name, ONNXTensorElementDataType type, const std::vector< size_t > &dims)
 
size_t size (void)
 
const char * name (size_t index)
 
const std::vector< std::string > & names (void)
 
ONNXTensorElementDataType type (size_t index)
 
const std::vector< size_t > & dim (size_t index)
 
const OrtValue * tensor (size_t index)
 
const std::vector< OrtValue * > & tensors (void)
 
OrtValue * mutable_tensor (size_t index)
 
std::vector< OrtValue * > mutable_tensors (void)
 

Detailed Description

Definition at line 36 of file TensorSet.h.

Constructor & Destructor Documentation

◆ TensorSet()

nnkit::support::onnx::TensorSet::TensorSet ( Allocator allocator,
size_t  nums 
)
inline

Definition at line 39 of file TensorSet.h.

40 : _allocator(allocator), _names(nums), _types(nums), _dims(nums), _tensors(nums, nullptr)
41 {
42 // DO NOTHING
43 }

◆ ~TensorSet()

nnkit::support::onnx::TensorSet::~TensorSet ( void  )
inline

Definition at line 45 of file TensorSet.h.

46 {
47 for (auto it : _tensors)
48 {
49 OrtReleaseValue(it);
50 }
51 }

Member Function Documentation

◆ dim()

const std::vector< size_t > & nnkit::support::onnx::TensorSet::dim ( size_t  index)
inline

Definition at line 76 of file TensorSet.h.

76{ return _dims[index]; }
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54

Referenced by nnkit::support::onnx::TensorContext::shape().

◆ mutable_tensor()

OrtValue * nnkit::support::onnx::TensorSet::mutable_tensor ( size_t  index)
inline

◆ mutable_tensors()

std::vector< OrtValue * > nnkit::support::onnx::TensorSet::mutable_tensors ( void  )
inline

Definition at line 82 of file TensorSet.h.

82{ return _tensors; }

◆ name()

const char * nnkit::support::onnx::TensorSet::name ( size_t  index)
inline

Definition at line 71 of file TensorSet.h.

71{ return _names[index].c_str(); }

Referenced by nnkit::support::onnx::TensorContext::name(), and set().

◆ names()

const std::vector< std::string > & nnkit::support::onnx::TensorSet::names ( void  )
inline

Definition at line 72 of file TensorSet.h.

72{ return _names; }

◆ set()

void nnkit::support::onnx::TensorSet::set ( size_t  index,
const std::string &  name,
ONNXTensorElementDataType  type,
const std::vector< size_t > &  dims 
)
inline

Definition at line 53 of file TensorSet.h.

55 {
56 _names[index] = name;
57 _types[index] = type;
58 _dims[index] = dims;
59
60 Status status;
61
62 status =
63 OrtCreateTensorAsOrtValue(_allocator, dims.data(), dims.size(), type, &_tensors[index]);
64 status.throwOnError();
65
66 assert(OrtIsTensor(_tensors[index]));
67 }
const char * name(size_t index)
Definition TensorSet.h:71
ONNXTensorElementDataType type(size_t index)
Definition TensorSet.h:74

References name(), nnkit::support::onnx::Status::throwOnError(), and type().

◆ size()

size_t nnkit::support::onnx::TensorSet::size ( void  )
inline

Definition at line 69 of file TensorSet.h.

69{ return _names.size(); }

Referenced by nnkit::support::onnx::TensorContext::size().

◆ tensor()

const OrtValue * nnkit::support::onnx::TensorSet::tensor ( size_t  index)
inline

Definition at line 78 of file TensorSet.h.

78{ return _tensors[index]; }

◆ tensors()

const std::vector< OrtValue * > & nnkit::support::onnx::TensorSet::tensors ( void  )
inline

Definition at line 79 of file TensorSet.h.

79{ return _tensors; }

◆ type()

ONNXTensorElementDataType nnkit::support::onnx::TensorSet::type ( size_t  index)
inline

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