google / google/xls

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

Open
#1,748 2 comments 0 reactions 0 assignees View on GitHub
bug dslx
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

**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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.