reminisce commented on a change in pull request #15007: Add matrix determinant 
operator in linalg
URL: https://github.com/apache/incubator-mxnet/pull/15007#discussion_r286175044
 
 

 ##########
 File path: src/operator/tensor/la_op.h
 ##########
 @@ -413,6 +413,50 @@ inline bool InverseShape(const nnvm::NodeAttrs& attrs,
   return true;
 }
 
+// Shape inference function for det functions in linalg
+template<int onum>
+inline bool DetShape(const nnvm::NodeAttrs& attrs,
+                     mxnet::ShapeVector* in_attrs,
+                     mxnet::ShapeVector* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 1);
+  CHECK_EQ(out_attrs->size(), onum + 2);
+  const mxnet::TShape& in = (*in_attrs)[0];
+  const int ndim(in.ndim());
+  CHECK_GE(ndim, 2) << "Input A's dimension must be >= 2";
+  CHECK_EQ(in[ndim-2], in[ndim-1]) << "Input A's last two dimension must be 
equal";
+  mxnet::TShape out;
+  if (ndim == 2) {
+    out = mxnet::TShape(1, 1);
+  } else {
+    out = mxnet::TShape(in.begin(), in.end() - 2);
+  }
+  for (int i = 0; i < onum; ++i) {
+    SHAPE_ASSIGN_CHECK(*out_attrs, i, out); /* sign or det or logdet */
+  }
+  SHAPE_ASSIGN_CHECK(*out_attrs, onum, in); /* LU */
+  SHAPE_ASSIGN_CHECK(*out_attrs, onum + 1, mxnet::TShape(in.begin(), in.end() 
- 1)); /* pivot */
+  return true;
 
 Review comment:
   replace this with
   ```cpp
   return shape_is_known(in);
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to