[GitHub] reminisce commented on a change in pull request #9681: Better Exception Handling for Operators

2018-02-02 Thread GitBox
reminisce commented on a change in pull request #9681: Better Exception 
Handling for Operators
URL: https://github.com/apache/incubator-mxnet/pull/9681#discussion_r165574175
 
 

 ##
 File path: src/engine/naive_engine.cc
 ##
 @@ -73,7 +73,7 @@ class NaiveEngine final : public Engine {
 std::vector const& const_vars,
 std::vector const& mutable_vars,
 FnProperty prop = FnProperty::kNormal,
-const char* opr_name = nullptr) override {
+const char* opr_name = nullptr, bool wait = false) 
override {
 
 Review comment:
   Put in the next line.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] reminisce commented on a change in pull request #9681: Better Exception Handling for Operators

2018-02-02 Thread GitBox
reminisce commented on a change in pull request #9681: Better Exception 
Handling for Operators
URL: https://github.com/apache/incubator-mxnet/pull/9681#discussion_r165574204
 
 

 ##
 File path: src/engine/naive_engine.cc
 ##
 @@ -125,7 +125,7 @@ class NaiveEngine final : public Engine {
  std::vector const& mutable_vars,
  FnProperty prop = FnProperty::kNormal,
  int priority = 0,
- const char* opr_name = nullptr) override {
+ const char* opr_name = nullptr, bool wait = false) override {
 
 Review comment:
   Next line.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] reminisce commented on a change in pull request #9681: Better Exception Handling for Operators

2018-02-02 Thread GitBox
reminisce commented on a change in pull request #9681: Better Exception 
Handling for Operators
URL: https://github.com/apache/incubator-mxnet/pull/9681#discussion_r165574053
 
 

 ##
 File path: include/mxnet/engine.h
 ##
 @@ -182,7 +182,7 @@ class MXNET_API Engine {
  std::vector const& mutable_vars,
  FnProperty prop = FnProperty::kNormal,
  int priority = 0,
- const char* opr_name = nullptr) = 0;
+ const char* opr_name = nullptr, bool wait = false) = 
0;
 
 Review comment:
   1. Add `\param` for `wait` in doc.
   2. Put `bool wait...` in the next line to keep the coding style consistent 
with the existing context. Same all the following changes.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] reminisce commented on a change in pull request #9681: Better Exception Handling for Operators

2018-02-02 Thread GitBox
reminisce commented on a change in pull request #9681: Better Exception 
Handling for Operators
URL: https://github.com/apache/incubator-mxnet/pull/9681#discussion_r165574890
 
 

 ##
 File path: tests/python/unittest/test_exc_handling.py
 ##
 @@ -0,0 +1,112 @@
+# 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.
+
+import mxnet as mx
+import numpy as np
+from mxnet import gluon
+from mxnet.gluon import nn
+from mxnet.base import MXNetError
+from mxnet.test_utils import assert_exception, default_context, 
set_default_context
+from nose.tools import assert_raises
+
+def test_exc_imperative():
+def imperative(exec_numpy=True):
+a = mx.nd.random_normal(0, 1, (2, 2))
+b = mx.nd.random_normal(0, -1, (2, 2))
+c = mx.nd.dot(a, b)
+if exec_numpy:
+c.asnumpy()
+
+imperative(exec_numpy=False)
+assert_raises(MXNetError, imperative, True)
+
+def test_exc_symbolic():
+def symbolic(exec_backward=True):
+x = mx.sym.Variable('x')
+y = mx.sym.Variable('y')
+z = mx.sym.Variable('z')
+x_shape = (2, 2)
+z_shape = (3, 2)
+inputs = [x, y]
+out = mx.symbol.ElementWiseSum(*inputs, name="esum")
+out = mx.sym.dot(z, out)
+out2 = mx.sym.random_normal(0, -1, x_shape, ctx=default_context())
 
 Review comment:
   random.normal as it's the preferred way now.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services