Vengineerの妄想(準備期間)

人生は短いけど、長いです。人生を楽しみましょう!

Tiramisu、その8


Halide勉強会での発表のために、Tiramisu の github を見直していたら、Tiramisu expressions なるものが。。。

Tiramisu is a compiler for expressing fast, portable and composable data parallel computations. It provides a simple C++ API for expressing algorithms (Tiramisu expressions) and how these algorithms should be optimized by the compiler. Tiramisu can be used in areas such as linear and tensor algebra, deep learning, image processing, stencil computations and machine learning.

サンプルだよ。引用します。
// C++ code with a Tiramisu expression.
#include "tiramisu.h"

void foo(int N, int array_a[N], int array_b[N], int array_c[N])
{

    tiramisu::init();

    // Declare an iterator and inputs
    tiramisu::iter i, j;
    tiramisu::in A(i,j), B(i,j);

    // Declare the Tiramisu expression (algorithm)
    tiramisu::comp C(i,j) = A(i,j) + B(i,j);
    
    // Specify optimizations
    C.parallelize(i).vectorize(j, 4);

    // Realize, compile and run the expression
    C.realize(tiramisu::int32_t, {N});
    C.compile({(A, array_a), (B, array_b), (C, array_c)});
    C.run();
}

なんか、Halide みたいになっているよね。。。

でも実態はね。まだ、実装されていないんだよね。

これみると、
引用します。
//#include <tiramisu/tiramisu.h>

/**
    Goal
    ----
    Write a simple Tiramisu expression that assigns 0 to the array buf.
    The Tiramisu expression would be equivalent to the following C code:
    for (int i = 0; i < N; i++)
	buf0[i] = 0;
    How to compile ?
    ----------------
    g++ ...
*/

int main(int argc, char **argv)
{

#if 0
    // Let us assume that we have a C++ code that has an array buf.
    // We want to write a Tiramisu expression that assigns 0 to this array.
    int buf[100];

    // All C++ files that call the Tiramisu API need to include
    // the file tiramisu/tiramisu.h

    // Initialize the Tiramisu compiler.
    tiramisu::init();

    // Declare Tiramisu computations (called A) attached to the buffer buf.
    tiramisu::comp A(buf);

    // Declare an iterator i that we will use to iterate over the computations A.
    tiramisu::iter i;

    // Assign 0 to each computation A(i)
    A(i) = 0;

    // Compile and run the Tiramisu expression.
    tiramisu::run();
#endif

    return 0;
}

で、コメントアウトされているし、tiramisu.h なるファイルは、無いんだよね。。。