[GitHub] 315386775 commented on issue #7778: float16 has no performance improvement

2018-02-02 Thread GitBox
315386775 commented on issue #7778: float16 has no performance improvement
URL: 
https://github.com/apache/incubator-mxnet/issues/7778#issuecomment-362788373
 
 
   @hfutxrg I run resnet-v1 but it does have impressive performance improvement 
if large --data-nthreads N is used. Actually. The speed is not speedup.
   Environment info :  one V100. Mxnet 0.11.0


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] 315386775 commented on issue #7778: float16 has no performance improvement

2018-02-02 Thread GitBox
315386775 commented on issue #7778: float16 has no performance improvement
URL: 
https://github.com/apache/incubator-mxnet/issues/7778#issuecomment-362234020
 
 
   @hfutxrg how to use fp16 with the pre-train model.  python 
/image-classification/fine-tune.py


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] szha commented on a change in pull request #9671: Exp backoff for downloads.

2018-02-02 Thread GitBox
szha commented on a change in pull request #9671: Exp backoff for downloads.
URL: https://github.com/apache/incubator-mxnet/pull/9671#discussion_r165807962
 
 

 ##
 File path: python/mxnet/utils.py
 ##
 @@ -0,0 +1,151 @@
+# 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.
+
+"""Utility functions applicable to all areas of code (tests, tutorials, gluon, 
etc)."""
+
+__all__ = ['check_sha1', 'download', 'create_dir']
+
+import errno
+import logging
+import time
+import os
+import hashlib
+
+try:
+import requests
+except ImportError:
+class requests_failed_to_import(object):
+pass
+requests = requests_failed_to_import
+
+
+def check_sha1(filename, sha1_hash):
+"""Check whether the sha1 hash of the file content matches the expected 
hash.
+
+Parameters
+--
+filename : str
+Path to the file.
+sha1_hash : str
+Expected sha1 hash in hexadecimal digits.
+
+Returns
+---
+bool
+Whether the file content matches the expected hash.
+"""
+sha1 = hashlib.sha1()
+with open(filename, 'rb') as f:
+while True:
+data = f.read(1048576)
+if not data:
+break
+sha1.update(data)
+
+return sha1.hexdigest() == sha1_hash
+
+
+def _download_retry_with_backoff(fname, url, max_attempts=4):
+"""Downloads a url with backoff applied, automatically re-requesting after 
a failure.
+:param fname : str
+Name of the target file being downloaded.
+:param url : str
+URL to download.
+:param max_attempts : int, optional
+The number of requests to attempt before throwing a RequestException.
+:return:
+A streaming request object.
+"""
+attempts = 1
+backoff_coef = 50.0
+while True:
+try:
+print('Downloading %s from %s...' % (fname, url))
+r = requests.get(url, stream=True)
+
+# If the remote server returned an error, raise a descriptive 
HTTPError.
+# For non-error http codes (e.g. 200, 206) do nothing.
+r.raise_for_status()
+return r
+except requests.exceptions.RequestException:
+# Likely non-2** result, possibly timeout or redirection failure.
+attempts = attempts + 1
+if attempts > max_attempts:
+print('Downloading %s from %s, failed after #%d attempts' % 
(fname, url, attempts))
+raise
+
+# Apply backoff with default values borrowed from the popular 
Boto3 lib.
+time.sleep((backoff_coef * (2 ** attempts)) / 1000.0)
+
+
+def download(url, path=None, overwrite=False, sha1_hash=None):
+"""Download a given URL
+
+Parameters
+--
+url : str
+URL to download
+path : str, optional
+Destination path to store downloaded file. By default stores to the
+current directory with same name as in url.
+overwrite : bool, optional
+Whether to overwrite destination file if already exists.
+sha1_hash : str, optional
+Expected sha1 hash in hexadecimal digits. Will ignore existing file 
when hash is specified
+but doesn't match.
+
+Returns
+---
+str
+The file path of the downloaded file.
+"""
+if path is None:
+fname = url.split('/')[-1]
+elif os.path.isdir(path):
+fname = os.path.join(path, url.split('/')[-1])
+else:
+fname = path
+
+if overwrite or not os.path.exists(fname) or (sha1_hash and not 
check_sha1(fname, sha1_hash)):
+dirname = os.path.dirname(os.path.abspath(os.path.expanduser(fname)))
+if not os.path.exists(dirname):
 
 Review comment:
   that's py3 feature. https://docs.python.org/2.7/library/os.html#os.makedirs


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] szha closed pull request #7938: instance norm and reflection padding

2018-02-02 Thread GitBox
szha closed pull request #7938: instance norm and reflection padding
URL: https://github.com/apache/incubator-mxnet/pull/7938
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docs/api/python/gluon/nn.md b/docs/api/python/gluon/nn.md
index 5e2dbe016d..4515644c6b 100644
--- a/docs/api/python/gluon/nn.md
+++ b/docs/api/python/gluon/nn.md
@@ -20,6 +20,7 @@ This document lists the neural network blocks in Gluon:
 Activation
 Dropout
 BatchNorm
+InstanceNorm
 LeakyReLU
 Embedding
 Flatten
@@ -62,6 +63,7 @@ This document lists the neural network blocks in Gluon:
 GlobalAvgPool1D
 GlobalAvgPool2D
 GlobalAvgPool3D
+ReflectionPad2D
 ```
 
 
diff --git a/python/mxnet/gluon/nn/basic_layers.py 
b/python/mxnet/gluon/nn/basic_layers.py
index 43b4bdaf1c..1517539553 100644
--- a/python/mxnet/gluon/nn/basic_layers.py
+++ b/python/mxnet/gluon/nn/basic_layers.py
@@ -19,8 +19,8 @@
 # pylint: disable= arguments-differ
 """Basic neural network layers."""
 __all__ = ['Sequential', 'HybridSequential', 'Dense', 'Activation',
-   'Dropout', 'BatchNorm', 'LeakyReLU', 'Embedding', 'Flatten',
-   'Lambda', 'HybridLambda']
+   'Dropout', 'BatchNorm', 'InstanceNorm', 'LeakyReLU', 'Embedding',
+   'Flatten', 'Lambda', 'HybridLambda']
 import warnings
 import numpy as np
 
@@ -480,6 +480,86 @@ def __repr__(self):
 return self.__class__.__name__
 
 
+class InstanceNorm(HybridBlock):
+r"""
+Applies instance normalization to the n-dimensional input array.
+This operator takes an n-dimensional input array where (n>2) and normalizes
+the input using the following formula:
+
+.. math::
+
+  out = \frac{x - mean[data]}{ \sqrt{Var[data]} + \epsilon} * gamma + beta
+
+Parameters
+--
+epsilon: float, default 1e-5
+Small float added to variance to avoid dividing by zero.
+center: bool, default True
+If True, add offset of `beta` to normalized tensor.
+If False, `beta` is ignored.
+scale: bool, default True
+If True, multiply by `gamma`. If False, `gamma` is not used.
+When the next layer is linear (also e.g. `nn.relu`),
+this can be disabled since the scaling
+will be done by the next layer.
+beta_initializer: str or `Initializer`, default 'zeros'
+Initializer for the beta weight.
+gamma_initializer: str or `Initializer`, default 'ones'
+Initializer for the gamma weight.
+in_channels : int, default 0
+Number of channels (feature maps) in input data. If not specified,
+initialization will be deferred to the first time `forward` is called
+and `in_channels` will be inferred from the shape of input data.
+
+Inputs:
+- **data**: input tensor with arbitrary shape.
+
+Outputs:
+- **out**: output tensor with the same shape as `data`.
+
+References
+--
+`Instance Normalization: The Missing Ingredient for Fast Stylization
+`_
+
+Examples
+
+>>> # Input of shape (2,1,2)
+>>> x = mx.nd.array([[[ 1.1,  2.2]],
+... [[ 3.3,  4.4]]])
+>>> # Instance normalization is calculated with the above formula
+>>> layer = InstanceNorm()
+>>> layer.initialize(ctx=mx.cpu(0))
+>>> layer(x)
+[[[-0.8355  0.8331]]
+ [[-0.8319  0.8361]]]
+
+"""
+def __init__(self, epsilon=1e-5, center=True, scale=False,
+ beta_initializer='zeros', gamma_initializer='ones',
+ in_channels=0, **kwargs):
+super(InstanceNorm, self).__init__(**kwargs)
+self._kwargs = {'eps': epsilon}
+self.gamma = self.params.get('gamma', grad_req='write' if scale else 
'null',
+ shape=(in_channels,), 
init=gamma_initializer,
+ allow_deferred_init=True)
+self.beta = self.params.get('beta', grad_req='write' if center else 
'null',
+shape=(in_channels,), 
init=beta_initializer,
+allow_deferred_init=True)
+
+def hybrid_forward(self, F, x, gamma, beta):
+return F.InstanceNorm(x, gamma, beta,
+  name='fwd', **self._kwargs)
+
+def __repr__(self):
+s = '{name}({content}'
+in_channels = self.gamma.shape[0]
+s += ', in_channels={0}'.format(in_channels)
+s += ')'
+return s.format(name=self.__class__.__name__,
+content=', '.join(['='.join([k, v.__repr__()])
+   for k, v in self._kwargs.items()]))
+
 class Lambda(Block):

[incubator-mxnet] branch master updated: instance norm and reflection padding (#7938)

2018-02-02 Thread zhasheng
This is an automated email from the ASF dual-hosted git repository.

zhasheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
 new d452162  instance norm and reflection padding (#7938)
d452162 is described below

commit d4521621a9c21e1ec8c23dab6e4139bd6ba45a65
Author: Hang Zhang <8041160+zhanghang1...@users.noreply.github.com>
AuthorDate: Fri Feb 2 23:30:32 2018 -0800

instance norm and reflection padding (#7938)

* instance norm and reflection padding

* r prefix

* indent and space

* fix docs

* change docs

* spacing

* typo

* hybrid forward

* spcaing

* add test for instance norm

* fix typo

* add to __all__

* rm white space

* integer value

* add test

* make line short

* rm white space

* add docs ref

* fix docs

* RFpad2D docs

* read shape from weight

* rm condition
---
 docs/api/python/gluon/nn.md   |  2 +
 python/mxnet/gluon/nn/basic_layers.py | 85 +--
 python/mxnet/gluon/nn/conv_layers.py  | 34 +-
 tests/python/unittest/test_gluon.py   | 11 +
 4 files changed, 128 insertions(+), 4 deletions(-)

diff --git a/docs/api/python/gluon/nn.md b/docs/api/python/gluon/nn.md
index 5e2dbe0..4515644 100644
--- a/docs/api/python/gluon/nn.md
+++ b/docs/api/python/gluon/nn.md
@@ -20,6 +20,7 @@ This document lists the neural network blocks in Gluon:
 Activation
 Dropout
 BatchNorm
+InstanceNorm
 LeakyReLU
 Embedding
 Flatten
@@ -62,6 +63,7 @@ This document lists the neural network blocks in Gluon:
 GlobalAvgPool1D
 GlobalAvgPool2D
 GlobalAvgPool3D
+ReflectionPad2D
 ```
 
 
diff --git a/python/mxnet/gluon/nn/basic_layers.py 
b/python/mxnet/gluon/nn/basic_layers.py
index 43b4bda..1517539 100644
--- a/python/mxnet/gluon/nn/basic_layers.py
+++ b/python/mxnet/gluon/nn/basic_layers.py
@@ -19,8 +19,8 @@
 # pylint: disable= arguments-differ
 """Basic neural network layers."""
 __all__ = ['Sequential', 'HybridSequential', 'Dense', 'Activation',
-   'Dropout', 'BatchNorm', 'LeakyReLU', 'Embedding', 'Flatten',
-   'Lambda', 'HybridLambda']
+   'Dropout', 'BatchNorm', 'InstanceNorm', 'LeakyReLU', 'Embedding',
+   'Flatten', 'Lambda', 'HybridLambda']
 import warnings
 import numpy as np
 
@@ -480,6 +480,86 @@ class Flatten(HybridBlock):
 return self.__class__.__name__
 
 
+class InstanceNorm(HybridBlock):
+r"""
+Applies instance normalization to the n-dimensional input array.
+This operator takes an n-dimensional input array where (n>2) and normalizes
+the input using the following formula:
+
+.. math::
+
+  out = \frac{x - mean[data]}{ \sqrt{Var[data]} + \epsilon} * gamma + beta
+
+Parameters
+--
+epsilon: float, default 1e-5
+Small float added to variance to avoid dividing by zero.
+center: bool, default True
+If True, add offset of `beta` to normalized tensor.
+If False, `beta` is ignored.
+scale: bool, default True
+If True, multiply by `gamma`. If False, `gamma` is not used.
+When the next layer is linear (also e.g. `nn.relu`),
+this can be disabled since the scaling
+will be done by the next layer.
+beta_initializer: str or `Initializer`, default 'zeros'
+Initializer for the beta weight.
+gamma_initializer: str or `Initializer`, default 'ones'
+Initializer for the gamma weight.
+in_channels : int, default 0
+Number of channels (feature maps) in input data. If not specified,
+initialization will be deferred to the first time `forward` is called
+and `in_channels` will be inferred from the shape of input data.
+
+Inputs:
+- **data**: input tensor with arbitrary shape.
+
+Outputs:
+- **out**: output tensor with the same shape as `data`.
+
+References
+--
+`Instance Normalization: The Missing Ingredient for Fast Stylization
+`_
+
+Examples
+
+>>> # Input of shape (2,1,2)
+>>> x = mx.nd.array([[[ 1.1,  2.2]],
+... [[ 3.3,  4.4]]])
+>>> # Instance normalization is calculated with the above formula
+>>> layer = InstanceNorm()
+>>> layer.initialize(ctx=mx.cpu(0))
+>>> layer(x)
+[[[-0.8355  0.8331]]
+ [[-0.8319  0.8361]]]
+
+"""
+def __init__(self, epsilon=1e-5, center=True, scale=False,
+ beta_initializer='zeros', gamma_initializer='ones',
+ in_channels=0, **kwargs):
+super(InstanceNorm, self).__init__(**kwargs)
+self._kwargs = {'eps': epsilon}
+self.gamma = 

[GitHub] szha closed pull request #9645: Fix DataBatch.__str__ for cases where we don't have labels.

