Пример #1
0
def run_affine():
    weight_array = SparseWeightArray(
        {Vector.index_vector(3) + (1, 1, 1) : 5}
    )
    component = StencilComponent(
        "input",
        weight_array
    )
    stencil = Stencil(
        component,
        "output",
        [(1, -1, 1)]*3
    )
    compiler = PythonCompiler()
    kern = compiler.compile(stencil)
    arr = np.arange(6**3, dtype=np.float).reshape((6, 6, 6))
    out = np.zeros_like(arr)
    kern(out, arr)
    print(out)