Skip to content

Conversation

@tqchen
Copy link
Member

@tqchen tqchen commented Jan 8, 2018

Resolves #746

Detect pattern dst[index] = f(src[index]) and fold src with dst when possible

Known limitation:

the current detection algorithm cannot handle the case when a location in an array is written multiple times. For example, the following program will pass the check, but we cannot make A and B to be the same array.

A[0] = B[0] + 1
A[0] = B[0] + 1

The high-level code generator needs to ensure that the generated code only write each location of the target once. This is the case with the current schedule.

This limitation is documented in the comment

So this pass works fine for now. To enhance the safety, we might be able to use another pass to detect some sufficient condition when an array is written once in each location, which requires some work but can be useful to make it work for an arbitrary segment of IR.

@tqchen
Copy link
Member Author

tqchen commented Jan 8, 2018

@tqchen tqchen merged commit 67b14a2 into apache:master Jan 8, 2018
tqchen added a commit to tqchen/tvm that referenced this pull request Jul 6, 2018
* [PASS] StorageRewrite Fold Inplace op storage when possible

* update comment to fix typos
sergei-mironov pushed a commit to sergei-mironov/tvm that referenced this pull request Aug 8, 2018
* [PASS] StorageRewrite Fold Inplace op storage when possible

* update comment to fix typos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant