Skip to content

Adjusting the Stdlib to cope with our conceptual TC problem#253

Merged
sbscholz merged 3 commits intoSacBase:masterfrom
sbscholz:master
Feb 13, 2026
Merged

Adjusting the Stdlib to cope with our conceptual TC problem#253
sbscholz merged 3 commits intoSacBase:masterfrom
sbscholz:master

Conversation

@sbscholz
Copy link
Member

@sbscholz sbscholz commented Feb 13, 2026

At the time being (Feb 2026), the default-element generation for Tensor Comprehensions (TCs) does not (yet) follow the translation described in https://dl.acm.org/doi/10.1145/3412932.3412947. Instead, we do the following:

{ iv -> expr(iv) | iv < shp } is translated into

tmp = expr([0,..., 0]);
with {
   (  iv  ) : express(iv);
} : genarray (shp, genarray( shape(tmp), zero(tmp)));

This can lead to errors if the compiler finds the (potentially) illegal selection before optimising it away....
Fortunately, there is a manual work-around. If we write

{ iv -> expr(iv) | iv < shp;
   iv -> const.   | iv < shp};

the compiler will generate

with {
   (  iv  ) : express(iv);
} : genarray (shp, const);

This PR changes (hopefully all) such cases from the former into the latter.

See https://gitlab.sac-home.org/sac-group/sac2c/-/issues/2544 for a detailed description of the compiler issue.

@sbscholz sbscholz requested a review from thomas3494 February 13, 2026 11:16
@sbscholz sbscholz merged commit d8787b9 into SacBase:master Feb 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants