feat(float-fusing): fuse float parts of an OPGraph during compilation

- this allows to be compatible with the current compiler and squash float
domains into a single int to int ArbitraryFunction
This commit is contained in:
Arthur Meyre
2021-08-16 14:04:49 +02:00
parent d48c4dba32
commit 4e40982f5a
5 changed files with 381 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
"""Test file for hnumpy compilation functions"""
import itertools
import numpy
import pytest
from hdk.common.data_types.integers import Integer
@@ -10,6 +11,14 @@ from hdk.common.extensions.table import LookupTable
from hdk.hnumpy.compile import compile_numpy_function
def no_fuse_unhandled(x, y):
"""No fuse unhandled"""
x_intermediate = x + 2.8
y_intermediate = y + 9.3
intermediate = x_intermediate + y_intermediate
return intermediate.astype(numpy.int32)
@pytest.mark.parametrize(
"function,input_ranges,list_of_arg_names",
[
@@ -21,6 +30,12 @@ from hdk.hnumpy.compile import compile_numpy_function
((4, 8), (3, 4), (0, 4)),
["x", "y", "z"],
),
pytest.param(
no_fuse_unhandled,
((-2, 2), (-2, 2)),
["x", "y"],
marks=pytest.mark.xfail(raises=ValueError),
),
],
)
def test_compile_function_multiple_outputs(function, input_ranges, list_of_arg_names):