TVM  0.9.4
traits.h
Go to the documentation of this file.
1 
3 #pragma once
4 
5 #include <tvm/Variable.h>
6 
8 {
9 
11 template<typename T, typename MethodT>
13 {
14  static constexpr bool isVoidAccessor = false;
15  static constexpr bool isVariableAccessor = false;
16 };
17 
19 template<typename T>
21 {
22  using ReturnT = T;
23  static constexpr bool isVoidAccessor = true;
24  static constexpr bool isVariableAccessor = false;
25 };
26 
28 template<typename T>
30 {
31  using ReturnT = T;
32  static constexpr bool isVoidAccessor = false;
33  static constexpr bool isVariableAccessor = true;
34 };
35 
36 template<typename T, typename U>
37 struct CheckAccessor<T, U (T::*)() const> : public ValidVoidAccessor<U>
38 {};
39 
40 template<typename T, typename U>
41 struct CheckAccessor<T, U (T::*)() const noexcept> : public ValidVoidAccessor<U>
42 {};
43 
44 #ifndef _MSC_VER
45 template<typename T, typename U, typename Base>
46 struct CheckAccessor<T, U (Base::*)() const> : public ValidVoidAccessor<U>
47 {
48  static_assert(std::is_base_of_v<Base, T>, "This method does not belong to T hierarchy");
49 };
50 
51 template<typename T, typename U, typename Base>
52 struct CheckAccessor<T, U (Base::*)() const noexcept> : public ValidVoidAccessor<U>
53 {
54  static_assert(std::is_base_of_v<Base, T>, "This method does not belong to T hierarchy");
55 };
56 #endif
57 
58 template<typename T, typename U>
59 struct CheckAccessor<T, U (T::*)(const Variable &) const> : public ValidVariableAccessor<U>
60 {};
61 
62 template<typename T, typename U>
63 struct CheckAccessor<T, U (T::*)(const Variable &) const noexcept> : public ValidVariableAccessor<U>
64 {};
65 
66 #ifndef _MSC_VER
67 template<typename T, typename U, typename Base>
68 struct CheckAccessor<T, U (Base::*)(const Variable &) const> : public ValidVariableAccessor<U>
69 {
70  static_assert(std::is_base_of_v<Base, T>, "This method does not belong to T hierarchy");
71 };
72 
73 template<typename T, typename U, typename Base>
74 struct CheckAccessor<T, U (Base::*)(const Variable &) const noexcept> : public ValidVariableAccessor<U>
75 {
76  static_assert(std::is_base_of_v<Base, T>, "This method does not belong to T hierarchy");
77 };
78 #endif
79 
81 template<typename ArgT, typename ConvertT>
82 std::function<Eigen::MatrixXd(const ArgT &)> MakeConvert(ConvertT && convertIn)
83 {
84  using RetT = std::function<Eigen::MatrixXd(const ArgT &)>;
85  if constexpr(std::is_constructible_v<RetT, ConvertT &&>)
86  {
87  return RetT(convertIn);
88  }
89  else
90  {
91  return [](const ArgT & u) { return u; };
92  }
93 }
94 
95 } // namespace tvm::diagnostic::internal
Definition: details.h:8
std::function< Eigen::MatrixXd(const ArgT &)> MakeConvert(ConvertT &&convertIn)
Definition: traits.h:82
static constexpr bool isVariableAccessor
Definition: traits.h:15
static constexpr bool isVoidAccessor
Definition: traits.h:14
static constexpr bool isVoidAccessor
Definition: traits.h:32
static constexpr bool isVariableAccessor
Definition: traits.h:33
static constexpr bool isVariableAccessor
Definition: traits.h:24
static constexpr bool isVoidAccessor
Definition: traits.h:23