Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 411
    • Issues 411
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 14
    • Merge requests 14
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #2544
Closed
Open
Created Feb 11, 2026 by Sven-Bodo Scholz@sbsOwner

Tensor Comprehension (TC) default element problem

The following code exposes the default element problem of the desugaring of tensor comprehensions:

bool[+] eq(int[+] a, int[+] b)
{
    shp = Array::shape(b);
#if TC_BUG
    return { iv -> _eq_SxS_(_sel_VxA_(iv, a), _sel_VxA_(iv, b)) | iv < shp};
#else
    return { iv -> _eq_SxS_(_sel_VxA_(iv, a), _sel_VxA_(iv, b)) | iv < shp;
             iv -> true | iv < shp };
#endif
}

int main ()
{
   StdIO::print( eq([], []));
   return 0;
}

The seemingly redundant second partition is essential for this code not to fail. The reason is that the desugaring mechanism otherwise creates the following code for the default element:

tmp = _eq_SxS_ (_sel_VxA_( _mul_SxV_( 0, shp), a), _sel_VxA_( _mul_SxV_( 0, shp), b))

which makes the type checker scream before it can be optimised away!

NB: the actual default element is genarray( shape(tmp), zero(tmp))

For the time being, this means we have to change the Stdlib ArrayArith operations accordingly :-(

Edited Feb 12, 2026 by Sven-Bodo Scholz
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking