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

[Relax][Frontent] "tensor_ir_inplace" op #16498

Merged

Conversation

MasterJH5574
Copy link
Contributor

This PR introduces the tensor_ir_inplace_op for frontend so that we can leverage our call_tir_inplace in SLM model definition flow.

One unit test is added. This PR also fixed a few typos in type annotations.

This PR introduces the `tensor_ir_inplace_op` for frontend
so that we can leverage our `call_tir_inplace` in SLM model
definition flow.

One unit test is added. This PR also fixed a few typos in
type annotations.
@slyubomirsky
Copy link
Contributor

Thanks for fixing the typos 🙂 Can't believe I had them there in the first place. Is the main reason to add this op so you could use an inline PrimFunc with it?

@MasterJH5574
Copy link
Contributor Author

@slyubomirsky You're welcome! The main reason introducing this op is to use call_tir_inplace under the principle of our new nn.Module interface: so that we can hide the definition of the TIR in a file (e.g., https://github.com/mlc-ai/mlc-llm/blob/0c5f88155/python/mlc_chat/model/llama/llama_model.py#L295-L303), and expose a clean interface without Relax concept to frontend model definition side (e.g., https://github.com/mlc-ai/mlc-llm/blob/0c5f88155/python/mlc_chat/model/llama/llama_model.py#L295-L303).

@jinhongyii jinhongyii merged commit 5c68932 into apache:main Feb 2, 2024
19 checks passed
def test(
self, embedding_table: Tensor, input_ids: Tensor, embedding_dst: Tensor, offset: int
):
tensor_expr_op_out = op.tensor_ir_op(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to call op.tensor_ir_inplace_op here? It doesn't look like you are testing the new nn.op.tensor_ir_inplace_op added in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooooooops sorry my bad. Is that updated? Or I can find a chance to update the test next time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, I was just hoping to use this PR to guide my use of nn.op.tensor_ir_inplace_op but then became nervous about using the feature when I saw it wasn't tested. I haven't made any change to update the test and would appreciate the update whenever you have cycles to come back to this. It's not blocking me though, so low priority is fine. Thanks @MasterJH5574

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for letting me know!

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.

4 participants