TVM  0.9.4
CompiledAssignment.h
Go to the documentation of this file.
1 
3 #pragma once
4 
6 
7 #include <Eigen/Core>
8 
9 #include <type_traits>
10 
11 namespace tvm
12 {
13 
14 namespace scheme
15 {
16 
17 namespace internal
18 {
19 
22 { COPY, ADD, SUB, MIN, MAX
28 };
29 
39 };
40 
45 {
53  CUSTOM
54 };
55 
64 enum Source
65 {
71  CONSTANT
72 };
73 
77 template<typename MatrixType>
78 using isVector = typename std::conditional<MatrixType::ColsAtCompileTime == 1, std::true_type, std::false_type>::type;
79 
80 /* trait-like definition to detect if an Eigen expression \p MatrixType is describing
81  * a matrix.
82  */
83 template<typename MatrixType>
84 using isMatrix = typename std::conditional<MatrixType::ColsAtCompileTime != 1, std::true_type, std::false_type>::type;
85 
87 class NoArg
88 {};
89 
93 template<int N>
94 class ParseArg_
95 {
96 public:
97  template<typename... Args>
98  static typename std::tuple_element<N, std::tuple<Args...>>::type get(Args &&... args)
99  { return std::get<N>(std::forward_as_tuple(args...)); }
100 };
101 
106 {
107 public:
108  template<typename... Args>
109  static NoArg get(Args &&...)
110  { return {}; }
111 };
112 
119 template<int N>
120 class ParseArg : public std::conditional<(N >= 0), ParseArg_<N>, ParseNoArg_>::type
121 {};
122 
124 template<typename T>
125 std::true_type hasNoArgCtorDummy(const T &);
129 template<typename T>
130 decltype(hasNoArgCtorDummy(T(NoArg()))) hasNoArgCtor_(int);
134 template<typename>
135 std::false_type hasNoArgCtor_(...);
136 
142 template<typename T>
143 class hasNoArgCtor : public decltype(hasNoArgCtor_<T>(0))
144 {};
145 
149 template<typename T, typename... Args>
150 class ArgCount
151 {
152 public:
153  static constexpr int count = ArgCount<Args...>::count + (hasNoArgCtor<T>::value ? 0 : 1);
154 };
155 
157 template<typename T>
158 class ArgCount<T>
159 {
160 public:
161  static constexpr int count = hasNoArgCtor<T>::value ? 0 : 1;
162 };
163 
167 template<typename MatrixType, bool Cache>
169 {
170 public:
171  CachedResult(const Eigen::Ref<MatrixType> &) {}
172 
173  template<typename T>
174  const T & cache(const T & M)
175  { return M; }
176 };
177 
179 template<typename MatrixType>
180 class CachedResult<MatrixType, true>
181 {
182 public:
183  CachedResult(const Eigen::Ref<MatrixType> & to) { TVM_TEMPORARY_ALLOW_EIGEN_MALLOC(cache_.resizeLike(to)); }
184 
185  template<typename T>
186  const MatrixType & cache(const T & M)
187  {
188  using ConstType = decltype(std::declval<Eigen::Ref<const Eigen::MatrixXd>>() * Eigen::VectorXd::Constant(1, 1));
189  if constexpr(std::is_same_v<const T, ConstType>)
190  {
191  // For the case where M = matrix * Constant, Eigen create a temporary to store Vector:Constant before evaluating
192  // the product. We avoid that here, by doing the product by hand. This could be further optimized by taking into
193  // account the WeightMult at once, and possibly without using a cache.
194  // The product A * v where v = c * 1 with c a scalar and 1 the vector of ones is equal to c * A * 1. We have that
195  // A * 1 is the sum of column of A, what we leverage in the following computations:
196  cache_ = M.lhs().rowwise().sum(); // TODO compare to a handmade loop summing the columns
197  cache_ *= M.rhs().functor().m_other;
198  }
199  else
200  {
201  cache_.noalias() = M;
202  }
203  return cache_;
204  }
205 
206  MatrixType & cache() { return cache_; }
207  const MatrixType & cache() const { return cache_; }
208 
209 private:
210  MatrixType cache_;
211 };
212 
216 template<typename MatrixType, AssignType A, WeightMult W, MatrixMult M, Source F>
217 class use_assign_cache : public std::false_type
218 {};
219 
223 template<typename MatrixType, WeightMult W>
224 class use_assign_cache<MatrixType, MIN, W, GENERAL, EXTERNAL> : public std::true_type
225 {};
226 template<typename MatrixType, WeightMult W>
227 class use_assign_cache<MatrixType, MAX, W, GENERAL, EXTERNAL> : public std::true_type
228 {};
229 
233 template<typename MatrixType, AssignType A, WeightMult W>
234 class use_assign_cache<MatrixType, A, W, GENERAL, CONSTANT> : public std::true_type
235 {};
236 
240 template<typename MatrixType, AssignType A, WeightMult W, MatrixMult M, Source F>
241 class use_product_cache : public std::false_type
242 {};
243 
248 template<typename MatrixType, AssignType A>
249 class use_product_cache<MatrixType, A, DIAGONAL, GENERAL, EXTERNAL> : public std::true_type
250 {};
251 template<typename MatrixType, AssignType A>
252 class use_product_cache<MatrixType, A, DIAGONAL, GENERAL, CONSTANT> : public std::true_type
253 {};
254 
256 template<AssignType A>
258 {};
259 
260 template<>
262 {
263 public:
264  template<typename T, typename U>
265  void assign(U & out, const T & in)
266  { out.noalias() = in; }
267 
268  template<typename U>
269  void assign(U & out, double in)
270  { out.setConstant(in); }
271 };
272 
273 template<>
275 {
276 public:
277  template<typename T, typename U>
278  void assign(U & out, const T & in)
279  { out.noalias() += in; }
280 
281  template<typename U>
282  void assign(U & out, double in)
283  { out.array() += in; }
284 };
285 
286 template<>
288 {
289 public:
290  template<typename T, typename U>
291  void assign(U & out, const T & in)
292  { out.noalias() -= in; }
293 
294  template<typename U>
295  void assign(U & out, double in)
296  { out.array() -= in; }
297 };
298 
299 template<>
301 {
302 public:
303  template<typename T, typename U>
304  void assign(U & out, const T & in)
305  { out.array() = out.array().min(in.array()); }
306 
307  template<typename U>
308  void assign(U & out, double in)
309  { out.array() = out.array().min(in); }
310 };
311 
312 template<>
314 {
315 public:
316  template<typename T, typename U>
317  void assign(U & out, const T & in)
318  { out.array() = out.array().max(in.array()); }
319 
320  template<typename U>
321  void assign(U & out, double in)
322  { out.array() = out.array().max(in); }
323 };
324 
326 template<WeightMult W>
328 {};
329 
331 template<>
333 {
334 public:
335  static const bool useArg = false;
336 
338 
339  template<typename T>
340  const T & applyWeightMult(const T & M)
341  { return M; }
342 };
343 
345 template<>
347 {
348 public:
349  static const bool useArg = false;
350 
352 
353  double applyWeightMult(const double & M) { return -M; }
354 
355  template<typename Derived>
356  decltype(-std::declval<Eigen::MatrixBase<Derived>>()) applyWeightMult(const Eigen::MatrixBase<Derived> & M)
357  { return -M; }
358 
360 #if EIGEN_VERSION_AT_LEAST(3, 2, 90)
361  template<typename Lhs, typename Rhs, int Option>
362  decltype(-(std::declval<Lhs>().lazyProduct(std::declval<Rhs>()))) applyWeightMult(
363  const Eigen::Product<Lhs, Rhs, Option> & P)
364  { return -(P.lhs().lazyProduct(P.rhs())); }
365 #else
366  template<typename Derived, typename Lhs, typename Rhs>
367  decltype((-std::declval<Lhs>())
368  * std::declval<Rhs>()) applyWeightMult(const Eigen::ProductBase<Derived, Lhs, Rhs> & P)
369  { return (-P.lhs()) * P.rhs(); }
370 #endif
371 };
372 
374 template<>
376 {
377 public:
378  WeightMultBase(const double & s) : s_(s) {};
379 
380  template<typename T>
381  decltype(double() * std::declval<T>()) applyWeightMult(const T & M)
382  { return s_ * M; }
383 
384 #if EIGEN_VERSION_AT_LEAST(3, 2, 90)
385  template<typename Lhs, typename Rhs, int Option>
386  decltype(double() * (std::declval<Lhs>().lazyProduct(std::declval<Rhs>()))) applyWeightMult(
387  const Eigen::Product<Lhs, Rhs, Option> & P)
388  { return s_ * (P.lhs().lazyProduct(P.rhs())); }
389 #endif
390 
391 private:
392  const double & s_;
393 };
394 
396 template<>
398 {
399 public:
400  WeightMultBase(const Eigen::Ref<const Eigen::VectorXd> & d) : d_(d) {}
401 
402  template<typename T>
403  using ReturnType = decltype(std::declval<Eigen::Ref<const Eigen::VectorXd>>().asDiagonal() * std::declval<T>());
404  template<typename T>
406  { return d_.asDiagonal() * M; }
407 
409  decltype(double() * std::declval<Eigen::Ref<const Eigen::VectorXd>>()) applyWeightMult(const double & d)
410  { return d * d_; }
411 
412 private:
413  Eigen::Ref<const Eigen::VectorXd> d_;
414 };
415 
417 template<typename MatrixType, MatrixMult M>
419 {};
420 
422 template<typename MatrixType>
423 class MatrixMultBase<MatrixType, IDENTITY>
424 {
425 public:
427 
428  template<typename T>
429  const T & applyMatrixMult(const T & M)
430  { return M; }
431 };
432 
434 template<typename MatrixType>
435 class MatrixMultBase<MatrixType, GENERAL>
436 {
437 public:
438  MatrixMultBase(const Eigen::Ref<const Eigen::MatrixXd> & M) : M_(M) {}
439 
441  template<typename T>
442  using PreType = decltype(std::declval<Eigen::Ref<const Eigen::MatrixXd>>() * std::declval<T>());
444  template<typename T>
445  using PostType = decltype(std::declval<T>() * std::declval<Eigen::Ref<const Eigen::MatrixXd>>());
447  using ConstType = decltype(std::declval<Eigen::Ref<const Eigen::MatrixXd>>() * Eigen::VectorXd::Constant(1, 1));
448 
449  template<typename T>
450  typename std::enable_if<isVector<MatrixType>::value, PreType<T>>::type applyMatrixMult(const T & M)
451  { return M_ * M; }
452 
453  template<typename T>
454  typename std::enable_if<!isVector<MatrixType>::value, PostType<T>>::type applyMatrixMult(const T & M)
455  { return M * M_; }
456 
457  template<typename U = MatrixType>
458  typename std::enable_if<isVector<U>::value, ConstType>::type applyMatrixMult(const double & d)
459  { return M_ * Eigen::VectorXd::Constant(M_.cols(), d); }
460 
462  template<typename T>
463  void applyMatrixMultCached(MatrixType & cache, const T & M)
464  {
465  const auto p = applyMatrixMult(M);
466  using ConstType = decltype(std::declval<Eigen::Ref<const Eigen::MatrixXd>>() * Eigen::VectorXd::Constant(1, 1));
467  if constexpr(std::is_same_v<decltype(p), ConstType>)
468  {
469  // For the case where M = matrix * Constant, Eigen create a temporary to store Vector:Constant before evaluating
470  // the product. We avoid that here, by doing the product by hand. This could be further optimized by taking into
471  // account the WeightMult at once, and possibly without using a cache.
472  // The product A * v where v = c * 1 with c a scalar and 1 the vector of ones is equal to c * A * 1. We have that
473  // A * 1 is the sum of column of A, what we leverage in the following computations:
474  cache = p.lhs().rowwise().sum(); // TODO compare to a handmade loop summing the columns
475  cache *= p.rhs().functor().m_other;
476  }
477  else
478  {
479  cache.noalias() = p;
480  }
481  }
482 
483 private:
484  Eigen::Ref<const Eigen::MatrixXd> M_;
485 };
486 
488 template<typename MatrixType>
490 {
491 public:
492  MatrixMultBase(const Eigen::Ref<const Eigen::MatrixXd> & M) : M_(M) {}
493 
495  using InvDiagType =
496  decltype(std::declval<Eigen::Ref<const Eigen::MatrixXd>>().diagonal().cwiseInverse().asDiagonal());
498  template<typename T>
499  using PreType = decltype(std::declval<InvDiagType>() * std::declval<T>());
501  template<typename T>
502  using PostType = decltype(std::declval<T>() * std::declval<InvDiagType>());
504  using ConstType = decltype(std::declval<InvDiagType>() * Eigen::VectorXd::Constant(1, 1));
505 
506  template<typename T>
507  typename std::enable_if<isVector<MatrixType>::value, PreType<T>>::type applyMatrixMult(const T & M)
508  { return M_.diagonal().cwiseInverse().asDiagonal() * M; }
509 
510  template<typename T>
511  typename std::enable_if<!isVector<MatrixType>::value, PostType<T>>::type applyMatrixMult(const T & M)
512  { return M * M_.diagonal().cwiseInverse().asDiagonal(); }
513 
514  template<typename U = MatrixType>
515  typename std::enable_if<isVector<U>::value, ConstType>::type applyMatrixMult(const double & d)
516  { return M_.diagonal().cwiseInverse().asDiagonal() * Eigen::VectorXd::Constant(M_.cols(), d); }
517 
519  template<typename T>
520  void applyMatrixMultCached(MatrixType & cache, const T & M)
521  { cache.noalias() = applyMatrixMult(M); }
522 
523 private:
524  Eigen::Ref<const Eigen::MatrixXd> M_;
525 };
526 
528 template<typename MatrixType>
529 class MatrixMultBase<MatrixType, CUSTOM>
530 {
531 public:
532  MatrixMultBase(void (*mult)(Eigen::Ref<MatrixType> out, const Eigen::Ref<const MatrixType> & in)) : mult_(mult) {}
533 
534  template<typename T>
535  void applyMatrixMultCached(MatrixType & cache, const T & M)
536  { mult_(cache, M); }
537 
538 private:
539  void (*mult_)(Eigen::Ref<MatrixType> out, const Eigen::Ref<const MatrixType> & in);
540 };
541 
543 template<typename MatrixType, Source F>
545 {
546 public:
547  using SourceType = typename std::conditional<F == CONSTANT, double, Eigen::Ref<const MatrixType>>::type;
548 
549  SourceBase(const SourceType & from) : from_(from) {}
550 
551  const SourceType & from() const { return from_; }
552 
553  void from(const SourceType & from)
554  {
555  // We want to do from_ = from but there is no operator= for Eigen::Ref,
556  // so we need to use a placement new.
557  new(&from_) SourceType(from);
558  }
559 
560 private:
561  SourceType from_;
562 };
563 
565 template<typename MatrixType>
566 class SourceBase<MatrixType, ZERO>
567 {};
568 
590 template<typename MatrixType, AssignType A, WeightMult W, MatrixMult M, Source F = EXTERNAL>
591 class CompiledAssignment : public CachedResult<MatrixType,
592  use_assign_cache<MatrixType, A, W, M, F>::value
593  || use_product_cache<MatrixType, A, W, M, F>::value>,
594  public AssignBase<A>,
595  public WeightMultBase<W>,
596  public MatrixMultBase<MatrixType, M>,
597  public SourceBase<MatrixType, F>
598 {
599 private:
600  using CBase =
601  CachedResult<MatrixType,
603  using WBase = WeightMultBase<W>;
606  using SParse =
607  typename std::conditional<hasNoArgCtor<SBase>::value, ParseArg<-1>, ParseArg<ArgCount<SBase>::count - 1>>::type;
608  using WParse = typename std::
609  conditional<hasNoArgCtor<WBase>::value, ParseArg<-1>, ParseArg<ArgCount<SBase, WBase>::count - 1>>::type;
610  using MParse = typename std::
611  conditional<hasNoArgCtor<MBase>::value, ParseArg<-1>, ParseArg<ArgCount<SBase, WBase, MBase>::count - 1>>::type;
612 
622  template<typename... Args>
623  CompiledAssignment(const Eigen::Ref<MatrixType> & to, Args &&... args)
624  : CBase(to), WBase(WParse::get(std::forward<Args>(args)...)), MBase(MParse::get(std::forward<Args>(args)...)),
625  SBase(SParse::get(std::forward<Args>(args)...)), to_(to)
626  { static_assert(!(isMatrix<MatrixType>::value && F == CONSTANT), "Constant source is only for vectors."); }
627 
628 public:
629  template<typename U = MatrixType>
630  typename std::enable_if<!use_product_cache<U, A, W, M, F>::value>::type run()
631  {
632  // There is room for speed improvement by switching at runtime in function of the
633  // matrices sizes, in particular for M = GENERAL, it seems that lazy product is
634  // faster for small matrices (but slower for bigger ones)
635  this->assign(to_, this->cache(this->applyWeightMult(this->applyMatrixMult(this->from()))));
636  }
637 
638  template<typename U = MatrixType>
639  typename std::enable_if<use_product_cache<U, A, W, M, F>::value && !use_assign_cache<U, A, W, M, F>::value>::type run()
640  {
641  this->applyMatrixMultCached(this->cache(), this->from());
642  this->assign(to_, this->applyWeightMult(this->cache()));
643  }
644 
645  template<typename U = MatrixType>
646  typename std::enable_if<use_product_cache<U, A, W, M, F>::value && use_assign_cache<U, A, W, M, F>::value>::type run()
647  {
648  this->applyMatrixMultCached(this->cache(), this->from());
649  this->cache() = this->applyWeightMult(this->cache());
650  this->assign(to_, this->cache());
651  }
652 
653  void to(const Eigen::Ref<MatrixType> & to)
654  {
655  // We want to do to_ = to but there is no operator= for Eigen::Ref,
656  // so we need to use a placement new.
657  new(&to_) Eigen::Ref<MatrixType>(to);
658  }
659 
660 private:
663  Eigen::Ref<MatrixType> to_;
664 
665  template<typename MatrixType_>
667 };
668 
670 template<typename MatrixType, AssignType A, WeightMult W, MatrixMult M>
671 class CompiledAssignment<MatrixType, A, W, M, ZERO>
672 {
673 public:
674  using SourceType = Eigen::Ref<const MatrixType>;
675 
676 private:
677  CompiledAssignment(const Eigen::Ref<MatrixType> & to) : to_(to) {}
678 
679 public:
680  void run() { /* Do nothing */ }
681  void from(const Eigen::Ref<const MatrixType> &) { /* Do nothing */ }
682  void to(const Eigen::Ref<MatrixType> & to)
683  {
684  // We want to do to_ = to but there is no operator= for Eigen::Ref,
685  // so we need to use a placement new.
686  new(&to_) Eigen::Ref<MatrixType>(to);
687  }
688 
689 private:
690  Eigen::Ref<MatrixType> to_;
691 
692  template<typename MatrixType_>
694 };
695 
697 template<typename MatrixType, WeightMult W, MatrixMult M>
698 class CompiledAssignment<MatrixType, COPY, W, M, ZERO>
699 {
700 public:
701  using SourceType = Eigen::Ref<const MatrixType>;
702 
703 private:
704  CompiledAssignment(const Eigen::Ref<MatrixType> & to) : to_(to) {}
705 
706 public:
707  void run() { to_.setZero(); }
708  void from(const Eigen::Ref<const MatrixType> &) { /* Do nothing */ }
709  void to(const Eigen::Ref<MatrixType> & to)
710  {
711  // We want to do to_ = to but there is no operator= for Eigen::Ref,
712  // so we need to use a placement new.
713  new(&to_) Eigen::Ref<MatrixType>(to);
714  }
715 
716 private:
717  Eigen::Ref<MatrixType> to_;
718 
719  template<typename MatrixType_>
721 };
722 
724 template<typename MatrixType, WeightMult W, MatrixMult M>
725 class CompiledAssignment<MatrixType, MIN, W, M, ZERO>
726 {
727 public:
728  using SourceType = Eigen::Ref<const MatrixType>;
729 
730 private:
731  CompiledAssignment(const Eigen::Ref<MatrixType> & to) : to_(to) {}
732 
733 public:
734  void run() { to_.array() = to_.array().min(static_cast<typename MatrixType::Scalar>(0)); }
735  void from(const Eigen::Ref<const MatrixType> &) { /* Do nothing */ }
736  void to(const Eigen::Ref<MatrixType> & to) { new(&to_) Eigen::Ref<MatrixType>(to); }
737 
738 private:
739  Eigen::Ref<MatrixType> to_;
740 
741  template<typename MatrixType_>
743 };
744 
746 template<typename MatrixType, WeightMult W, MatrixMult M>
747 class CompiledAssignment<MatrixType, MAX, W, M, ZERO>
748 {
749 public:
750  using SourceType = Eigen::Ref<const MatrixType>;
751 
752 private:
753  CompiledAssignment(const Eigen::Ref<MatrixType> & to) : to_(to) {}
754 
755 public:
756  void run() { to_.array() = to_.array().max(static_cast<typename MatrixType::Scalar>(0)); }
757  void from(const Eigen::Ref<const MatrixType> &) { /* Do nothing */ }
758  void to(const Eigen::Ref<MatrixType> & to) { new(&to_) Eigen::Ref<MatrixType>(to); }
759 
760 private:
761  Eigen::Ref<MatrixType> to_;
762 
763  template<typename MatrixType_>
765 };
766 
767 } // namespace internal
768 
769 } // namespace scheme
770 
771 } // namespace tvm
Definition: CompiledAssignment.h:151
static constexpr int count
Definition: CompiledAssignment.h:153
void assign(U &out, const T &in)
Definition: CompiledAssignment.h:278
void assign(U &out, double in)
Definition: CompiledAssignment.h:282
void assign(U &out, const T &in)
Definition: CompiledAssignment.h:265
void assign(U &out, double in)
Definition: CompiledAssignment.h:269
void assign(U &out, const T &in)
Definition: CompiledAssignment.h:317
void assign(U &out, double in)
Definition: CompiledAssignment.h:321
void assign(U &out, double in)
Definition: CompiledAssignment.h:308
void assign(U &out, const T &in)
Definition: CompiledAssignment.h:304
void assign(U &out, const T &in)
Definition: CompiledAssignment.h:291
void assign(U &out, double in)
Definition: CompiledAssignment.h:295
Definition: CompiledAssignment.h:258
const MatrixType & cache(const T &M)
Definition: CompiledAssignment.h:186
CachedResult(const Eigen::Ref< MatrixType > &to)
Definition: CompiledAssignment.h:183
MatrixType & cache()
Definition: CompiledAssignment.h:206
const MatrixType & cache() const
Definition: CompiledAssignment.h:207
Definition: CompiledAssignment.h:169
const T & cache(const T &M)
Definition: CompiledAssignment.h:174
CachedResult(const Eigen::Ref< MatrixType > &)
Definition: CompiledAssignment.h:171
Definition: CompiledAssignmentWrapper.h:30
Eigen::Ref< const MatrixType > SourceType
Definition: CompiledAssignment.h:674
void from(const Eigen::Ref< const MatrixType > &)
Definition: CompiledAssignment.h:681
void to(const Eigen::Ref< MatrixType > &to)
Definition: CompiledAssignment.h:682
void from(const Eigen::Ref< const MatrixType > &)
Definition: CompiledAssignment.h:708
void to(const Eigen::Ref< MatrixType > &to)
Definition: CompiledAssignment.h:709
Eigen::Ref< const MatrixType > SourceType
Definition: CompiledAssignment.h:701
Eigen::Ref< const MatrixType > SourceType
Definition: CompiledAssignment.h:750
void from(const Eigen::Ref< const MatrixType > &)
Definition: CompiledAssignment.h:757
void to(const Eigen::Ref< MatrixType > &to)
Definition: CompiledAssignment.h:758
void to(const Eigen::Ref< MatrixType > &to)
Definition: CompiledAssignment.h:736
Eigen::Ref< const MatrixType > SourceType
Definition: CompiledAssignment.h:728
void from(const Eigen::Ref< const MatrixType > &)
Definition: CompiledAssignment.h:735
Definition: CompiledAssignment.h:598
std::enable_if< use_product_cache< U, A, W, M, F >::value &&!use_assign_cache< U, A, W, M, F >::value >::type run()
Definition: CompiledAssignment.h:639
std::enable_if<!use_product_cache< U, A, W, M, F >::value >::type run()
Definition: CompiledAssignment.h:630
void to(const Eigen::Ref< MatrixType > &to)
Definition: CompiledAssignment.h:653
std::enable_if< use_product_cache< U, A, W, M, F >::value &&use_assign_cache< U, A, W, M, F >::value >::type run()
Definition: CompiledAssignment.h:646
MatrixMultBase(void(*mult)(Eigen::Ref< MatrixType > out, const Eigen::Ref< const MatrixType > &in))
Definition: CompiledAssignment.h:532
void applyMatrixMultCached(MatrixType &cache, const T &M)
Definition: CompiledAssignment.h:535
std::enable_if<!isVector< MatrixType >::value, PostType< T > >::type applyMatrixMult(const T &M)
Definition: CompiledAssignment.h:454
decltype(std::declval< Eigen::Ref< const Eigen::MatrixXd > >() *Eigen::VectorXd::Constant(1, 1)) ConstType
Definition: CompiledAssignment.h:447
std::enable_if< isVector< MatrixType >::value, PreType< T > >::type applyMatrixMult(const T &M)
Definition: CompiledAssignment.h:450
std::enable_if< isVector< U >::value, ConstType >::type applyMatrixMult(const double &d)
Definition: CompiledAssignment.h:458
MatrixMultBase(const Eigen::Ref< const Eigen::MatrixXd > &M)
Definition: CompiledAssignment.h:438
void applyMatrixMultCached(MatrixType &cache, const T &M)
Definition: CompiledAssignment.h:463
decltype(std::declval< T >() *std::declval< Eigen::Ref< const Eigen::MatrixXd > >()) PostType
Definition: CompiledAssignment.h:445
decltype(std::declval< Eigen::Ref< const Eigen::MatrixXd > >() *std::declval< T >()) PreType
Definition: CompiledAssignment.h:442
MatrixMultBase(NoArg)
Definition: CompiledAssignment.h:426
const T & applyMatrixMult(const T &M)
Definition: CompiledAssignment.h:429
decltype(std::declval< InvDiagType >() *std::declval< T >()) PreType
Definition: CompiledAssignment.h:499
std::enable_if< isVector< U >::value, ConstType >::type applyMatrixMult(const double &d)
Definition: CompiledAssignment.h:515
decltype(std::declval< InvDiagType >() *Eigen::VectorXd::Constant(1, 1)) ConstType
Definition: CompiledAssignment.h:504
MatrixMultBase(const Eigen::Ref< const Eigen::MatrixXd > &M)
Definition: CompiledAssignment.h:492
void applyMatrixMultCached(MatrixType &cache, const T &M)
Definition: CompiledAssignment.h:520
std::enable_if<!isVector< MatrixType >::value, PostType< T > >::type applyMatrixMult(const T &M)
Definition: CompiledAssignment.h:511
decltype(std::declval< T >() *std::declval< InvDiagType >()) PostType
Definition: CompiledAssignment.h:502
decltype(std::declval< Eigen::Ref< const Eigen::MatrixXd > >().diagonal().cwiseInverse().asDiagonal()) InvDiagType
Definition: CompiledAssignment.h:496
std::enable_if< isVector< MatrixType >::value, PreType< T > >::type applyMatrixMult(const T &M)
Definition: CompiledAssignment.h:507
Definition: CompiledAssignment.h:419
Definition: CompiledAssignment.h:88
Definition: CompiledAssignment.h:95
static std::tuple_element< N, std::tuple< Args... > >::type get(Args &&... args)
Definition: CompiledAssignment.h:98
Definition: CompiledAssignment.h:121
Definition: CompiledAssignment.h:106
static NoArg get(Args &&...)
Definition: CompiledAssignment.h:109
Definition: CompiledAssignment.h:545
const SourceType & from() const
Definition: CompiledAssignment.h:551
SourceBase(const SourceType &from)
Definition: CompiledAssignment.h:549
void from(const SourceType &from)
Definition: CompiledAssignment.h:553
typename std::conditional< F==CONSTANT, double, Eigen::Ref< const MatrixType > >::type SourceType
Definition: CompiledAssignment.h:547
WeightMultBase(const Eigen::Ref< const Eigen::VectorXd > &d)
Definition: CompiledAssignment.h:400
ReturnType< T > applyWeightMult(const T &M)
Definition: CompiledAssignment.h:405
decltype(std::declval< Eigen::Ref< const Eigen::VectorXd > >().asDiagonal() *std::declval< T >()) ReturnType
Definition: CompiledAssignment.h:403
double applyWeightMult(const double &M)
Definition: CompiledAssignment.h:353
WeightMultBase(NoArg)
Definition: CompiledAssignment.h:351
WeightMultBase(NoArg)
Definition: CompiledAssignment.h:337
const T & applyWeightMult(const T &M)
Definition: CompiledAssignment.h:340
WeightMultBase(const double &s)
Definition: CompiledAssignment.h:378
Definition: CompiledAssignment.h:328
Definition: CompiledAssignment.h:144
Definition: CompiledAssignment.h:218
Definition: CompiledAssignment.h:242
#define TVM_TEMPORARY_ALLOW_EIGEN_MALLOC(x)
Definition: memoryChecks.h:85
Definition: AffineExprDetail.h:95
Definition: probe.h:44
typename std::conditional< MatrixType::ColsAtCompileTime==1, std::true_type, std::false_type >::type isVector
Definition: CompiledAssignment.h:78
Source
Definition: CompiledAssignment.h:65
@ ZERO
Definition: CompiledAssignment.h:69
@ CONSTANT
Definition: CompiledAssignment.h:71
@ EXTERNAL
Definition: CompiledAssignment.h:67
WeightMult
Definition: CompiledAssignment.h:34
@ NONE
Definition: CompiledAssignment.h:35
@ SCALAR
Definition: CompiledAssignment.h:37
@ DIAGONAL
Definition: CompiledAssignment.h:38
@ MINUS
Definition: CompiledAssignment.h:36
AssignType
Definition: CompiledAssignment.h:22
@ ADD
Definition: CompiledAssignment.h:24
@ MAX
Definition: CompiledAssignment.h:27
@ MIN
Definition: CompiledAssignment.h:26
@ SUB
Definition: CompiledAssignment.h:25
@ COPY
Definition: CompiledAssignment.h:23
decltype(hasNoArgCtorDummy(T(NoArg()))) hasNoArgCtor_(int)
typename std::conditional< MatrixType::ColsAtCompileTime !=1, std::true_type, std::false_type >::type isMatrix
Definition: CompiledAssignment.h:84
MatrixMult
Definition: CompiledAssignment.h:45
@ CUSTOM
Definition: CompiledAssignment.h:53
@ IDENTITY
Definition: CompiledAssignment.h:47
@ GENERAL
Definition: CompiledAssignment.h:49
@ INVERSE_DIAGONAL
Definition: CompiledAssignment.h:51
std::true_type hasNoArgCtorDummy(const T &)
Proportional P
Definition: Proportional.h:92
Definition: Clock.h:12