| 115 | uint32_t HDF5Loader::size(void) const { return _hdf5->numData(); } |
| 116 | |
| 117 | InputDataLoader::Data HDF5Loader::get(uint32_t data_idx) const |
| 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 | { |
| 140 | DataType dtype; |
| 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 | } |
| 157 | |
| 158 | DirectoryLoader::DirectoryLoader(const std::string &dir_path, |
| 159 | const std::vector<loco::Node *> &input_nodes) |