Open a NPY file and reads its metadata * * @param[in] npy_filename File to open * @param[in] file_layout (Optional) Layout in which the weights are stored in the file. */
| 312 | * @param[in] file_layout (Optional) Layout in which the weights are stored in the file. |
| 313 | */ |
| 314 | void open(const std::string &npy_filename, DataLayout file_layout = DataLayout::NCHW) |
| 315 | { |
| 316 | ARM_COMPUTE_ERROR_ON(is_open()); |
| 317 | try |
| 318 | { |
| 319 | _fs.open(npy_filename, std::ios::in | std::ios::binary); |
| 320 | ARM_COMPUTE_EXIT_ON_MSG_VAR(!_fs.good(), "Failed to load binary data from %s", npy_filename.c_str()); |
| 321 | _fs.exceptions(std::ifstream::failbit | std::ifstream::badbit); |
| 322 | _file_layout = file_layout; |
| 323 | |
| 324 | npy::header_t header = parse_npy_header(_fs); |
| 325 | _shape = header.shape; |
| 326 | _fortran_order = header.fortran_order; |
| 327 | _typestring = header.dtype.str(); |
| 328 | } |
| 329 | catch (const std::ifstream::failure &e) |
| 330 | { |
| 331 | ARM_COMPUTE_ERROR_VAR("Accessing %s: %s", npy_filename.c_str(), e.what()); |
| 332 | } |
| 333 | } |
| 334 | /** Return true if a NPY file is currently open */ |
| 335 | bool is_open() |
| 336 | { |
no test coverage detected