google / google/xls

proc `config` function should be able to index non-channel type

Open
#1,747 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**
It seems that `proc`'s `config` function assuming that all indexing is done against channel types.

**To Reproduce**
`ir_convert` on the following code:
```
const F32_0 = float32::zero(false);
const F32_2 = F32 { sign: false, bexp: u8:128, fraction: u23:0 };
const 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],
];

proc matmul {
south_outputs: chan[COLS][ROWS] out;
west_inputs: chan[COLS][ROWS] in;

config(activations_in: chan[ROWS] in, results_out: chan[COLS] out) {
let (east_outputs, west_inputs) = chan[COLS][ROWS]("east_west");

let (south_outputs, north_inputs) = chan[COLS][ROWS]("north_south");

spawn node(
activations_in[0], north_inputs[0][0], east_outputs[0][0], south_outputs[1][0],
WEIGHTS[0][0]);
spawn node(
west_inputs[0][0], north_inputs[0][1], east_outputs[0][1], south_outputs[1][1],
WEIGHTS[0][1]);
spawn node(
west_inputs[0][1], north_inputs[0][2], east_outputs[0][2], south_outputs[1][2],
WEIGHTS[0][2]);
spawn node(
west_inputs[0][2], north_inputs[0][3], east_outputs[0][3], south_outputs[1][3],
WEIGHTS[0][3]);

spawn node(
activations_in[1], north_inputs[1][0], east_outputs[1][0], south_outputs[2][0],
WEIGHTS[1][0]);
spawn node(
west_inputs[1][0], north_inputs[1][1], east_outputs[1][1], south_outputs[2][1],
WEIGHTS[1][1]);
spawn node(
west_inputs[1][1], north_inputs[1][2], east_outputs[1][2], south_outputs[2][2],
WEIGHTS[1][2]);
spawn node(
west_inputs[1][2], north_inputs[1][3], east_outputs[1][3], south_outputs[2][3],
WEIGHTS[1][3]);

spawn node(
activations_in[2], north_inputs[2][0], east_outputs[2][0], south_outputs[3][0],
WEIGHTS[2][0]);
spawn node(
west_inputs[2][0], north_inputs[2][1], east_outputs[2][1], south_outputs[3][1],
WEIGHTS[2][1]);
spawn node(
west_inputs[2][1], north_inputs[2][2], east_outputs[2][2], south_outputs[3][2],
WEIGHTS[2][2]);
spawn node(
west_inputs[2][2], north_inputs[2][3], east_outputs[2][3], south_outputs[3][3],
WEIGHTS[2][3]);

spawn node(
activations_in[3], north_inputs[3][0], east_outputs[3][0], results_out[0], WEIGHTS[3][0]);
spawn node(
west_inputs[3][0], north_inputs[3][1], east_outputs[3][1], results_out[1], WEIGHTS[3][1]);
spawn node(
west_inputs[3][1], north_inputs[3][2], east_outputs[3][2], results_out[2], WEIGHTS[3][2]);
spawn node(
west_inputs[3][2], north_inputs[3][3], east_outputs[3][3], results_out[3], WEIGHTS[3][3]);

(south_outputs, west_inputs)
}

init { () }
next(state: ()) {
unroll_for! (col, _): (u32, ()) in u32:0..COLS {
send(join(), south_outputs[0][col], float32::zero(false));
}(());
unroll_for! (row, _): (u32, ()) in u32:0..ROWS {
recv(join(), west_inputs[row][3]);
}(());
}
}
```
fails with the following error:
```
xls/dslx/frontend/bindings.cc:55
Error: NOT_FOUND: Not a channel or channel array: WEIGHTS; Failed to convert input to IR for comparison. Consider turning off comparison with `--compare=none`:
=== Source Location Trace: ===
xls/common/status/status_builder.cc:197
xls/dslx/ir_convert/channel_scope.cc:368
xls/dslx/ir_convert/proc_config_ir_converter.cc:143
xls/dslx/ir_convert/proc_config_ir_converter.cc:260
xls/dslx/ir_convert/proc_config_ir_converter.cc:105
xls/dslx/ir_convert/ir_converter.cc:185
xls/dslx/ir_convert/ir_converter.cc:326
xls/dslx/ir_convert/ir_converter.cc:349
xls/dslx/ir_convert/ir_converter.cc:361
xls/dslx/run_routines/run_routines.cc:719
xls/dslx/interpreter_main.cc:203
```

**Expected behavior**

`proc` can access any array type in `config`.

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.