Esempio n. 1
0
def test_moa_compile_complex(benchmark):
    A = LazyArray(name='A', shape=('n', 'm'))
    B = LazyArray(name='B', shape=('k', 'l'))
    C = LazyArray(name='C', shape=(10, 5))

    expression = (A.inner('+', '*', B)).T[0] + C.reduce('+')

    def _test():
        expression.compile(backend='python', use_numba=True)

    benchmark(_test)
Esempio n. 2
0
def test_moa_numba_inner_product(benchmark):
    n = 1000
    m = 1000

    _A = LazyArray(name='A', shape=('n', 'm'))
    _B = LazyArray(name='B', shape=('m', 'k'))
    expression = _A.inner('+', '*', _B)

    local_dict = {}
    exec(expression.compile(backend='python', use_numba=True), globals(),
         local_dict)

    A = numpy.random.random((n, m))
    B = numpy.random.random((n, m))

    benchmark(local_dict['f'], A, B)