13
13
14
14
using namespace taco ;
15
15
16
+ // XOR Op and Algebra
16
17
struct GeneralAdd {
17
18
ir::Expr operator ()(const std::vector<ir::Expr> &v) {
18
19
taco_iassert (v.size () >= 1 ) << " Add operator needs at least one operand" ;
@@ -45,6 +46,7 @@ struct orAlgebra {
45
46
}
46
47
};
47
48
49
+ // Right shift op and Algebra
48
50
struct RightShift {
49
51
ir::Expr operator ()(const std::vector<ir::Expr> &v) {
50
52
if (v.size () == 1 )
@@ -64,6 +66,7 @@ struct leftIncAlgebra {
64
66
}
65
67
};
66
68
69
+ // LdExp Op (algbra same as right shift)
67
70
struct Ldexp {
68
71
ir::Expr operator ()(const std::vector<ir::Expr> &v) {
69
72
if (v.size () == 1 )
@@ -77,6 +80,46 @@ struct Ldexp {
77
80
}
78
81
};
79
82
83
+ // Power op and algebra (X U Y^(c) if 1 compressed out, X^(c) U Y if 0 compressed out)
84
+ struct Power {
85
+ ir::Expr operator ()(const std::vector<ir::Expr> &v) {
86
+ if (v.size () == 1 )
87
+ return v[0 ];
88
+
89
+ ir::Expr pow = ir::BinOp::make (v[0 ], v[1 ], " pow(" , " , " , " )" );
90
+ for (size_t idx = 2 ; idx < v.size (); ++idx) {
91
+ pow = ir::BinOp::make (pow , v[idx], " pow(" , " , " , " )" );
92
+ }
93
+ return pow ;
94
+ }
95
+ };
96
+
97
+ struct UnionRightCompAlgebra {
98
+ IterationAlgebra operator ()(const std::vector<IndexExpr>& regions) {
99
+ return Union (regions[0 ], Complement (regions[1 ]));
100
+ }
101
+ };
102
+
103
+ struct UnionLeftCompAlgebra {
104
+ IterationAlgebra operator ()(const std::vector<IndexExpr>& regions) {
105
+ return Union (Complement (regions[0 ]), regions[1 ]);
106
+ }
107
+ };
108
+
109
+ // Logical Not Op and Algebra
110
+ struct Power {
111
+ ir::Expr operator ()(const std::vector<ir::Expr> &v) {
112
+ return ir::Literal (1 , v.get )
113
+ }
114
+ };
115
+
116
+ struct CompAlgebra {
117
+ IterationAlgebra operator ()(const std::vector<IndexExpr>& regions) {
118
+ return Complement (regions[0 ]);
119
+ }
120
+ };
121
+
122
+
80
123
template <int I, class ...Ts>
81
124
decltype (auto ) get(Ts&&... ts) {
82
125
return std::get<I>(std::forward_as_tuple (ts...));
@@ -136,9 +179,6 @@ static void bench_ufunc_sparse(benchmark::State& state, ExtraArgs&&... extra_arg
136
179
A.pack (); B.pack ();
137
180
138
181
// Output tensors to file
139
- // FIXME (owhsu): Why for dim == 10, does the CSR dense mode repeat indices?
140
- // This is causing a problem for the format of csr_matrix(...) in pytest
141
- // See <repo>/data/* for examples
142
182
printTensor (A, " ./data" , __FUNCTION__ , dim, extra_args...);
143
183
printTensor (B, " ./data" , __FUNCTION__ , dim, extra_args...);
144
184
0 commit comments