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

Add few ops as methods of tensors #242

Open
akhilg-nv opened this issue Oct 1, 2024 · 0 comments
Open

Add few ops as methods of tensors #242

akhilg-nv opened this issue Oct 1, 2024 · 0 comments

Comments

@akhilg-nv
Copy link
Collaborator

akhilg-nv commented Oct 1, 2024

Certain operations (specifically basic shape manipulations - reshape, transpose, permute, etc.) are commonly used as methods of tensors in other frameworks (Torch, Numpy, Jax, etc.) and often "chained" together, e.g. tensor2 = tensor1.method1(args1).method2(args2).method3(args3). Adding these as methods of tensors improves code readability significantly when used in this way, as we've seen when translating demos from Torch to Tripy (the current approach requires tensor2 = tp.method3(tp.method2(tp.method1(tensor1, args1), args2), args3) to write on one line).

We should add such methods as methods of tensors, however, we only want to do this for a few methods where it "makes sense" and not create too many ways to do the same thing for every operation. Some approaches to evaluate this:

  • Check what NumPy / JAX support as methods of tensors
  • Check demos and see what patterns are commonly using a "chain" of methods on a tensor (i.e. are commonly paired with other related funcs)
  • Gut check if it "makes sense" - would you think to call tensor1.ReLU() or tp.ReLU(tensor1)? Assume users read left to right.
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

1 participant