Skip to content

Commit 5a4d5fc

Browse files
committed
Rebase for orAlgebra
1 parent dc394d1 commit 5a4d5fc

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ numba==0.53.0
66
numpy==1.19.5
77
opencv-python==4.5.1.48
88
packaging==20.9
9-
pkg-resources==0.0.0
109
pluggy==0.13.1
1110
py==1.10.0
1211
py-cpuinfo==7.0.0

taco/ufuncs.cpp

+43-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
using namespace taco;
1515

16+
// XOR Op and Algebra
1617
struct GeneralAdd {
1718
ir::Expr operator()(const std::vector<ir::Expr> &v) {
1819
taco_iassert(v.size() >= 1) << "Add operator needs at least one operand";
@@ -45,6 +46,7 @@ struct orAlgebra {
4546
}
4647
};
4748

49+
// Right shift op and Algebra
4850
struct RightShift{
4951
ir::Expr operator()(const std::vector<ir::Expr> &v) {
5052
if (v.size() == 1)
@@ -64,6 +66,7 @@ struct leftIncAlgebra {
6466
}
6567
};
6668

69+
// LdExp Op (algbra same as right shift)
6770
struct Ldexp {
6871
ir::Expr operator()(const std::vector<ir::Expr> &v) {
6972
if (v.size() == 1)
@@ -77,6 +80,46 @@ struct Ldexp {
7780
}
7881
};
7982

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+
80123
template <int I, class...Ts>
81124
decltype(auto) get(Ts&&... ts) {
82125
return std::get<I>(std::forward_as_tuple(ts...));
@@ -136,9 +179,6 @@ static void bench_ufunc_sparse(benchmark::State& state, ExtraArgs&&... extra_arg
136179
A.pack(); B.pack();
137180

138181
// 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
142182
printTensor(A, "./data", __FUNCTION__ , dim, extra_args...);
143183
printTensor(B, "./data", __FUNCTION__ , dim, extra_args...);
144184

0 commit comments

Comments
 (0)