29 std::unordered_map<std::string, core::Tensor> output;
30 output.emplace(
"key", active_keys);
34 std::vector<int64_t>{
static_cast<int64_t
>(values.size())},
36 for (
size_t i = 0; i < values.size(); ++i) {
39 output.emplace(
fmt::format(
"value_{:03d}", i), active_value_i);
44 std::string postfix = ext !=
"npz" ?
".npz" :
"";
45 WriteNpz(file_name + postfix, output);
49 std::unordered_map<std::string, core::Tensor> tensor_map =
63 int64_t n_values = tensor_map.at(
"n_values")[0].Item<int64_t>();
65 std::vector<core::Tensor> arr_input_values;
66 std::vector<core::Dtype> dtypes_value;
67 std::vector<core::SizeVector> element_shapes_value;
69 for (int64_t i = 0; i < n_values; ++i) {
78 arr_input_values.push_back(value_i);
79 dtypes_value.push_back(value_dtype_i);
80 element_shapes_value.push_back(value_element_shape_i);
88 hashmap.Insert(keys, arr_input_values, masks, buf_indices);
filament::Texture::InternalFormat format
std::vector< Tensor > GetValueTensors() const
Tensor GetActiveIndices() const
Tensor GetKeyTensor() const
int64_t GetLength() const
Tensor IndexGet(const std::vector< Tensor > &index_tensors) const
Advanced indexing getter. This will always allocate a new Tensor.
SizeVector GetShape() const
Tensor To(Dtype dtype, bool copy=false) const
void To(const core::Tensor &src, core::Tensor &dst, double scale, double offset)
core::HashMap ReadHashMap(const std::string &file_name)
std::unordered_map< std::string, core::Tensor > ReadNpz(const std::string &file_name)
void WriteHashMap(const std::string &file_name, const core::HashMap &hashmap)
void WriteNpz(const std::string &file_name, const std::unordered_map< std::string, core::Tensor > &tensor_map)
std::string GetFileExtensionInLowerCase(const std::string &filename)
Generic file read and write utility for python interface.