DLConvertor.h 834 B

12345678910111213141516171819202122232425
  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(DLManagedTensor* src);
  12. C10_DEPRECATED_MESSAGE("Please migrate to a non-const variant")
  13. inline Tensor fromDLPack(const DLManagedTensor* src) {
  14. return fromDLPack(const_cast<DLManagedTensor*>(src));
  15. }
  16. TORCH_API Tensor
  17. fromDLPack(DLManagedTensor* src, std::function<void(void*)> deleter);
  18. TORCH_API DLDataType getDLDataType(const Tensor& t);
  19. TORCH_API DLDevice getDLContext(const Tensor& tensor, const int64_t& device_id);
  20. } // namespace at