TVM  0.9.4
AffineExprDetail.h
Go to the documentation of this file.
1 
3 #pragma once
4 
5 #include <tvm/api.h>
6 #include <tvm/defs.h>
7 
8 #include <Eigen/Core>
9 
10 namespace tvm
11 {
12 namespace utils
13 {
14 namespace internal
15 {
16 
18 using IdentityType = decltype(Eigen::MatrixXd::Identity());
20 using MultIdentityType = decltype(2. * Eigen::MatrixXd::Identity());
22 using MinusIdentityType = decltype(-Eigen::MatrixXd::Identity());
23 
26 {
27 public:
28  NoConstant operator-() const { return {}; }
29 };
30 
32 template<typename RhsType>
33 inline const RhsType & operator+(const NoConstant &, const Eigen::MatrixBase<RhsType> & rhs)
34 { return rhs.derived(); }
35 
37 template<typename LhsType>
38 inline const LhsType & operator+(const Eigen::MatrixBase<LhsType> & lhs, const NoConstant &)
39 { return lhs.derived(); }
40 
42 inline auto operator+(const NoConstant &, const NoConstant &) { return NoConstant(); }
43 
45 template<typename MultType>
46 inline NoConstant operator*(const MultType & /*m*/, const NoConstant &)
47 { return {}; }
48 
58 template<typename Derived>
60 {
61  using type = typename Eigen::internal::ref_selector<Derived>::type;
62 };
63 template<>
65 {
66  using type = NoConstant;
67 };
68 
69 template<typename Derived>
71 
73 template<typename LhsType, typename RhsType>
75  std::remove_const_t<std::remove_reference_t<decltype(std::declval<LhsType>() + std::declval<RhsType>())>>;
76 
80 template<typename Tuple, size_t... Indices>
81 auto tupleUnaryMinus(const Tuple & tuple, std::index_sequence<Indices...>)
82 { return std::make_tuple((-std::get<Indices>(tuple))...); }
83 
87 template<typename MultType, typename Tuple, size_t... Indices>
88 auto tuplePremult(const MultType & m, const Tuple & tuple, std::index_sequence<Indices...>)
89 { return std::make_tuple((m * std::get<Indices>(tuple))...); }
90 } // namespace internal
91 } // namespace utils
92 } // namespace tvm
93 
94 namespace Eigen
95 {
96 namespace internal
97 {
99 template<>
100 struct traits<tvm::utils::internal::NoConstant> : public traits<tvm::utils::internal::IdentityType>
101 {};
102 } // namespace internal
103 } // namespace Eigen
Definition: AffineExprDetail.h:26
NoConstant operator-() const
Definition: AffineExprDetail.h:28
Definition: AffineExprDetail.h:95
decltype(Eigen::MatrixXd::Identity()) IdentityType
Definition: AffineExprDetail.h:18
decltype(-Eigen::MatrixXd::Identity()) MinusIdentityType
Definition: AffineExprDetail.h:22
NoConstant operator*(const MultType &, const NoConstant &)
Definition: AffineExprDetail.h:46
const RhsType & operator+(const NoConstant &, const Eigen::MatrixBase< RhsType > &rhs)
Definition: AffineExprDetail.h:33
auto tuplePremult(const MultType &m, const Tuple &tuple, std::index_sequence< Indices... >)
Definition: AffineExprDetail.h:88
std::remove_const_t< std::remove_reference_t< decltype(std::declval< LhsType >()+std::declval< RhsType >())> > AddConstantsRetType
Definition: AffineExprDetail.h:75
auto tupleUnaryMinus(const Tuple &tuple, std::index_sequence< Indices... >)
Definition: AffineExprDetail.h:81
decltype(2. *Eigen::MatrixXd::Identity()) MultIdentityType
Definition: AffineExprDetail.h:20
typename RefSelector< Derived >::type RefSelector_t
Definition: AffineExprDetail.h:70
Definition: Clock.h:12
Definition: AffineExprDetail.h:60
typename Eigen::internal::ref_selector< Derived >::type type
Definition: AffineExprDetail.h:61