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

Ban numeric literals that result in ambiguous shape #93

Open
Mikolaj opened this issue Mar 20, 2023 · 0 comments
Open

Ban numeric literals that result in ambiguous shape #93

Mikolaj opened this issue Mar 20, 2023 · 0 comments
Labels

Comments

@Mikolaj
Copy link
Owner

Mikolaj commented Mar 20, 2023

For any rank higher than 0, literals such as 42 have ambiguous shape and in ranked tensors this ambiguity usually can't be resolved. Branch https://github.com/Mikolaj/horde-ad/tree/ban-ambiguous-shape bans such cases (actually rank 1 is there permitted, optimistically), but the checks are triggered by a large portion of our tests, probably rightly so. Tests are more important than correctness, so for now this check can't be enabled.

If we switch to shaped tensors, this is no longer a problem. Alternatively, we may try to extend horde-ad and orthotope with a mechanism similar to what hmatrix describes in its haddocks: "In most operations, single-element vectors and matrices (created from numeric literals or using scalar), and matrices with just one row or column, automatically expand to match the dimensions of the other operand".

It's possible horde-ad has some other ways of resolving the ambiguity that I don't remember, e.g., for orphan instances of ranked tensors. That would explain why the tests make sense. Perhaps these ways can be improved and extended to other layers of the horde-ad pipeline.

Edit: there are currently a couple of workarounds in place, e.g., dScaleByScalar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant