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

Commit ca98a28

Browse files
author
Sven Verdoolaege
committed
makeSpecializationSet: do not assume parameters have a fixed position
Additionally, do not require the user to add the parameters to the space first. Trying to check if a parameter already appears in a space currently requires functionality that is only available in the TC copy of isl, which is what this commit is trying to remove. Simply adding the parameter if it does not already appear is much easier.
1 parent 51bb12f commit ca98a28

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

include/tc/external/detail/islpp.h

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -317,37 +317,24 @@ inline isl::set makeParameterContext(
317317

318318
// Given a space and values for parameters, this function creates the set
319319
// that ties the space parameter to the values.
320-
// This assumes space.dim(isl::dim_type::param) == paramValues.size()
321320
//
322321
template <typename T>
323322
inline isl::set makeSpecializationSet(
324323
isl::space space,
325-
const std::unordered_map<int, T>& paramValues) {
326-
CHECK_GE(space.dim(isl::dim_type::param), paramValues.size());
327-
auto lspace = isl::local_space(space);
324+
const std::unordered_map<std::string, T>& paramValues) {
325+
auto ctx = space.get_ctx();
326+
for (auto kvp : paramValues) {
327+
space = space.add_param(isl::id(ctx, kvp.first));
328+
}
328329
auto set = isl::set::universe(space);
329330
for (auto kvp : paramValues) {
330-
auto affParam = isl::aff(lspace, isl::dim_type::param, kvp.first);
331+
auto id = isl::id(ctx, kvp.first);
332+
isl::aff affParam(isl::aff::param_on_domain_space(space, id));
331333
set = set & (isl::aff_set(affParam) == kvp.second);
332334
}
333335
return set;
334336
}
335337

336-
template <typename T>
337-
inline isl::set makeSpecializationSet(
338-
isl::space space,
339-
const std::unordered_map<std::string, T>& paramValues) {
340-
CHECK_GE(space.dim(isl::dim_type::param), paramValues.size());
341-
std::unordered_map<int, T> aux;
342-
for (auto kvp : paramValues) {
343-
auto pos = space.find_dim_by_name(isl::dim_type::param, kvp.first);
344-
CHECK_LE(0, pos) << "No " << kvp.first << " in: " << space;
345-
CHECK_EQ(0, aux.count(pos));
346-
aux[pos] = kvp.second;
347-
}
348-
return makeSpecializationSet(space, aux);
349-
}
350-
351338
template <typename T>
352339
inline isl::set makeSpecializationSet(
353340
isl::space space,

0 commit comments

Comments
 (0)