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

Eliminate equivalent solutions / convert solutions to canonical form #6

Open
g-dspencer opened this issue Aug 23, 2022 · 0 comments
Open

Comments

@g-dspencer
Copy link

The proposal is to have the solver recognize that, say these two
calls are equivalent, so once you've tried the first you don't need to
try the second:

 tf.multiply(tf.constant(2), tf.range(5)
 tf.multiply(tf.constant(5), tf.range(2)

i.e., multiply(a,b) == multiply(b,a) and ditto for add.
Maybe a and be have to be of the same dtype however.

This is the problem I gave it (and of note is that adding constant 2 is necessary):

inputs = {
    'data': [[0, 1, 1, 0, 0],
             [0, 0, 0, 0, 0],
             [1, 1, 1, 1, 1]]
}

output = [[0, 3, 5, 6, 8],
          [0, 2, 4, 6, 8],
          [1, 3, 5, 7, 9]]

constants = [2]

And these are the solutions - of course only the first is interesting since tf-coder
is just reordering args.

Found solution: tf.add(data, tf.multiply(tf.constant(2), tf.range(5)))
Found solution: tf.add(data, tf.multiply(tf.range(5), tf.constant(2)))
Found solution: tf.add(tf.multiply(tf.constant(2), tf.range(5)), data)
Found solution: tf.add(tf.multiply(tf.range(5), tf.constant(2)), data)
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