diff --git a/Jenkinsfile b/Jenkinsfile index 9cc72c98fcb0..809a9b03872a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -81,6 +81,7 @@ stage('Build') { init_git() def flag = """ \ USE_PROFILER=1 \ +USE_CPP_PACKAGE=1 \ USE_BLAS=openblas \ -j\$(nproc) """ @@ -99,6 +100,7 @@ USE_BLAS=openblas \ USE_CUDA=1 \ USE_CUDA_PATH=/usr/local/cuda \ USE_CUDNN=1 \ +USE_CPP_PACKAGE=1 \ -j\$(nproc) """ make('gpu', flag) @@ -126,6 +128,7 @@ USE_MKL2017_EXPERIMENTAL=1 \ USE_CUDA=1 \ USE_CUDA_PATH=/usr/local/cuda \ USE_CUDNN=1 \ +USE_CPP_PACKAGE=1 \ -j\$(nproc) """ make('mklml_gpu', flag) diff --git a/cpp-package/example/charRNN.cpp b/cpp-package/example/charRNN.cpp index daf31a4fe69c..4dd1ce7a5a51 100644 --- a/cpp-package/example/charRNN.cpp +++ b/cpp-package/example/charRNN.cpp @@ -115,7 +115,7 @@ Symbol LSTMUnroll(int num_lstm_layer, int sequence_length, int input_dim, auto label = Symbol::Variable("softmax_label"); label = transpose(label); - label = Reshape(label, Shape(), false, false, Shape(-1)); // -1: infer from graph + label = Reshape(label, Shape(), false, Shape(-1), false); // -1: infer from graph auto sm = SoftmaxOutput("softmax", pred, label); if (isTrain) return sm; @@ -141,7 +141,7 @@ Symbol LSTMWithBuiltInRNNOp(int num_lstm_layer, int sequence_length, int input_d auto label = Symbol::Variable("softmax_label"); label = transpose(label); label = Reshape(label, Shape(), false, - false, Shape(-1)); // FullyConnected requires one dimension + Shape(-1), false); // FullyConnected requires one dimension if (!TIME_MAJOR && isTrain) embed = SwapAxis(embed, 0, 1); // Change to time-major as cuDNN requires @@ -151,7 +151,7 @@ Symbol LSTMWithBuiltInRNNOp(int num_lstm_layer, int sequence_length, int input_d auto rnn_params = Symbol::Variable("LSTM_parameters"); // See explanations near RNNXavier class auto rnn = RNN(embed, rnn_params, rnn_h_init, rnn_c_init, num_hidden, num_lstm_layer, RNNMode::lstm, false, dropout, !isTrain); - auto hidden = Reshape(rnn[0], Shape(), false, false, Shape(-1, num_hidden)); + auto hidden = Reshape(rnn[0], Shape(), false, Shape(-1, num_hidden), false); auto cls_weight = Symbol::Variable("cls_weight"); auto cls_bias = Symbol::Variable("cls_bias"); @@ -194,7 +194,8 @@ class Shuffler { class BucketSentenceIter : public DataIter { Shuffler* random; - int batch, current, end, sequence_length; + int batch, current, end; + unsigned int sequence_length; Context device; vector> sequences; vector index2chars; @@ -582,7 +583,7 @@ void predict(wstring* ptext, int sequence_length, const string param_file, LoadCheckpoint(param_file, exe); mx_float index; - wchar_t next; + wchar_t next = 0; vector softmax; softmax.resize(input_dim); for (auto c : *ptext) { @@ -642,7 +643,7 @@ void predictWithBuiltInRNNOp(wstring* ptext, int sequence_length, const string p LoadCheckpoint(param_file, exe); mx_float index; - wchar_t next; + wchar_t next = 0; vector softmax; softmax.resize(input_dim); for (auto c : *ptext) { diff --git a/cpp-package/include/mxnet-cpp/op_suppl.h b/cpp-package/include/mxnet-cpp/op_suppl.h index 5eb86d8ef275..9381a1ecade9 100644 --- a/cpp-package/include/mxnet-cpp/op_suppl.h +++ b/cpp-package/include/mxnet-cpp/op_suppl.h @@ -119,48 +119,7 @@ inline Symbol Crop(const std::string& symbol_name, /*! - * \breif Slice input equally along specified axis. - * \param data input symbol. - * \param num_outputs Number of outputs to be sliced. - * \param axis Dimension along which to slice. - * \param squeeze_axis If true AND the sliced dimension becomes 1, squeeze that dimension. - * \return new symbol - */ -inline Symbol SliceChannel(Symbol data, - int num_outputs, - int axis = 1, - bool squeeze_axis = false) { - return Operator("SliceChannel") - .SetParam("num_outputs", num_outputs) - .SetParam("axis", axis) - .SetParam("squeeze_axis", squeeze_axis) (data) - .CreateSymbol(); -} - - -/*! - * \breif Slice input equally along specified axis. - * \param symbol_name name of the resulting symbol. - * \param data input symbol. - * \param num_outputs Number of outputs to be sliced. - * \param axis Dimension along which to slice. - * \param squeeze_axis If true AND the sliced dimension becomes 1, squeeze that dimension. - * \return new symbol - */ -inline Symbol SliceChannel(const std::string& symbol_name, - Symbol data, - int num_outputs, - int axis = 1, - bool squeeze_axis = false) { - return Operator("SliceChannel") - .SetParam("num_outputs", num_outputs) - .SetParam("axis", axis) - .SetParam("squeeze_axis", squeeze_axis) (data) - .CreateSymbol(symbol_name); -} - -/*! - * \breif Apply activation function to input. + * \brief Apply activation function to input. * Softmax Activation is only available with CUDNN on GPUand will be * computed at each location across channel if input is 4D. * \param symbol_name name of the resulting symbol.