| 137 | } |
| 138 | |
| 139 | void ExampleTensorDLPack() { |
| 140 | namespace ffi = tvm::ffi; |
| 141 | ffi::Shape shape = {1, 2, 3}; |
| 142 | DLDataType dtype = {kDLFloat, 32, 1}; |
| 143 | DLDevice device = {kDLCPU, 0}; |
| 144 | ffi::Tensor tensor = ffi::Tensor::FromNDAlloc(CPUNDAlloc(), shape, dtype, device); |
| 145 | // convert to DLManagedTensorVersioned |
| 146 | DLManagedTensorVersioned* dlpack = tensor.ToDLPackVersioned(); |
| 147 | // load back from DLManagedTensorVersioned |
| 148 | ffi::Tensor tensor2 = ffi::Tensor::FromDLPackVersioned(dlpack); |
| 149 | } |
| 150 | |
| 151 | TEST(Example, Tensor) { |
| 152 | ExampleTensor(); |
no test coverage detected