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 15
    • Merge requests 15
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #2374
Closed
Open
Created Feb 01, 2024 by Thomas Koopman@thomasDeveloper

Type patterns does incorrect dimension computation

sac2c 1.3.3-MijasCosta-1143-g21fdd4
build-type: DEBUG
built-by: "thomas" at 2024-01-30T10:37:51

Following program throws runtime error *** Type pattern error in application of MultiConv: feature \b:bshp' in return value does not match feature `b' in in`

use StdIO: all;
use Array: all;

noinline
float[m:mshp,n:oshp,b:bshp] MultiConv(float[n:ishp,b:bshp] in,
                                      float[m:mshp,n:wshp] weights,
                                      float[m:mshp] bias)
  | all(oshp == ishp - wshp + 1)
{
  printf("m = %d, n = %d, b = %d\n", m, n, b);
  x = {iv -> Convolve(in, weights[iv]) + bias[iv] | iv < mshp};
  print(shape(x));
  return x;
}

noinline 
float[n:oshp,b:bshp] Convolve(float[n:ishp,b:bshp] in, float[n:wshp] weights)
{
  oshp = ishp - wshp + 1;
//  return {iv -> rsum(n, {jv -> weights[jv] * in[iv + jv]}) | iv < oshp};
  return {iv -> sum({jv -> weights[jv] * in[iv + jv]}) | iv < oshp};
}

int main()
{
  in = genarray([28, 28], 0f);
  weights = genarray([6, 5, 5], 0f);
  bias = genarray([6], 0f);

  print(MultiConv(in, weights, bias));

  return 0;
}

Generated guard shows

  _rtpf_0_pred = ( _eq_SxS_( b, _sub_SxS_( _dim_A_( _rtpf_1_ret), _sub_SxS_( m, n))) ? _rtpf_0_pred : _guard_error_( _|_ /* Type pattern error in application of MultiConv: feature `b:bshp' in return value does not match feature `b' in in */) ); 

or in other words checks that b == dim(out) - (m - n) while it should be b == dim(out) - (m + n).

Edited Feb 01, 2024 by Thomas Koopman
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking