18 class DeviceHashBackend;
26 const Dtype& key_dtype,
28 const Dtype& value_dtype,
37 const Dtype& key_dtype,
39 const std::vector<Dtype>& dtypes_value,
40 const std::vector<SizeVector>& element_shapes_value,
58 std::pair<Tensor, Tensor>
Insert(
const Tensor& input_keys,
59 const Tensor& input_values);
65 std::pair<Tensor, Tensor>
Insert(
67 const std::vector<Tensor>& input_values_soa);
80 std::pair<Tensor, Tensor>
Find(
const Tensor& input_keys);
96 const Tensor& input_values,
97 Tensor& output_buf_indices,
104 const std::vector<Tensor>& input_values_soa,
105 Tensor& output_buf_indices,
112 Tensor& output_buf_indices,
119 Tensor& output_buf_indices,
137 void Save(
const std::string& file_name);
150 int64_t
Size()
const;
184 return device_hashmap_;
188 void Init(int64_t init_capacity,
193 const std::vector<Tensor>& input_values_soa,
194 Tensor& output_buf_indices,
196 bool is_activate_op =
false);
201 const std::vector<Tensor>& input_values_soa)
const;
204 const std::vector<Tensor>& input_values_soa)
const;
212 std::shared_ptr<DeviceHashBackend> device_hashmap_;
217 std::vector<Dtype> dtypes_value_;
218 std::vector<SizeVector> element_shapes_value_;
bool copy
Definition: VtkUtils.cpp:73
HashMap Clone() const
Clone the hash map with buffers.
Definition: HashMap.cpp:226
std::vector< Tensor > GetValueTensors() const
Definition: HashMap.cpp:274
void CheckKeyLength(const Tensor &input_keys) const
Definition: HashMap.cpp:356
void CheckKeyCompatibility(const Tensor &input_keys) const
Definition: HashMap.cpp:382
void CheckValueCompatibility(const std::vector< Tensor > &input_values_soa) const
Definition: HashMap.cpp:397
void PrepareIndicesOutput(Tensor &output_buf_indices, int64_t length) const
Definition: HashMap.cpp:428
~HashMap()=default
Default destructor.
int64_t GetCapacity() const
Get the capacity of the hash map.
Definition: HashMap.cpp:257
float LoadFactor() const
Return size / bucket_count.
Definition: HashMap.cpp:316
void Save(const std::string &file_name)
Definition: HashMap.cpp:218
static HashMap Load(const std::string &file_name)
Definition: HashMap.cpp:222
int64_t GetBucketCount() const
Get the number of buckets of the internal hash map.
Definition: HashMap.cpp:259
Tensor GetKeyTensor() const
Definition: HashMap.cpp:265
void PrepareMasksOutput(Tensor &output_masks, int64_t length) const
Definition: HashMap.cpp:437
HashMap(int64_t init_capacity, const Dtype &key_dtype, const SizeVector &key_element_shape, const Dtype &value_dtype, const SizeVector &value_element_shapes, const Device &device, const HashBackendType &backend=HashBackendType::Default)
Initialize a hash map given a key and a value dtype and element shape.
Definition: HashMap.cpp:19
std::pair< int64_t, std::vector< int64_t > > GetCommonValueSizeDivisor()
Device GetDevice() const override
Get the device of the hash map.
Definition: HashMap.cpp:263
std::shared_ptr< DeviceHashBackend > GetDeviceHashBackend() const
Return the implementation of the device hash backend.
Definition: HashMap.h:183
std::pair< Tensor, Tensor > Insert(const Tensor &input_keys, const Tensor &input_values)
Definition: HashMap.cpp:79
std::pair< Tensor, Tensor > Find(const Tensor &input_keys)
Definition: HashMap.cpp:99
std::pair< Tensor, Tensor > Activate(const Tensor &input_keys)
Definition: HashMap.cpp:93
Tensor GetValueTensor(size_t index=0) const
Definition: HashMap.cpp:293
void Init(int64_t init_capacity, const Device &device, const HashBackendType &backend)
Definition: HashMap.cpp:318
int64_t Size() const
Get the size (number of active entries) of the hash map.
Definition: HashMap.cpp:255
void CheckKeyValueLengthCompatibility(const Tensor &input_keys, const std::vector< Tensor > &input_values_soa) const
Definition: HashMap.cpp:363
Tensor Erase(const Tensor &input_keys)
Definition: HashMap.cpp:105
HashMap To(const Device &device, bool copy=false) const
Convert the hash map to another device.
Definition: HashMap.cpp:228
void Reserve(int64_t capacity)
Reserve the internal hash map with the given capacity by rehashing.
Definition: HashMap.cpp:47
void InsertImpl(const Tensor &input_keys, const std::vector< Tensor > &input_values_soa, Tensor &output_buf_indices, Tensor &output_masks, bool is_activate_op=false)
Definition: HashMap.cpp:117
std::vector< int64_t > BucketSizes() const
Return number of elements per bucket.
Definition: HashMap.cpp:312
void Clear()
Clear stored map without reallocating the buffers.
Definition: HashMap.cpp:216
Tensor GetActiveIndices() const
Definition: HashMap.cpp:111
Definition: SizeVector.h:69
HashBackendType
Definition: HashMap.h:20
Definition: PinholeCameraIntrinsic.cpp:16