DLConvertor.h 669 B

123456789101112131415161718192021
  1. #pragma once
  2. #include <ATen/ATen.h>
  3. #include <ATen/Tensor.h>
  4. #include <ATen/dlpack.h>
  5. // this convertor will:
  6. // 1) take a Tensor object and wrap it in the DLPack tensor
  7. // 2) take a dlpack tensor and convert it to the ATen Tensor
  8. namespace at {
  9. TORCH_API ScalarType toScalarType(const DLDataType& dtype);
  10. TORCH_API DLManagedTensor* toDLPack(const Tensor& src);
  11. TORCH_API Tensor fromDLPack(const DLManagedTensor* src);
  12. TORCH_API Tensor
  13. fromDLPack(const DLManagedTensor* src, std::function<void(void*)> deleter);
  14. TORCH_API DLDataType getDLDataType(const Tensor& t);
  15. TORCH_API DLDevice getDLContext(const Tensor& tensor, const int64_t& device_id);
  16. } // namespace at