2018-02-02 Thread GitBox
szha closed pull request #9645: Fix DataBatch.__str__ for cases where we don't 
have labels.
URL: https://github.com/apache/incubator-mxnet/pull/9645
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/python/mxnet/io.py b/python/mxnet/io.py
index b07f7c1bea..201414e8f6 100644
--- a/python/mxnet/io.py
+++ b/python/mxnet/io.py
@@ -168,7 +168,10 @@ def __init__(self, data, label=None, pad=None, index=None,
 
 def __str__(self):
 data_shapes = [d.shape for d in self.data]
-label_shapes = [l.shape for l in self.label]
+if self.label:
+label_shapes = [l.shape for l in self.label]
+else:
+label_shapes = None
 return "{}: data shapes: {} label shapes: {}".format(
 self.__class__.__name__,
 data_shapes,
diff --git a/tests/python/unittest/test_io.py b/tests/python/unittest/test_io.py
index e8aba38b82..58ca1d74fb 100644
--- a/tests/python/unittest/test_io.py
+++ b/tests/python/unittest/test_io.py
@@ -252,6 +252,17 @@ def check_libSVMIter_news_data():
 check_libSVMIter_synthetic()
 check_libSVMIter_news_data()
 
+
+def test_DataBatch():
+from nose.tools import ok_
+from mxnet.io import DataBatch
+import re
+batch = DataBatch(data=[mx.nd.ones((2,3))])
+ok_(re.match('DataBatch: data shapes: \[\(2L?, 3L?\)\] label shapes: 
None', str(batch)))
+batch = DataBatch(data=[mx.nd.ones((2,3)), mx.nd.ones((7,8))], 
label=[mx.nd.ones((4,5))])
+ok_(re.match('DataBatch: data shapes: \[\(2L?, 3L?\), \(7L?, 8L?\)\] label 
shapes: \[\(4L?, 5L?\)\]', str(batch)))
+
+
 @unittest.skip("test fails intermittently. temporarily disabled till it gets 
fixed. tracked at https://github.com/apache/incubator-mxnet/issues/7826;)
 def test_CSVIter():
 def check_CSVIter_synthetic():


 


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


[incubator-mxnet] branch master updated: Fix DataBatch.__str__ for cases where we don't have labels. (#9645)

2018-02-02 Thread zhasheng
This is an automated email from the ASF dual-hosted git repository.

zhasheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
 new fe5b56e  Fix DataBatch.__str__ for cases where we don't have labels. 
(#9645)
fe5b56e is described below

commit fe5b56e419d454dc8f42f0307f53ced133804ca7
Author: Pedro Larroy <928489+lar...@users.noreply.github.com>
AuthorDate: Sat Feb 3 08:25:20 2018 +0100

Fix DataBatch.__str__ for cases where we don't have labels. (#9645)
---
 python/mxnet/io.py   |  5 -
 tests/python/unittest/test_io.py | 11 +++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/python/mxnet/io.py b/python/mxnet/io.py
index b07f7c1..201414e 100644
--- a/python/mxnet/io.py
+++ b/python/mxnet/io.py
@@ -168,7 +168,10 @@ class DataBatch(object):
 
 def __str__(self):
 data_shapes = [d.shape for d in self.data]
-label_shapes = [l.shape for l in self.label]
+if self.label:
+label_shapes = [l.shape for l in self.label]
+else:
+label_shapes = None
 return "{}: data shapes: {} label shapes: {}".format(
 self.__class__.__name__,
 data_shapes,
diff --git a/tests/python/unittest/test_io.py b/tests/python/unittest/test_io.py
index e8aba38..58ca1d7 100644
--- a/tests/python/unittest/test_io.py
+++ b/tests/python/unittest/test_io.py
@@ -252,6 +252,17 @@ def test_LibSVMIter():
 check_libSVMIter_synthetic()
 check_libSVMIter_news_data()
 
+
+def test_DataBatch():
+from nose.tools import ok_
+from mxnet.io import DataBatch
+import re
+batch = DataBatch(data=[mx.nd.ones((2,3))])
+ok_(re.match('DataBatch: data shapes: \[\(2L?, 3L?\)\] label shapes: 
None', str(batch)))
+batch = DataBatch(data=[mx.nd.ones((2,3)), mx.nd.ones((7,8))], 
label=[mx.nd.ones((4,5))])
+ok_(re.match('DataBatch: data shapes: \[\(2L?, 3L?\), \(7L?, 8L?\)\] label 
shapes: \[\(4L?, 5L?\)\]', str(batch)))
+
+
 @unittest.skip("test fails intermittently. temporarily disabled till it gets 
fixed. tracked at https://github.com/apache/incubator-mxnet/issues/7826;)
 def test_CSVIter():
 def check_CSVIter_synthetic():

-- 
To stop receiving notification emails like this one, please contact
zhash...@apache.org.


[GitHub] szha commented on issue #9662: Gluon PReLU, ELU, SELU, Swish

2018-02-02 Thread GitBox
szha commented on issue #9662: Gluon PReLU, ELU, SELU, Swish
URL: https://github.com/apache/incubator-mxnet/pull/9662#issuecomment-362786409
 
 
   @piiswrong addressed the infer shape issue. Let me know if you have more 
comments.


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] szha commented on a change in pull request #9662: Gluon PReLU, ELU, SELU, Swish

2018-02-02 Thread GitBox
szha commented on a change in pull request #9662: Gluon PReLU, ELU, SELU, Swish
URL: https://github.com/apache/incubator-mxnet/pull/9662#discussion_r165807578
 
 

 ##
 File path: src/operator/leaky_relu-inl.h
 ##
 @@ -177,9 +182,20 @@ class LeakyReLUOp : public Operator {
   case leakyrelu::kPReLU: {
 weight = in_data[leakyrelu::kGamma].get(s);
 grad_weight = in_grad[leakyrelu::kGamma].get(s);
-grad_weight = sumall_except_dim<1>(F(data) * grad);
-gdata = F(data, 
mshadow::expr::broadcast<1>(weight, data.shape_))
-* grad;
+if (weight.shape_[0] == 1) {
 
 Review comment:
   There are two options, either writing it in Gluon by defining hybrid_forward 
in python, or extending the leaky relu operator in C for better performance.


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] szha commented on a change in pull request #9662: Gluon PReLU, ELU, SELU, Swish

2018-02-02 Thread GitBox
szha commented on a change in pull request #9662: Gluon PReLU, ELU, SELU, Swish
URL: https://github.com/apache/incubator-mxnet/pull/9662#discussion_r165807547
 
 

 ##
 File path: src/operator/leaky_relu-inl.h
 ##
 @@ -177,9 +182,20 @@ class LeakyReLUOp : public Operator {
   case leakyrelu::kPReLU: {
 weight = in_data[leakyrelu::kGamma].get(s);
 grad_weight = in_grad[leakyrelu::kGamma].get(s);
-grad_weight = sumall_except_dim<1>(F(data) * grad);
-gdata = F(data, 
mshadow::expr::broadcast<1>(weight, data.shape_))
-* grad;
+if (weight.shape_[0] == 1) {
 
 Review comment:
   @bradcar sorry that I missed your comment earlier, and thanks for sharing 
your work. In this PR I'd like to first focus on wrapping up the previous two 
PRs for activations. Since you wrote the paper, would you like to implement 
that in mxnet?


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] pengzhao-intel commented on issue #2986: [call for contribution] Improving CPU performance

2018-02-02 Thread GitBox
pengzhao-intel commented on issue #2986: [call for contribution] Improving CPU 
performance
URL: 
https://github.com/apache/incubator-mxnet/issues/2986#issuecomment-362783687
 
 
   FYI, MKL-DNN integration is done and will be merged soon in #9677.
   You can find the performance data in #8302 
   


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] piiswrong commented on a change in pull request #9688: bilinear upsample from PyTorch

2018-02-02 Thread GitBox
piiswrong commented on a change in pull request #9688: bilinear upsample from 
PyTorch
URL: https://github.com/apache/incubator-mxnet/pull/9688#discussion_r165806013
 
 

 ##
 File path: src/operator/bilinear_upsample.cc
 ##
 @@ -0,0 +1,185 @@
+/*
+ * 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.
+ */
+/*!
+ * Copyright (c) 2018 by Contributors
+ * \file bilinear_upsample.cc
+ * \brief bilinear upsample operator
+ * \author Hang Zhang
+ * Adapted from PyTorch
+*/
+#include "devicetensor.h"
+#include "bilinear_upsample-inl.h"
+#include "elemwise_op_common.h"
+
+namespace mxnet {
+namespace op {
+
+
+template
+void SpatialUpSamplingBilinearUpdateOutput(mshadow::Stream *s,
+   const std::vector ,
+   const std::vector ) {
+  DeviceTensor itensor = devicetensor(input[0]);
+  DeviceTensor otensor = devicetensor(output[0]);
+  int nbatch = otensor.getSize(0);
+  int channels = otensor.getSize(1);
+  int outputHeight = otensor.getSize(2);
+  int outputWidth = otensor.getSize(3);
+  int inputHeight = itensor.getSize(2);
+  int inputWidth = itensor.getSize(3);
+
+  DType *idata = itensor.data_ptr();
+  DType *odata = otensor.data_ptr();
+  channels = nbatch * channels;
+  // special case: just copy
+  if (inputHeight == outputHeight && inputWidth == outputWidth) {
+for (int h2 = 0; h2 < outputHeight; ++h2) {
+  const int h1 = h2;
+  for (int w2 = 0; w2 < outputWidth; ++w2) {
+const int w1 = w2;
+const DType* pos1 = [h1 * inputWidth + w1];
+DType* pos2 = [h2 * outputWidth + w2];
+for (int c = 0; c < channels; ++c) {
+  pos2[0] = pos1[0];
+  pos1 += inputWidth * inputHeight;
+  pos2 += outputWidth * outputHeight;
+}
+  }
+}
+return;
+  }
+  const float rheight =(outputHeight > 1) ? (float)(inputHeight - 
1)/(outputHeight - 1) : 0.f;
+  const float rwidth = (outputWidth > 1) ? (float)(inputWidth - 1) / 
(outputWidth - 1) : 0.f;
+  for (int h2 = 0; h2 < outputHeight; ++h2) {
+const float h1r = rheight * h2;
+const int h1 = h1r;
+const int h1p = (h1 < inputHeight - 1) ? 1 : 0;
+const DType h1lambda = h1r - h1;
+const DType h0lambda = (DType)1. - h1lambda;
+for (int w2 = 0; w2 < outputWidth; ++w2) {
+  const float w1r = rwidth * w2;
+  const int w1 = w1r;
+  const int w1p = (w1 < inputWidth - 1) ? 1 : 0;
+  const DType w1lambda = w1r - w1;
+  const DType w0lambda = (DType)1. - w1lambda;
+  const DType* pos1 = [h1 * inputWidth + w1];
+  DType* pos2 = [h2 * outputWidth + w2];
+  for (int c = 0; c < channels; ++c) {
+pos2[0] = h0lambda * (w0lambda * pos1[0]+ w1lambda * pos1[w1p])
+  + h1lambda * (w0lambda * pos1[h1p * inputWidth]
+  + w1lambda * pos1[h1p * inputWidth + w1p]);
+pos1 += inputWidth * inputHeight;
+pos2 += outputWidth * outputHeight;
+  }
+}
+  }
+}
+
+
+template
+void SpatialUpSamplingBilinearUpdateGradInput(mshadow::Stream *s,
+  const std::vector ,
+  const std::vector 
) {
+  DeviceTensor gradOutput = devicetensor(input[0]);
+  DeviceTensor gradInput = devicetensor(output[0]);
+  int nbatch = gradInput.getSize(0);
+  int channels = gradInput.getSize(1);
+  int outputHeight = gradInput.getSize(2);
+  int outputWidth = gradInput.getSize(3);
+  int inputHeight = gradOutput.getSize(2);
+  int inputWidth = gradOutput.getSize(3);
+
+  DType *data1 = gradInput.data_ptr();
+  DType *data2 = gradOutput.data_ptr();
+  channels = nbatch * channels;
+
+  // special case: same-size matching grids
+  if (inputHeight == outputHeight && inputWidth == outputWidth) {
+for (int h2 = 0; h2 < outputHeight; ++h2) {
+  const int h1 = h2;
+  for (int w2 = 0; w2 < outputWidth; ++w2) {
+const int w1 = w2;
+DType* pos1 = [h1 * inputWidth + w1];
+const DType* pos2 = [h2 * outputWidth + w2];
+for (int c = 0; c < channels; ++c) {
+  pos1[0] += pos2[0];
+  pos1 

[GitHub] piiswrong commented on a change in pull request #9688: bilinear upsample from PyTorch

2018-02-02 Thread GitBox
piiswrong commented on a change in pull request #9688: bilinear upsample from 
PyTorch
URL: https://github.com/apache/incubator-mxnet/pull/9688#discussion_r165805994
 
 

 ##
 File path: src/operator/bilinear_upsample.cc
 ##
 @@ -0,0 +1,185 @@
+/*
+ * 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.
+ */
+/*!
+ * Copyright (c) 2018 by Contributors
+ * \file bilinear_upsample.cc
+ * \brief bilinear upsample operator
+ * \author Hang Zhang
+ * Adapted from PyTorch
+*/
+#include "devicetensor.h"
+#include "bilinear_upsample-inl.h"
+#include "elemwise_op_common.h"
+
+namespace mxnet {
+namespace op {
+
+
+template
+void SpatialUpSamplingBilinearUpdateOutput(mshadow::Stream *s,
+   const std::vector ,
+   const std::vector ) {
+  DeviceTensor itensor = devicetensor(input[0]);
+  DeviceTensor otensor = devicetensor(output[0]);
+  int nbatch = otensor.getSize(0);
+  int channels = otensor.getSize(1);
+  int outputHeight = otensor.getSize(2);
+  int outputWidth = otensor.getSize(3);
+  int inputHeight = itensor.getSize(2);
+  int inputWidth = itensor.getSize(3);
+
+  DType *idata = itensor.data_ptr();
+  DType *odata = otensor.data_ptr();
+  channels = nbatch * channels;
+  // special case: just copy
+  if (inputHeight == outputHeight && inputWidth == outputWidth) {
+for (int h2 = 0; h2 < outputHeight; ++h2) {
+  const int h1 = h2;
+  for (int w2 = 0; w2 < outputWidth; ++w2) {
+const int w1 = w2;
+const DType* pos1 = [h1 * inputWidth + w1];
+DType* pos2 = [h2 * outputWidth + w2];
+for (int c = 0; c < channels; ++c) {
+  pos2[0] = pos1[0];
+  pos1 += inputWidth * inputHeight;
+  pos2 += outputWidth * outputHeight;
+}
+  }
+}
+return;
+  }
+  const float rheight =(outputHeight > 1) ? (float)(inputHeight - 
1)/(outputHeight - 1) : 0.f;
+  const float rwidth = (outputWidth > 1) ? (float)(inputWidth - 1) / 
(outputWidth - 1) : 0.f;
+  for (int h2 = 0; h2 < outputHeight; ++h2) {
+const float h1r = rheight * h2;
+const int h1 = h1r;
+const int h1p = (h1 < inputHeight - 1) ? 1 : 0;
+const DType h1lambda = h1r - h1;
+const DType h0lambda = (DType)1. - h1lambda;
+for (int w2 = 0; w2 < outputWidth; ++w2) {
+  const float w1r = rwidth * w2;
+  const int w1 = w1r;
+  const int w1p = (w1 < inputWidth - 1) ? 1 : 0;
+  const DType w1lambda = w1r - w1;
+  const DType w0lambda = (DType)1. - w1lambda;
+  const DType* pos1 = [h1 * inputWidth + w1];
+  DType* pos2 = [h2 * outputWidth + w2];
+  for (int c = 0; c < channels; ++c) {
+pos2[0] = h0lambda * (w0lambda * pos1[0]+ w1lambda * pos1[w1p])
+  + h1lambda * (w0lambda * pos1[h1p * inputWidth]
+  + w1lambda * pos1[h1p * inputWidth + w1p]);
+pos1 += inputWidth * inputHeight;
+pos2 += outputWidth * outputHeight;
+  }
+}
+  }
+}
+
+
+template
+void SpatialUpSamplingBilinearUpdateGradInput(mshadow::Stream *s,
+  const std::vector ,
+  const std::vector 
) {
+  DeviceTensor gradOutput = devicetensor(input[0]);
+  DeviceTensor gradInput = devicetensor(output[0]);
+  int nbatch = gradInput.getSize(0);
+  int channels = gradInput.getSize(1);
+  int outputHeight = gradInput.getSize(2);
+  int outputWidth = gradInput.getSize(3);
+  int inputHeight = gradOutput.getSize(2);
+  int inputWidth = gradOutput.getSize(3);
+
+  DType *data1 = gradInput.data_ptr();
+  DType *data2 = gradOutput.data_ptr();
+  channels = nbatch * channels;
+
+  // special case: same-size matching grids
 
 Review comment:
   This should be handled at the top level with a identity compute function


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



[GitHub] piiswrong commented on a change in pull request #9688: bilinear upsample from PyTorch

2018-02-02 Thread GitBox
piiswrong commented on a change in pull request #9688: bilinear upsample from 
PyTorch
URL: https://github.com/apache/incubator-mxnet/pull/9688#discussion_r165805994
 
 

 ##
 File path: src/operator/bilinear_upsample.cc
 ##
 @@ -0,0 +1,185 @@
+/*
+ * 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.
+ */
+/*!
+ * Copyright (c) 2018 by Contributors
+ * \file bilinear_upsample.cc
+ * \brief bilinear upsample operator
+ * \author Hang Zhang
+ * Adapted from PyTorch
+*/
+#include "devicetensor.h"
+#include "bilinear_upsample-inl.h"
+#include "elemwise_op_common.h"
+
+namespace mxnet {
+namespace op {
+
+
+template
+void SpatialUpSamplingBilinearUpdateOutput(mshadow::Stream *s,
+   const std::vector ,
+   const std::vector ) {
+  DeviceTensor itensor = devicetensor(input[0]);
+  DeviceTensor otensor = devicetensor(output[0]);
+  int nbatch = otensor.getSize(0);
+  int channels = otensor.getSize(1);
+  int outputHeight = otensor.getSize(2);
+  int outputWidth = otensor.getSize(3);
+  int inputHeight = itensor.getSize(2);
+  int inputWidth = itensor.getSize(3);
+
+  DType *idata = itensor.data_ptr();
+  DType *odata = otensor.data_ptr();
+  channels = nbatch * channels;
+  // special case: just copy
+  if (inputHeight == outputHeight && inputWidth == outputWidth) {
+for (int h2 = 0; h2 < outputHeight; ++h2) {
+  const int h1 = h2;
+  for (int w2 = 0; w2 < outputWidth; ++w2) {
+const int w1 = w2;
+const DType* pos1 = [h1 * inputWidth + w1];
+DType* pos2 = [h2 * outputWidth + w2];
+for (int c = 0; c < channels; ++c) {
+  pos2[0] = pos1[0];
+  pos1 += inputWidth * inputHeight;
+  pos2 += outputWidth * outputHeight;
+}
+  }
+}
+return;
+  }
+  const float rheight =(outputHeight > 1) ? (float)(inputHeight - 
1)/(outputHeight - 1) : 0.f;
+  const float rwidth = (outputWidth > 1) ? (float)(inputWidth - 1) / 
(outputWidth - 1) : 0.f;
+  for (int h2 = 0; h2 < outputHeight; ++h2) {
+const float h1r = rheight * h2;
+const int h1 = h1r;
+const int h1p = (h1 < inputHeight - 1) ? 1 : 0;
+const DType h1lambda = h1r - h1;
+const DType h0lambda = (DType)1. - h1lambda;
+for (int w2 = 0; w2 < outputWidth; ++w2) {
+  const float w1r = rwidth * w2;
+  const int w1 = w1r;
+  const int w1p = (w1 < inputWidth - 1) ? 1 : 0;
+  const DType w1lambda = w1r - w1;
+  const DType w0lambda = (DType)1. - w1lambda;
+  const DType* pos1 = [h1 * inputWidth + w1];
+  DType* pos2 = [h2 * outputWidth + w2];
+  for (int c = 0; c < channels; ++c) {
+pos2[0] = h0lambda * (w0lambda * pos1[0]+ w1lambda * pos1[w1p])
+  + h1lambda * (w0lambda * pos1[h1p * inputWidth]
+  + w1lambda * pos1[h1p * inputWidth + w1p]);
+pos1 += inputWidth * inputHeight;
+pos2 += outputWidth * outputHeight;
+  }
+}
+  }
+}
+
+
+template
+void SpatialUpSamplingBilinearUpdateGradInput(mshadow::Stream *s,
+  const std::vector ,
+  const std::vector 
) {
+  DeviceTensor gradOutput = devicetensor(input[0]);
+  DeviceTensor gradInput = devicetensor(output[0]);
+  int nbatch = gradInput.getSize(0);
+  int channels = gradInput.getSize(1);
+  int outputHeight = gradInput.getSize(2);
+  int outputWidth = gradInput.getSize(3);
+  int inputHeight = gradOutput.getSize(2);
+  int inputWidth = gradOutput.getSize(3);
+
+  DType *data1 = gradInput.data_ptr();
+  DType *data2 = gradOutput.data_ptr();
+  channels = nbatch * channels;
+
+  // special case: same-size matching grids
 
 Review comment:
   This should be handled at the top level by passing through to identity 
compute function


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:

[GitHub] piiswrong commented on issue #9688: bilinear upsample from PyTorch

2018-02-02 Thread GitBox
piiswrong commented on issue #9688: bilinear upsample from PyTorch
URL: https://github.com/apache/incubator-mxnet/pull/9688#issuecomment-362782532
 
 
   We prefer a rewrite based on mxnet utilities instead of copy paste if 
possible.
   
   The current code doesn't use openmp for cpu parallelization. If you use 
kernel launch it will be handled automatically.


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


[incubator-mxnet] branch master updated: Fix warning in sequence_last-inl.h (#9687)

2018-02-02 Thread jxie
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
 new ec76003  Fix warning in sequence_last-inl.h (#9687)
ec76003 is described below

commit ec7600381b4cd1ab829021c0574e38c88be4665b
Author: Haibin Lin 
AuthorDate: Fri Feb 2 21:43:04 2018 -0800

Fix warning in sequence_last-inl.h (#9687)

* Update sequence_last-inl.h

* Update optimizer_op-inl.h

-- 
To stop receiving notification emails like this one, please contact
j...@apache.org.


[GitHub] piiswrong commented on a change in pull request #9688: bilinear upsample from PyTorch

2018-02-02 Thread GitBox
piiswrong commented on a change in pull request #9688: bilinear upsample from 
PyTorch
URL: https://github.com/apache/incubator-mxnet/pull/9688#discussion_r165805897
 
 

 ##
 File path: src/operator/bilinear_upsample-inl.h
 ##
 @@ -0,0 +1,162 @@
+/*
+ * 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.
+ */
+ /*!
+ * Copyright (c) 2018 by Contributors
+ * \file bilinear_upsample-inl.h
+ * \brief  bilinear upsample operator
+ * \author Hang Zhang
+ */
+#ifndef MXNET_OPERATOR_BILINEAR_SAMPLE_INL_H_
+#define MXNET_OPERATOR_BILINEAR_SAMPLE_INL_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "../ndarray/ndarray_function.h"
+#include "./operator_common.h"
+#include "./mxnet_op.h"
+#include "./mshadow_op.h"
+
+namespace mxnet {
+namespace op {
+
+struct BilinearSampleParam : public dmlc::Parameter {
+  int out_height;
 
 Review comment:
   is data channel first or channel last?


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] piiswrong closed pull request #9687: Fix warning in sequence_last-inl.h

2018-02-02 Thread GitBox
piiswrong closed pull request #9687: Fix warning in sequence_last-inl.h
URL: https://github.com/apache/incubator-mxnet/pull/9687
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/operator/optimizer_op-inl.h b/src/operator/optimizer_op-inl.h
index 60981aa6d2..89d27e17ec 100644
--- a/src/operator/optimizer_op-inl.h
+++ b/src/operator/optimizer_op-inl.h
@@ -917,7 +917,6 @@ inline void AdamStdUpdateRspRspRspImpl(const AdamParam& 
param,
   using namespace mxnet_op;
   using namespace rowsparse;
   CHECK_RSP_ALL_ROWS_NON_ZERO(weight, "AdamStdUpdate", "weights");
-  mshadow::Stream* s = ctx.get_stream();
   TBlob out_blob = out->data();
   // reuse dns rsp implementation when storage_shape == shape
   AdamStdUpdateDnsRspDnsImpl(param, ctx, weight.data(), grad, mean.data(),
diff --git a/src/operator/sequence_last-inl.h b/src/operator/sequence_last-inl.h
index 07c4709baf..58562862a4 100644
--- a/src/operator/sequence_last-inl.h
+++ b/src/operator/sequence_last-inl.h
@@ -198,7 +198,6 @@ class SequenceLastOp : public Operator {
 auto dsize = in_data[seq_last::kData].Size();
 
 auto batch = (axis != 0) ? d0 : d1;
-auto max_seq_len = in_data[seq_last::kData].size(axis);
 auto rest_size = dsize / (d0 * d1);
 
 Tensor data_grad =


 


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] piiswrong commented on a change in pull request #9688: bilinear upsample from PyTorch

2018-02-02 Thread GitBox
piiswrong commented on a change in pull request #9688: bilinear upsample from 
PyTorch
URL: https://github.com/apache/incubator-mxnet/pull/9688#discussion_r165805891
 
 

 ##
 File path: src/operator/bilinear_upsample-inl.h
 ##
 @@ -0,0 +1,162 @@
+/*
+ * 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.
+ */
+ /*!
+ * Copyright (c) 2018 by Contributors
+ * \file bilinear_upsample-inl.h
+ * \brief  bilinear upsample operator
+ * \author Hang Zhang
+ */
+#ifndef MXNET_OPERATOR_BILINEAR_SAMPLE_INL_H_
+#define MXNET_OPERATOR_BILINEAR_SAMPLE_INL_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "../ndarray/ndarray_function.h"
+#include "./operator_common.h"
+#include "./mxnet_op.h"
+#include "./mshadow_op.h"
+
+namespace mxnet {
+namespace op {
+
+struct BilinearSampleParam : public dmlc::Parameter {
+  int out_height;
 
 Review comment:
   use tuple scale


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] piiswrong commented on a change in pull request #9688: bilinear upsample from PyTorch

2018-02-02 Thread GitBox
piiswrong commented on a change in pull request #9688: bilinear upsample from 
PyTorch
URL: https://github.com/apache/incubator-mxnet/pull/9688#discussion_r165805852
 
 

 ##
 File path: src/operator/bilinear_upsample-inl.h
 ##
 @@ -0,0 +1,162 @@
+/*
+ * 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.
+ */
+ /*!
+ * Copyright (c) 2018 by Contributors
+ * \file bilinear_upsample-inl.h
+ * \brief  bilinear upsample operator
+ * \author Hang Zhang
+ */
+#ifndef MXNET_OPERATOR_BILINEAR_SAMPLE_INL_H_
+#define MXNET_OPERATOR_BILINEAR_SAMPLE_INL_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "../ndarray/ndarray_function.h"
+#include "./operator_common.h"
+#include "./mxnet_op.h"
+#include "./mshadow_op.h"
+
+namespace mxnet {
+namespace op {
+
+struct BilinearSampleParam : public dmlc::Parameter {
+  int out_height;
+  int out_width;
+  DMLC_DECLARE_PARAMETER(BilinearSampleParam) {
+DMLC_DECLARE_FIELD(out_height).set_range(1, 1000)
+.describe("output height");
+DMLC_DECLARE_FIELD(out_width).set_range(1, 1000)
+.describe("output width");
+  }
+};
+
+template
+void SpatialUpSamplingBilinearUpdateOutput(mshadow::Stream *s,
+   const std::vector ,
+   const std::vector );
+
+template
+void SpatialUpSamplingBilinearUpdateGradInput(mshadow::Stream *s,
+  const std::vector ,
+  const std::vector 
);
+
+#if MXNET_USE_CUDA
+template
+void SpatialUpSamplingBilinearUpdateOutput(mshadow::Stream *s,
+   const std::vector ,
+   const std::vector );
+
+template
+void SpatialUpSamplingBilinearUpdateGradInput(mshadow::Stream *s,
+  const std::vector ,
+  const std::vector 
);
+#endif  // MXNET_USE_CUDA
+
+template 
+inline void BilinearSampleOpForward(const nnvm::NodeAttrs& attrs,
+  const OpContext ,
+  const std::vector ,
+  const std::vector ,
+  const std::vector ) {
+  CHECK_EQ(inputs.size(), 1U);
+  CHECK_EQ(outputs.size(), 1U);
+  mshadow::Stream *s = ctx.get_stream();
+  MSHADOW_REAL_TYPE_SWITCH_EX(inputs[0].type_flag_, DType, AccReal, {
+SpatialUpSamplingBilinearUpdateOutput(s, inputs, 
outputs);
+  });
+}
+
+
+template 
+inline void BilinearSampleOpBackward(const nnvm::NodeAttrs& attrs,
+ const OpContext ,
+ const std::vector ,
+ const std::vector ,
+ const std::vector ) {
+  CHECK_EQ(inputs.size(), 1U);
+  CHECK_EQ(outputs.size(), 1U);
+  mshadow::Stream *s = ctx.get_stream();
+  MSHADOW_REAL_TYPE_SWITCH_EX(inputs[0].type_flag_, DType, AccReal, {
+SpatialUpSamplingBilinearUpdateGradInput(s, inputs, 
outputs);
 
 Review comment:
   check for req


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] piiswrong commented on a change in pull request #9688: bilinear upsample from PyTorch

2018-02-02 Thread GitBox
piiswrong commented on a change in pull request #9688: bilinear upsample from 
PyTorch
URL: https://github.com/apache/incubator-mxnet/pull/9688#discussion_r165805825
 
 

 ##
 File path: src/operator/bilinear_upsample.cu
 ##
 @@ -0,0 +1,217 @@
+/*
+ * 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.
+ */
+/*!
+ * Copyright (c) 2018 by Contributors
+ * \file bilinear_upsample.cu
+ * \brief bilinear upsample operator
+ * \author Hang Zhang
+ * Adapted from PyTorch, Caffe
+*/
+#include 
+#include 
+#include "devicetensor.h"
+#include "bilinear_upsample-inl.h"
+
+namespace mxnet {
+namespace op {
+
+template
+struct ScalarConvert {
+  static __host__ __device__ __forceinline__ Out to(const In v) { return (Out) 
v; }
+};
+
+
+// The maximum number of threads in a block
+static const unsigned MAX_BLOCK_SIZE = 512U;
+
+// Number of threads in a block given an input size up to MAX_BLOCK_SIZE
+static unsigned getNumThreads(int nElem, const bool smaller) {
+  unsigned threadSizes[5] = {32, 64, 128, 256, MAX_BLOCK_SIZE};
+  const int maxi = smaller ? 4 : 5;
+  for (int i = 0; i != maxi; ++i) {
+if (static_cast(nElem) <= threadSizes[i]) {
+  return threadSizes[i];
+}
+  }
+  return smaller ? (MAX_BLOCK_SIZE >> 1) : MAX_BLOCK_SIZE;
+}
+
+template
+__global__ void caffe_gpu_interp2_kernel(const int n,
+const Acctype rheight, const Acctype rwidth,
+const DeviceTensor data1, DeviceTensor data2) {
 
 Review comment:
   Use mshadow Tensor instead of device tensor


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 issue #9552: [REQUEST FOR REVIEW | DO NOT MERGE] Model Quantization with Calibration

2018-02-02 Thread GitBox
reminisce commented on issue #9552: [REQUEST FOR REVIEW | DO NOT MERGE] Model 
Quantization with Calibration
URL: https://github.com/apache/incubator-mxnet/pull/9552#issuecomment-362779633
 
 
   @pengzhao-intel I will definitely let you know if there are breaking changes.
   
   For testing inference, you can use the script 
`example/quantization/imagenet_gen_qsym.py` to generate quantized models 
(resnet-152 and inception w/ bn) and run the inference using 
`example/quantization/imagenet_inference.py`. Remember to change the `ctx` to 
`mx.cpu` since it's currently default to `mx.gpu(0)`.


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] kice opened a new issue #9689: How to use gluon to train GAN network on multiple GPUs?

2018-02-02 Thread GitBox
kice opened a new issue #9689: How to use gluon to train GAN network on 
multiple GPUs?
URL: https://github.com/apache/incubator-mxnet/issues/9689
 
 
   I come up with a solution, but it trains discriminator for an epoch and then 
uses the same thing to train the generator.
   ```
   def forward_backward(net, data, label):
   with autograd.record():
   losses_D = [loss(netD(X), Y) for X, Y in zip(data, label)]
   for l in losses_D:
   l.backward()
   
   with autograd.record():
   losses_G = [loss(netG(X), Y) for X, Y in zip(data, label)]
   for l in losses_G:
   l.backward()
   
   label = gluon.utils.split_and_load(trainging_data, ctx)
   forward_backward(net, data, label)
   ```
   I want to update the both network by batch.  Something like:
   ```
   def forward_backward(net, data, label):
   for X, Y in zip(data, label)
   with autograd.record():
   losses_D.append(loss(netD(X), Y))
   
   for l in losses_D:
   l.backward()
   
   with autograd.record():
   losses_G.append(loss(netG(X), Y))
   
   for l in losses_G:
   l.backward()
   
   label = gluon.utils.split_and_load(trainging_data, ctx)
   forward_backward(net, data, label)
   ```
   
   I have no idea if this code will work. Please let me know if it works.


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] anirudh2290 closed issue #8699: Temporary workspace for operators can only be allocated once

2018-02-02 Thread GitBox
anirudh2290 closed issue #8699: Temporary workspace for operators can only be 
allocated once
URL: https://github.com/apache/incubator-mxnet/issues/8699
 
 
   


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] pengzhao-intel commented on issue #9552: [REQUEST FOR REVIEW | DO NOT MERGE] Model Quantization with Calibration

2018-02-02 Thread GitBox
pengzhao-intel commented on issue #9552: [REQUEST FOR REVIEW | DO NOT MERGE] 
Model Quantization with Calibration
URL: https://github.com/apache/incubator-mxnet/pull/9552#issuecomment-362766471
 
 
   @reminisce It makes sense. We will submit a new PR for CPU implementation.
   
   If there're big design or code changes before this PR is merged, please 
kindly let us know (maybe you need to write a simple summary) so we can adjust 
our local code.
   
   We will update more info of CPU accuracy and performance later. 


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] zhanghang1989 commented on issue #9138: I cannot make mxnet.ndarray.UpSampling work with bilinear interpolation

2018-02-02 Thread GitBox
zhanghang1989 commented on issue #9138: I cannot make mxnet.ndarray.UpSampling 
work with bilinear interpolation
URL: 
https://github.com/apache/incubator-mxnet/issues/9138#issuecomment-362766186
 
 
   Thanks @feevos! A new bilinear upsample operator is coming in the PR 
https://github.com/apache/incubator-mxnet/pull/9688
   Stay tuned.


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] zhanghang1989 opened a new pull request #9688: bilinear upsample from PyTorch

2018-02-02 Thread GitBox
zhanghang1989 opened a new pull request #9688: bilinear upsample from PyTorch
URL: https://github.com/apache/incubator-mxnet/pull/9688
 
 
   ## Description ##
   Add an operator of bilinear upsample. Also provide a convenient interface 
for converting code from PyTorch in `device-tensor.h`. 
   
   ## Checklist ##
   ### Essentials ###
   - [ ] Passed code style checking (`make lint`)
   - [ ] Changes are complete (i.e. I finished coding on this PR)
   - [ ] All changes have test coverage:
   - Unit tests are added for small changes to verify correctness (e.g. adding 
a new operator)
   - Nightly tests are added for complicated/long-running ones (e.g. changing 
distributed kvstore)
   - Build tests will be added for build configuration changes (e.g. adding a 
new build option with NCCL)
   - [ ] Code is well-documented: 
   - For user-facing API changes, API doc string has been updated. 
   - For new C++ functions in header files, their functionalities and arguments 
are documented. 
   - For new examples, README.md is added to explain the what the example does, 
the source of the dataset, expected performance on test set and reference to 
the original paper if applicable
   - [ ] To the my best knowledge, examples are either not affected by this 
change, or have been fixed to be compatible with this change
   
   ### Changes ###
   - [ ] Feature1, tests, (and when applicable, API doc)
   - [ ] Feature2, tests, (and when applicable, API doc)
   
   ## Comments ##
   - If this change is a backward incompatible change, why must this change be 
made.
   - Interesting edge cases to note here
   


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] szha commented on a change in pull request #7938: instance norm and reflection padding

2018-02-02 Thread GitBox
szha commented on a change in pull request #7938: instance norm and reflection 
padding
URL: https://github.com/apache/incubator-mxnet/pull/7938#discussion_r16576
 
 

 ##
 File path: python/mxnet/gluon/nn/basic_layers.py
 ##
 @@ -555,8 +553,9 @@ def hybrid_forward(self, F, x, gamma, beta):
 
 def __repr__(self):
 s = '{name}({content}'
+in_channels = self.gamma.shape[0]
 if hasattr(self, 'in_channels'):
 
 Review comment:
   remove condition


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] zhanghang1989 commented on a change in pull request #7938: instance norm and reflection padding

2018-02-02 Thread GitBox
zhanghang1989 commented on a change in pull request #7938: instance norm and 
reflection padding
URL: https://github.com/apache/incubator-mxnet/pull/7938#discussion_r165799668
 
 

 ##
 File path: python/mxnet/gluon/nn/basic_layers.py
 ##
 @@ -480,6 +480,88 @@ def __repr__(self):
 return self.__class__.__name__
 
 
+class InstanceNorm(HybridBlock):
+r"""
+Applies instance normalization to the n-dimensional input array.
+This operator takes an n-dimensional input array where (n>2) and normalizes
+the input using the following formula:
+
+.. math::
+
+  out = \frac{x - mean[data]}{ \sqrt{Var[data]} + \epsilon} * gamma + beta
+
+Parameters
+--
+epsilon: float, default 1e-5
+Small float added to variance to avoid dividing by zero.
+center: bool, default True
+If True, add offset of `beta` to normalized tensor.
+If False, `beta` is ignored.
+scale: bool, default True
+If True, multiply by `gamma`. If False, `gamma` is not used.
+When the next layer is linear (also e.g. `nn.relu`),
+this can be disabled since the scaling
+will be done by the next layer.
+beta_initializer: str or `Initializer`, default 'zeros'
+Initializer for the beta weight.
+gamma_initializer: str or `Initializer`, default 'ones'
+Initializer for the gamma weight.
+in_channels : int, default 0
+Number of channels (feature maps) in input data. If not specified,
+initialization will be deferred to the first time `forward` is called
+and `in_channels` will be inferred from the shape of input data.
+
+Inputs:
+- **data**: input tensor with arbitrary shape.
+
+Outputs:
+- **out**: output tensor with the same shape as `data`.
+
+References
+--
+`Instance Normalization: The Missing Ingredient for Fast Stylization
+`_
+
+Examples
+
+>>> # Input of shape (2,1,2)
+>>> x = mx.nd.array([[[ 1.1,  2.2]],
+... [[ 3.3,  4.4]]])
+>>> # Instance normalization is calculated with the above formula
+>>> layer = InstanceNorm()
+>>> layer.initialize(ctx=mx.cpu(0))
+>>> layer(x)
+[[[-0.8355  0.8331]]
+ [[-0.8319  0.8361]]]
+
+"""
+def __init__(self, epsilon=1e-5, center=True, scale=False,
+ beta_initializer='zeros', gamma_initializer='ones',
+ in_channels=0, **kwargs):
+super(InstanceNorm, self).__init__(**kwargs)
+self._kwargs = {'eps': epsilon}
+if in_channels != 0:
+self.in_channels = in_channels
 
 Review comment:
   Actually, BatchNorm uses the same thing
   
https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/gluon/nn/basic_layers.py#L375


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] zhanghang1989 commented on a change in pull request #7938: instance norm and reflection padding

2018-02-02 Thread GitBox
zhanghang1989 commented on a change in pull request #7938: instance norm and 
reflection padding
URL: https://github.com/apache/incubator-mxnet/pull/7938#discussion_r165799668
 
 

 ##
 File path: python/mxnet/gluon/nn/basic_layers.py
 ##
 @@ -480,6 +480,88 @@ def __repr__(self):
 return self.__class__.__name__
 
 
+class InstanceNorm(HybridBlock):
+r"""
+Applies instance normalization to the n-dimensional input array.
+This operator takes an n-dimensional input array where (n>2) and normalizes
+the input using the following formula:
+
+.. math::
+
+  out = \frac{x - mean[data]}{ \sqrt{Var[data]} + \epsilon} * gamma + beta
+
+Parameters
+--
+epsilon: float, default 1e-5
+Small float added to variance to avoid dividing by zero.
+center: bool, default True
+If True, add offset of `beta` to normalized tensor.
+If False, `beta` is ignored.
+scale: bool, default True
+If True, multiply by `gamma`. If False, `gamma` is not used.
+When the next layer is linear (also e.g. `nn.relu`),
+this can be disabled since the scaling
+will be done by the next layer.
+beta_initializer: str or `Initializer`, default 'zeros'
+Initializer for the beta weight.
+gamma_initializer: str or `Initializer`, default 'ones'
+Initializer for the gamma weight.
+in_channels : int, default 0
+Number of channels (feature maps) in input data. If not specified,
+initialization will be deferred to the first time `forward` is called
+and `in_channels` will be inferred from the shape of input data.
+
+Inputs:
+- **data**: input tensor with arbitrary shape.
+
+Outputs:
+- **out**: output tensor with the same shape as `data`.
+
+References
+--
+`Instance Normalization: The Missing Ingredient for Fast Stylization
+`_
+
+Examples
+
+>>> # Input of shape (2,1,2)
+>>> x = mx.nd.array([[[ 1.1,  2.2]],
+... [[ 3.3,  4.4]]])
+>>> # Instance normalization is calculated with the above formula
+>>> layer = InstanceNorm()
+>>> layer.initialize(ctx=mx.cpu(0))
+>>> layer(x)
+[[[-0.8355  0.8331]]
+ [[-0.8319  0.8361]]]
+
+"""
+def __init__(self, epsilon=1e-5, center=True, scale=False,
+ beta_initializer='zeros', gamma_initializer='ones',
+ in_channels=0, **kwargs):
+super(InstanceNorm, self).__init__(**kwargs)
+self._kwargs = {'eps': epsilon}
+if in_channels != 0:
+self.in_channels = in_channels
 
 Review comment:
   Actually, BatchNorm uses the same thing
   
https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/gluon/nn/basic_layers.py#L375


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] DickJC123 commented on issue #9674: Fix test_sparse_operator failures due to out-of-bounds ref.

2018-02-02 Thread GitBox
DickJC123 commented on issue #9674: Fix test_sparse_operator failures due to 
out-of-bounds ref.
URL: https://github.com/apache/incubator-mxnet/pull/9674#issuecomment-362760136
 
 
   To prove that the prior code referenced uninitialized data, substitute the 
following 4 lines for the single line the PR changed:
   ```
  bool will_reference_axis_first_element = !dispatched && in_stype == 
kCSRStorage;
 if (will_reference_axis_first_element && param.axis.ndim() == 0)
   LOG(FATAL) << "Code is about to make out-of-bounds reference of 
param.axis[0]";
 if (!dispatched && in_stype == kCSRStorage &&
   ```
   Then re-built mxnet and run:
   ```
   nosetests --verbose 
tests/python/unittest/test_sparse_operator.py:test_sparse_storage_fallback
   ```
   For me, the fatal exception is thrown.


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] anirudh2290 commented on issue #9674: Fix test_sparse_operator failures due to out-of-bounds ref.

2018-02-02 Thread GitBox
anirudh2290 commented on issue #9674: Fix test_sparse_operator failures due to 
out-of-bounds ref.
URL: https://github.com/apache/incubator-mxnet/pull/9674#issuecomment-362753597
 
 
   @DickJC123 would it be possible for you to provide the reproduction steps 
for the issue. I tried to run the test: test_sparse_storage_fallback but wasn't 
able to reproduce the issue.


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] szha commented on issue #8427: Bug: ThreadedEnginePerDevice: speed variation with mixed Mxnet API and Amalgamation API

2018-02-02 Thread GitBox
szha commented on issue #8427: Bug: ThreadedEnginePerDevice: speed variation 
with mixed Mxnet API and Amalgamation API
URL: 
https://github.com/apache/incubator-mxnet/issues/8427#issuecomment-362750470
 
 
   @apache/mxnet-committers: This issue has been inactive for the past 90 days. 
It has no label and needs triage.
   
   For general "how-to" questions, our [user forum](https://discuss.mxnet.io/) 
(and [Chinese version](https://discuss.gluon.ai/)) is a good place to get help.


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] szha commented on issue #8424: windows binaries

2018-02-02 Thread GitBox
szha commented on issue #8424: windows binaries 
URL: 
https://github.com/apache/incubator-mxnet/issues/8424#issuecomment-362750466
 
 
   @apache/mxnet-committers: This issue has been inactive for the past 90 days. 
It has no label and needs triage.
   
   For general "how-to" questions, our [user forum](https://discuss.mxnet.io/) 
(and [Chinese version](https://discuss.gluon.ai/)) is a good place to get help.


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] szha commented on issue #8530: Fatal JVM Error due to Exception in CustomOpProp#inferTypeEntry

2018-02-02 Thread GitBox
szha commented on issue #8530: Fatal JVM Error due to Exception in 
CustomOpProp#inferTypeEntry
URL: 
https://github.com/apache/incubator-mxnet/issues/8530#issuecomment-362750469
 
 
   @apache/mxnet-committers: This issue has been inactive for the past 90 days. 
It has no label and needs triage.
   
   For general "how-to" questions, our [user forum](https://discuss.mxnet.io/) 
(and [Chinese version](https://discuss.gluon.ai/)) is a good place to get help.


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.cc
 ##
 @@ -391,6 +400,11 @@ void ThreadedEngine::WaitForAll() {
   finished_cv_.wait(lock, [this]() {
   return pending_.load() == 0 || kill_.load();
 });
+  if (global_ex_ptr) {
+std::exception_ptr ex_ptr = global_ex_ptr;
 
 Review comment:
   Rolling this back, Since the state of global_ex_ptr is not guaranteed to be 
nullptr after the move and it depends on the implementation. This probably 
explains why it started failing on windows, after the change. Please let me 
know if you have any concerns.


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] marcoabreu commented on issue #9552: [REQUEST FOR REVIEW | DO NOT MERGE] Model Quantization with Calibration

2018-02-02 Thread GitBox
marcoabreu commented on issue #9552: [REQUEST FOR REVIEW | DO NOT MERGE] Model 
Quantization with Calibration
URL: https://github.com/apache/incubator-mxnet/pull/9552#issuecomment-362748394
 
 
   Feel free to create a new dockerfile that uses a cuda9 based layer as base.
   
   Am 02.02.2018 3:44 nachm. schrieb "reminisce" :
   
   > @marcoabreu  It looks like the cuDNN
   > version (5.0) is too low for building quantization implementation. Do we
   > have plan to upgrade the lib?
   >
   > ?
   > You are receiving this because you were mentioned.
   > Reply to this email directly, view it on GitHub
   > 
,
   > or mute the thread
   > 

   > .
   >
   


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] chsin commented on issue #9647: Gluon in Core API

2018-02-02 Thread GitBox
chsin commented on issue #9647: Gluon in Core API
URL: 
https://github.com/apache/incubator-mxnet/issues/9647#issuecomment-362746458
 
 
   I would also like more attention on the C/C++ API. Most of the focus has 
been on Python, which results in the other supported languages being overlooked 
to the point that they are barely supported. It seems more an issue that the 
C/C++ API is being neglected since (correct me if I?m wrong) the other 
languages call C/C++ core functions, so if a functionality is only in Python, 
that would mean you have to recode the functonallity in the other languages you 
support.  I, however, only care about the C/C++ API since the code I write is 
mostly in C/C++, which makes using Mxnet difficult since the C/C++ API is 
poorly documented and neglected compared to the Python API. I understand why it 
makes sense for people to use Python since it?s must easier for prototyping and 
homework assignments, but less so for fast and reliable production code. Hence, 
I hope the C/C++ API won?t be neglected, though it seems like plans to improve 
it, e.g. #5647, are quickly forgotten. 


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 issue #9552: [REQUEST FOR REVIEW | DO NOT MERGE] Model Quantization with Calibration

2018-02-02 Thread GitBox
reminisce commented on issue #9552: [REQUEST FOR REVIEW | DO NOT MERGE] Model 
Quantization with Calibration
URL: https://github.com/apache/incubator-mxnet/pull/9552#issuecomment-362742835
 
 
   @marcoabreu It looks like the cuDNN version (5.0) is too low for building 
quantization implementation. Do we have plan to upgrade the lib?


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] eric-haibin-lin opened a new pull request #9687: Fix warning in sequence_last-inl.h

2018-02-02 Thread GitBox
eric-haibin-lin opened a new pull request #9687: Fix warning in 
sequence_last-inl.h
URL: https://github.com/apache/incubator-mxnet/pull/9687
 
 
   Fix a complier warning (unused variable) in `sequence_last-inl.h` 
   @sbodenstein 


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] eric-haibin-lin commented on issue #9675: Add contrib.compute_accidental_hits operator for candidate sampling

2018-02-02 Thread GitBox
eric-haibin-lin commented on issue #9675: Add contrib.compute_accidental_hits 
operator for candidate sampling
URL: https://github.com/apache/incubator-mxnet/pull/9675#issuecomment-362741701
 
 
   Requires https://github.com/dmlc/mshadow/pull/324 


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.h
 ##
 @@ -338,33 +346,46 @@ class ThreadedEngine : public Engine {
 #endif
 CallbackOnComplete callback = this->CreateCallback(
 ThreadedEngine::OnCompleteStatic, opr_block);
+CallbackOnComplete on_start_callback = this->CreateCallback(
+ThreadedEngine::OnStartStatic, opr_block);
 bool debug_info = (engine_info_ && debug_push_opr_ == opr_block);
 if (debug_info) {
   LOG(INFO) << "ExecuteOprBlock " << opr_block
 << "shutdown_phase=" << shutdown_phase_;
 }
 if (!shutdown_phase_) {
   try {
+on_start_callback();
 if (debug_info) {
   LOG(INFO) << "ExecuteOprFn ";
 }
-threaded_opr->fn(run_ctx, callback);
+try {
+  if (!threaded_opr->ex_ptr || threaded_opr->wait) {
+threaded_opr->fn(run_ctx, callback);
+  } else {
+callback();
+  }
+} catch (dmlc::Error& e) {
+  threaded_opr->ex_ptr = std::current_exception();
+  callback();
+}
 if (debug_info) {
   LOG(INFO) << "Fin ExecuteOprFn ";
 }
-  } catch(dmlc::Error ) {
+  } catch (dmlc::Error& e) {
 
 Review comment:
   @piiswrong my intention for the outer block was to catch all other 
exceptions which are not caught in the inner block. I should change dmlc::Error 
to std::exception to catch all standard exception. But you make a good point 
about propagating all the exceptions and not just dmlc::Error to the frontend. 
We can take one of the two approaches here: 1. catch dmlc::Error and terminate 
the process for everything else. 2. catch both dmlc::Error and standard 
exceptions and propagate to frontend. This will require code changes to the 
guards , c_api_error and potentially frontend code. 


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.h
 ##
 @@ -338,33 +346,46 @@ class ThreadedEngine : public Engine {
 #endif
 CallbackOnComplete callback = this->CreateCallback(
 ThreadedEngine::OnCompleteStatic, opr_block);
+CallbackOnComplete on_start_callback = this->CreateCallback(
+ThreadedEngine::OnStartStatic, opr_block);
 bool debug_info = (engine_info_ && debug_push_opr_ == opr_block);
 if (debug_info) {
   LOG(INFO) << "ExecuteOprBlock " << opr_block
 << "shutdown_phase=" << shutdown_phase_;
 }
 if (!shutdown_phase_) {
   try {
+on_start_callback();
 if (debug_info) {
   LOG(INFO) << "ExecuteOprFn ";
 }
-threaded_opr->fn(run_ctx, callback);
+try {
+  if (!threaded_opr->ex_ptr || threaded_opr->wait) {
+threaded_opr->fn(run_ctx, callback);
+  } else {
+callback();
+  }
+} catch (dmlc::Error& e) {
+  threaded_opr->ex_ptr = std::current_exception();
+  callback();
+}
 if (debug_info) {
   LOG(INFO) << "Fin ExecuteOprFn ";
 }
-  } catch(dmlc::Error ) {
+  } catch (dmlc::Error& e) {
 
 Review comment:
   @piiswrong my intention for the outer block was to catch all other 
exceptions which are not caught in the inner block. I should change dmlc::Error 
to std::exception to catch all standard exception. But you make a good point 
about propagating all the exceptions and not just dmlc::Error to the frontend. 
We can take two approaches here: 1. catch dmlc::Error and terminate the process 
for everything else. 2. catch both dmlc::Error and standard exceptions and 
propagate to frontend. This will require code changes to the guards , 
c_api_error and potentially frontend code. 


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] zhreshold commented on a change in pull request #8582: Yolo2 operator

2018-02-02 Thread GitBox
zhreshold commented on a change in pull request #8582: Yolo2 operator
URL: https://github.com/apache/incubator-mxnet/pull/8582#discussion_r165778720
 
 

 ##
 File path: src/operator/contrib/yolo_output-inl.h
 ##
 @@ -0,0 +1,703 @@
+/*
+ * 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 yolo_output-inl.h
+ * \brief yolo-v2 output layer, v1 to be added
+ * \author Joshua Zhang
+*/
+#ifndef MXNET_OPERATOR_CONTRIB_YOLO_OUTPUT_INL_H_
+#define MXNET_OPERATOR_CONTRIB_YOLO_OUTPUT_INL_H_
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "../operator_common.h"
+#include "../mshadow_op.h"
+#include "../mxnet_op.h"
+#include "../tensor/sort_op.h"
+
+namespace mxnet {
+namespace op {
+namespace yolo2out_enum {
+enum Yolo2OutputOpInputs {kData, kLabel};
+enum Yolo2OutputOpOutputs {kOut, kTemp, kCopy};
+enum Yolo2OutputOpAuxiliary {kCounter};
+enum Yolo2OutputOpResource {kTempSpace};
+}  // namespace yolo2out_enum
+
+struct Yolo2OutputParam : public dmlc::Parameter {
+  int num_class;
+  int num_anchor;
+  float overlap_thresh;
+  float object_grad_scale;
+  float background_grad_scale;
+  float class_grad_scale;
+  float coord_grad_scale;
+  nnvm::Tuple anchors;
+  int warmup_samples;
+  float warmup_grad_scale;
+  float nms_threshold;
+  int nms_topk;
+  bool force_suppress;
+  DMLC_DECLARE_PARAMETER(Yolo2OutputParam) {
+DMLC_DECLARE_FIELD(num_class).set_lower_bound(1)
+.describe("Number of object classes.");
+DMLC_DECLARE_FIELD(num_anchor).set_default(5)
+.set_lower_bound(1)
+.describe("Number of anchors.");
+DMLC_DECLARE_FIELD(overlap_thresh).set_default(0.6)
+.describe("Positive overlap threshold.");
+DMLC_DECLARE_FIELD(object_grad_scale).set_default(1.0)
+.describe("Gradient scale for positive objects.");
+DMLC_DECLARE_FIELD(background_grad_scale).set_default(1.0)
+.describe("Gradient scale for background.");
+DMLC_DECLARE_FIELD(class_grad_scale).set_default(1.0)
+.describe("Gradient scale for positive objects.");
+DMLC_DECLARE_FIELD(coord_grad_scale).set_default(1.0)
+.describe("Gradient scale for box offsets.");
+DMLC_DECLARE_FIELD(anchors)
+.set_default({1.08f, 1.19f, 3.42f, 4.41f, 6.63f, 11.38f, 9.42f, 5.11f, 
16.62f, 10.52f})
+.describe("Predefined anchor box widths and heights.");
+DMLC_DECLARE_FIELD(warmup_samples).set_default(12800)
+.describe("Number of images to warm up towards averaging position for box "
+"predictions when starting a new training. ");
+DMLC_DECLARE_FIELD(warmup_grad_scale).set_default(0.01)
+.describe("Gradient scale for non-critical anchors during warm-up stage.");
+DMLC_DECLARE_FIELD(nms_threshold).set_default(0.5f)
+.describe("Non-maximum suppression threshold.");
+DMLC_DECLARE_FIELD(force_suppress).set_default(false)
+.describe("Suppress all detections regardless of class_id.");
+DMLC_DECLARE_FIELD(nms_topk).set_default(-1)
+.describe("Keep maximum top k detections before nms, -1 for no limit.");
+  }
+};  // struct Yolo2OutputParam
+
+template
+MSHADOW_XINLINE DType Intersect(DType l1, DType r1, DType l2, DType r2) {
+  DType left = l1 > l2 ? l1 : l2;
+  DType right = r1 < r2 ? r1 : r2;
+  DType w = right - left;
+  return w > 0 ? w : DType(0);
+}
+
+template
+MSHADOW_XINLINE DType Area(DType l1, DType t1, DType r1, DType b1) {
+  DType width = r1 - l1;
+  DType height = b1 - t1;
+  if (width <= 0 || height <= 0) return DType(0);
+  return width * height;
+}
+
+template
+MSHADOW_XINLINE DType IOU(DType l1, DType t1, DType r1, DType b1,
+  DType l2, DType t2, DType r2, DType b2) {
+  DType inter_area = Intersect(l1, r1, l2, r2) * Intersect(t1, b1, t2, b2);
+  if (inter_area <= 0) return DType(0);
+  DType area1 = Area(l1, t1, r1, b1);
+  DType area2 = Area(l2, t2, r2, b2);
+  return inter_area / (area1 + area2 - inter_area);
+}
+
+// compute intersection-over-union overlap between two boxes
+struct calc_overlap {
+  template
+  MSHADOW_XINLINE static void Map(int i, DType* out,
+  const DType* L1, const DType* T1, const DType* R1, const DType* B1,
+  const DType* L2, const DType* T2, const DType* R2, 

[GitHub] zhreshold commented on a change in pull request #8582: Yolo2 operator

2018-02-02 Thread GitBox
zhreshold commented on a change in pull request #8582: Yolo2 operator
URL: https://github.com/apache/incubator-mxnet/pull/8582#discussion_r165778530
 
 

 ##
 File path: src/operator/contrib/yolo_output-inl.h
 ##
 @@ -0,0 +1,703 @@
+/*
+ * 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 yolo_output-inl.h
+ * \brief yolo-v2 output layer, v1 to be added
+ * \author Joshua Zhang
+*/
+#ifndef MXNET_OPERATOR_CONTRIB_YOLO_OUTPUT_INL_H_
+#define MXNET_OPERATOR_CONTRIB_YOLO_OUTPUT_INL_H_
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "../operator_common.h"
+#include "../mshadow_op.h"
+#include "../mxnet_op.h"
+#include "../tensor/sort_op.h"
+
+namespace mxnet {
+namespace op {
+namespace yolo2out_enum {
+enum Yolo2OutputOpInputs {kData, kLabel};
+enum Yolo2OutputOpOutputs {kOut, kTemp, kCopy};
+enum Yolo2OutputOpAuxiliary {kCounter};
+enum Yolo2OutputOpResource {kTempSpace};
+}  // namespace yolo2out_enum
+
+struct Yolo2OutputParam : public dmlc::Parameter {
+  int num_class;
+  int num_anchor;
+  float overlap_thresh;
+  float object_grad_scale;
+  float background_grad_scale;
+  float class_grad_scale;
+  float coord_grad_scale;
+  nnvm::Tuple anchors;
+  int warmup_samples;
+  float warmup_grad_scale;
+  float nms_threshold;
+  int nms_topk;
+  bool force_suppress;
+  DMLC_DECLARE_PARAMETER(Yolo2OutputParam) {
+DMLC_DECLARE_FIELD(num_class).set_lower_bound(1)
+.describe("Number of object classes.");
+DMLC_DECLARE_FIELD(num_anchor).set_default(5)
+.set_lower_bound(1)
+.describe("Number of anchors.");
+DMLC_DECLARE_FIELD(overlap_thresh).set_default(0.6)
+.describe("Positive overlap threshold.");
+DMLC_DECLARE_FIELD(object_grad_scale).set_default(1.0)
+.describe("Gradient scale for positive objects.");
+DMLC_DECLARE_FIELD(background_grad_scale).set_default(1.0)
+.describe("Gradient scale for background.");
+DMLC_DECLARE_FIELD(class_grad_scale).set_default(1.0)
+.describe("Gradient scale for positive objects.");
+DMLC_DECLARE_FIELD(coord_grad_scale).set_default(1.0)
+.describe("Gradient scale for box offsets.");
+DMLC_DECLARE_FIELD(anchors)
+.set_default({1.08f, 1.19f, 3.42f, 4.41f, 6.63f, 11.38f, 9.42f, 5.11f, 
16.62f, 10.52f})
+.describe("Predefined anchor box widths and heights.");
+DMLC_DECLARE_FIELD(warmup_samples).set_default(12800)
+.describe("Number of images to warm up towards averaging position for box "
+"predictions when starting a new training. ");
+DMLC_DECLARE_FIELD(warmup_grad_scale).set_default(0.01)
+.describe("Gradient scale for non-critical anchors during warm-up stage.");
+DMLC_DECLARE_FIELD(nms_threshold).set_default(0.5f)
+.describe("Non-maximum suppression threshold.");
+DMLC_DECLARE_FIELD(force_suppress).set_default(false)
+.describe("Suppress all detections regardless of class_id.");
+DMLC_DECLARE_FIELD(nms_topk).set_default(-1)
+.describe("Keep maximum top k detections before nms, -1 for no limit.");
+  }
+};  // struct Yolo2OutputParam
+
+template
+MSHADOW_XINLINE DType Intersect(DType l1, DType r1, DType l2, DType r2) {
+  DType left = l1 > l2 ? l1 : l2;
+  DType right = r1 < r2 ? r1 : r2;
+  DType w = right - left;
+  return w > 0 ? w : DType(0);
+}
+
+template
+MSHADOW_XINLINE DType Area(DType l1, DType t1, DType r1, DType b1) {
+  DType width = r1 - l1;
+  DType height = b1 - t1;
+  if (width <= 0 || height <= 0) return DType(0);
+  return width * height;
+}
+
+template
+MSHADOW_XINLINE DType IOU(DType l1, DType t1, DType r1, DType b1,
+  DType l2, DType t2, DType r2, DType b2) {
+  DType inter_area = Intersect(l1, r1, l2, r2) * Intersect(t1, b1, t2, b2);
+  if (inter_area <= 0) return DType(0);
+  DType area1 = Area(l1, t1, r1, b1);
+  DType area2 = Area(l2, t2, r2, b2);
+  return inter_area / (area1 + area2 - inter_area);
+}
+
+// compute intersection-over-union overlap between two boxes
+struct calc_overlap {
+  template
+  MSHADOW_XINLINE static void Map(int i, DType* out,
+  const DType* L1, const DType* T1, const DType* R1, const DType* B1,
+  const DType* L2, const DType* T2, const DType* R2, 

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

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

 ##
 File path: src/engine/threaded_engine.h
 ##
 @@ -476,6 +507,9 @@ class ThreadedEngine : public Engine {
*/
   std::mutex finished_m_;
   std::condition_variable finished_cv_;
+  /*! \brief exception_ptr associated with the engine,
+   * which is used to throw exception in waitall */
+  std::exception_ptr global_ex_ptr;
 
 Review comment:
   Changed!


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/storage/gpu_device_storage.h
 ##
 @@ -62,7 +62,7 @@ inline void* GPUDeviceStorage::Alloc(size_t size) {
 #endif  // MXNET_USE_NCCL
   cudaError_t e = cudaMalloc(, size);
   if (e != cudaSuccess && e != cudaErrorCudartUnloading)
-throw std::bad_alloc();
+LOG(FATAL) << cudaGetLastError();
 
 Review comment:
   Good catch! I have changed it to call cudaGetErrorString


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 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:
   Fixed.


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 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:
   Good catch! Fixed here and other places.


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.h
 ##
 @@ -338,33 +346,46 @@ class ThreadedEngine : public Engine {
 #endif
 CallbackOnComplete callback = this->CreateCallback(
 ThreadedEngine::OnCompleteStatic, opr_block);
+CallbackOnComplete on_start_callback = this->CreateCallback(
+ThreadedEngine::OnStartStatic, opr_block);
 bool debug_info = (engine_info_ && debug_push_opr_ == opr_block);
 if (debug_info) {
   LOG(INFO) << "ExecuteOprBlock " << opr_block
 << "shutdown_phase=" << shutdown_phase_;
 }
 if (!shutdown_phase_) {
   try {
+on_start_callback();
 if (debug_info) {
   LOG(INFO) << "ExecuteOprFn ";
 }
-threaded_opr->fn(run_ctx, callback);
+try {
+  if (!threaded_opr->ex_ptr || threaded_opr->wait) {
+threaded_opr->fn(run_ctx, callback);
+  } else {
+callback();
+  }
+} catch (dmlc::Error& e) {
 
 Review comment:
   The reason I catch only dmlc::Error is that The guards in the c_api 
API_BEGIN and API_END/API_END_HANDLE_ERROR only catch dmlc::Error currently and 
propagate to frontend. 


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.h
 ##
 @@ -338,33 +346,46 @@ class ThreadedEngine : public Engine {
 #endif
 CallbackOnComplete callback = this->CreateCallback(
 ThreadedEngine::OnCompleteStatic, opr_block);
+CallbackOnComplete on_start_callback = this->CreateCallback(
 
 Review comment:
   The callback is not strictly necessary here, since it is called only once, 
but I included it to keep the ExecuteOprBlock easier to read and separate out 
the OnStart logic.


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.h
 ##
 @@ -175,6 +175,8 @@ class ThreadedVar final
   static std::atomic counter;
   ~ThreadedVar() { LOG(INFO) << __func__ << " " << --counter; }
 #endif  // ENGINE_DEBUG
+  /*! \brief exception_ptr associated with the ThreadedVar */
+  std::exception_ptr ex_ptr;
 
 Review comment:
   i changed ex_ptr for var to var_exception, ex_ptr for opr to opr_exception 
and the global exception_ptr global_exception_ . I welcome if you have any 
other suggestions for naming them.


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.cc
 ##
 @@ -403,7 +417,11 @@ inline void ThreadedEngine::OnComplete(ThreadedOpr* 
threaded_opr) {
   }
   // Mark complete for write variables.
   for (auto&& i : threaded_opr->mutable_vars) {
-const bool debug_info = (engine_info_ && debug_wait_var_ == i);
+if (threaded_opr->ex_ptr) {
+  i->ex_ptr = threaded_opr->ex_ptr;
+  if (!global_ex_ptr) global_ex_ptr = i->ex_ptr;
+}
 
 Review comment:
   z += 1 won't execute since z already has an exception associated with it. 
z.asnumpy() will still raise the error.


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.cc
 ##
 @@ -403,7 +417,11 @@ inline void ThreadedEngine::OnComplete(ThreadedOpr* 
threaded_opr) {
   }
   // Mark complete for write variables.
   for (auto&& i : threaded_opr->mutable_vars) {
-const bool debug_info = (engine_info_ && debug_wait_var_ == i);
+if (threaded_opr->ex_ptr) {
+  i->ex_ptr = threaded_opr->ex_ptr;
+  if (!global_ex_ptr) global_ex_ptr = i->ex_ptr;
+}
+bool debug_info = (engine_info_ && debug_wait_var_ == i);
 
 Review comment:
   This was not intentional. Added it back.


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.cc
 ##
 @@ -391,6 +400,11 @@ void ThreadedEngine::WaitForAll() {
   finished_cv_.wait(lock, [this]() {
   return pending_.load() == 0 || kill_.load();
 });
+  if (global_ex_ptr) {
+std::exception_ptr ex_ptr = global_ex_ptr;
 
 Review comment:
   Fixed.


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.cc
 ##
 @@ -356,7 +357,11 @@ void ThreadedEngine::DeleteVariable(SyncFn delete_fn,
 void ThreadedEngine::WaitForVar(VarHandle var) {
   BulkFlush();
   ThreadedVar* threaded_var = ThreadedVar::CastFromBase(var);
-  if (threaded_var->ready_to_read()) return;
+  if (threaded_var->ready_to_read()) {
+if (threaded_var->ex_ptr) {
+  std::rethrow_exception(threaded_var->ex_ptr);
+}
+  }
 
 Review comment:
   Good catch! Fixed.


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 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:
   wait is used to indicate  to the ExecuteOprBlock whether it is a waitforvar 
operation. it should not block the execution of the operator for WaitForVar.


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] anirudh2290 commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 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,
 
 Review comment:
   Good catch! Fixed.


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] ShownX commented on issue #9676: [Feature Request] Cross Product Operation

2018-02-02 Thread GitBox
ShownX commented on issue #9676: [Feature Request] Cross Product Operation
URL: 
https://github.com/apache/incubator-mxnet/issues/9676#issuecomment-362717027
 
 
   Numpy: 
https://github.com/numpy/numpy/blob/v1.12.0/numpy/core/numeric.py#L1640-L1838
   PyTorch:  
http://pytorch.org/docs/master/torch.html?highlight=cross#torch.cross


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] szha opened a new issue #9686: APIs that might be a good idea to remove in 2.0

2018-02-02 Thread GitBox
szha opened a new issue #9686: APIs that might be a good idea to remove in 2.0
URL: https://github.com/apache/incubator-mxnet/issues/9686
 
 
   Now that we decided to follow semantic versioning for releases, it would be 
a good idea to coordinate features and API changes to make the best use of the 
next major release. Thus, I propose that we use this issue to track the APIs 
we'd like to change in the next major version.
   
   The candidates I've collected so far:
   1. remove legacy ops such as batch-norm v1
   2. reorganizing namespace for utility functions such as `download` in #9671 
   
   Once there are more of such requests, I will try to organize these 
API-breaking requests better.


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] chsin commented on issue #9028: How to use the C API to train simple a Softmax in pure C?

2018-02-02 Thread GitBox
chsin commented on issue #9028: How to use the C API to train simple a Softmax 
in pure C?
URL: 
https://github.com/apache/incubator-mxnet/issues/9028#issuecomment-362707675
 
 
   No, they're just going to ignore this for 90 days and then close it.


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


[incubator-mxnet] branch master updated: Set the autotune default to 1 in docs (#9653)

2018-02-02 Thread zhasheng
This is an automated email from the ASF dual-hosted git repository.

zhasheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
 new 95095e4  Set the autotune default to 1 in docs (#9653)
95095e4 is described below

commit 95095e4138b67ce033b999e8acc487ade6bf9018
Author: Kellen Sunderland 
AuthorDate: Fri Feb 2 22:06:45 2018 +0100

Set the autotune default to 1 in docs (#9653)

From the usages I see, the default value is 1.


https://github.com/apache/incubator-mxnet/blob/2cc2aa2272881326c8a50c6204aedd71e1821c3f/src/operator/nn/cudnn/cudnn_convolution-inl.h#L100
and

https://github.com/apache/incubator-mxnet/blob/2cc2aa2272881326c8a50c6204aedd71e1821c3f/src/operator/nn/cudnn/cudnn_deconvolution-inl.h#L97
---
 docs/faq/env_var.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/faq/env_var.md b/docs/faq/env_var.md
index 41b8bca..af698ca 100644
--- a/docs/faq/env_var.md
+++ b/docs/faq/env_var.md
@@ -110,7 +110,7 @@ When USE_PROFILER is enabled in Makefile or CMake, the 
following environments ca
 ## Other Environment Variables
 
 * MXNET_CUDNN_AUTOTUNE_DEFAULT
-  - Values: 0(false) or 1(true) ```(default=0)```
+  - Values: 0(false) or 1(true) ```(default=1)```
   - The default value of cudnn auto tunning for convolution layers.
   - Auto tuning is turned off by default. For benchmarking, set this to 1 to 
turn it on by default.
 

-- 
To stop receiving notification emails like this one, please contact
zhash...@apache.org.


[GitHub] szha closed pull request #9653: Set the autotune default to 1 in docs

2018-02-02 Thread GitBox
szha closed pull request #9653: Set the autotune default to 1 in docs
URL: https://github.com/apache/incubator-mxnet/pull/9653
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docs/faq/env_var.md b/docs/faq/env_var.md
index 41b8bcabe3..af698ca639 100644
--- a/docs/faq/env_var.md
+++ b/docs/faq/env_var.md
@@ -110,7 +110,7 @@ When USE_PROFILER is enabled in Makefile or CMake, the 
following environments ca
 ## Other Environment Variables
 
 * MXNET_CUDNN_AUTOTUNE_DEFAULT
-  - Values: 0(false) or 1(true) ```(default=0)```
+  - Values: 0(false) or 1(true) ```(default=1)```
   - The default value of cudnn auto tunning for convolution layers.
   - Auto tuning is turned off by default. For benchmarking, set this to 1 to 
turn it on by default.
 


 


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] piiswrong commented on issue #9676: [Feature Request] Cross Product Operation

2018-02-02 Thread GitBox
piiswrong commented on issue #9676: [Feature Request] Cross Product Operation
URL: 
https://github.com/apache/incubator-mxnet/issues/9676#issuecomment-362682999
 
 
   Could you give a mathematical description or a reference paper?


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


[incubator-mxnet] branch master updated: Fix test_sparse_operator failures due to out-of-bounds ref. (#9674)

2018-02-02 Thread jxie
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
 new 51776aa  Fix test_sparse_operator failures due to out-of-bounds ref. 
(#9674)
51776aa is described below

commit 51776aa2384430d67bf3bd23d2c36059503fd3c8
Author: Dick Carter 
AuthorDate: Fri Feb 2 11:19:51 2018 -0800

Fix test_sparse_operator failures due to out-of-bounds ref. (#9674)
---
 src/operator/tensor/broadcast_reduce_op.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/operator/tensor/broadcast_reduce_op.h 
b/src/operator/tensor/broadcast_reduce_op.h
index 76c78be..02d48b4 100644
--- a/src/operator/tensor/broadcast_reduce_op.h
+++ b/src/operator/tensor/broadcast_reduce_op.h
@@ -362,7 +362,7 @@ inline bool SumOpForwardInferStorageType(const 
nnvm::NodeAttrs& attrs,
  DispatchMode::kFCompute);
   }
 
-  if (!dispatched && in_stype == kCSRStorage &&
+  if (!dispatched && in_stype == kCSRStorage && param.axis.ndim() == 1 &&
   (param.axis[0] == 0 || param.axis[0] == 1) && !param.keepdims &&
   !param.exclude) {
 // If input is csr and axis is 0 or 1, and neither of keepdims or exclude

-- 
To stop receiving notification emails like this one, please contact
j...@apache.org.


[GitHub] piiswrong closed pull request #9674: Fix test_sparse_operator failures due to out-of-bounds ref.

2018-02-02 Thread GitBox
piiswrong closed pull request #9674: Fix test_sparse_operator failures due to 
out-of-bounds ref.
URL: https://github.com/apache/incubator-mxnet/pull/9674
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/operator/tensor/broadcast_reduce_op.h 
b/src/operator/tensor/broadcast_reduce_op.h
index 76c78be35a..02d48b4697 100644
--- a/src/operator/tensor/broadcast_reduce_op.h
+++ b/src/operator/tensor/broadcast_reduce_op.h
@@ -362,7 +362,7 @@ inline bool SumOpForwardInferStorageType(const 
nnvm::NodeAttrs& attrs,
  DispatchMode::kFCompute);
   }
 
-  if (!dispatched && in_stype == kCSRStorage &&
+  if (!dispatched && in_stype == kCSRStorage && param.axis.ndim() == 1 &&
   (param.axis[0] == 0 || param.axis[0] == 1) && !param.keepdims &&
   !param.exclude) {
 // If input is csr and axis is 0 or 1, and neither of keepdims or exclude


 


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] piiswrong commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.h
 ##
 @@ -476,6 +507,9 @@ class ThreadedEngine : public Engine {
*/
   std::mutex finished_m_;
   std::condition_variable finished_cv_;
+  /*! \brief exception_ptr associated with the engine,
+   * which is used to throw exception in waitall */
+  std::exception_ptr global_ex_ptr;
 
 Review comment:
   ex_ptr is a bad name. class members should end with `_`.


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] piiswrong commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/storage/gpu_device_storage.h
 ##
 @@ -62,7 +62,7 @@ inline void* GPUDeviceStorage::Alloc(size_t size) {
 #endif  // MXNET_USE_NCCL
   cudaError_t e = cudaMalloc(, size);
   if (e != cudaSuccess && e != cudaErrorCudartUnloading)
-throw std::bad_alloc();
+LOG(FATAL) << cudaGetLastError();
 
 Review comment:
   Does cudaGetLastError return a string or an error code?


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] piiswrong commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/storage/cpu_device_storage.h
 ##
 @@ -61,10 +61,10 @@ inline void* CPUDeviceStorage::Alloc(size_t size) {
   void* ptr;
 #if _MSC_VER
   ptr = _aligned_malloc(size, alignment_);
-  if (ptr == NULL) throw std::bad_alloc();
+  if (ptr == NULL) LOG(FATAL) << "Malloc failure";
 
 Review comment:
   Failed to allocate CPU memory


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] piiswrong commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.h
 ##
 @@ -338,33 +346,46 @@ class ThreadedEngine : public Engine {
 #endif
 CallbackOnComplete callback = this->CreateCallback(
 ThreadedEngine::OnCompleteStatic, opr_block);
+CallbackOnComplete on_start_callback = this->CreateCallback(
+ThreadedEngine::OnStartStatic, opr_block);
 bool debug_info = (engine_info_ && debug_push_opr_ == opr_block);
 if (debug_info) {
   LOG(INFO) << "ExecuteOprBlock " << opr_block
 << "shutdown_phase=" << shutdown_phase_;
 }
 if (!shutdown_phase_) {
   try {
+on_start_callback();
 if (debug_info) {
   LOG(INFO) << "ExecuteOprFn ";
 }
-threaded_opr->fn(run_ctx, callback);
+try {
+  if (!threaded_opr->ex_ptr || threaded_opr->wait) {
+threaded_opr->fn(run_ctx, callback);
+  } else {
+callback();
+  }
+} catch (dmlc::Error& e) {
+  threaded_opr->ex_ptr = std::current_exception();
+  callback();
+}
 if (debug_info) {
   LOG(INFO) << "Fin ExecuteOprFn ";
 }
-  } catch(dmlc::Error ) {
+  } catch (dmlc::Error& e) {
 
 Review comment:
   what would this catch now? There is already a try block inside


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] zhanghang1989 commented on a change in pull request #7938: instance norm and reflection padding

2018-02-02 Thread GitBox
zhanghang1989 commented on a change in pull request #7938: instance norm and 
reflection padding
URL: https://github.com/apache/incubator-mxnet/pull/7938#discussion_r165729982
 
 

 ##
 File path: python/mxnet/gluon/nn/conv_layers.py
 ##
 @@ -1007,3 +1008,37 @@ def __init__(self, layout='NCDHW', **kwargs):
 assert layout == 'NCDHW', "Only supports NCDHW layout for now"
 super(GlobalAvgPool3D, self).__init__(
 (1, 1, 1), None, 0, True, True, 'avg', **kwargs)
+
+
+class ReflectionPad2D(HybridBlock):
+"""Pads the input tensor using the reflection of the input boundary.
+
+Parameters
+--
+padding: int or a tuple of int
+An integer padding width for height and weight or a tuple of
+integers padding widths for each axis of the format ``(before_1, 
after_1, ... ,
+before_N, after_N)``. The `padding` should be of length ``2*N`` where 
``N``
 
 Review comment:
   Agree. Just made the changes. Will refactor when adding 1D/3D


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


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

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

 ##
 File path: src/engine/threaded_engine.h
 ##
 @@ -338,33 +346,46 @@ class ThreadedEngine : public Engine {
 #endif
 CallbackOnComplete callback = this->CreateCallback(
 ThreadedEngine::OnCompleteStatic, opr_block);
+CallbackOnComplete on_start_callback = this->CreateCallback(
+ThreadedEngine::OnStartStatic, opr_block);
 bool debug_info = (engine_info_ && debug_push_opr_ == opr_block);
 if (debug_info) {
   LOG(INFO) << "ExecuteOprBlock " << opr_block
 << "shutdown_phase=" << shutdown_phase_;
 }
 if (!shutdown_phase_) {
   try {
+on_start_callback();
 if (debug_info) {
   LOG(INFO) << "ExecuteOprFn ";
 }
-threaded_opr->fn(run_ctx, callback);
+try {
+  if (!threaded_opr->ex_ptr || threaded_opr->wait) {
+threaded_opr->fn(run_ctx, callback);
+  } else {
+callback();
+  }
+} catch (dmlc::Error& e) {
 
 Review comment:
   why only catch dmlc error?


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] piiswrong commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.h
 ##
 @@ -338,33 +346,46 @@ class ThreadedEngine : public Engine {
 #endif
 CallbackOnComplete callback = this->CreateCallback(
 ThreadedEngine::OnCompleteStatic, opr_block);
+CallbackOnComplete on_start_callback = this->CreateCallback(
 
 Review comment:
   what's the point of creating a call back here?


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] piiswrong commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.h
 ##
 @@ -175,6 +175,8 @@ class ThreadedVar final
   static std::atomic counter;
   ~ThreadedVar() { LOG(INFO) << __func__ << " " << --counter; }
 #endif  // ENGINE_DEBUG
+  /*! \brief exception_ptr associated with the ThreadedVar */
+  std::exception_ptr ex_ptr;
 
 Review comment:
   ex_ptr is a bad variable name


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] piiswrong commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.cc
 ##
 @@ -403,7 +417,11 @@ inline void ThreadedEngine::OnComplete(ThreadedOpr* 
threaded_opr) {
   }
   // Mark complete for write variables.
   for (auto&& i : threaded_opr->mutable_vars) {
-const bool debug_info = (engine_info_ && debug_wait_var_ == i);
+if (threaded_opr->ex_ptr) {
+  i->ex_ptr = threaded_opr->ex_ptr;
+  if (!global_ex_ptr) global_ex_ptr = i->ex_ptr;
+}
 
 Review comment:
   suppose and operator has three outputs x, y and z and it raises an exception.
   then x.asnumpy() would raise an error.
   Then y.asnumpy() would raise the same error again.
   
   and if I do z += 1 and it succeeds, z.asnumpy() would still raise the error


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] piiswrong commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.cc
 ##
 @@ -403,7 +417,11 @@ inline void ThreadedEngine::OnComplete(ThreadedOpr* 
threaded_opr) {
   }
   // Mark complete for write variables.
   for (auto&& i : threaded_opr->mutable_vars) {
-const bool debug_info = (engine_info_ && debug_wait_var_ == i);
+if (threaded_opr->ex_ptr) {
+  i->ex_ptr = threaded_opr->ex_ptr;
+  if (!global_ex_ptr) global_ex_ptr = i->ex_ptr;
+}
 
 Review comment:
   suppose and operator has two outputs x and y and it raises an exception.
   then x.asnumpy() would raise an error.
   Then y.asnumpy() would raise the same error again.
   
   and if I do x += 1 and it succeeds, x.asnumpy() would still raise the error


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] piiswrong commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.cc
 ##
 @@ -403,7 +417,11 @@ inline void ThreadedEngine::OnComplete(ThreadedOpr* 
threaded_opr) {
   }
   // Mark complete for write variables.
   for (auto&& i : threaded_opr->mutable_vars) {
-const bool debug_info = (engine_info_ && debug_wait_var_ == i);
+if (threaded_opr->ex_ptr) {
+  i->ex_ptr = threaded_opr->ex_ptr;
+  if (!global_ex_ptr) global_ex_ptr = i->ex_ptr;
+}
 
 Review comment:
   suppose and operator has two outputs x and y and it raises an exception.
   then x.asnumpy() would raise an error.
   Then y.asnumpy() would raise the same error again.
   


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] piiswrong commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.cc
 ##
 @@ -403,7 +417,11 @@ inline void ThreadedEngine::OnComplete(ThreadedOpr* 
threaded_opr) {
   }
   // Mark complete for write variables.
   for (auto&& i : threaded_opr->mutable_vars) {
-const bool debug_info = (engine_info_ && debug_wait_var_ == i);
+if (threaded_opr->ex_ptr) {
+  i->ex_ptr = threaded_opr->ex_ptr;
+  if (!global_ex_ptr) global_ex_ptr = i->ex_ptr;
+}
+bool debug_info = (engine_info_ && debug_wait_var_ == i);
 
 Review comment:
   why remove const?


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] piiswrong commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.cc
 ##
 @@ -391,6 +400,11 @@ void ThreadedEngine::WaitForAll() {
   finished_cv_.wait(lock, [this]() {
   return pending_.load() == 0 || kill_.load();
 });
+  if (global_ex_ptr) {
+std::exception_ptr ex_ptr = global_ex_ptr;
 
 Review comment:
   use std::rethrow_exception(std::move(global_ex_ptr))


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] piiswrong commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.cc
 ##
 @@ -391,6 +400,11 @@ void ThreadedEngine::WaitForAll() {
   finished_cv_.wait(lock, [this]() {
   return pending_.load() == 0 || kill_.load();
 });
+  if (global_ex_ptr) {
+std::exception_ptr ex_ptr = global_ex_ptr;
 
 Review comment:
   use std::move


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] szha commented on a change in pull request #7938: instance norm and reflection padding

2018-02-02 Thread GitBox
szha commented on a change in pull request #7938: instance norm and reflection 
padding
URL: https://github.com/apache/incubator-mxnet/pull/7938#discussion_r165726019
 
 

 ##
 File path: python/mxnet/gluon/nn/conv_layers.py
 ##
 @@ -1007,3 +1008,37 @@ def __init__(self, layout='NCDHW', **kwargs):
 assert layout == 'NCDHW', "Only supports NCDHW layout for now"
 super(GlobalAvgPool3D, self).__init__(
 (1, 1, 1), None, 0, True, True, 'avg', **kwargs)
+
+
+class ReflectionPad2D(HybridBlock):
+"""Pads the input tensor using the reflection of the input boundary.
+
+Parameters
+--
+padding: int or a tuple of int
+An integer padding width for height and weight or a tuple of
+integers padding widths for each axis of the format ``(before_1, 
after_1, ... ,
+before_N, after_N)``. The `padding` should be of length ``2*N`` where 
``N``
 
 Review comment:
   Since the class name says 2D, it should support 2D.
   
   You can do something similar to the conv blocks, with a common abstract 
class for the forward logic, and the actual 1D/2D/3D classes for specific 
implementation.


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] piiswrong commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 File path: src/engine/threaded_engine.cc
 ##
 @@ -356,7 +357,11 @@ void ThreadedEngine::DeleteVariable(SyncFn delete_fn,
 void ThreadedEngine::WaitForVar(VarHandle var) {
   BulkFlush();
   ThreadedVar* threaded_var = ThreadedVar::CastFromBase(var);
-  if (threaded_var->ready_to_read()) return;
+  if (threaded_var->ready_to_read()) {
+if (threaded_var->ex_ptr) {
+  std::rethrow_exception(threaded_var->ex_ptr);
+}
+  }
 
 Review comment:
   why are you not returning?


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] piiswrong commented on a change in pull request #9681: Better Exception Handling for Operators

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

 ##
 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:
   what's wait? Why do you need it? Please document arguments


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


[incubator-mxnet] branch master updated: typo (#9683)

2018-02-02 Thread jxie
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
 new 8ee3177  typo (#9683)
8ee3177 is described below

commit 8ee3177c86c39820e3b81de3af0a489a29fca4eb
Author: dongzhuoyao 
AuthorDate: Sat Feb 3 02:41:10 2018 +0800

typo (#9683)
---
 python/mxnet/gluon/block.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python/mxnet/gluon/block.py b/python/mxnet/gluon/block.py
index c733dda..6ed3b79 100644
--- a/python/mxnet/gluon/block.py
+++ b/python/mxnet/gluon/block.py
@@ -597,7 +597,7 @@ class HybridBlock(Block):
 
 class SymbolBlock(HybridBlock):
 """Construct block from symbol. This is useful for using pre-trained models
-as feature extractors. For example, you may want to extract get the output
+as feature extractors. For example, you may want to extract the output
 from fc2 layer in AlexNet.
 
 Parameters

-- 
To stop receiving notification emails like this one, please contact
j...@apache.org.


[GitHub] piiswrong closed pull request #9683: gluon block.py typo

2018-02-02 Thread GitBox
piiswrong closed pull request #9683: gluon block.py typo
URL: https://github.com/apache/incubator-mxnet/pull/9683
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/python/mxnet/gluon/block.py b/python/mxnet/gluon/block.py
index c84c528aa8..d068a564f5 100644
--- a/python/mxnet/gluon/block.py
+++ b/python/mxnet/gluon/block.py
@@ -597,7 +597,7 @@ def hybrid_forward(self, F, x, *args, **kwargs):
 
 class SymbolBlock(HybridBlock):
 """Construct block from symbol. This is useful for using pre-trained models
-as feature extractors. For example, you may want to extract get the output
+as feature extractors. For example, you may want to extract the output
 from fc2 layer in AlexNet.
 
 Parameters


 


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] eric-haibin-lin commented on issue #9666: [scala-package][master] bump up project version

2018-02-02 Thread GitBox
eric-haibin-lin commented on issue #9666: [scala-package][master] bump up 
project version
URL: https://github.com/apache/incubator-mxnet/pull/9666#issuecomment-362664186
 
 
   I?m not sure about that. For MXNet it is required. 
   
   On 2018?2?1?, at 13:04, Nan Zhu  wrote:
   
   oh, going to general is a requirement for incubating project only?
   
   ?
   You are receiving this because you commented.
   Reply to this email directly, view it on GitHub, or mute the thread.
   
   


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 issue #9552: [REQUEST FOR REVIEW | DO NOT MERGE] Model Quantization with Calibration

2018-02-02 Thread GitBox
reminisce commented on issue #9552: [REQUEST FOR REVIEW | DO NOT MERGE] Model 
Quantization with Calibration
URL: https://github.com/apache/incubator-mxnet/pull/9552#issuecomment-362662671
 
 
   @pengzhao-intel Thank you guys for implementing quantized ops for CPU 
computing. We look forward to seeing and benchmarking the implementation.
   
   I propose that your team work on top this PR and submit a separate PR of 
your work after this one is merged. This is already a big PR (>3000 lines of 
code) and adding more code would make the review process overwhelming. Please 
also know that we still need to wait for P3 instances in the CI being 
officially ready to fully test the PR.


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] zhanghang1989 commented on a change in pull request #7938: instance norm and reflection padding

2018-02-02 Thread GitBox
zhanghang1989 commented on a change in pull request #7938: instance norm and 
reflection padding
URL: https://github.com/apache/incubator-mxnet/pull/7938#discussion_r165713203
 
 

 ##
 File path: python/mxnet/gluon/nn/conv_layers.py
 ##
 @@ -1007,3 +1008,37 @@ def __init__(self, layout='NCDHW', **kwargs):
 assert layout == 'NCDHW', "Only supports NCDHW layout for now"
 super(GlobalAvgPool3D, self).__init__(
 (1, 1, 1), None, 0, True, True, 'avg', **kwargs)
+
+
+class ReflectionPad2D(HybridBlock):
+"""Pads the input tensor using the reflection of the input boundary.
+
+Parameters
+--
+padding: int or a tuple of int
+An integer padding width for height and weight or a tuple of
+integers padding widths for each axis of the format ``(before_1, 
after_1, ... ,
+before_N, after_N)``. The `padding` should be of length ``2*N`` where 
``N``
 
 Review comment:
   If pass into a tuple, it works for different dimensions. Should we remove 
this?


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 issue #9552: [REQUEST FOR REVIEW | DO NOT MERGE] Model Quantization with Calibration

2018-02-02 Thread GitBox
reminisce commented on issue #9552: [REQUEST FOR REVIEW | DO NOT MERGE] Model 
Quantization with Calibration
URL: https://github.com/apache/incubator-mxnet/pull/9552#issuecomment-362642270
 
 
   @KellenSunderland Thank you for the note. I will either cherry pick the PR 
or rebased with the master once your PR is merged.


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] nswamy commented on issue #9678: [First cut] Scala Inference APIs

2018-02-02 Thread GitBox
nswamy commented on issue #9678: [First cut] Scala Inference APIs
URL: https://github.com/apache/incubator-mxnet/pull/9678#issuecomment-362641862
 
 
   @calumleslie @yizhi @lupesko @jesterhazy


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] nswamy commented on issue #9678: [First cut] Scala Inference APIs

2018-02-02 Thread GitBox
nswamy commented on issue #9678: [First cut] Scala Inference APIs
URL: https://github.com/apache/incubator-mxnet/pull/9678#issuecomment-362641862
 
 
   @lupesko please review.


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] nswamy commented on issue #9678: [First cut] Scala Inference APIs

2018-02-02 Thread GitBox
nswamy commented on issue #9678: [First cut] Scala Inference APIs
URL: https://github.com/apache/incubator-mxnet/pull/9678#issuecomment-362641760
 
 
   Unit Tests are failing for a requirement(number of dimensions in shape match 
the number of elements in layout) I put into the DataDesc. I will fix the unit 
tests and update the PR.


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] marcoabreu commented on a change in pull request #9684: Enable dp4a for the CI

2018-02-02 Thread GitBox
marcoabreu commented on a change in pull request #9684: Enable dp4a for the CI
URL: https://github.com/apache/incubator-mxnet/pull/9684#discussion_r165696114
 
 

 ##
 File path: tests/ci_build/ci_build.sh
 ##
 @@ -176,7 +180,7 @@ ${DOCKER_BINARY} run --rm --pid=host \
 -e "CI_BUILD_UID=$(id -u)" \
 -e "CI_BUILD_GROUP=$(id -g -n)" \
 -e "CI_BUILD_GID=$(id -g)" \
--e "CUDA_ARCH=-gencode arch=compute_52,code=[sm_52,compute_52] 
--fatbin-options -compress-all" \
+-e "CUDA_ARCH=-gencode arch=compute_52,code=[sm_52,compute_52] -gencode 
arch=compute_61,code=sm_61 --fatbin-options -compress-all" \
 
 Review comment:
   6.1 is Pascal based GPUs and thus would have no effect on our CI. Could you 
elaborate?


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] larroy opened a new pull request #9685: Script to install on a python virtualenv for development

2018-02-02 Thread GitBox
larroy opened a new pull request #9685: Script to install on a python 
virtualenv for development
URL: https://github.com/apache/incubator-mxnet/pull/9685
 
 
   


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] pengzhao-intel commented on a change in pull request #9552: [REQUEST FOR REVIEW | DO NOT MERGE] Model Quantization with Calibration

2018-02-02 Thread GitBox
pengzhao-intel commented on a change in pull request #9552: [REQUEST FOR REVIEW 
| DO NOT MERGE] Model Quantization with Calibration
URL: https://github.com/apache/incubator-mxnet/pull/9552#discussion_r165646442
 
 

 ##
 File path: src/operator/quantization/quantized_conv.cc
 ##
 @@ -0,0 +1,171 @@
+/*
+ * 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.
+ */
+
+/*!
+ * Copyright (c) 2017 by Contributors
+ * \file quantized_conv.cc
+ * \brief
+ * \author Ziheng Jiang, Jun Wu
+*/
+#include "../nn/convolution-inl.h"
+
+namespace mxnet {
+namespace op {
+
+// TODO(junwu): Reuse the InferShape function of convolution op after
+// this pr is merged: https://github.com/apache/incubator-mxnet/pull/8302
+bool QuantizedConvShape(const nnvm::NodeAttrs& attrs,
+std::vector* in_shape,
+std::vector* out_shape) {
+  using namespace mshadow;
+  const ConvolutionParam& param = nnvm::get(attrs.parsed);
+  CHECK_EQ(param.num_group, 1U) << "quantized_conv only supports num_group=1 
for now";
+  CHECK_EQ(in_shape->size(), param.no_bias? 6U : 9U);
+  CHECK_EQ(out_shape->size(), 3U);
+  if (param.layout.has_value()) {
+CHECK_EQ(param.layout.value(), mshadow::kNCHW) << "quantized_conv only 
supports NCHW for now";
+  }
+  CHECK_EQ(param.kernel.ndim(), 2U) << "quantized_conv only supports 2D 
convolution for now";
+  CHECK(param.dilate.ndim() == 0U || param.dilate.Size() == 1U)
+<< "quantized_conv only supports dilation=1 for all dimensions";
+  const TShape& dshape =  in_shape->at(0);
+  CHECK_EQ(dshape.ndim(), 4U);
+  if (dshape.ndim() == 0U) return false;
+
+  const int N = 0, H = 2, W = 3, C = 1;
+  CHECK_EQ(dshape[C] % 4,  0U)
+<< "for 8bit cudnn conv, the number of channel must be multiple of 4";
+  CHECK_EQ(param.num_filter % 4, 0U)
+<< "for 8bit cudnn conv, the number of channel must be multiple of 4";
+
+  TShape wshape{0, 0, 0, 0};
+  wshape[N] = param.num_filter;
+  wshape[H] = param.kernel[0];
+  wshape[W] = param.kernel[1];
+  wshape[C] = dshape[C];
+  SHAPE_ASSIGN_CHECK(*in_shape, 1, wshape);
+  const int start = param.no_bias? 2 : 3;
+  const int end = param.no_bias? 6 : 9;
+  for (int i = start; i < end; ++i) {
+SHAPE_ASSIGN_CHECK(*in_shape, i, TShape{1});
+  }
+  if (!param.no_bias) {
+SHAPE_ASSIGN_CHECK(*in_shape, 2, Shape1(param.num_filter));
+  }
+
+  auto AddPad = [](index_t dsize, index_t pad) { return dsize + 2 * pad; };
+  TShape oshape{1, 1, 1, 1};
+  oshape[N] = dshape[N];
+  oshape[C] = wshape[N];
+  oshape[H] = (AddPad(dshape[H], param.pad[0]) - wshape[H]) / param.stride[0] 
+ 1;
+  oshape[W] = (AddPad(dshape[W], param.pad[1]) - wshape[W]) / param.stride[1] 
+ 1;
+
+  SHAPE_ASSIGN_CHECK(*out_shape, 0, oshape);
+  SHAPE_ASSIGN_CHECK(*out_shape, 1, TShape({1}));
+  SHAPE_ASSIGN_CHECK(*out_shape, 2, TShape({1}));
+  return true;
+}
+
+bool QuantizedConvType(const nnvm::NodeAttrs& attrs,
+   std::vector *in_type,
+   std::vector *out_type) {
+  const ConvolutionParam& param = nnvm::get(attrs.parsed);
+  CHECK_EQ(in_type->size(), param.no_bias? 6U : 9U);
+  CHECK_EQ(out_type->size(), 3U);
+  TYPE_ASSIGN_CHECK(*in_type, 0, mshadow::kInt8);
+  TYPE_ASSIGN_CHECK(*in_type, 1, mshadow::kInt8);
+  if (!param.no_bias) {
+TYPE_ASSIGN_CHECK(*in_type, 2, mshadow::kInt8);
+  }
+
+  const size_t start = param.no_bias? 2 : 3;
+  const size_t end = param.no_bias? 6 : 9;
+  for (size_t i = start; i < end; ++i) {
+TYPE_ASSIGN_CHECK(*in_type, i, mshadow::kFloat32);
+  }
+
+  TYPE_ASSIGN_CHECK(*out_type, 0, mshadow::kInt32);
+  TYPE_ASSIGN_CHECK(*out_type, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_type, 2, mshadow::kFloat32);
+  return true;
+}
+
+NNVM_REGISTER_OP(_contrib_quantized_conv)
+.describe(R"code(Convolution operator for input, weight and bias data type of 
int8,
+and accumulates in type int32 for the output. For each argument, two more 
arguments of type
+float32 must be provided representing the thresholds of quantizing argument 
from data
+type float32 to int8. The final outputs contain the convolution result in 
int32, and min
+and max thresholds representing the threholds for quantizing the float32 
output into int32.
+

[GitHub] KellenSunderland commented on a change in pull request #9671: Exp backoff for downloads.

2018-02-02 Thread GitBox
KellenSunderland commented on a change in pull request #9671: Exp backoff for 
downloads.
URL: https://github.com/apache/incubator-mxnet/pull/9671#discussion_r165642736
 
 

 ##
 File path: python/mxnet/gluon/utils.py
 ##
 @@ -61,13 +52,13 @@ def split_data(data, num_slice, batch_axis=0, 
even_split=True):
 size = data.shape[batch_axis]
 if size < num_slice:
 raise ValueError(
-"Too many slices for data with shape %s. Arguments are " \
-"num_slice=%d and batch_axis=%d."%(str(data.shape), num_slice, 
batch_axis))
+"Too many slices for data with shape %s. Arguments are "
 
 Review comment:
   I think triplequotes would be the equiv of
   
   ```python
   "Too many slices for data with shape %s. Arguments are \n" \
   "num_slice=%d and batch_axis=%d."%(str(data.shape), num_slice, batch_axis))
   ```
   
   but I'll try a few options.


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


  1   2   >