1 #pragma once 2 3 #include <string> 4 5 namespace at { 6 class Tensor; 7 } // namespace at 8 9 namespace c10 { 10 struct IValue; 11 namespace detail { 12 // Determine the return type of `IValue::to() const &`. It's a const 13 // reference when possible and a copy otherwise. It is in this 14 // separate header so that List can use it as well. 15 template<typename T> 16 struct ivalue_to_const_ref_overload_return { 17 using type = T; 18 }; 19 20 template<> 21 struct ivalue_to_const_ref_overload_return<at::Tensor> { 22 using type = const at::Tensor&; 23 }; 24 25 template<> 26 struct ivalue_to_const_ref_overload_return<std::string> { 27 using type = const std::string&; 28 }; 29 30 template<> 31 struct ivalue_to_const_ref_overload_return<IValue> { 32 using type = const IValue&; 33 }; 34 35 } // namespace detail 36 } // namespace c10 37