Lunderberg commented on code in PR #14502:
URL: https://github.com/apache/tvm/pull/14502#discussion_r1160750098
##########
src/tir/schedule/primitive/compute_inline.cc:
##########
@@ -295,7 +295,8 @@ class BaseInliner : public StmtExprMutator {
* \param stmt The statement in which to count undefined variables
*/
static int GetNumUndefinedNonpointerVars(const Stmt& stmt) {
- auto undefined_vars = UndefinedVars(stmt, {});
+ // Do not visit buffer shape/strides.
+ auto undefined_vars = UndefinedVars(/*stmt=*/stmt, /*defs=*/{},
/*visit_buffer=*/false);
Review Comment:
As I'm thinking on it, this would also allow `compute_inline` to apply in
cases that are currently forbidden, but are semantically valid. In the example
below, the block `"B"` couldn't be inlined, because it refers to the variable
`value`. However, `value`'s definition is accessible from both block `"B"` and
block `"C"`, so it could be inlined without risk of an undefined variable.
```python
@T.prim_func
def func(A: T.Buffer(64, "int32"), C: T.Buffer(64, "int32")):
B = T.alloc_buffer(64, "int32")
value: T.int32 = 42
for i in range(64):
with T.block("B"):
vi = T.axis.remap("S", [i])
B[vi] = value
for i in range(64):
with T.block("C"):
vi = T.axis.remap("S", [i])
C[vi] = value
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]