-
Notifications
You must be signed in to change notification settings - Fork 3.8k
TVMC: Add new text/relay frontend #10941
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
Conversation
fbeb139 to
ca4962a
Compare
leandron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general the functionality looks good. I have reservations about calling it "text" frontend. My suggestion is to refer to it as "Relay" frontend, so that it is more specific. See my suggestions below, and if you agree, adjust in the other places affected, for example, log messages.
|
@leandron Thank you for your feedback. I already considered using the name What do you think about adding a way to provide custom (non-constant) data for the weights? This would involve small changes to the TVMC command line as more that one input file (e.g. |
I think the package makes it clear as a distinction, so I'd be in favour or renaming
Not sure, it feels like we should think about a file format that incorporate all these for Relay, so that we bundle all that is needed in a single file to be used and reused in TVM, rather making it a special case in tvmc? it would be the "relay" export format, so to speak. cc @areusch |
areusch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @PhilippvK, i agree with calling it relay frontend but am very supportive of adding this!
|
Thanks for your feedback. I renamed all instances of The recommended approach for bundling the relay format with the parameters/weights wouldn't be solved in this PR, right? As recommended by @areusch I could add a warning like |
You're correct. This would need to be agreed within the TVM community in an RFC.
I think this message is OK given it is the Relay frontend and it has limited scope in terms of published models. However, I would suggest, for the sake of having a better way to provide Relay in future (not only in tvmc, but for TVM in general), to start that discussion above (regarding a Relay format that includes parameters) in the community forum - https://discuss.tvm.apache.org - what do you think? |
|
@leandron I totally agree. I will start a thread in the discussion forum in the next few days. |
|
This failed in CI due to what is being fixed in #11007. Once that gets merged, I think we can re-trigger CI here to get this merged. |
leandron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
a19ae3a to
83736e2
Compare
|
I just ran into a few issues with the implementation when providing more complex models. I will have a look at but, but please do not merge this in its current state. Sorry for the inconvenience. |
|
@PhilippvK we could also merge and you could submit some fixes. could you elaborate? |
b6328a4 to
ecc49b0
Compare
|
These are the two issues I ran into:
@areusch Feel free to have another look at the changes. |
|
hm. for (1), it seems like we could do something like:
for (2), that seems like an oversight on Model Library Format part. it seems like we should make tvmc validate the version numbers in relay models. Perhaps we should change Model Library Format? i suppose it's also a bit of a burden on users authoring relay to figure out the presently-supported version, and they probably always just mean "the current version." so maybe allowing some implicitness there makes sense. @leandron what are your thoughts? |
This feature enables passing a textural representation of a relay module to the tvmc command line. Example: `tvmc compile relay.txt --target c --runtime=crt --executor=aot --executor-aot-unpacked-api=1 --pass-config tir.disable_vectorize=1 -f mlf` Currently it is not possible to supply parameters as it is mainly intended to be used for testing certain relay functions or operators. In the future (with minor changes to the tvmc frontend api) params could be passed via an additional i.e. `params.bin` file This commit also adds minimal unit testing of the added feature. Resolve PR comments TVMC: add warning if relay frontend is used
…t-shapes is provided This prevents that the constants inputs are used for Constant folding, thus changing the complexity of the model. If there would be a way, to distinguish between model inputs and parameter this workaround would not be required.
…m.parser.fromtext()
ecc49b0 to
2797383
Compare
I currently already use
Would maybe be a good idea for the future, but I think this is out-of scope for this PR.
The thing is that exporting the full relay model including metadata can result in very lang files which might not be desirable for the
I can look into this. |
|
@PhilippvK I'm merging this after a long time. It's a great new feature - sorry it took so long to realise it was pending. |
* TVMC: Add new text/relay frontend This feature enables passing a textural representation of a relay module to the tvmc command line. Example: `tvmc compile relay.txt --target c --runtime=crt --executor=aot --executor-aot-unpacked-api=1 --pass-config tir.disable_vectorize=1 -f mlf` Currently it is not possible to supply parameters as it is mainly intended to be used for testing certain relay functions or operators. In the future (with minor changes to the tvmc frontend api) params could be passed via an additional i.e. `params.bin` file This commit also adds minimal unit testing of the added feature. Resolve PR comments TVMC: add warning if relay frontend is used * [TVMC] populate parameters with random values instead of ones * [TVMC] Relay frontend: do not populate input tensor buffers if --input-shapes is provided This prevents that the constants inputs are used for Constant folding, thus changing the complexity of the model. If there would be a way, to distinguish between model inputs and parameter this workaround would not be required. * [TVMC] Relay frontend: check provided file contents before calling tvm.parser.fromtext()
* TVMC: Add new text/relay frontend This feature enables passing a textural representation of a relay module to the tvmc command line. Example: `tvmc compile relay.txt --target c --runtime=crt --executor=aot --executor-aot-unpacked-api=1 --pass-config tir.disable_vectorize=1 -f mlf` Currently it is not possible to supply parameters as it is mainly intended to be used for testing certain relay functions or operators. In the future (with minor changes to the tvmc frontend api) params could be passed via an additional i.e. `params.bin` file This commit also adds minimal unit testing of the added feature. Resolve PR comments TVMC: add warning if relay frontend is used * [TVMC] populate parameters with random values instead of ones * [TVMC] Relay frontend: do not populate input tensor buffers if --input-shapes is provided This prevents that the constants inputs are used for Constant folding, thus changing the complexity of the model. If there would be a way, to distinguish between model inputs and parameter this workaround would not be required. * [TVMC] Relay frontend: check provided file contents before calling tvm.parser.fromtext()
This feature enables passing a textural representation of a relay module to the tvmc command line.
Example:
tvmc compile relay.txt --target c --runtime=crt --executor=aot --executor-aot-unpacked-api=1 --pass-config tir.disable_vectorize=1 -f mlfCurrently it is not possible to supply parameters as it is mainly intended to be used for testing certain relay functions or operators. In the future (with minor changes to the tvmc frontend api) params could be passed via an additional i.e.
params.binfileThis commit also adds minimal unit testing of the added feature.