43 const std::vector<int64_t>& value_dsizes,
57 virtual void Reserve(int64_t capacity) = 0;
60 virtual void Insert(
const void* input_keys,
61 const std::vector<const void*>& input_values,
67 virtual void Find(
const void* input_keys,
73 virtual void Erase(
const void* input_keys,
81 virtual void Clear() = 0;
84 virtual int64_t
Size()
const = 0;
99 virtual std::vector<int64_t>
BucketSizes()
const = 0;
110 virtual void Allocate(int64_t capacity) = 0;
111 virtual void Free() = 0;
129 int64_t init_capacity,
130 const Dtype& key_dtype,
132 const std::vector<Dtype>& value_dtypes,
133 const std::vector<SizeVector>& value_element_shapes,
138 int64_t init_capacity,
139 const Dtype& key_dtype,
141 const std::vector<Dtype>& value_dtypes,
142 const std::vector<SizeVector>& value_element_shapes,
147 int64_t init_capacity,
148 const Dtype& key_dtype,
150 const std::vector<Dtype>& value_dtypes,
151 const std::vector<SizeVector>& value_element_shapes,
std::shared_ptr< HashBackendBuffer > buffer_
Definition: DeviceHashBackend.h:121
virtual void Erase(const void *input_keys, bool *output_masks, int64_t count)=0
Parallel erase a contiguous array of keys.
virtual std::vector< int64_t > BucketSizes() const =0
Get the number of entries per bucket.
virtual void Find(const void *input_keys, buf_index_t *output_buf_indices, bool *output_masks, int64_t count)=0
Parallel find a contiguous array of keys.
virtual int64_t Size() const =0
Get the size (number of valid entries) of the hash map.
std::vector< int64_t > value_dsizes_
Definition: DeviceHashBackend.h:117
HashBackendType
Definition: HashMap.h:38
Tensor GetValueBuffer(size_t i=0)
Get the i-th value buffer that store an actual value array.
Definition: DeviceHashBackend.h:108
virtual int64_t GetActiveIndices(buf_index_t *output_buf_indices)=0
Parallel collect all iterators in the hash table.
Device device_
Definition: DeviceHashBackend.h:119
std::shared_ptr< DeviceHashBackend > CreateCPUHashBackend(int64_t init_capacity, const Dtype &key_dtype, const SizeVector &key_element_shape, const std::vector< Dtype > &value_dtypes, const std::vector< SizeVector > &value_element_shapes, const Device &device, const HashBackendType &backend)
Non-templated factory.
Definition: CreateCPUHashBackend.cpp:35
Definition: SizeVector.h:79
uint32_t buf_index_t
Definition: HashBackendBuffer.h:63
int64_t key_dsize_
Definition: DeviceHashBackend.h:116
virtual ~DeviceHashBackend()
Definition: DeviceHashBackend.h:49
int64_t capacity_
Definition: DeviceHashBackend.h:114
Device GetDevice() const
Get the current device.
Definition: DeviceHashBackend.h:96
Tensor GetKeyBuffer()
Get the key buffer that stores actual keys.
Definition: DeviceHashBackend.h:102
int64_t GetCapacity() const
Get the maximum capacity of the hash map.
Definition: DeviceHashBackend.h:93
virtual float LoadFactor() const =0
Get the current load factor, defined as size / bucket count.
std::shared_ptr< DeviceHashBackend > CreateDeviceHashBackend(int64_t init_capacity, const Dtype &key_dtype, const SizeVector &key_element_shape, const std::vector< Dtype > &value_dtypes, const std::vector< SizeVector > &value_element_shapes, const Device &device, const HashBackendType &backend)
Definition: DeviceHashBackend.cpp:36
Definition: PinholeCameraIntrinsic.cpp:35
virtual int64_t GetBucketCount() const =0
Get the number of buckets of the hash map.
Definition: DeviceHashBackend.h:39
std::shared_ptr< DeviceHashBackend > CreateCUDAHashBackend(int64_t init_capacity, const Dtype &key_dtype, const SizeVector &key_element_shape, const std::vector< Dtype > &value_dtypes, const std::vector< SizeVector > &value_element_shapes, const Device &device, const HashBackendType &backend)
virtual void Allocate(int64_t capacity)=0
DeviceHashBackend(int64_t init_capacity, int64_t key_dsize, const std::vector< int64_t > &value_dsizes, const Device &device)
Definition: DeviceHashBackend.h:41
virtual void Reserve(int64_t capacity)=0
virtual void Clear()=0
Clear stored map without reallocating memory.
virtual void Insert(const void *input_keys, const std::vector< const void *> &input_values, buf_index_t *output_buf_indices, bool *output_masks, int64_t count)=0
Parallel insert contiguous arrays of keys and values.
std::vector< Tensor > GetValueBuffers()
Get the value buffers that store actual array of values.
Definition: DeviceHashBackend.h:105