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

Generate random Tensor (and Boolean and Integral) programs #86

Open
Mikolaj opened this issue Feb 21, 2023 · 1 comment
Open

Generate random Tensor (and Boolean and Integral) programs #86

Mikolaj opened this issue Feb 21, 2023 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@Mikolaj
Copy link
Owner

Mikolaj commented Feb 21, 2023

@tomsmeding said:

I wonder if what you need here is generating random programs :p

And indeed I need it. Dimensions only 1, 2 or 3, ranks up to 5, I guess. Maybe 7. Not too high so that the programs don't take forever to vectorize and forever to AD.

Probably just QuickCheck generators? We already have them for orthotope tensors. I guess it's enough to generate Ast programs, which are terms, not Tensor programs, which can desugar and instantiate to terms.

The difficulty I can see at this point is generating correctly ranked and correctly shaped programs. E.g., in tfromList [t, u], t and u should have the same shape.

We could go top-down and first generate a shape and then a constructor that can have that shape, e.g., AstIndex and then, recursively, that would partially determine the shapes of subterms and sometimes we'd have to generate more shapes, within constraints of the outer shape. This sounds complex. We'd surely need unification. Probably a fully fledges shape reconstruction for Ast terms with holes (not the current simplistic shape-checking of concrete Ast terms).

Another top-down methods is to generate a constructor and only then a shape that the constructor can possibly have, etc. Similarly complex.

A bottom-up methods seems hopless: we generate t and u, they have totally different shapes, none of the constructors can take t and u at once, we give up.

Is it know that randomly generating well-typed expressions is as hard as reconstruction of the most general type (or something close) for the expressions?

@Mikolaj Mikolaj added the help wanted Extra attention is needed label Feb 21, 2023
@Mikolaj
Copy link
Owner Author

Mikolaj commented Feb 16, 2024

Here's a promising approach: https://gitlab.haskell.org/ghc/ghc/-/issues/24422

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant