MCPcopy Create free account
hub / github.com/apache/tvm-ffi / ExampleTensorDLPack

Function ExampleTensorDLPack

tests/cpp/test_example.cc:139–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139void 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
151TEST(Example, Tensor) {
152 ExampleTensor();

Callers 1

TESTFunction · 0.85

Calls 2

CPUNDAllocClass · 0.70
ToDLPackVersionedMethod · 0.45

Tested by

no test coverage detected