23 const Dtype& key_dtype,
42 std::pair<Tensor, Tensor>
Insert(
const Tensor& input_keys);
48 std::pair<Tensor, Tensor>
Find(
const Tensor& input_keys);
64 Tensor& output_buf_indices,
71 Tensor& output_buf_indices,
88 void Save(
const std::string& file_name);
100 int64_t
Size()
const;
127 std::shared_ptr<HashMap> internal_;
void Save(const std::string &file_name)
std::pair< Tensor, Tensor > Find(const Tensor &input_keys)
int64_t Size() const
Get the size (number of active entries) of the hash set.
void Clear()
Clear stored map without reallocating the buffers.
Tensor GetKeyTensor() const
HashSet(int64_t init_capacity, const Dtype &key_dtype, const SizeVector &key_element_shape, const Device &device, const HashBackendType &backend=HashBackendType::Default)
Initialize a hash set given a key dtype and element shape.
static HashSet Load(const std::string &file_name)
Load active keys and values from a npz file that contains 'key'.
void Reserve(int64_t capacity)
Reserve the internal hash map with the capcity by rehashing.
int64_t GetBucketCount() const
Get the number of buckets of the internal hash set.
std::shared_ptr< DeviceHashBackend > GetDeviceHashBackend() const
Return the implementation of the device hash backend.
~HashSet()=default
Default destructor.
int64_t GetCapacity() const
Get the capacity of the hash set.
Tensor GetActiveIndices() const
float LoadFactor() const
Return size / bucket_count.
std::pair< Tensor, Tensor > Insert(const Tensor &input_keys)
HashSet To(const Device &device, bool copy=false) const
Convert the hash set to another device.
HashSet Clone() const
Clone the hash set with buffers.
std::vector< int64_t > BucketSizes() const
Return number of elements per bucket.
Tensor Erase(const Tensor &input_keys)
Device GetDevice() const override
Get the device of the hash set.
Generic file read and write utility for python interface.