wkcn commented on a change in pull request #14443: Mxnet allclose
URL: https://github.com/apache/incubator-mxnet/pull/14443#discussion_r279197851
 
 

 ##########
 File path: src/operator/contrib/allclose_op-inl.h
 ##########
 @@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file allclose-inl.h
+ * \brief Operator implementing numpy.allclose function.
+ * \author Andrei Ivanov
+ */
+#ifndef MXNET_OPERATOR_CONTRIB_ALLCLOSE_OP_INL_H_
+#define MXNET_OPERATOR_CONTRIB_ALLCLOSE_OP_INL_H_
+
+#include <mxnet/operator_util.h>
+#include <vector>
+#include "../mshadow_op.h"
+#include "../mxnet_op.h"
+#include "../operator_common.h"
+#include "../elemwise_op_common.h"
+#include "../tensor/init_op.h"
+
+namespace mxnet {
+namespace op {
+
+// Intermediate and Output data types could be integers OR unsigned characters
+#define USE_INTEGER   0
+#if USE_INTEGER
+  #define INTERM_DATA_TYPE int32_t
+  #define OUT_DATA_TYPE    mshadow::kInt32
+#else
+  #define INTERM_DATA_TYPE uint8_t
+  #define OUT_DATA_TYPE    mshadow::kUint8
+#endif
+
+struct AllCloseParam : public dmlc::Parameter<AllCloseParam> {
+  float rtol, atol;
+  bool equal_nan;
+  DMLC_DECLARE_PARAMETER(AllCloseParam) {
+    DMLC_DECLARE_FIELD(rtol)
+      .set_default(1e-05)
+      .describe("Relative tolerance.");
+    DMLC_DECLARE_FIELD(atol)
+      .set_default(1e-08)
+      .describe("Absolute tolerance.");
+    DMLC_DECLARE_FIELD(equal_nan)
+      .set_default(true)
+      .describe("Whether to compare NaN’s as equal. If True, NaN’s in A will 
be considered equal "
+                "to NaN’s in B in the output array.");
+  }
+};
+
+inline bool AllCloseShape(const nnvm::NodeAttrs& attrs,
+                          std::vector<TShape>* in_attrs,
+                          std::vector<TShape>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 2U) << "Input:[array1, array2]";
+  CHECK_EQ(out_attrs->size(), 1U);
+
+  SHAPE_ASSIGN_CHECK(*out_attrs, 0, TShape());
 
 Review comment:
   I guess that it will trigger flaky bug. It's better to assign shape to `(1,)`

----------------------------------------------------------------
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