2020-07-06 09:09:43 +08:00
|
|
|
# RUN: %PYTHON %s | npcomp-opt -split-input-file -npcomp-cpa-type-inference -canonicalize | FileCheck %s --dump-input=fail
|
2020-07-04 07:38:10 +08:00
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
from npcomp.compiler import test_config
|
|
|
|
from npcomp.compiler.frontend import EmittedError
|
|
|
|
|
|
|
|
import_global = test_config.create_import_dump_decorator()
|
|
|
|
|
|
|
|
global_data = (np.zeros((2, 3)) + [1.0, 2.0, 3.0] * np.reshape([1.0, 2.0],
|
|
|
|
(2, 1)))
|
|
|
|
|
|
|
|
a = np.asarray([1.0, 2.0])
|
|
|
|
b = np.asarray([3.0, 4.0])
|
|
|
|
|
|
|
|
|
|
|
|
# Test the basic flow of invoking a ufunc call with constants captured from
|
|
|
|
# a global using explicit function syntax (np.add(a, b)).
|
|
|
|
# CHECK-LABEL: func @global_add
|
2020-07-06 08:34:03 +08:00
|
|
|
# CHECK-SAME: -> !numpy.ndarray<*:f64>
|
2020-07-04 07:38:10 +08:00
|
|
|
@import_global
|
|
|
|
def global_add():
|
2020-07-06 07:09:16 +08:00
|
|
|
# CHECK-NOT: UnknownType
|
2020-07-06 09:09:43 +08:00
|
|
|
# CHECK: numpy.builtin_ufunc_call<"numpy.multiply"> ({{.*}}, {{.*}}) : (tensor<2xf64>, tensor<2xf64>) -> tensor<*xf64>
|
|
|
|
# CHECK: numpy.builtin_ufunc_call<"numpy.add"> ({{.*}}, {{.*}}) : (tensor<2xf64>, tensor<*xf64>) -> tensor<*xf64>
|
2020-07-06 07:09:16 +08:00
|
|
|
# CHECK-NOT: UnknownType
|
2020-07-06 09:09:43 +08:00
|
|
|
return np.add(a, np.multiply(a, b))
|