Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 25a014a

Browse files
author
Sven Verdoolaege
committed
memory_promotion.cc: extract out shared add_range
This function isolates lower-level space manipulations and uses the newly introduced isl::space::unnamed_set_from_params. It may be useful to add a function similar to add_range to isl itself, but for now it is easier to add the function locally.
1 parent 670c461 commit 25a014a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tc/core/polyhedral/memory_promotion.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ ScopedFootprint outputRanges(isl::map access) {
9898
}
9999
return footprint;
100100
}
101+
102+
// Given a set space, construct a map space with the input as domain and
103+
// a range of the given size.
104+
isl::space add_range(isl::space space, unsigned dim) {
105+
auto range = space.params().unnamed_set_from_params(dim);
106+
return space.map_from_domain_and_range(range);
107+
}
108+
101109
} // namespace
102110

103111
// Access has the shape :: [D -> ref] -> O
@@ -128,8 +136,7 @@ std::unique_ptr<TensorReferenceGroup> TensorReferenceGroup::makeSingleton(
128136
}
129137

130138
isl::set ScopedFootprint::footprint(isl::set domain) const {
131-
auto space = domain.get_space().from_domain();
132-
space = space.add_dims(isl::dim_type::out, size());
139+
auto space = add_range(domain.get_space(), size());
133140
auto accessed = isl::map::universe(space).intersect_domain(domain);
134141
auto lspace = isl::local_space(accessed.get_space().range());
135142

@@ -147,8 +154,7 @@ isl::multi_aff ScopedFootprint::lowerBounds() const {
147154
if (size() == 0) {
148155
throw promotion::PromotionNYI("promotion for scalars");
149156
}
150-
auto space = at(0).lowerBound.get_space();
151-
space = space.add_dims(isl::dim_type::out, size() - 1);
157+
auto space = add_range(at(0).lowerBound.get_space().domain(), size());
152158
auto ma = isl::multi_aff::zero(space);
153159

154160
int i = 0;
@@ -442,7 +448,7 @@ isl::multi_aff dropDummyTensorDimensions(
442448
}
443449
}
444450

445-
space = space.from_domain().add_dims(isl::dim_type::out, list.n());
451+
space = add_range(space, list.n());
446452
return isl::multi_aff(space, list);
447453
}
448454
} // namespace

0 commit comments

Comments
 (0)