cloudViewer.core.HashMap#

class cloudViewer.core.HashMap#

A HashMap is a map from key to data wrapped by Tensors.

__init__(*args, **kwargs)#

Overloaded function.

  1. __init__(self, init_capacity, key_dtype, key_element_shape, value_dtype, value_element_shape, device=Device(“CPU”, 0))

Parameters:
  1. __init__(self, init_capacity, key_dtype, key_element_shape, value_dtypes, value_element_shapes, device=Device(“CPU”, 0))

Parameters:
activate(self, keys)#

Activate an array of keys stored in Tensors without copying values.

Parameters:

keys (cloudViewer.core.Tensor) – Input keys stored in a tensor of shape (N, key_element_shape).

Returns:

tuple

active_buf_indices(self: cloudViewer.core.HashMap) cloudViewer.core.Tensor#

Get the buffer indices corresponding to active entries in the hash map.

capacity(self: cloudViewer.core.HashMap) int#

Get the capacity of the hash map.

clone(self: cloudViewer.core.HashMap) cloudViewer.core.HashMap#

Clone the hash map, including the data structure and the data buffers.

cpu(self: cloudViewer.core.HashMap) cloudViewer.core.HashMap#

Transfer the hash map to CPU. If the hash map is already on CPU, no copy will be performed.

cuda(self, device_id=0)#

Transfer the hash map to a CUDA device. If the hash map is already on the specified CUDA device, no copy will be performed.

Parameters:

device_id (SupportsInt, optional, default=0) – Target CUDA device ID.

Returns:

cloudViewer.core.HashMap

erase(self, keys)#

Erase an array of keys stored in Tensors.

Parameters:

keys (cloudViewer.core.Tensor) – Input keys stored in a tensor of shape (N, key_element_shape).

Returns:

cloudViewer.core.Tensor

find(self, keys)#

Find an array of keys stored in Tensors.

Parameters:

keys (cloudViewer.core.Tensor) – Input keys stored in a tensor of shape (N, key_element_shape).

Returns:

tuple

insert(*args, **kwargs)#

Overloaded function.

  1. insert(self, keys, values)

    Insert an array of keys and an array of values stored in Tensors.

Parameters:
Returns:

tuple

  1. insert(self, keys, list_values)

    Insert an array of keys and a list of value arrays stored in Tensors.

Parameters:
Returns:

tuple

key_tensor(self: cloudViewer.core.HashMap) cloudViewer.core.Tensor#

Get the key tensor stored in the buffer.

static load(file_name)#

Load a hash map from a .npz file.

Parameters:

file_name (str) – File name of the corresponding .npz file.

Returns:

cloudViewer.core.HashMap

reserve(self, capacity)#

Reserve the hash map given the capacity.

Parameters:

capacity (SupportsInt) – New capacity for rehashing.

Returns:

None

save(self, file_name)#

Save the hash map into a .npz file.

Parameters:

file_name (str) – File name of the corresponding .npz file.

Returns:

None

size(self: cloudViewer.core.HashMap) int#

Get the size of the hash map.

to(self, device, copy=False)#

Convert the hash map to a selected device.

Parameters:
  • device (cloudViewer.core.Device) – Compute device to store and operate on the hash container.

  • copy (bool, optional, default=False) – If true, a new tensor is always created; if false, the copy is avoided when the original tensor already has the targeted dtype.

Returns:

cloudViewer.core.HashMap

value_tensor(*args, **kwargs)#

Overloaded function.

  1. value_tensor(self)

    Get the value tensor stored at index 0.

Returns:

cloudViewer.core.Tensor

  1. value_tensor(self, value_buffer_id)

    Get the value tensor stored at index i

Parameters:

value_buffer_id (SupportsInt) –

Returns:

cloudViewer.core.Tensor

value_tensors(self: cloudViewer.core.HashMap) list[cloudViewer.core.Tensor]#

Get the list of value tensors stored in the buffer.

property device#
property is_cpu#
property is_cuda#