MEP 5: BlankIdの実装
- Created: 2022-12-01 14:43:29
使わない変数のプレースホルダとしてアンダースコアをサポートする。
letのdestructuringでのBlank Id
let [a, _, _, _] = input(x, y)
この場合、aのletだけが生成される。
Tensorの引数
@bounds(256, 4)
def _hist |_, _| { 0 }
この場合内部的にはtemp変数が使われる。
rsum
Tensorの引数の場合と同じ
Tensorのfor_each、sumなど
weight.for_each |ix, iy, _| {
...
}
for_eachの場合、indexの値はtemp変数になり、最後のテンソルの値は生成されなくなる。
accumulate、reduce
mut! trans<_hist>.accumulate!(dim=0) |i, col, _, accm | { i+accm }
accmはアンダースコアは禁止(テンソルに入れる値が不定になってしまう為、acccumulateの意味的におかしい)。テンソルのindexや値はアンダースコアに出来る。