good first issue
仓库指标
- 星标
- (80 个星标)
- PR 合并指标
- (PR 指标待抓取)
描述
DaphneDSL's ctable() built-in function takes two column matrices as input (there can be additional parameters, see the docs), e.g., ctable([1, 2, 3], [2, 3, 1]). Not too unfrequently, one of these column matrices contains just the same value, e.g., ctable([1, 2, 3], [1, 1, 1]) or ctable([1, 2, 3], fill(1, 3, 1)). For convenience, it would be great if we could pass just a scalar in such cases, e.g., ctable([1, 2, 3], 1).
Hints:
- The simplest approach would be, informally speaking, to rewrite a scalar input
xtofill(x, h, w)(wherehandware the shape of the other input). This should not be done in the parser, since both the data type (scalar/matrix) of the argument and the shape of the other argument may not be known yet. They may be known only after property inference and constant propagation in the DAPHNE compiler. Thus, a good idea would be to write a canonicalization of theCTableOpthat checks if an argument is a scalar and if so, wraps it into aFillOp. - At the time of this writing, all existing canonicalization rewrites in DAPHNE reside in
src/ir/daphneir/DaphneDialect.cpp, see there for some examples. - That simple approach is fine from a user point-of-view, but unnecessarily materializes a potentially large matrix of constant value. Thus, one could optionally adapt the
ctable-kernel to accept scalar inputs (see theEwBinaryMatvs.EwBinaryMatScakernels for some inspiration). However, the convenience for users would currently be more important than this optimization.