19#include <ATen/DLConvertor.h>
22#include "torch/script.h"
26namespace torch_bridge {
36inline core::Tensor TorchToOpen3DTensor(
const torch::Tensor&
t) {
50inline torch::Tensor Open3DToTorchTensor(
const core::Tensor&
t) {
61 if (
t.NumElements() == 0) {
63 c10::Device torch_device(c10::kCPU);
65 torch_device = c10::Device(c10::kCUDA, device.
GetID());
66 }
else if (device.
IsSYCL()) {
67 torch_device = c10::Device(c10::kXPU, device.
GetID());
68 }
else if (device.
IsCPU()) {
69 torch_device = c10::Device(c10::kCPU);
72 "Open3DToTorchTensor: unsupported Open3D device ",
77 torch::ScalarType scalar_type;
79 scalar_type = torch::kFloat32;
81 scalar_type = torch::kFloat64;
83 scalar_type = torch::kInt32;
85 scalar_type = torch::kInt64;
87 TORCH_CHECK(
false,
"Open3DToTorchTensor: unsupported Open3D dtype ",
92 std::vector<int64_t> sizes(shape.
begin(), shape.
end());
93 return torch::empty(sizes,
94 torch::dtype(scalar_type).device(torch_device));
98 return at::fromDLPack(dlmt);
double t
Definition SurfaceReconstructionPoisson.cpp:175
bool IsSYCL() const
Returns true iff device type is SYCL GPU.
Definition Device.h:54
int GetID() const
Returns the device index (within the same device type).
Definition Device.h:63
bool IsCPU() const
Returns true iff device type is CPU.
Definition Device.h:48
bool IsCUDA() const
Returns true iff device type is CUDA.
Definition Device.h:51
std::string ToString() const
Returns string representation of device, e.g. "CPU:0", "CUDA:0".
Definition Device.cpp:94
std::string ToString() const
Definition Dtype.h:64
Definition SizeVector.h:69
iterator begin()
Definition SmallVector.h:302
iterator end()
Definition SmallVector.h:304
static Tensor FromDLPack(const DLManagedTensor *dlmt, std::function< void(void *)> deleter=nullptr)
Convert DLManagedTensor to Tensor (DLPack v0.x).
Definition Tensor.cpp:1987
const Dtype Int64
Definition Dtype.cpp:47
const Dtype Int32
Definition Dtype.cpp:46
const Dtype Float64
Definition Dtype.cpp:43
const Dtype Float32
Definition Dtype.cpp:42
Definition PinholeCameraIntrinsic.cpp:16
C Tensor object, manage memory of DLTensor. This data structure is intended to facilitate the borrowi...
Definition DLPack.h:319