Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ir_convert should recognize inline array as valid RHS const expr in proc config functions #1748

Open
proppy opened this issue Nov 28, 2024 · 2 comments

Comments

@proppy
Copy link
Member

proppy commented Nov 28, 2024

Describe the bug
In the context of a proc config function, it seems that ir_convert doesn't recognize inline array definitions as const expr .

To Reproduce

Attempting to convert the following proc:

import float32;
type F32 = float32::F32;

const F32_0 = float32::zero(false);
const F32_2 = F32 { sign: false, bexp: u8:128, fraction: u23:0 };

proc matmul {
    weight: F32[u32:4][u32:4];
    config() {
      let weights = F32[u32:4][u32:4]:[
          [F32_2, F32_0, F32_0, F32_0], [F32_0, F32_2, F32_0, F32_0], [F32_0, F32_0, F32_2, F32_0],
          [F32_0, F32_0, F32_0, F32_2],
      ];
      (weights,)
    }

    init { () }

    next(state: ()) {
      ()
    }
}

will produce the following error:

Error: INTERNAL: Let RHS not evaluated as constexpr: weights : F32[u32:4][u32:4]:[[F32_2, F32_0, F32_0, F32_0], [F32_0, F32_2, F32_0, F32_0], [F32_0, F32_0, F32_2, F32_0], [F32_0, F32_0, F32_0, F32_2]]

Expected behavior
ir_convert infer the const expr-ness for the array let binding.

@proppy
Copy link
Member Author

proppy commented Nov 28, 2024

Note that switching let weights to const WEIGHTS doesn't seems to help.

@proppy proppy changed the title ir_conver should evaluate inline array RHS as const expr in proc config functions ir_conver should recognize inline array as valid RHS const expr in proc config functions Nov 28, 2024
@proppy
Copy link
Member Author

proppy commented Nov 28, 2024

And moving it outside of config triggers #1747 (comment).

@proppy proppy changed the title ir_conver should recognize inline array as valid RHS const expr in proc config functions ir_convert should recognize inline array as valid RHS const expr in proc config functions Nov 28, 2024
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

No branches or pull requests

1 participant