Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OP] Introduces auxiliary attrs into compute #1293

Merged
merged 2 commits into from
Jun 17, 2018
Merged

Conversation

tqchen
Copy link
Member

@tqchen tqchen commented Jun 16, 2018

Previously we allow set a tag field to indicate the type of the compute op. After discussing with various TOPI developers, we find that it is helpful to further embed more meta information, such as padding size of the conv2d, to pass information from compute to schedule function. This PR introduces such change.

Attrs allows storing any Expr indexed by string.

Example

n = 10
m = 100
C = tvm.compute((n, m), 
    lambda i, j: tvm.sum(A[i, k] * B[j, k], axis=k), attrs={"n" : n, "shape":[n, m]})
print(C.op.attrs)
assert C.op.attrs["n"].value == 10
assert C.op.attrs["shape"][1].value == 100

NOTE

This change will break the json storage convention of the current TVM operations.

@tqchen
Copy link
Member Author

tqchen commented Jun 16, 2018

@merrymercy @Laurawly @cowanmeg @srkreddy1238 can you review this PR?

@cowanmeg
Copy link
Contributor

Looks good to me. If I'm understanding correctly this is to make it easier to look-up or compute parameters that are shared across compute and schedule? For example, in the rasp conv2d we wouldn't need to infer the stride and padding in the schedules if they were attributes.

@srkreddy1238
Copy link
Contributor

srkreddy1238 commented Jun 17, 2018

Expr or Array<Expr> ??
In the context of passing a tuple (ex pad) leads to passing 2 or 4 different attributes !

@tqchen
Copy link
Member Author

tqchen commented Jun 17, 2018

@srkreddy1238 made a very good point. I have changed the attrs to be Map<std::string, NodeRef>, so we can store any node object as an attribute value. test cases are updated.

@tqchen tqchen merged commit df4a629 into apache:master Jun 17, 2018
tqchen added a commit to tqchen/tvm that referenced this pull request Jul 6, 2018
mnuyens pushed a commit to mnuyens/tvm that referenced this pull request Jul 10, 2018
sergei-mironov pushed a commit to sergei-mironov/tvm that referenced this pull request Aug 8, 2018
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.

None yet

3 participants