AndrewZhaoLuo commented on code in PR #10873:
URL: https://github.com/apache/tvm/pull/10873#discussion_r841975072
##########
include/tvm/topi/transform.h:
##########
@@ -1886,13 +1883,16 @@ inline Tensor matrix_set_diag(const Tensor& input,
const Tensor& diagonal, int k
: 0,
sub_diag_right_align ? get_offset(input->shape[ndim],
input->shape[ndim - 1] + k)
: 0);
- }
+ return k;
+ };
+ auto get_k = [&]() { return if_then_else(k1(0) == k2(0), k1(0),
multi_diagonals()); };
+ k = get_k();
Review Comment:
can you just do something like `k = if_then_else(k1(0) == k2(0), k1(0),
multi_diagonals());`?
##########
src/relay/op/tensor/transform.cc:
##########
@@ -3812,59 +3812,45 @@ TVM_REGISTER_NODE_TYPE(MatrixSetDiagAttrs);
bool MatrixSetDiagRel(const Array<Type>& types, int num_inputs, const Attrs&
attrs,
const TypeReporter& reporter) {
// `types` contains: [input, diagonal, result]
Review Comment:
make sure to update this comment
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]