TVM  0.9.4
DiagonalCalculator.h
Go to the documentation of this file.
1 
3 #pragma once
4 
5 #include <tvm/api.h>
6 #include <tvm/defs.h>
7 
10 
11 namespace tvm
12 {
13 
14 namespace hint
15 {
16 
17 namespace internal
18 {
25 {
26 public:
28  {
29  public:
30  Impl(const std::vector<LinearConstraintPtr> & cstr,
31  const std::vector<VariablePtr> & x,
32  int rank,
33  Eigen::DenseIndex first,
34  Eigen::DenseIndex size);
35  Impl(const std::vector<LinearConstraintPtr> & cstr,
36  const std::vector<VariablePtr> & x,
37  int rank,
38  const std::vector<Eigen::DenseIndex> & nnzRows,
39  const std::vector<Eigen::DenseIndex> & zeroRows);
40 
41  virtual void update_() override;
43  MatrixRef outS,
44  const MatrixConstRef & in,
45  bool minus) const override;
46  virtual void postMultiplyByN_(MatrixRef out, const MatrixConstRef & in, bool add) const override;
47 
48  private:
49  void build();
50 
51  Eigen::DenseIndex first_;
52  Eigen::DenseIndex size_;
53  std::vector<Eigen::DenseIndex> nnz_; // indices of the non-zero rows
54  std::vector<Eigen::DenseIndex> innz_; // indices of the non-zero rows in the resulting matrix
55  std::vector<Eigen::DenseIndex> cnnz_; // complementary to nnz in [0:col-1]
56  std::vector<Eigen::DenseIndex> zeros_; // indices of the zero rows
57 
58  Eigen::VectorXd inverse_;
59  };
60 
65  DiagonalCalculator(Eigen::DenseIndex first = 0, Eigen::DenseIndex size = -1);
84  DiagonalCalculator(const std::vector<Eigen::DenseIndex> & nnzRows,
85  const std::vector<Eigen::DenseIndex> & zeroRows = {});
86 
87 protected:
88  std::unique_ptr<abstract::SubstitutionCalculatorImpl> impl_(const std::vector<LinearConstraintPtr> & cstr,
89  const std::vector<VariablePtr> & x,
90  int rank) const;
91 
92 private:
93  Eigen::DenseIndex first_;
94  Eigen::DenseIndex size_;
95  std::vector<Eigen::DenseIndex> nnz_; // indices of the non-zero rows
96  std::vector<Eigen::DenseIndex> zeros_; // indices of the zero rows
97 };
98 } // namespace internal
99 
100 } // namespace hint
101 
102 } // namespace tvm
#define TVM_DLLAPI
Definition: api.h:35
Definition: SubstitutionCalculatorImpl.h:33
Definition: SubstitutionCalculator.h:27
Definition: DiagonalCalculator.h:28
Impl(const std::vector< LinearConstraintPtr > &cstr, const std::vector< VariablePtr > &x, int rank, Eigen::DenseIndex first, Eigen::DenseIndex size)
Impl(const std::vector< LinearConstraintPtr > &cstr, const std::vector< VariablePtr > &x, int rank, const std::vector< Eigen::DenseIndex > &nnzRows, const std::vector< Eigen::DenseIndex > &zeroRows)
virtual void postMultiplyByN_(MatrixRef out, const MatrixConstRef &in, bool add) const override
virtual void premultiplyByASharpAndSTranspose_(MatrixRef outA, MatrixRef outS, const MatrixConstRef &in, bool minus) const override
Definition: DiagonalCalculator.h:25
DiagonalCalculator(const std::vector< Eigen::DenseIndex > &nnzRows, const std::vector< Eigen::DenseIndex > &zeroRows={})
std::unique_ptr< abstract::SubstitutionCalculatorImpl > impl_(const std::vector< LinearConstraintPtr > &cstr, const std::vector< VariablePtr > &x, int rank) const
DiagonalCalculator(Eigen::DenseIndex first=0, Eigen::DenseIndex size=-1)
Definition: Clock.h:12
Eigen::Ref< Eigen::MatrixXd > MatrixRef
Definition: defs.h:49
Eigen::Ref< const Eigen::MatrixXd > MatrixConstRef
Definition: defs.h:48