You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/04/04 17:29:22 UTC

[GitHub] [tvm] AndrewZhaoLuo commented on a diff in pull request #10873: [Relay/TOPI][ONNX/TFLite] Refactor MATRIX_SET_DIAG Operator for Relay/TOPI to support ONNX Trilu operator

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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org