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)
def test_array_reduction(): _A = LazyArray(name='A', shape=(3, 2)) expression = _A.reduce('+') local_dict = {} print(expression.compile()) exec(expression.compile(), globals(), local_dict) A = Array(shape=(3, 2), value=tuple(range(1, 7))) B = local_dict['f'](A=A) assert B.shape == (2, ) assert B.value == [9, 12]