You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by ma...@apache.org on 2018/12/12 14:25:15 UTC

[incubator-mxnet] branch master updated: Optimize C++ API (#13496)

This is an automated email from the ASF dual-hosted git repository.

marcoabreu 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 002e0bb  Optimize C++ API (#13496)
002e0bb is described below

commit 002e0bb08d03813a992d8a485e563f4c15f0f991
Author: zhaoyao73 <zh...@users.noreply.github.com>
AuthorDate: Wed Dec 12 09:24:49 2018 -0500

    Optimize C++ API (#13496)
    
    * Optimize C++ API
    
    Pass parameter with reference instead of value.
    Add const as well as it is not changed.
    
    * fix docs/architecture/overview.md
    
    Fix BinaryShapeFunction typedef
    Add a right brace for SmoothL1Shape_
---
 cpp-package/example/utils.h                | 2 +-
 cpp-package/include/mxnet-cpp/operator.h   | 4 ++--
 cpp-package/include/mxnet-cpp/operator.hpp | 4 ++--
 docs/architecture/overview.md              | 5 +++--
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/cpp-package/example/utils.h b/cpp-package/example/utils.h
index 98b6472..2ed5c4c 100644
--- a/cpp-package/example/utils.h
+++ b/cpp-package/example/utils.h
@@ -42,7 +42,7 @@ bool check_datafiles(const std::vector<std::string> &data_files) {
   return true;
   }
 
-bool setDataIter(MXDataIter *iter , std::string useType,
+bool setDataIter(MXDataIter *iter , const std::string &useType,
               const std::vector<std::string> &data_files, int batch_size) {
     if (!check_datafiles(data_files))
         return false;
diff --git a/cpp-package/include/mxnet-cpp/operator.h b/cpp-package/include/mxnet-cpp/operator.h
index 4d4beda..9f289f0 100644
--- a/cpp-package/include/mxnet-cpp/operator.h
+++ b/cpp-package/include/mxnet-cpp/operator.h
@@ -86,7 +86,7 @@ class Operator {
   * \param symbol the input symbol
   * \return reference of self
   */
-  Operator &SetInput(const std::string &name, Symbol symbol);
+  Operator &SetInput(const std::string &name, const Symbol &symbol);
   /*!
   * \brief add an input symbol
   * \param symbol the input symbol
@@ -133,7 +133,7 @@ class Operator {
   * \param ndarray the input ndarray
   * \return reference of self
   */
-  Operator &SetInput(const std::string &name, NDArray ndarray);
+  Operator &SetInput(const std::string &name, const NDArray &ndarray);
   /*!
   * \brief add an input ndarray
   * \param ndarray the input ndarray
diff --git a/cpp-package/include/mxnet-cpp/operator.hpp b/cpp-package/include/mxnet-cpp/operator.hpp
index f4ce43d..edc396f 100644
--- a/cpp-package/include/mxnet-cpp/operator.hpp
+++ b/cpp-package/include/mxnet-cpp/operator.hpp
@@ -158,7 +158,7 @@ inline void Operator::Invoke(NDArray &output) {
   Invoke(outputs);
 }
 
-inline Operator &Operator::SetInput(const std::string &name, Symbol symbol) {
+inline Operator &Operator::SetInput(const std::string &name, const Symbol &symbol) {
     if (symbol.GetHandle()) {
       input_keys_.push_back(name.c_str());
       input_symbols_.push_back(symbol.GetHandle());
@@ -166,7 +166,7 @@ inline Operator &Operator::SetInput(const std::string &name, Symbol symbol) {
     return *this;
 }
 
-inline Operator &Operator::SetInput(const std::string &name, NDArray ndarray) {
+inline Operator &Operator::SetInput(const std::string &name, const NDArray &ndarray) {
   input_keys_.push_back(name.c_str());
   input_ndarrays_.push_back(ndarray.GetHandle());
   return *this;
diff --git a/docs/architecture/overview.md b/docs/architecture/overview.md
index a7632d4..6a37f88 100644
--- a/docs/architecture/overview.md
+++ b/docs/architecture/overview.md
@@ -567,8 +567,8 @@ let's check input data shape consistency and provide output shape.
 ```cpp
     typedef TShape (*UnaryShapeFunction)(const TShape& src,
                                          const EnvArguments& env);
-    typedef TShape (*BinaryShapeFunction)(const TShape&                                         const TShape& rhs,lhs,
-
+    typedef TShape (*BinaryShapeFunction)(const TShape& lhs,
+                                          const TShape& rhs,
                                           const EnvArguments& env);
 ```
 You can use `mshadow::TShape` to check input data shape and designate output data shape.
@@ -597,6 +597,7 @@ Written explicitly, it is:
     inline TShape SmoothL1Shape_(const TShape& src,
                                  const EnvArguments& env) {
       return TShape(src);
+    }
 ```
 
 ### Define Functions