You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/04/30 17:06:07 UTC
[GitHub] piiswrong closed pull request #10725: [WIP] Rc2 fixes
piiswrong closed pull request #10725: [WIP] Rc2 fixes
URL: https://github.com/apache/incubator-mxnet/pull/10725
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/3rdparty/mshadow b/3rdparty/mshadow
index 0b4cedd7015..e051c2c91c1 160000
--- a/3rdparty/mshadow
+++ b/3rdparty/mshadow
@@ -1 +1 @@
-Subproject commit 0b4cedd7015cc69191f8338a8feaacda90697758
+Subproject commit e051c2c91c1ac4a3a8fed3e90ef2fb549220d972
diff --git a/docs/README.md b/docs/README.md
index d62a73c9621..42e068cbb35 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -8,9 +8,9 @@ MXNet Documentation Website is built with [Sphinx](http://www.sphinx-doc.org) an
## How to Build the MXNet Website for Development and QA
-* [Dependencies](build_doc_version/README.md#dependencies)
-* [Developer Build Instructions](build_doc_version/README.md#developer-instructions)
-* [Full Site Build Instructions](build_doc_version/README.md#full-website-build)
+* [Dependencies](https://github.com/apache/incubator-mxnet/tree/master/docs/build_version_doc#dependencies)
+* [Developer Build Instructions](https://github.com/apache/incubator-mxnet/tree/master/docs/build_version_doc#developer-instructions)
+* [Full Site Build Instructions](https://github.com/apache/incubator-mxnet/tree/master/docs/build_version_doc#full-website-build)
## File Structure
@@ -22,28 +22,33 @@ MXNet Documentation Website is built with [Sphinx](http://www.sphinx-doc.org) an
* Page contents originate as markdown files. Sphinx converts markdown files to html through an `rst` intermediate format. Each content folder should contain an index file as landing page.
-* There are some utility scripts to help building website, such as `mxdoc.py` and `build_version_doc/`. They are used to manipulate website contents during building. Refer to [Developer Build Instructions](build_doc_version/README.md#developer-instructions) for more information.
+* There are some utility scripts to help building website, such as `mxdoc.py` and `build_version_doc/`. They are used to manipulate website contents during building. Refer to [Developer Build Instructions](https://github.com/apache/incubator-mxnet/tree/master/docs/build_version_doc#developer-instructions) for more information.
-## Production Website Building Process
-
-**IMPORTANT**: this is currently offline.
+## Production Website Deployment Process
[Apache Jenkins MXNet website building job](https://builds.apache.org/job/incubator-mxnet-build-site/) is used to build MXNet website.
-There are two ways to trigger this job.
-First is nightly build for master branch.
-Second is manually trigger job when a new version is released. This will build for new version.
-The job will fetch mxnet repository, build MXNet website and push all static files to [host repository](https://github.com/apache/incubator-mxnet-site.git).
+The Jenkins docs build job will fetch MXNet repository, build MXNet website and push all static files to [host repository](https://github.com/apache/incubator-mxnet-site.git).
The host repo is hooked with [Apache gitbox](https://gitbox.apache.org/repos/asf?p=incubator-mxnet-site.git;a=summary) to host website.
-## Build Versioning Website
+### Process for Running the Docs Build Job
-**IMPORTANT**: Refer to [Full Site Build Instructions](build_doc_version/README.md#full-website-build) for a working site build with the versions dropdown in the UI.
+1. Login to [Jenkins](http://jenkins.mxnet-ci.amazon-ml.com/).
+1. View the pipeline currently called `website build pipeline`.
+1. Click `Build with Parameters`.
+1. Use the defaults, or change the domain to be your staging server's IP/DNS web address.
+1. Wait about 20-30 minutes while it builds the full site.
+1. On your staging server, clone the [mxnet site repo](https://github.com/apache/incubator-mxnet-site.git).
+1. When you ran `website build pipeline` it followed up with website build - test publish which pushed the changes to the incubator-mxnet-site repo.
+1. Make sure you git pull if you had already cloned the site repo before this first run-through.
+1. Copy the files to your webroot. For more info on this see the developer instructions for docs build.
+1. Preview the site on your staging server. Note, use the domain default before you try to use this for production, but using your own is helpful for QA'ing the site.
+## Build Versioning Website
-`build_doc.sh` is used by Apache Jenkins MXNet website building job to incremental adding of versions. We don't need it for local website development. **Currently offline due to site rendering problems.**
+**IMPORTANT**: Refer to [Full Site Build Instructions](https://github.com/apache/incubator-mxnet/tree/master/docs/build_version_doc#full-website-build) for a working site build with the versions dropdown in the UI.
## Troubleshooting
diff --git a/python/mxnet/gluon/block.py b/python/mxnet/gluon/block.py
index 2f8cdd80fc7..0f415436116 100644
--- a/python/mxnet/gluon/block.py
+++ b/python/mxnet/gluon/block.py
@@ -84,7 +84,7 @@ def __exit__(self, ptype, value, trace):
_BlockScope._current = self._old_scope
-def _flatten(args):
+def _flatten(args, inout_str):
if isinstance(args, NDArray):
return [args], int(0)
if isinstance(args, Symbol):
@@ -93,12 +93,12 @@ def _flatten(args):
return [args], int(length)
assert isinstance(args, (list, tuple)), \
- "HybridBlock input must be (nested) list of Symbol or NDArray, " \
- "but got %s of type %s"%(str(args), str(type(args)))
+ "HybridBlock %s must be (nested) list of Symbol or NDArray, " \
+ "but got %s of type %s"%(inout_str, str(args), str(type(args)))
flat = []
fmts = []
for i in args:
- arg, fmt = _flatten(i)
+ arg, fmt = _flatten(i, inout_str)
flat.extend(arg)
fmts.append(fmt)
return flat, fmts
@@ -461,7 +461,7 @@ def __setattr__(self, name, value):
def _get_graph(self, *args):
if not self._cached_graph:
- args, self._in_format = _flatten(args)
+ args, self._in_format = _flatten(args, "input")
if len(args) > 1:
inputs = [symbol.var('data%d'%i) for i in range(len(args))]
else:
@@ -471,7 +471,7 @@ def _get_graph(self, *args):
params = {i: j.var() for i, j in self._reg_params.items()}
with self.name_scope():
out = self.hybrid_forward(symbol, *grouped_inputs, **params) # pylint: disable=no-value-for-parameter
- out, self._out_format = _flatten(out)
+ out, self._out_format = _flatten(out, "output")
self._cached_graph = inputs, symbol.Group(out)
@@ -521,7 +521,7 @@ def _call_cached_op(self, *args):
if self._cached_op is None:
self._build_cache(*args)
- args, fmt = _flatten(args)
+ args, fmt = _flatten(args, "input")
assert fmt == self._in_format, "Invalid input format"
cargs = [args[i] if is_arg else i.data()
for is_arg, i in self._cached_op_args]
@@ -558,7 +558,7 @@ def cast(self, dtype):
def _infer_attrs(self, infer_fn, attr, *args):
"""Generic infer attributes."""
inputs, out = self._get_graph(*args)
- args, _ = _flatten(args)
+ args, _ = _flatten(args, "input")
with warnings.catch_warnings(record=True) as w:
arg_attrs, _, aux_attrs = getattr(out, infer_fn)(
**{i.name: getattr(j, attr) for i, j in zip(inputs, args)})
@@ -690,8 +690,8 @@ def __init__(self, outputs, inputs, params=None):
if isinstance(outputs, (list, tuple)) and len(outputs) == 1:
outputs = outputs[0]
- syms, self._in_format = _flatten(inputs)
- out, self._out_format = _flatten(outputs)
+ syms, self._in_format = _flatten(inputs, "input")
+ out, self._out_format = _flatten(outputs, "output")
out = symbol.Group(out)
input_names = set()
@@ -724,7 +724,7 @@ def forward(self, x, *args):
assert isinstance(x, Symbol), \
"HybridBlock requires the first argument to forward be either " \
"Symbol or NDArray, but got %s"%type(x)
- args, in_fmt = _flatten([x] + list(args))
+ args, in_fmt = _flatten([x] + list(args), "input")
assert in_fmt == self._in_format, "Invalid input format"
ret = copy.copy(self._cached_graph[1])
ret._compose(**{k.name: v for k, v in zip(self._cached_graph[0], args)})
diff --git a/python/mxnet/gluon/nn/basic_layers.py b/python/mxnet/gluon/nn/basic_layers.py
index 76415090ccf..9201dc5ee2b 100644
--- a/python/mxnet/gluon/nn/basic_layers.py
+++ b/python/mxnet/gluon/nn/basic_layers.py
@@ -153,6 +153,8 @@ class Dense(HybridBlock):
If true, all but the first axis of input data are collapsed together.
If false, all but the last axis of input data are kept the same, and the transformation
applies on the last axis.
+ dtype : str or np.dtype, default 'float32'
+ Data type of output embeddings.
weight_initializer : str or `Initializer`
Initializer for the `kernel` weights matrix.
bias_initializer: str or `Initializer`
@@ -179,7 +181,7 @@ class Dense(HybridBlock):
`(x1, x2, ..., xn, units)`.
"""
def __init__(self, units, activation=None, use_bias=True, flatten=True,
- weight_initializer=None, bias_initializer='zeros',
+ dtype='float32', weight_initializer=None, bias_initializer='zeros',
in_units=0, **kwargs):
super(Dense, self).__init__(**kwargs)
self._flatten = flatten
@@ -187,11 +189,11 @@ def __init__(self, units, activation=None, use_bias=True, flatten=True,
self._units = units
self._in_units = in_units
self.weight = self.params.get('weight', shape=(units, in_units),
- init=weight_initializer,
+ init=weight_initializer, dtype=dtype,
allow_deferred_init=True)
if use_bias:
self.bias = self.params.get('bias', shape=(units,),
- init=bias_initializer,
+ init=bias_initializer, dtype=dtype,
allow_deferred_init=True)
else:
self.bias = None
@@ -379,7 +381,7 @@ def __init__(self, input_dim, output_dim, dtype='float32',
self._kwargs = {'input_dim': input_dim, 'output_dim': output_dim,
'dtype': dtype}
self.weight = self.params.get('weight', shape=(input_dim, output_dim),
- init=weight_initializer,
+ init=weight_initializer, dtype=dtype,
allow_deferred_init=True)
def hybrid_forward(self, F, x, weight):
diff --git a/python/mxnet/gluon/parameter.py b/python/mxnet/gluon/parameter.py
index ce82171a087..99885eb7d47 100644
--- a/python/mxnet/gluon/parameter.py
+++ b/python/mxnet/gluon/parameter.py
@@ -194,13 +194,13 @@ def _load_init(self, data, ctx):
for self_dim, data_dim in zip(self.shape, data.shape):
assert self_dim == 0 or self_dim == data_dim, \
"Failed loading Parameter '%s' from saved params: " \
- "shape incompatible expacted %s vs saved %s"%(
+ "shape incompatible expected %s vs saved %s"%(
self.name, str(self.shape), str(data.shape))
self.shape = tuple(i if i != 0 else j for i, j in zip(self.shape, data.shape))
if self.dtype:
assert np.dtype(self.dtype).type == data.dtype, \
"Failed loading Parameter '%s' from saved params: " \
- "dtype incompatible expacted %s vs saved %s"%(
+ "dtype incompatible expected %s vs saved %s"%(
self.name, str(self.dtype), str(data.dtype))
if isinstance(ctx, Context):
ctx = [ctx]
diff --git a/python/mxnet/ndarray/sparse.py b/python/mxnet/ndarray/sparse.py
index 363ed9deb06..c7355c2e46d 100644
--- a/python/mxnet/ndarray/sparse.py
+++ b/python/mxnet/ndarray/sparse.py
@@ -400,7 +400,7 @@ def __setitem__(self, key, value):
[ 0., 0., 0.],
[ 0., 0., 0.]], dtype=float32)
>>> # assign CSRNDArray with same storage type
- >>> x = mx.nd.ones('row_sparse', (3,3)).tostype('csr')
+ >>> x = mx.nd.ones((3,3)).tostype('csr')
>>> x[:] = src
>>> x.asnumpy()
array([[ 1., 1., 1.],
diff --git a/src/imperative/cached_op.cc b/src/imperative/cached_op.cc
index 93a8bc6c54b..ce23735d1e2 100644
--- a/src/imperative/cached_op.cc
+++ b/src/imperative/cached_op.cc
@@ -474,6 +474,12 @@ void Imperative::CachedOp::Backward(
}
std::vector<OpReqType> array_reqs(arrays.size(), kWriteTo);
+ // set output reqs
+ for (size_t i = 0, j = num_forward_outputs; i < reqs.size(); ++i) {
+ if (reqs[i] == kNullOp) continue;
+ array_reqs[idx.entry_id(idx.outputs()[j++])] = reqs[i];
+ }
+ // set null reqs based on ref counts
for (size_t i = num_forward_entries; i < idx.num_node_entries(); ++i) {
if (ref_count[i] == 0) array_reqs[i] = kNullOp;
}
diff --git a/src/operator/cudnn_rnn-inl.h b/src/operator/cudnn_rnn-inl.h
index 4bd170cfac7..1a54b73660c 100644
--- a/src/operator/cudnn_rnn-inl.h
+++ b/src/operator/cudnn_rnn-inl.h
@@ -96,6 +96,7 @@ class CuDNNRNNOp : public Operator {
CUDNN_CALL(cudnnDestroyTensorDescriptor(dcy_desc_));
CUDNN_CALL(cudnnDestroyFilterDescriptor(w_desc_));
+ CUDNN_CALL(cudnnDestroyFilterDescriptor(dw_desc_));
CUDNN_CALL(cudnnDestroyRNNDescriptor(rnn_desc_));
CUDNN_CALL(cudnnDestroyDropoutDescriptor(dropout_desc_));
Storage::Get()->Free(dropout_states_);
diff --git a/src/operator/quantization/quantized_conv.cu b/src/operator/quantization/quantized_conv.cu
index 2db5416309b..a76782b8baa 100644
--- a/src/operator/quantization/quantized_conv.cu
+++ b/src/operator/quantization/quantized_conv.cu
@@ -49,7 +49,7 @@ struct QuantizedBiasAddKernel {
}
};
-#if MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6
+#if MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6 && CUDA_VERSION >= 8000
template<typename SrcType, typename DstType, typename CmpType>
class QuantizedCuDNNConvOp {
public:
@@ -260,7 +260,7 @@ class QuantizedCuDNNConvOp {
float alpha_ = 1.0f;
float beta_ = 0.0f;
}; // class QuantizedCuDNNConvOp
-#endif // MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6
+#endif // MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6 && CUDA_VERSION >= 8000
void QuantizedConvForwardGPU(const nnvm::NodeAttrs& attrs,
const OpContext& ctx,
@@ -270,7 +270,7 @@ void QuantizedConvForwardGPU(const nnvm::NodeAttrs& attrs,
const ConvolutionParam& param = nnvm::get<ConvolutionParam>(attrs.parsed);
CHECK_EQ(param.kernel.ndim(), 2U)
<< "QuantizedConvForward<gpu> only supports 2D convolution for now";
-#if MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6
+#if MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6 && CUDA_VERSION >= 8000
typedef QuantizedCuDNNConvOp<int8_t, float, int32_t> QuantizedConvOpInt8;
#if DMLC_CXX11_THREAD_LOCAL
static thread_local QuantizedConvOpInt8 op;
@@ -280,8 +280,9 @@ void QuantizedConvForwardGPU(const nnvm::NodeAttrs& attrs,
op.Init(param, ctx, {inputs[0].shape_, inputs[1].shape_}, {outputs[0].shape_});
op.Forward(ctx, inputs, req, outputs);
#else
- LOG(FATAL) << "QuantizedConvForward<gpu> only supports cudnnConvolutionForward for now";
-#endif // MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6
+ LOG(FATAL) << "QuantizedConvForward<gpu> only supports cudnnConvolutionForward "
+ "with CUDNN >= 6.0 and CUDA >= 8.0";
+#endif // MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6 && CUDA_VERSION >= 8000
}
NNVM_REGISTER_OP(_contrib_quantized_conv)
diff --git a/src/operator/quantization/quantized_fully_connected.cu b/src/operator/quantization/quantized_fully_connected.cu
index ac7ba1e21df..beecc759864 100644
--- a/src/operator/quantization/quantized_fully_connected.cu
+++ b/src/operator/quantization/quantized_fully_connected.cu
@@ -30,6 +30,7 @@
namespace mxnet {
namespace op {
+#if CUDA_VERSION >= 8000
// value + bias_value * (range1 / limit_range1) * (limit_range2 / range2)
struct QuantizedBiasAddKernel {
MSHADOW_XINLINE static void Map(int i, size_t k, int32_t *out,
@@ -49,6 +50,7 @@ struct QuantizedBiasAddKernel {
float_for_one_out_quant;
}
};
+#endif // CUDA_VERSION >= 8000
template<typename SrcType, typename DstType, typename CmpType>
void QuantizedFullyConnectedForwardGPU(const nnvm::NodeAttrs& attrs,
@@ -56,6 +58,7 @@ void QuantizedFullyConnectedForwardGPU(const nnvm::NodeAttrs& attrs,
const std::vector<TBlob> &inputs,
const std::vector<OpReqType> &req,
const std::vector<TBlob> &outputs) {
+#if CUDA_VERSION >= 8000
const FullyConnectedParam& param = nnvm::get<FullyConnectedParam>(attrs.parsed);
using namespace mshadow;
using namespace mxnet_op;
@@ -113,6 +116,9 @@ void QuantizedFullyConnectedForwardGPU(const nnvm::NodeAttrs& attrs,
outputs[1].dptr<float>(), outputs[2].dptr<float>(),
inputs[7].dptr<float>(), inputs[8].dptr<float>());
}
+#else
+ LOG(FATAL) << "QuantizedFullyConnectedForwardGPU only supports CUDA >= 8.0";
+#endif // CUDA_VERSION >= 8000
}
NNVM_REGISTER_OP(_contrib_quantized_fully_connected)
diff --git a/src/operator/quantization/quantized_pooling.cu b/src/operator/quantization/quantized_pooling.cu
index 78011b885c5..2bbac5fc151 100644
--- a/src/operator/quantization/quantized_pooling.cu
+++ b/src/operator/quantization/quantized_pooling.cu
@@ -29,7 +29,7 @@
namespace mxnet {
namespace op {
-#if MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6
+#if MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6 && CUDA_VERSION >= 8000
template<typename DType>
class QuantizedCuDNNPoolingOp {
public:
@@ -115,7 +115,7 @@ class QuantizedCuDNNPoolingOp {
cudnnTensorDescriptor_t out_desc_;
cudnnPoolingDescriptor_t pool_desc_;
}; // class QuantizedCuDNNPoolingOp
-#endif // MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6
+#endif // MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6 && CUDA_VERSION >= 8000
void QuantizedPoolingForwardGPU(const nnvm::NodeAttrs& attrs,
const OpContext& ctx,
@@ -125,7 +125,7 @@ void QuantizedPoolingForwardGPU(const nnvm::NodeAttrs& attrs,
const PoolingParam& param = nnvm::get<PoolingParam>(attrs.parsed);
CHECK_EQ(param.kernel.ndim(), 2U)
<< "QuantizedPoolingForward<gpu> only supports 2D convolution for now";
-#if MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6
+#if MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6 && CUDA_VERSION >= 8000
#if DMLC_CXX11_THREAD_LOCAL
static thread_local QuantizedCuDNNPoolingOp<int8_t> op;
#else
@@ -134,8 +134,9 @@ void QuantizedPoolingForwardGPU(const nnvm::NodeAttrs& attrs,
op.Init(param, {inputs[0].shape_}, {outputs[0].shape_});
op.Forward(ctx.get_stream<gpu>(), inputs, req, outputs);
#else
- LOG(FATAL) << "QuantizedPoolingForward<gpu> only supports cudnnPoolingForward for now";
-#endif // MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6
+ LOG(FATAL) << "QuantizedPoolingForward<gpu> only supports cudnnPoolingForward "
+ "with CUDNN >= 6.0 and CUDA >= 8.0";
+#endif // MXNET_USE_CUDNN == 1 && CUDNN_MAJOR >= 6 && CUDA_VERSION >= 8000
}
NNVM_REGISTER_OP(_contrib_quantized_pooling)
diff --git a/src/operator/tensor/cast_storage-inl.cuh b/src/operator/tensor/cast_storage-inl.cuh
index c441341eafd..a5b4df53843 100644
--- a/src/operator/tensor/cast_storage-inl.cuh
+++ b/src/operator/tensor/cast_storage-inl.cuh
@@ -436,6 +436,8 @@ struct CastDnsCsrColIdxAndValsBlockKernel {
nnz++;
}
}
+ // make sure k was updated using block_nnz in the previous iter
+ __syncthreads();
if (threadIdx.x == kBaseThreadNum-1) {
block_nnz = nnz;
}
diff --git a/tests/python/unittest/test_gluon.py b/tests/python/unittest/test_gluon.py
index 854e6fe07f1..0a5bda831d9 100644
--- a/tests/python/unittest/test_gluon.py
+++ b/tests/python/unittest/test_gluon.py
@@ -126,7 +126,7 @@ def __init__(self, **kwargs):
assert lines[0] == 'net1_ ('
assert 'net1_dense0_weight' in lines[1]
assert '(10, 5)' in lines[1]
- assert 'numpy.float32' in lines[1]
+ assert 'float32' in lines[1]
assert lines[2] == ')'
@@ -776,6 +776,24 @@ def test_dtype():
mx.nd.waitall()
+ class Net(gluon.Block):
+ def __init__(self, in_dim, output_dim):
+ super(Net, self).__init__()
+ with self.name_scope():
+ self.embed = gluon.nn.Embedding(input_dim=in_dim, output_dim=output_dim,dtype=np.float64)
+ self.dense = gluon.nn.Dense(2, dtype=np.float64)
+
+ def forward(self, x):
+ e = self.embed(x)
+ assert(e.dtype == np.float64)
+ y = self.dense(e)
+ assert(y.dtype == np.float64)
+ return y
+
+ net = Net(5, 10)
+ net.initialize()
+ out = net(mx.nd.ones((3,), dtype=np.float64))
+ mx.nd.waitall()
@with_seed()
def test_fill_shape_load():
@@ -902,6 +920,42 @@ def check_dropout_axes(ratio, shape, axes):
check_dropout_axes(0.25, nshape, axes = (0, 2, 3))
check_dropout_axes(0.25, nshape, axes = (1, 2, 3))
+@with_seed()
+def test_req():
+ data = mx.nd.random.uniform(shape=(1,3,224,224))
+ label = mx.nd.random.uniform(shape=(1))
+ label[:] = 1
+ loss = gluon.loss.SoftmaxCrossEntropyLoss()
+
+ net = nn.HybridSequential()
+ net1 = nn.HybridSequential()
+ net1.add(nn.Dense(4))
+ net2 = nn.HybridSequential()
+ net2.add(nn.Dense(3))
+ net2.add(nn.Dense(2))
+ net.add(net1)
+ net.add(net2)
+ net.initialize()
+
+ net.hybridize()
+
+ for v in net.collect_params().values():
+ v.grad_req = 'add'
+
+ net.collect_params().zero_grad()
+ with mx.autograd.record():
+ pred = net(data)
+ l = loss(pred, label)
+ l.backward()
+ grad = net[0][0].weight.grad().mean().asnumpy()
+ # run twice to check req = add
+ pred = net(data)
+ l = loss(pred, label)
+ l.backward()
+
+ grad_double = net[0][0].weight.grad().mean().asnumpy()
+ assert_almost_equal(grad * 2, grad_double)
+
def test_save_load():
net = mx.gluon.model_zoo.vision.get_resnet(1, 18, pretrained=True)
@@ -913,6 +967,7 @@ def test_save_load():
net.load_params('test.params')
+
if __name__ == '__main__':
import nose
nose.runmodule()
diff --git a/tests/python/unittest/test_sparse_operator.py b/tests/python/unittest/test_sparse_operator.py
index 34794866546..d3aef2a9e66 100644
--- a/tests/python/unittest/test_sparse_operator.py
+++ b/tests/python/unittest/test_sparse_operator.py
@@ -1198,6 +1198,9 @@ def check_cast_storage(shape, density, from_stype, to_stype, check_numeric_grad=
# test gpu block kernel
check_cast_storage((dim0, rnd.randint(512, 1024)), d, 'default', 'csr',
check_numeric_grad=False)
+ # check race condition in block kernel
+ check_cast_storage((200, 128 * 2 + 1), d, 'default', 'csr',
+ check_numeric_grad=False)
# test gpu thread kernel
check_cast_storage((dim0, rnd.randint( 1, 32)), d, 'default', 'row_sparse')
# test gpu warp kernel
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services