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 393
    • Issues 393
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 16
    • Merge requests 16
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #2406
Closed
Open
Created Apr 17, 2024 by Jordy Aaldering@JordyAalderingDeveloper

Incorrect zero function used for record tensor comprehensions

Records do not play well with tensor-comprehensions.

The following code produces an error:

struct Foo { int x; };

int main()
{
    y = { [i] -> Foo{ i } | [i] < [3] };
    return _dim_A_(y);
}
No definition found for a function "sacprelude_d::zero" that accepts an argument of type "_MAIN::_struct_Foo" as parameter no 1. Full argument types are "( _MAIN::_struct_Foo)".

Applying the zero function manually works as expected.

struct Foo { int x; };

int main()
{
    y = with {
        ( . <= [i] <= .) : Foo{ i };
    } : genarray([3], zero(Foo{0}));
    return _dim_A_(y);
}

The problem is that the zero overload for the Foo record is not being applied in the expanded tensor-comprehension.

After hide-structs (-bpre:hs) we have:

int main()
{ 
  y = { [i] -> _struct_con_Foo( i) | (NULL) <= ? < [ 3 ]  }; 
  return( _dim_A_( y)); 
}

Which is later (-bpre:hse) transformed into:

int main()
/*
 *  main ::  ---
 */
{ 
  _mose_2 = _struct_con_Foo( 0) ; 
  y = with {
          blah
      } : genarray([ 3 ], with {
                              (. <= _hse_3 <= .) : sacprelude_d::zero( _mose_2)  ; 
                          } : genarray( _shape_A_( _mose_2), sacprelude_d::zero( _mose_2) )); 
  return _dim_A_(y); 
}

Note that sacprelude_d::zero is being applied here, which does not exist for record type Foo. It should have been _MAIN::zero(_mose_2) instead.

Edited Apr 26, 2024 by Jordy Aaldering
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking