google / google/xls

Error with Array/Tuple of tokens in IR

Open
#775 0 comments 0 reactions 0 assignees View on GitHub
documentation ir
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

The following IR:

```
package sample

file_number 0 "fake_file.x"

chan sample__x7(bits[41], id=0, kind=streaming, ops=receive_only, flow_control=ready_valid, metadata="""""")
chan sample__x30(bits[40], id=1, kind=streaming, ops=receive_only, flow_control=ready_valid, metadata="""""")

fn ____sample__main_0_next_counted_for_0_body(i: bits[4], __token_wrapped: (token, bits[1], bits[1])) -> (token, bits[1], bits[1]) {
literal.49: bits[4] = literal(value=0, id=49)
tuple_index.52: token = tuple_index(__token_wrapped, index=0, id=52)
tuple_index.53: bits[1] = tuple_index(__token_wrapped, index=1, id=53)
tuple_index.54: bits[1] = tuple_index(__token_wrapped, index=2, id=54)
add.50: bits[4] = add(i, literal.49, id=50)
ret tuple.55: (token, bits[1], bits[1]) = tuple(tuple_index.52, tuple_index.53, tuple_index.54, id=55)
}

top proc __sample__main_0_next(__token: token, __state: (), init={()}) {
x1: token = after_all(__token, id=4)
x8: (token, bits[41], bits[1]) = receive(x1, channel_id=0, blocking=false, id=11)
x10: bits[41] = tuple_index(x8, index=1, id=16, pos=[(0,18,21)])
x12: bits[41] = and(x10, x10, id=19, pos=[(0,20,25)])
x13: bits[1] = or_reduce(x10, id=20)
x11: bits[1] = tuple_index(x8, index=2, id=18, pos=[(0,19,22)])
x24: bits[41] = not(x12, id=32, pos=[(0,30,19)])
zero_ext.29: bits[1] = zero_ext(x13, new_bit_count=1, id=29)
x19: bits[1] = not(x11, id=27, pos=[(0,26,20)])
x2: (token, token) = tuple(x1, __token, id=5, pos=[(0,12,29)])
reverse.33: bits[41] = reverse(x24, id=33, pos=[(0,31,22)])
literal.3: bits[1] = literal(value=1, id=3)
x22: bits[1] = xor(zero_ext.29, x19, id=30, pos=[(0,28,38)])
x3: token = tuple_index(x2, index=0, id=7, pos=[(0,13,22)])
one_hot.34: bits[42] = one_hot(reverse.33, lsb_prio=true, id=34, pos=[(0,31,22)])
zero_ext.22: bits[41] = zero_ext(x11, new_bit_count=41, id=22)
literal.24: bits[1] = literal(value=1, id=24, pos=[(0,24,34)])
tuple.56: (token, bits[1], bits[1]) = tuple(__token, literal.3, x22, id=56)
x31: (token, bits[40], bits[1]) = receive(x3, channel_id=1, blocking=false, id=40)
x4: token = tuple_index(x2, index=1, id=9, pos=[(0,14,22)])
encode.35: bits[6] = encode(one_hot.34, id=35, pos=[(0,31,22)])
x16: bits[1] = ule(x10, zero_ext.22, id=23, pos=[(0,23,26)])
x17: bits[1] = udiv(x13, literal.24, id=25, pos=[(0,24,26)])
x14: bits[1] = or(x13, x13, id=21, pos=[(0,22,26)])
counted_for.57: (token, bits[1], bits[1]) = counted_for(tuple.56, trip_count=7, stride=1, body=____sample__main_0_next_counted_for_0_body, id=57)
literal.61: bits[41] = literal(value=268435456, id=61, pos=[(0,43,32)])
tuple_index.12: token = tuple_index(x8, index=0, id=12)
x27: token = after_all(__token, id=38)
tuple_index.41: token = tuple_index(x31, index=0, id=41)
literal.6: bits[32] = literal(value=0, id=6, pos=[(0,13,23)])
literal.8: bits[32] = literal(value=1, id=8, pos=[(0,14,23)])
x6: token[3] = array(__token, x4, __token, id=10, pos=[(0,15,20)])
literal.13: bits[32] = literal(value=0, id=13, pos=[(0,17,23)])
x9: token = tuple_index(x8, index=0, id=14, pos=[(0,17,22)])
literal.15: bits[32] = literal(value=1, id=15, pos=[(0,18,22)])
literal.17: bits[32] = literal(value=2, id=17, pos=[(0,19,23)])
x18: bits[1] = not(x11, id=26, pos=[(0,25,20)])
x21: (token, token)[1] = array(x2, id=28, pos=[(0,27,22)])
x23: bits[13] = literal(value=0, id=31, pos=[(0,29,23)])
x25: bits[41] = zero_ext(encode.35, new_bit_count=41, id=36, pos=[(0,31,22)])
x26: bits[1] = dynamic_bit_slice(x16, x17, width=1, id=37, pos=[(0,32,25)])
x29: bits[1][3] = array(x13, x14, x17, id=39, pos=[(0,34,22)])
literal.42: bits[32] = literal(value=0, id=42, pos=[(0,36,25)])
x32: token = tuple_index(x31, index=0, id=43, pos=[(0,36,24)])
literal.44: bits[32] = literal(value=1, id=44, pos=[(0,37,23)])
x33: bits[40] = tuple_index(x31, index=1, id=45, pos=[(0,37,22)])
literal.46: bits[32] = literal(value=2, id=46, pos=[(0,38,24)])
x34: bits[1] = tuple_index(x31, index=2, id=47, pos=[(0,38,23)])
tuple_index.58: token = tuple_index(counted_for.57, index=0, id=58)
x35: bits[1] = tuple_index(counted_for.57, index=2, id=59)
x36: bits[1] = not(x13, id=60, pos=[(0,42,20)])
x37: bits[41] = udiv(x24, literal.61, id=62, pos=[(0,43,25)])
x38: bits[1] = ne(x31, x31, id=63, pos=[(0,44,26)])
literal.64: bits[1] = literal(value=1, id=64, pos=[(0,45,36)])
x39: bits[2] = one_hot(x22, lsb_prio=true, id=65, pos=[(0,45,25)])
x40: bits[1] = xor_reduce(x22, id=66)
tuple.67: () = tuple(id=67, pos=[(0,47,4)])
after_all.68: token = after_all(__token, x1, tuple_index.12, x27, tuple_index.41, id=68)
next (after_all.68, tuple.67)
}
```

