示例#1
0
def _fpext(tyctx, val):
    def impl(cgctx, builder, signature, args):
        val = args[0]
        return builder.fpext(val, lc.Type.double())

    sig = types.float64(types.float32)
    return sig, impl
示例#2
0
    def test_common_field(self):
        """
        Test that subtypes do not require new compilations
        """
        njit_sig = njit(types.float64(typeof(self.a_rec1)))
        functions = [
            njit(self.func),  # jitted function with open njit
            njit_sig(self.func)  # jitted fc with closed signature
        ]

        for fc in functions:
            fc(self.a_rec1)
            fc.disable_compile()
            y = fc(self.ab_rec1)
            self.assertEqual(self.value, y)
示例#3
0
    def test_isinstance_numba_types(self):
        # This makes use of type aliasing between python scalars and NumPy
        # scalars, see also test_numba_types()
        pyfunc = isinstance_usecase_numba_types
        cfunc = jit(nopython=True)(pyfunc)

        inputs = ((types.int32(1), 'int32'), (types.int64(2), 'int64'),
                  (types.float32(3.0), 'float32'), (types.float64(4.0),
                                                    'float64'),
                  (types.complex64(5j), 'no match'), (typed.List([1, 2]),
                                                      'typed list'),
                  (typed.Dict.empty(types.int64, types.int64), 'typed dict'))

        for inpt, expected in inputs:
            got = cfunc(inpt)
            self.assertEqual(expected, got)
示例#4
0
import warnings

from numba.core.imputils import Registry
from numba.core import types
from numba.core.itanium_mangler import mangle
from .hsaimpl import _declare_function

registry = Registry()
lower = registry.lower

# -----------------------------------------------------------------------------

_unary_b_f = types.int32(types.float32)
_unary_b_d = types.int32(types.float64)
_unary_f_f = types.float32(types.float32)
_unary_d_d = types.float64(types.float64)
_binary_f_ff = types.float32(types.float32, types.float32)
_binary_d_dd = types.float64(types.float64, types.float64)

function_descriptors = {
    'isnan': (_unary_b_f, _unary_b_d),
    'isinf': (_unary_b_f, _unary_b_d),
    'ceil': (_unary_f_f, _unary_d_d),
    'floor': (_unary_f_f, _unary_d_d),
    'fabs': (_unary_f_f, _unary_d_d),
    'sqrt': (_unary_f_f, _unary_d_d),
    'exp': (_unary_f_f, _unary_d_d),
    'expm1': (_unary_f_f, _unary_d_d),
    'log': (_unary_f_f, _unary_d_d),
    'log10': (_unary_f_f, _unary_d_d),
    'log1p': (_unary_f_f, _unary_d_d),
示例#5
0
def int_to_float(x):
    return types.float64(x) / 2