[RFC] Make tflite frontend more data driven / improve errors. #5519
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a draft PR and only for discussion but not for merging as is.
These are a couple of commits that show a proof of concept about how we could restructure and improve the tflite frontend. I've lightly tested these by compiling a couple of tflite models to give me some confidence that they work. If this looks reasonable I'm happy to pull things out into separate individual pull requests that could allow us to migrate to this with newer operators that get added and refactor the existing operators in a piecemeal fashion with time and availability of folks.
The first commit tries to make the tflite operator table more data driven, the observation being that the common case is that of input and output operands being subject to an equality check that we can commonize into the top level. This means we can reduce the number of individual checks in every helper function and thus making it simpler for our developers to add new operators.
The second commit here shows another aspect of the tflite frontend which is the use of asserts instead of using tvm.error . If we have a set of errors that can be raised by the various frontends attached to tvm, we should use them more efficiently.
Thanks,
Ramana
@tqchen , @anijain2305 , @FrozenGene - comments / reviews would be welcome.