Open3D (C++ API)
dlpack.h
Go to the documentation of this file.
1 
6 #ifndef DLPACK_DLPACK_H_
7 #define DLPACK_DLPACK_H_
8 
9 #ifdef __cplusplus
10 #define DLPACK_EXTERN_C extern "C"
11 #else
12 #define DLPACK_EXTERN_C
13 #endif
14 
16 #define DLPACK_VERSION 020
17 
19 #ifdef _WIN32
20 #ifdef DLPACK_EXPORTS
21 #define DLPACK_DLL __declspec(dllexport)
22 #else
23 #define DLPACK_DLL __declspec(dllimport)
24 #endif
25 #else
26 #define DLPACK_DLL
27 #endif
28 
29 #include <stddef.h>
30 #include <stdint.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
38 typedef enum {
40  kDLCPU = 1,
42  kDLGPU = 2,
49  kDLOpenCL = 4,
51  kDLVulkan = 7,
53  kDLMetal = 8,
55  kDLVPI = 9,
57  kDLROCM = 10,
63  kDLExtDev = 12,
64 } DLDeviceType;
65 
69 typedef struct {
73  int device_id;
74 } DLContext;
75 
79 typedef enum {
80  kDLInt = 0U,
81  kDLUInt = 1U,
82  kDLFloat = 2U,
84 
93 typedef struct {
99  uint8_t code;
103  uint8_t bits;
105  uint16_t lanes;
106 } DLDataType;
107 
111 typedef struct {
131  void* data;
135  int ndim;
139  int64_t* shape;
144  int64_t* strides;
147 } DLTensor;
148 
156 typedef struct DLManagedTensor {
162  void* manager_ctx;
168  void (*deleter)(struct DLManagedTensor* self);
170 #ifdef __cplusplus
171 } // DLPACK_EXTERN_C
172 #endif
173 #endif // DLPACK_DLPACK_H_
ROCm GPUs for AMD GPUs.
Definition: dlpack.h:57
Definition: dlpack.h:81
Pinned CUDA GPU device by cudaMallocHost.
Definition: dlpack.h:47
C Tensor object, manage memory of DLTensor. This data structure is intended to faciliate the borrowin...
Definition: dlpack.h:156
int64_t * shape
The shape of the tensor.
Definition: dlpack.h:139
void * manager_ctx
the context of the original host framework of DLManagedTensor in which DLManagedTensor is used in the...
Definition: dlpack.h:162
uint16_t lanes
Number of lanes in the type, used for vector types.
Definition: dlpack.h:105
int device_id
The device index.
Definition: dlpack.h:73
DLDataType dtype
The data type of the pointer.
Definition: dlpack.h:137
int64_t * strides
strides of the tensor (in number of elements, not bytes) can be NULL, indicating tensor is compact an...
Definition: dlpack.h:144
OpenCL devices.
Definition: dlpack.h:49
Definition: dlpack.h:80
Definition: dlpack.h:82
struct DLManagedTensor DLManagedTensor
C Tensor object, manage memory of DLTensor. This data structure is intended to faciliate the borrowin...
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample uint64_t
Definition: K4aPlugin.cpp:348
CPU device.
Definition: dlpack.h:40
int ndim
Number of dimensions.
Definition: dlpack.h:135
Metal for Apple GPU.
Definition: dlpack.h:53
void * data
The opaque data pointer points to the allocated data. This will be CUDA device pointer or cl_mem hand...
Definition: dlpack.h:131
Vulkan buffer for next generation graphics.
Definition: dlpack.h:51
const char const char value recording_handle imu_sample void
Definition: K4aPlugin.cpp:255
A Device context for Tensor and operator.
Definition: dlpack.h:69
DLDeviceType device_type
The device type used in the device.
Definition: dlpack.h:71
uint8_t bits
Number of bits, common choices are 8, 16, 32.
Definition: dlpack.h:103
DLDeviceType
The device type in DLContext.
Definition: dlpack.h:38
DLTensor dl_tensor
DLTensor which is being memory managed.
Definition: dlpack.h:158
DLDataTypeCode
The type code options DLDataType.
Definition: dlpack.h:79
uint64_t byte_offset
The offset in bytes to the beginning pointer to data.
Definition: dlpack.h:146
DLContext ctx
The device context of the tensor.
Definition: dlpack.h:133
CUDA GPU device.
Definition: dlpack.h:42
The data type the tensor can hold.
Definition: dlpack.h:93
Reserved extension device type, used for quickly test extension device The semantics can differ depen...
Definition: dlpack.h:63
uint8_t code
Type code of base types. We keep it uint8_t instead of DLDataTypeCode for minimal memory footprint...
Definition: dlpack.h:99
void(* deleter)(struct DLManagedTensor *self)
Destructor signature void (*)(void*) - this should be called to destruct manager_ctx which holds the ...
Definition: dlpack.h:168
Plain C Tensor object, does not manage memory.
Definition: dlpack.h:111
Verilog simulator buffer.
Definition: dlpack.h:55