Receive:
```
F1108 20:23:58.174922 63278 eval_proc_main.cc:708] Check failed: ::absl::OkStatus() == (xls::RealMain( positional_args[0], backend, absl::GetFlag(FLAGS_block_signature_proto), ticks, absl::GetFlag(FLAGS_max_cycles_no_output), absl::GetFlag(FLAGS_inputs_for_channels), absl::GetFlag(FLAGS_expected_outputs_for_channels), absl::GetFlag(FLAGS_inputs_for_all_channels), absl::GetFlag(FLAGS_expected_outputs_for_all_channels), absl::GetFlag(FLAGS_streaming_channel_data_suffix), absl::GetFlag(FLAGS_streaming_channel_ready_suffix), absl::GetFlag(FLAGS_streaming_channel_valid_suffix), absl::GetFlag(FLAGS_idle_channel_name), absl::GetFlag(FLAGS_random_seed), absl::GetFlag(FLAGS_prob_input_valid_assert))) (OK vs. INVALID_ARGUMENT: Expected token of type "=" @ 49:12, but found: Token("[", value="") @ 49:12; @
=== Source Location Trace: ===
xls/common/status/status_builder.cc:160
)
```

Should we update the doc in https://google.github.io/xls/ir_semantics/ to state that tokens can not be coupled into a tuple or array?

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.