24 const std::vector<int64_t>& value_dsizes,
38 virtual void Reserve(int64_t capacity) = 0;
41 virtual void Insert(
const void* input_keys,
42 const std::vector<const void*>& input_values,
48 virtual void Find(
const void* input_keys,
54 virtual void Erase(
const void* input_keys,
65 virtual int64_t
Size()
const = 0;
110 int64_t init_capacity,
111 const Dtype& key_dtype,
113 const std::vector<Dtype>& value_dtypes,
114 const std::vector<SizeVector>& value_element_shapes,
119 int64_t init_capacity,
120 const Dtype& key_dtype,
122 const std::vector<Dtype>& value_dtypes,
123 const std::vector<SizeVector>& value_element_shapes,
128 int64_t init_capacity,
129 const Dtype& key_dtype,
131 const std::vector<Dtype>& value_dtypes,
132 const std::vector<SizeVector>& value_element_shapes,
std::vector< Tensor > GetValueBuffers()
Get the value buffers that store actual array of values.
virtual int64_t GetBucketCount() const =0
Get the number of buckets of the hash map.
virtual void Erase(const void *input_keys, bool *output_masks, int64_t count)=0
Parallel erase a contiguous array of keys.
virtual void Reserve(int64_t capacity)=0
virtual int64_t GetActiveIndices(buf_index_t *output_buf_indices)=0
Parallel collect all iterators in the hash table.
virtual ~DeviceHashBackend()
virtual void Allocate(int64_t capacity)=0
std::shared_ptr< HashBackendBuffer > buffer_
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.
Tensor GetValueBuffer(size_t i=0)
Get the i-th value buffer that store an actual value array.
Tensor GetKeyBuffer()
Get the key buffer that stores actual keys.
virtual void Clear()=0
Clear stored map without reallocating memory.
virtual int64_t Size() const =0
Get the size (number of valid entries) of the hash map.
Device GetDevice() const
Get the current device.
std::vector< int64_t > value_dsizes_
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.
DeviceHashBackend(int64_t init_capacity, int64_t key_dsize, const std::vector< int64_t > &value_dsizes, const Device &device)
int64_t GetCapacity() const
Get the maximum capacity of the hash map.
virtual float LoadFactor() const =0
Get the current load factor, defined as size / bucket count.
virtual std::vector< int64_t > BucketSizes() const =0
Get the number of entries per bucket.
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.
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)
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)
Generic file read and write utility for python interface.