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

Improve efficiency of getting shapes of constants #360

Closed
pranavm-nvidia opened this issue Nov 12, 2024 · 1 comment
Closed

Improve efficiency of getting shapes of constants #360

pranavm-nvidia opened this issue Nov 12, 2024 · 1 comment

Comments

@pranavm-nvidia
Copy link
Collaborator

In cases where the shape of a tensor is known in the frontend (e.g. constants), we should not generate code to retrieve the shape dynamically. Instead, we can just return the shape of the trace tensor.

One way to do this would be to update the shape property of the frontend tensor to check if the shape of the trace tensor is known (check that all dimensions are non-negative integers). If it is, we can just return that shape directly.

A case where this optimization could be very important is in tp.Parameters. When we overwrite the parameters of a module, we perform shape/dtype checks to ensure that the new parameter is compatible. We should add a test to make sure this is sufficiently fast (we can use the benchmark fixture and add a test under test_perf.py).

@slyubomirsky
Copy link
Collaborator

Implemented.

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

No branches or pull requests

2 participants