ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
DeviceHashBackend.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
9 
10 #include <Helper.h>
11 #include <Logging.h>
12 
14 
15 namespace cloudViewer {
16 namespace core {
17 
18 std::shared_ptr<DeviceHashBackend> CreateDeviceHashBackend(
19  int64_t init_capacity,
20  const Dtype& key_dtype,
21  const SizeVector& key_element_shape,
22  const std::vector<Dtype>& value_dtypes,
23  const std::vector<SizeVector>& value_element_shapes,
24  const Device& device,
25  const HashBackendType& backend) {
26  if (device.IsCPU()) {
27  return CreateCPUHashBackend(init_capacity, key_dtype, key_element_shape,
28  value_dtypes, value_element_shapes, device,
29  backend);
30  }
31 #if defined(BUILD_CUDA_MODULE)
32  else if (device.IsCUDA()) {
33  return CreateCUDAHashBackend(init_capacity, key_dtype,
34  key_element_shape, value_dtypes,
35  value_element_shapes, device, backend);
36  }
37 #endif
38  else {
39  utility::LogError("Unimplemented device");
40  }
41 }
42 
43 } // namespace core
44 } // namespace cloudViewer
bool IsCUDA() const
Returns true iff device type is CUDA.
Definition: Device.h:49
bool IsCPU() const
Returns true iff device type is CPU.
Definition: Device.h:46
#define LogError(...)
Definition: Logging.h:60
Helper functions for the ml ops.
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.