Skip to content

Added support of :id. in const. arrays and in array selections

This merge request completely revamps the desugaring of Tensor Comprehensions and selections. We now allow the features <num>:<id>, <id>:<id>, and :<id> to be used within the generator variables. Similar to type pattern, these denote vector snippets of length , , or maximal length. Likewise, we enable a mix of scalar values and vectors within selections by prefixing vectors with the symbol :.

These extensions enable specifications such as:

int[m:isp] sel( int[n] iv, int[n:shp,m:ishp] a)
{
    return { jv -> _sel_VxA_([:iv,:jv], a) };
}

or

int[m:isp] sel( int[n] iv, int[n:shp,m:ishp] a)
{
    return { [m:jv] -> _sel_VxA_([:iv,:jv], a) };
}

This can also be combined with the use of single dots or triple dots. Note also that such vectors can turn out to be empty. Here an extreme example:

int main()
{
    a = { [i,.,:jv] -> _mul_SxV_(i,jv) | [i,:jv] < [2,4,5,6]};

    xv = [2,2];

    b = { [...,2:kv,.] ->  a[.,:kv,0] };

    return _sel_VxA_([1, 2, 3, 5], b);
}

where a is of shape [2,3,4,5,6] and b is of shape [2,3,4,6].

Edited by Sven-Bodo Scholz

Merge request reports