Skip to content

Commit 3744a82

Browse files
committed
Added padded property
1 parent cf45095 commit 3744a82

File tree

11 files changed

+54
-21
lines changed

11 files changed

+54
-21
lines changed

include/taco/format.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ class ModeFormat {
9797
/// Properties of a mode format
9898
enum Property {
9999
FULL, NOT_FULL, ORDERED, NOT_ORDERED, UNIQUE, NOT_UNIQUE, BRANCHLESS,
100-
NOT_BRANCHLESS, COMPACT, NOT_COMPACT, ZEROLESS, NOT_ZEROLESS
100+
NOT_BRANCHLESS, COMPACT, NOT_COMPACT, ZEROLESS, NOT_ZEROLESS, PADDED,
101+
NOT_PADDED
101102
};
102103

103104
/// Instantiates an undefined mode format
@@ -129,6 +130,7 @@ class ModeFormat {
129130
bool isBranchless() const;
130131
bool isCompact() const;
131132
bool isZeroless() const;
133+
bool isPadded() const;
132134

133135
/// Returns true if a mode format has a specific capability, false otherwise
134136
bool hasCoordValIter() const;

include/taco/lower/mode_format_impl.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ class ModeFormatImpl {
106106
public:
107107
ModeFormatImpl(std::string name, bool isFull, bool isOrdered, bool isUnique,
108108
bool isBranchless, bool isCompact, bool isZeroless,
109-
bool hasCoordValIter, bool hasCoordPosIter, bool hasLocate,
110-
bool hasInsert, bool hasAppend, bool hasSeqInsertEdge,
111-
bool hasInsertCoord, bool isYieldPosPure);
109+
bool isPadded, bool hasCoordValIter, bool hasCoordPosIter,
110+
bool hasLocate, bool hasInsert, bool hasAppend,
111+
bool hasSeqInsertEdge, bool hasInsertCoord,
112+
bool isYieldPosPure);
112113

113114
virtual ~ModeFormatImpl();
114115

@@ -246,6 +247,7 @@ class ModeFormatImpl {
246247
const bool isBranchless;
247248
const bool isCompact;
248249
const bool isZeroless;
250+
const bool isPadded;
249251

250252
const bool hasCoordValIter;
251253
const bool hasCoordPosIter;

include/taco/lower/mode_format_singleton.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ class SingletonModeFormat : public ModeFormatImpl {
1010
using ModeFormatImpl::getInsertCoord;
1111

1212
SingletonModeFormat();
13-
SingletonModeFormat(bool isFull, bool isOrdered,
14-
bool isUnique, bool isZeroless, long long allocSize = DEFAULT_ALLOC_SIZE);
13+
SingletonModeFormat(bool isFull, bool isOrdered, bool isUnique,
14+
bool isZeroless, bool isPadded,
15+
long long allocSize = DEFAULT_ALLOC_SIZE);
1516

1617
~SingletonModeFormat() override {}
1718

src/format.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ bool ModeFormat::hasProperties(const std::vector<Property>& properties) const {
187187
return false;
188188
}
189189
break;
190+
case PADDED:
191+
if (!isPadded()) {
192+
return false;
193+
}
194+
break;
190195
case NOT_FULL:
191196
if (isFull()) {
192197
return false;
@@ -217,6 +222,11 @@ bool ModeFormat::hasProperties(const std::vector<Property>& properties) const {
217222
return false;
218223
}
219224
break;
225+
case NOT_PADDED:
226+
if (isPadded()) {
227+
return false;
228+
}
229+
break;
220230
}
221231
}
222232
return true;
@@ -252,6 +262,11 @@ bool ModeFormat::isZeroless() const {
252262
return impl->isZeroless;
253263
}
254264

265+
bool ModeFormat::isPadded() const {
266+
taco_iassert(defined());
267+
return impl->isPadded;
268+
}
269+
255270
bool ModeFormat::hasCoordValIter() const {
256271
taco_iassert(defined());
257272
return impl->hasCoordValIter;

src/lower/mode_format_compressed.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ CompressedModeFormat::CompressedModeFormat(bool isFull, bool isOrdered,
1717
bool isUnique, bool isZeroless,
1818
long long allocSize) :
1919
ModeFormatImpl("compressed", isFull, isOrdered, isUnique, false, true,
20-
isZeroless, false, true, false, false, true, true, true,
21-
false),
20+
isZeroless, false, false, true, false, false, true, true,
21+
true, false),
2222
allocSize(allocSize) {
2323
}
2424

src/lower/mode_format_dense.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ DenseModeFormat::DenseModeFormat() : DenseModeFormat(true, true, false) {
1111
DenseModeFormat::DenseModeFormat(const bool isOrdered, const bool isUnique,
1212
const bool isZeroless) :
1313
ModeFormatImpl("dense", true, isOrdered, isUnique, false, true, isZeroless,
14-
false, false, true, true, false, false, false, true) {
14+
true, false, false, true, true, false, false, false, true) {
1515
}
1616

1717
ModeFormat DenseModeFormat::copy(

src/lower/mode_format_impl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,16 @@ std::ostream& operator<<(std::ostream& os, const ModeFunction& modeFunction) {
147147
// class ModeTypeImpl
148148
ModeFormatImpl::ModeFormatImpl(const std::string name, bool isFull,
149149
bool isOrdered, bool isUnique, bool isBranchless,
150-
bool isCompact, bool isZeroless,
150+
bool isCompact, bool isZeroless, bool isPadded,
151151
bool hasCoordValIter, bool hasCoordPosIter,
152152
bool hasLocate, bool hasInsert, bool hasAppend,
153153
bool hasSeqInsertEdge, bool hasInsertCoord,
154154
bool isYieldPosPure) :
155155
name(name), isFull(isFull), isOrdered(isOrdered), isUnique(isUnique),
156156
isBranchless(isBranchless), isCompact(isCompact), isZeroless(isZeroless),
157-
hasCoordValIter(hasCoordValIter), hasCoordPosIter(hasCoordPosIter),
158-
hasLocate(hasLocate), hasInsert(hasInsert), hasAppend(hasAppend),
157+
isPadded(isPadded), hasCoordValIter(hasCoordValIter),
158+
hasCoordPosIter(hasCoordPosIter), hasLocate(hasLocate),
159+
hasInsert(hasInsert), hasAppend(hasAppend),
159160
hasSeqInsertEdge(hasSeqInsertEdge), hasInsertCoord(hasInsertCoord),
160161
isYieldPosPure(isYieldPosPure) {
161162
}

src/lower/mode_format_singleton.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ using namespace taco::ir;
1010
namespace taco {
1111

1212
SingletonModeFormat::SingletonModeFormat() :
13-
SingletonModeFormat(false, true, true, false) {
13+
SingletonModeFormat(false, true, true, false, false) {
1414
}
1515

1616
SingletonModeFormat::SingletonModeFormat(bool isFull, bool isOrdered,
1717
bool isUnique, bool isZeroless,
18-
long long allocSize) :
18+
bool isPadded, long long allocSize) :
1919
ModeFormatImpl("singleton", isFull, isOrdered, isUnique, true, true,
20-
isZeroless, false, true, false, false, true, false, true,
21-
true),
20+
isZeroless, isPadded, false, true, false, false, true,
21+
false, true, true),
2222
allocSize(allocSize) {
2323
}
2424

@@ -28,6 +28,7 @@ ModeFormat SingletonModeFormat::copy(
2828
bool isOrdered = this->isOrdered;
2929
bool isUnique = this->isUnique;
3030
bool isZeroless = this->isZeroless;
31+
bool isPadded = this->isPadded;
3132
for (const auto property : properties) {
3233
switch (property) {
3334
case ModeFormat::FULL:
@@ -54,13 +55,19 @@ ModeFormat SingletonModeFormat::copy(
5455
case ModeFormat::NOT_ZEROLESS:
5556
isZeroless = false;
5657
break;
58+
case ModeFormat::PADDED:
59+
isPadded = true;
60+
break;
61+
case ModeFormat::NOT_PADDED:
62+
isPadded = false;
63+
break;
5764
default:
5865
break;
5966
}
6067
}
6168
const auto singletonVariant =
6269
std::make_shared<SingletonModeFormat>(isFull, isOrdered, isUnique,
63-
isZeroless);
70+
isZeroless, isPadded);
6471
return ModeFormat(singletonVariant);
6572
}
6673

@@ -128,7 +135,7 @@ Expr SingletonModeFormat::getAssembledSize(Expr prevSize, Mode mode) const {
128135
Stmt SingletonModeFormat::getInitCoords(Expr prevSize,
129136
std::vector<AttrQueryResult> queries, Mode mode) const {
130137
Expr crdArray = getCoordArray(mode.getModePack());
131-
return Allocate::make(crdArray, prevSize, false, Expr(), true);
138+
return Allocate::make(crdArray, prevSize, false, Expr(), isPadded);
132139
}
133140

134141
ModeFunction SingletonModeFormat::getYieldPos(Expr parentPos,

test/tests-expr_storage.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,11 +957,13 @@ INSTANTIATE_TEST_CASE_P(bspmv, expr,
957957
)
958958
);
959959

960+
Format ell({Dense, Dense, Singleton({ModeFormat::UNIQUE, ModeFormat::PADDED})});
961+
960962
INSTANTIATE_TEST_CASE_P(espmv, expr,
961963
Values(
962964
TestData(Tensor<double>("a",{5},Format({Dense})),
963965
{i},
964-
d355a("B",Format({Dense, Dense, Singleton(ModeFormat::UNIQUE)}))(j,i,k) *
966+
d355a("B", ell)(j,i,k) *
965967
d5e("c",Format({Dense}))(k),
966968
{
967969
{

test/tests-merge_lattice.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ namespace tests {
2424
class HashedModeFormat : public ModeFormatImpl {
2525
public:
2626
HashedModeFormat() : ModeFormatImpl("hashed", false, false, true, false,
27-
false, false, false, true, true, true,
28-
false, true, true, false) {}
27+
false, false, false, false, true, true,
28+
true, false, true, true, false) {}
2929

3030
ModeFormat copy(std::vector<ModeFormat::Property> properties) const {
3131
return ModeFormat(std::make_shared<HashedModeFormat>());

0 commit comments

Comments
 (0)