ONE - On-device Neural Engine
Loading...
Searching...
No Matches
circle_eval_diff::HDF5Loader Class Referencefinal

#include <InputDataLoader.h>

Collaboration diagram for circle_eval_diff::HDF5Loader:

Public Member Functions

 HDF5Loader (const std::string &file_path, const std::vector< loco::Node * > &input_nodes)
 
uint32_t size (void) const final
 
Data get (uint32_t data_idx) const final
 
- Public Member Functions inherited from circle_eval_diff::InputDataLoader
virtual ~InputDataLoader ()=default
 

Additional Inherited Members

- Public Types inherited from circle_eval_diff::InputDataLoader
using Data = std::vector< Tensor >
 

Detailed Description

Definition at line 63 of file InputDataLoader.h.

Constructor & Destructor Documentation

◆ HDF5Loader()

circle_eval_diff::HDF5Loader::HDF5Loader ( const std::string &  file_path,
const std::vector< loco::Node * > &  input_nodes 
)

Definition at line 98 of file InputDataLoader.cpp.

99 : _input_nodes{input_nodes}
100{
101 try
102 {
103 using HDF5Importer = dio::hdf5::HDF5Importer;
104
105 _hdf5 = std::make_unique<HDF5Importer>(file_path);
106 _hdf5->importGroup("value");
107 }
108 catch (const H5::Exception &e)
109 {
110 H5::Exception::printErrorStack();
111 throw std::runtime_error("HDF5 error occurred.");
112 }
113}
std::vector< Node * > input_nodes(const Graph *)
Definition Graph.cpp:71

Member Function Documentation

◆ get()

InputDataLoader::Data circle_eval_diff::HDF5Loader::get ( uint32_t  data_idx) const
finalvirtual

Implements circle_eval_diff::InputDataLoader.

Definition at line 117 of file InputDataLoader.cpp.

118{
119 Data data;
120 data.resize(_input_nodes.size());
121
122 for (uint32_t input_idx = 0; input_idx < _input_nodes.size(); input_idx++)
123 {
124 auto input_node = loco::must_cast<luci::CircleInput *>(_input_nodes.at(input_idx));
125 assert(input_node->index() == input_idx);
126
127 data.at(input_idx) = *createEmptyTensor(input_node).get();
128
129 auto input_buffer = data.at(input_idx).buffer();
130 const auto input_buffer_bytes = data.at(input_idx).byte_size();
131
132 try
133 {
134 if (_hdf5->isRawData())
135 {
136 _hdf5->readTensor(data_idx, input_idx, input_buffer, input_buffer_bytes);
137 }
138 else
139 {
141 Shape shape;
142 _hdf5->readTensor(data_idx, input_idx, &dtype, &shape, input_buffer, input_buffer_bytes);
143
144 // Check the type and the shape of the input data is valid
145 verifyTypeShape(input_node, dtype, shape);
146 }
147 }
148 catch (const H5::Exception &e)
149 {
150 H5::Exception::printErrorStack();
151 throw std::runtime_error("HDF5 error occurred.");
152 }
153 }
154
155 return data;
156}
void index(const loco::GraphInputIndex &index)
std::shared_ptr< Tensor > createEmptyTensor(const luci::CircleNode *node)
Definition Tensor.cpp:90
void verifyTypeShape(const luci::CircleInput *input_node, const DataType &dtype, const Shape &shape)
DataType
"scalar" value type
Definition DataType.h:27
CircleInput * input_node(loco::Graph *g, const loco::GraphInputIndex &index)
Find a Pull node with a given input index.
Definition Shape.h:28

References circle_eval_diff::createEmptyTensor(), luci::CircleInput::index(), and circle_eval_diff::verifyTypeShape().

◆ size()

uint32_t circle_eval_diff::HDF5Loader::size ( void  ) const
finalvirtual

Implements circle_eval_diff::InputDataLoader.

Definition at line 115 of file InputDataLoader.cpp.

115{ return _hdf5->numData(); }

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