Open a file for reading.
46{
49 return fail(
"set_layout() must describe the tensors before open()");
50 }
51
56 }
57 m_file.seekg(0, std::ios::end);
58 const auto file_size =
static_cast<uint64_t
>(
m_file.tellg());
59
60 uint64_t cursor = 0;
62 const uint64_t begin = entry.file_offset.value_or(cursor);
63 const auto range = entry.spec.byte_range();
64 if (!range ||
range->second > file_size || begin > file_size -
range->second) {
66 return fail(
"tensor '" + entry.spec.name +
"' extends past the end of the file");
67 }
69 cursor = begin +
range->second;
70 }
71
74 return true;
75}
static std::string resolve_path(const std::string &filepath)
Resolve a filepath against the project source root if not found as-is.
std::vector< RawTensorEntry > m_layout
std::vector< uint64_t > m_offsets
void close() override
Close the currently open file.
bool fail(std::string reason)
Record a failure reason and return false.
std::vector< double > range(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Value range (max - min) per window.