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