justinlubin / cobbler

Refactor programs to use library functions!
5 stars 0 forks source link

Rewrite rules for enabling np.where and np.convolve #25

Closed jeremyferguson closed 1 year ago

jeremyferguson commented 1 year ago

This PR adds the np.where function and the np.convolve function with the "valid" option to the library. It adds some benchmarking cases for testing these functions, and also includes some extra changes for making synthesis work with these functions. These are:

  1. Partial evaluation rules to convert calls of the form np.ones(n) @ i -> 1, and similarly for np.zeros
  2. Equality saturation rewrite rules to add a rewrite between x @ i = 1 -> x @ i = ones(len(x)) @ i
  3. An intermediate value replacement step which will serve to make sure that no expressions containing intermediate values make it into the final synthesized expression. These are the buildExprMap and postprocess functions in the np_synthesis.ml file, and currently they find assignment statements and add a mapping between the length of the variable being assigned to and the length passed into the np.zeros function, if the np.zeros function is used in the assingment statement.
  4. Equality saturation is run on the pattern as well as the target now.