chan array should be indexable w/ values deduced from proc parameters
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
**Describe the bug**
It seems that one can't currently index array w/ values deduced from proc parameters.
**To Reproduce**
```
proc matmul {
activations_in: chan[ROWS] in;
results_out: chan[COLS] out;
west_inputs: chan[COLS + u32:1][ROWS] in;
east_outputs: chan[COLS + u32:1][ROWS] out;
north_inputs: chan[COLS][ROWS + u32:1] in;
south_outputs: chan[COLS][ROWS + u32:1] out;
config(activations_in: chan[ROWS] in, results_out: chan[COLS] out) {
let (east_outputs, west_inputs) = chan[COLS + u32:1][ROWS]("east_west");
let (south_outputs, north_inputs) = chan[COLS][ROWS + u32:1]("north_south");
unroll_for! (row, _): (u32, ()) in u32:0..ROWS {
unroll_for! (col, _): (u32, ()) in u32:0..COLS {
let weight = F32 {
sign: false,
bexp: if col == row { u8:128 } else { u8:0 },
fraction: u23:0,
};
spawn node(
west_inputs[row][col], north_inputs[row][col], east_outputs[row][col + u32:1],
south_outputs[row + u32:1][col], weight);
}(());
}(());
(activations_in, results_out, west_inputs, east_outputs, north_inputs, south_outputs)
}
init { () }
next(state: ()) {
let activations_col = u32:0;
unroll_for! (row, _): (u32, ()) in u32:0..ROWS {
let (tok, activation) = recv(join(), activations_in[row]);
send(tok, east_outputs[row][activations_col], activation);
}(());
let zeroes_row = u32:0;
unroll_for! (col, _): (u32, ()) in u32:0..COLS {
send(join(), south_outputs[zeroes_row][col], float32::zero(false));
}(());
let drops_col = COLS + u32:1;
unroll_for! (row, _): (u32, ()) in u32:0..ROWS {
recv(join(), west_inputs[row][drops_col]);
}(());
let results_row = ROWS + u32:1;
unroll_for! (col, _): (u32, ()) in u32:0..COLS {
let (tok, result) = recv(join(), north_inputs[results_row][col]);
send(tok, results_out[col], result);
}(());
}
}
```
will produce the following error:
```
F1128 00:52:50.016040 4046 channel_scope.cc:417] Check failed: !subarray->flattened_names_in_order().empty()
*** Check failure stack trace: ***
absl::log_internal::LogMessage::SendToLog()
absl::log_internal::LogMessage::Flush()
absl::log_internal::LogMessageFatal::~LogMessageFatal()
xls::dslx::ChannelScope::GetOrDefineSubarray()
xls::dslx::ChannelScope::GetChannelArrayElement()
xls::dslx::ChannelScope::EvaluateIndex()
xls::dslx::ChannelScope::GetChannelOrArrayForArrayIndex()
xls::dslx::FunctionConverter::HandleIndex()
xls::dslx::FunctionConverterVisitor::Visit()
xls::dslx::FunctionConverter::HandleBuiltinRecv()
xls::dslx::FunctionConverter::HandleInvocation()
xls::dslx::FunctionConverterVisitor::Visit()
std::__u::__variant_detail::__visitation::__base::__dispatcher<>::__dispatch<>()
xls::dslx::FunctionConverter::HandleStatement()
xls::dslx::FunctionConverterVisitor::Visit()
xls::dslx::FunctionConverter::HandleStatementBlock()
xls::dslx::FunctionConverterVisitor::Visit()
std::__u::__variant_detail::__visitation::__base::__dispatcher<>::__dispatch<>()
xls::dslx::FunctionConverter::HandleStatement()
xls::dslx::FunctionConverterVisitor::Visit()
xls::dslx::FunctionConverter::HandleStatementBlock()
xls::dslx::FunctionConverterVisitor::HandleUnrollFor()
xls::dslx::FunctionConverterVisitor::Visit()
std::__u::__variant_detail::__visitation::__base::__dispatcher<>::__dispatch<>()
xls::dslx::FunctionConverter::HandleStatement()
xls::dslx::FunctionConverterVisitor::Visit()
xls::dslx::FunctionConverter::HandleStatementBlock()
xls::dslx::FunctionConverterVisitor::Visit()
xls::dslx::FunctionConverter::HandleProcNextFunction()
xls::dslx::(anonymous namespace)::ConvertCallGraph()
xls::dslx::ConvertModuleIntoPackage()
xls::dslx::ConvertModuleToPackage()
xls::dslx::AbstractTestRunner::ParseAndTest()
main
__libc_start_main
_start
```
**Expected behavior**
chan array can be indexes from arbitrary computed values.
Contributor guide
Assessment
This issue has not been assessed yet.