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

Commit 9ee4c33

Browse files
author
Sven Verdoolaege
committed
halide2isl.cc: extractAccess: construct expressions on parameter space
Since 2ab86bb (makeIslAffFromExpr: only accept parametric expressions, Mon Mar 26 14:50:33 2018 +0200), makeIslAffFromExpr only constructs parametric expressions. However, it would still accept a set space as input and extractAccess continued to do so. Call it on a parameter space instead for consistency. This will make it easier to provide proper typing of makeIslAffFromExpr when switching to templated isl types.
1 parent 1e7572d commit 9ee4c33

File tree

4 files changed

+76
-2
lines changed

4 files changed

+76
-2
lines changed

tc/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ add_library(
3434
polyhedral/scop.cc
3535
polyhedral/separation.cc
3636
polyhedral/unroll.cc
37+
polyhedral/utils.cc
3738
)
3839
target_include_directories(tc_core PUBLIC ${LLVM_INCLUDE_DIRS})
3940
target_link_libraries(

tc/core/halide2isl.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "tc/core/polyhedral/schedule_isl_conversion.h"
2525
#include "tc/core/polyhedral/schedule_transforms.h"
2626
#include "tc/core/polyhedral/schedule_tree.h"
27+
#include "tc/core/polyhedral/utils.h"
2728
#include "tc/core/tc2halide.h"
2829

2930
namespace tc {
@@ -259,7 +260,8 @@ isl::map extractAccess(
259260

260261
isl::space paramSpace = domain.paramSpace;
261262
isl::id tensorID(paramSpace.get_ctx(), tensor);
262-
auto tensorSpace = paramSpace.add_named_tuple_id_ui(tensorID, args.size());
263+
auto tensorTuple = constructTensorTuple(paramSpace, tensorID, args.size());
264+
auto tensorSpace = tensorTuple.get_space();
263265

264266
// Start with a totally unconstrained set - every point in
265267
// the allocation could be accessed.
@@ -275,8 +277,9 @@ isl::map extractAccess(
275277
// The coordinate written to in the range ...
276278
auto rangePoint = identity.get_aff(i);
277279
// ... equals the coordinate accessed as a function of the parameters.
278-
auto domainPoint = halide2isl::makeIslAffFromExpr(tensorSpace, args[i]);
280+
auto domainPoint = halide2isl::makeIslAffFromExpr(paramSpace, args[i]);
279281
if (!domainPoint.is_null()) {
282+
domainPoint = domainPoint.unbind_params_insert_domain(tensorTuple);
280283
access = access.intersect(domainPoint.eq_set(rangePoint));
281284
}
282285
}

tc/core/polyhedral/utils.cc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright (c) 2018, Facebook, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#include "tc/core/polyhedral/utils.h"
17+
18+
namespace tc {
19+
namespace polyhedral {
20+
21+
/* Construct a tuple representing the tensor with identifier "tensorId" and
22+
* dimension "dim" from the parameter space "paramSpace",
23+
* without any specific names for the indices, from the perspective
24+
* of the user.
25+
* Since some names are required, use names of the form "__tc_tensor_arg*".
26+
*/
27+
isl::multi_id
28+
constructTensorTuple(isl::space paramSpace, isl::id tensorId, size_t dim) {
29+
auto tensorSpace = paramSpace.add_named_tuple_id_ui(tensorId, dim);
30+
isl::id_list tensorArgs(paramSpace.get_ctx(), 0);
31+
for (size_t i = 0; i < dim; ++i) {
32+
auto name = std::string("__tc_tensor_arg") + std::to_string(i);
33+
tensorArgs = tensorArgs.add(isl::id(paramSpace.get_ctx(), name));
34+
}
35+
return isl::multi_id(tensorSpace, tensorArgs);
36+
}
37+
38+
} // namespace polyhedral
39+
} // namespace tc

tc/core/polyhedral/utils.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Copyright (c) 2018, Facebook, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#pragma once
17+
18+
#include "tc/external/isl.h"
19+
20+
namespace tc {
21+
namespace polyhedral {
22+
23+
/* Construct a tuple representing the tensor with identifier "tensorId" and
24+
* dimension "dim" from the parameter space "paramSpace",
25+
* without any specific names for the indices.
26+
*/
27+
isl::multi_id
28+
constructTensorTuple(isl::space paramSpace, isl::id tensorId, size_t dim);
29+
30+
} // namespace polyhedral
31+
} // namespace tc

0 commit comments

Comments
 (0)