You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by zh...@apache.org on 2018/05/11 18:51:59 UTC
[incubator-mxnet] branch master updated: Added nullptr check for
LeakyRelu gamma parameter. (#10886)
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 ca08c1a Added nullptr check for LeakyRelu gamma parameter. (#10886)
ca08c1a is described below
commit ca08c1a7dc583a8935fd3e0794d9e047046d7821
Author: Rajan Singh <33...@users.noreply.github.com>
AuthorDate: Fri May 11 11:51:53 2018 -0700
Added nullptr check for LeakyRelu gamma parameter. (#10886)
* Added nullptr checks for LeakyRelu gamma parameter.
It is used only for act type "prelu".
This fixes github issue:
https://github.com/apache/incubator-mxnet/issues/10885
* Added mlp_cpu, mlp, mlp_gpu tests to CI tests.
* Enabling CI tests
* Fix file name
---
Jenkinsfile | 6 ++++++
cpp-package/example/mlp_cpu.cpp | 24 ++++++++++++------------
cpp-package/example/mlp_gpu.cpp | 24 ++++++++++++------------
cpp-package/include/mxnet-cpp/operator.hpp | 8 +++++---
cpp-package/include/mxnet-cpp/symbol.h | 2 +-
cpp-package/tests/ci_test.sh | 9 +++++++++
6 files changed, 45 insertions(+), 28 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 62ffb70..f18d7a9 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -260,6 +260,9 @@ try {
stash includes: 'build/cpp-package/example/googlenet', name: 'cpp_googlenet'
stash includes: 'build/cpp-package/example/lenet_with_mxdataiter', name: 'cpp_lenet_with_mxdataiter'
stash includes: 'build/cpp-package/example/resnet', name: 'cpp_resnet'
+ stash includes: 'build/cpp-package/example/mlp', name: 'cpp_mlp'
+ stash includes: 'build/cpp-package/example/mlp_cpu', name: 'cpp_mlp_cpu'
+ stash includes: 'build/cpp-package/example/mlp_gpu', name: 'cpp_mlp_gpu'
stash includes: 'build/cpp-package/example/test_score', name: 'cpp_test_score'
stash includes: 'build/cpp-package/example/test_optimizer', name: 'cpp_test_optimizer'
}
@@ -791,6 +794,9 @@ try {
unstash 'cpp_googlenet'
unstash 'cpp_lenet_with_mxdataiter'
unstash 'cpp_resnet'
+ unstash 'cpp_mlp'
+ unstash 'cpp_mlp_cpu'
+ unstash 'cpp_mlp_gpu'
unstash 'cpp_test_score'
unstash 'cpp_test_optimizer'
sh "ci/build.py --nvidiadocker --platform ubuntu_gpu /work/runtime_functions.sh integrationtest_ubuntu_gpu_cpp_package"
diff --git a/cpp-package/example/mlp_cpu.cpp b/cpp-package/example/mlp_cpu.cpp
index ebb0eca..dc1ab36 100644
--- a/cpp-package/example/mlp_cpu.cpp
+++ b/cpp-package/example/mlp_cpu.cpp
@@ -21,6 +21,7 @@
* Xin Li yakumolx@gmail.com
*/
#include <chrono>
+#include "utils.h"
#include "mxnet-cpp/MxNetCpp.h"
using namespace mxnet::cpp;
@@ -55,18 +56,17 @@ int main(int argc, char** argv) {
const float learning_rate = 0.1;
const float weight_decay = 1e-2;
- auto train_iter = MXDataIter("MNISTIter")
- .SetParam("image", "./mnist_data/train-images-idx3-ubyte")
- .SetParam("label", "./mnist_data/train-labels-idx1-ubyte")
- .SetParam("batch_size", batch_size)
- .SetParam("flat", 1)
- .CreateDataIter();
- auto val_iter = MXDataIter("MNISTIter")
- .SetParam("image", "./mnist_data/t10k-images-idx3-ubyte")
- .SetParam("label", "./mnist_data/t10k-labels-idx1-ubyte")
- .SetParam("batch_size", batch_size)
- .SetParam("flat", 1)
- .CreateDataIter();
+ std::vector<std::string> data_files = { "./data/mnist_data/train-images-idx3-ubyte",
+ "./data/mnist_data/train-labels-idx1-ubyte",
+ "./data/mnist_data/t10k-images-idx3-ubyte",
+ "./data/mnist_data/t10k-labels-idx1-ubyte"
+ };
+
+ auto train_iter = MXDataIter("MNISTIter");
+ setDataIter(&train_iter, "Train", data_files, batch_size);
+
+ auto val_iter = MXDataIter("MNISTIter");
+ setDataIter(&val_iter, "Label", data_files, batch_size);
auto net = mlp(layers);
diff --git a/cpp-package/example/mlp_gpu.cpp b/cpp-package/example/mlp_gpu.cpp
index 8c620db..67992a1 100644
--- a/cpp-package/example/mlp_gpu.cpp
+++ b/cpp-package/example/mlp_gpu.cpp
@@ -21,6 +21,7 @@
* Xin Li yakumolx@gmail.com
*/
#include <chrono>
+#include "utils.h"
#include "mxnet-cpp/MxNetCpp.h"
using namespace mxnet::cpp;
@@ -55,18 +56,17 @@ int main(int argc, char** argv) {
const float learning_rate = 0.1;
const float weight_decay = 1e-2;
- auto train_iter = MXDataIter("MNISTIter")
- .SetParam("image", "./mnist_data/train-images-idx3-ubyte")
- .SetParam("label", "./mnist_data/train-labels-idx1-ubyte")
- .SetParam("batch_size", batch_size)
- .SetParam("flat", 1)
- .CreateDataIter();
- auto val_iter = MXDataIter("MNISTIter")
- .SetParam("image", "./mnist_data/t10k-images-idx3-ubyte")
- .SetParam("label", "./mnist_data/t10k-labels-idx1-ubyte")
- .SetParam("batch_size", batch_size)
- .SetParam("flat", 1)
- .CreateDataIter();
+ std::vector<std::string> data_files = { "./data/mnist_data/train-images-idx3-ubyte",
+ "./data/mnist_data/train-labels-idx1-ubyte",
+ "./data/mnist_data/t10k-images-idx3-ubyte",
+ "./data/mnist_data/t10k-labels-idx1-ubyte"
+ };
+
+ auto train_iter = MXDataIter("MNISTIter");
+ setDataIter(&train_iter, "Train", data_files, batch_size);
+
+ auto val_iter = MXDataIter("MNISTIter");
+ setDataIter(&val_iter, "Label", data_files, batch_size);
auto net = mlp(layers);
diff --git a/cpp-package/include/mxnet-cpp/operator.hpp b/cpp-package/include/mxnet-cpp/operator.hpp
index a0100cd..f4ce43d 100644
--- a/cpp-package/include/mxnet-cpp/operator.hpp
+++ b/cpp-package/include/mxnet-cpp/operator.hpp
@@ -159,9 +159,11 @@ inline void Operator::Invoke(NDArray &output) {
}
inline Operator &Operator::SetInput(const std::string &name, Symbol symbol) {
- input_keys_.push_back(name.c_str());
- input_symbols_.push_back(symbol.GetHandle());
- return *this;
+ if (symbol.GetHandle()) {
+ input_keys_.push_back(name.c_str());
+ input_symbols_.push_back(symbol.GetHandle());
+ }
+ return *this;
}
inline Operator &Operator::SetInput(const std::string &name, NDArray ndarray) {
diff --git a/cpp-package/include/mxnet-cpp/symbol.h b/cpp-package/include/mxnet-cpp/symbol.h
index 127ef15..1c825c1 100644
--- a/cpp-package/include/mxnet-cpp/symbol.h
+++ b/cpp-package/include/mxnet-cpp/symbol.h
@@ -138,7 +138,7 @@ class Symbol {
/*!
* \return the SymbolHandle
*/
- SymbolHandle GetHandle() const { return blob_ptr_->handle_; }
+ SymbolHandle GetHandle() const { return (blob_ptr_) ? blob_ptr_->handle_: NULL; }
/*!
* \brief construct an operator Symbol, with given input Symbol and config
* \param name the name of the Symbol
diff --git a/cpp-package/tests/ci_test.sh b/cpp-package/tests/ci_test.sh
index 55bcad4..57007f3 100755
--- a/cpp-package/tests/ci_test.sh
+++ b/cpp-package/tests/ci_test.sh
@@ -36,6 +36,15 @@ cp ../../build/cpp-package/example/lenet_with_mxdataiter .
cp ../../build/cpp-package/example/resnet .
./resnet 5
+cp ../../build/cpp-package/example/mlp .
+./mlp
+
+cp ../../build/cpp-package/example/mlp_cpu .
+./mlp_cpu
+
+cp ../../build/cpp-package/example/mlp_gpu .
+./mlp_gpu
+
cp ../../build/cpp-package/example/test_optimizer .
./test_optimizer
--
To stop receiving notification emails like this one, please contact
zhasheng@apache.org.