Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit ed19095

Browse files
authored
Refactor Stateful operator and custom op (#6928)
* refactor create layer * fix * refactor custom op * fix * fix * fix * fix * fix OpState * remove superfluous infershape * fix * fix * fix lint * fix * fix * fix * Update CMakeLists.txt * delete * fix * fix scala
1 parent 65d0d47 commit ed19095

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1012
-919
lines changed

Jenkinsfile

+10-2
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,21 @@ del /Q *.7z
215215
// Python unittest for CPU
216216
def python_ut(docker_type) {
217217
timeout(time: max_time, unit: 'MINUTES') {
218+
sh "${docker_run} ${docker_type} find . -name '*.pyc' -type f -delete"
218219
sh "${docker_run} ${docker_type} PYTHONPATH=./python/ nosetests --with-timer --verbose tests/python/unittest"
219-
sh "${docker_run} ${docker_type} PYTHONPATH=./python/ nosetests-3.4 --with-timer --verbose tests/python/unittest"
220220
sh "${docker_run} ${docker_type} PYTHONPATH=./python/ nosetests --with-timer --verbose tests/python/train"
221+
sh "${docker_run} ${docker_type} find . -name '*.pyc' -type f -delete"
222+
sh "${docker_run} ${docker_type} PYTHONPATH=./python/ nosetests-3.4 --with-timer --verbose tests/python/unittest"
221223
}
222224
}
223225

224226
// GPU test has two parts. 1) run unittest on GPU, 2) compare the results on
225227
// both CPU and GPU
226228
def python_gpu_ut(docker_type) {
227229
timeout(time: max_time, unit: 'MINUTES') {
230+
sh "${docker_run} ${docker_type} find . -name '*.pyc' -type f -delete"
228231
sh "${docker_run} ${docker_type} PYTHONPATH=./python/ nosetests --with-timer --verbose tests/python/gpu"
232+
sh "${docker_run} ${docker_type} find . -name '*.pyc' -type f -delete"
229233
sh "${docker_run} ${docker_type} PYTHONPATH=./python/ nosetests-3.4 --with-timer --verbose tests/python/gpu"
230234
}
231235
}
@@ -312,11 +316,13 @@ stage('Unit Test') {
312316
xcopy C:\\mxnet\\model model /E /I /Y
313317
call activate py3
314318
set PYTHONPATH=${env.WORKSPACE}\\pkg_vc14_cpu\\python
319+
del /S /Q ${env.WORKSPACE}\\pkg_vc14_cpu\\python\\*.pyc
315320
C:\\mxnet\\test_cpu.bat"""
316321
bat """xcopy C:\\mxnet\\data data /E /I /Y
317322
xcopy C:\\mxnet\\model model /E /I /Y
318323
call activate py2
319324
set PYTHONPATH=${env.WORKSPACE}\\pkg_vc14_cpu\\python
325+
del /S /Q ${env.WORKSPACE}\\pkg_vc14_cpu\\python\\*.pyc
320326
C:\\mxnet\\test_cpu.bat"""
321327
}
322328
}
@@ -332,11 +338,13 @@ C:\\mxnet\\test_cpu.bat"""
332338
xcopy C:\\mxnet\\model model /E /I /Y
333339
call activate py3
334340
set PYTHONPATH=${env.WORKSPACE}\\pkg_vc14_gpu\\python
341+
del /S /Q ${env.WORKSPACE}\\pkg_vc14_gpu\\python\\*.pyc
335342
C:\\mxnet\\test_gpu.bat"""
336343
bat """xcopy C:\\mxnet\\data data /E /I /Y
337344
xcopy C:\\mxnet\\model model /E /I /Y
338345
call activate py2
339346
set PYTHONPATH=${env.WORKSPACE}\\pkg_vc14_gpu\\python
347+
del /S /Q ${env.WORKSPACE}\\pkg_vc14_gpu\\python\\*.pyc
340348
C:\\mxnet\\test_gpu.bat"""
341349
}
342350
}
@@ -390,4 +398,4 @@ stage('Deploy') {
390398
}
391399
}
392400
}
393-
}
401+
}

cpp-package/include/mxnet-cpp/MxNetCpp.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Chuntao Hong, Zhang Chen
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_MXNETCPP_H_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_MXNETCPP_H_
8+
#ifndef MXNET_CPP_MXNETCPP_H_
9+
#define MXNET_CPP_MXNETCPP_H_
1010

1111
#include "mxnet-cpp/executor.hpp"
1212
#include "mxnet-cpp/symbol.hpp"
@@ -21,4 +21,4 @@
2121
#include "mxnet-cpp/metric.h"
2222
#include "mxnet-cpp/initializer.h"
2323

24-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_MXNETCPP_H_
24+
#endif // MXNET_CPP_MXNETCPP_H_

cpp-package/include/mxnet-cpp/base.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Chuntao Hong, Zhang Chen
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_BASE_H_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_BASE_H_
8+
#ifndef MXNET_CPP_BASE_H_
9+
#define MXNET_CPP_BASE_H_
1010

1111
#include <cstdlib>
1212
#include "mxnet/c_api.h"
@@ -35,4 +35,4 @@ enum OpReqType {
3535
} // namespace cpp
3636
} // namespace mxnet
3737

38-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_BASE_H_
38+
#endif // MXNET_CPP_BASE_H_

cpp-package/include/mxnet-cpp/executor.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Chuntao Hong, Zhang Chen
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_EXECUTOR_H_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_EXECUTOR_H_
8+
#ifndef MXNET_CPP_EXECUTOR_H_
9+
#define MXNET_CPP_EXECUTOR_H_
1010

1111
#include <vector>
1212
#include <map>
@@ -135,4 +135,4 @@ class Executor {
135135
};
136136
} // namespace cpp
137137
} // namespace mxnet
138-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_EXECUTOR_H_
138+
#endif // MXNET_CPP_EXECUTOR_H_

cpp-package/include/mxnet-cpp/executor.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Zhang Chen, Chuntao Hong
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_EXECUTOR_HPP_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_EXECUTOR_HPP_
8+
#ifndef MXNET_CPP_EXECUTOR_HPP_
9+
#define MXNET_CPP_EXECUTOR_HPP_
1010

1111
#include <vector>
1212
#include <map>
@@ -89,4 +89,4 @@ inline void Executor::UpdateAll(Optimizer *opt, float lr, float wd,
8989
} // namespace cpp
9090
} // namespace mxnet
9191

92-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_EXECUTOR_HPP_
92+
#endif // MXNET_CPP_EXECUTOR_HPP_

cpp-package/include/mxnet-cpp/initializer.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Zhang Chen
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_INITIALIZER_H_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_INITIALIZER_H_
8+
#ifndef MXNET_CPP_INITIALIZER_H_
9+
#define MXNET_CPP_INITIALIZER_H_
1010

1111
#include <cmath>
1212
#include <string>
@@ -179,4 +179,4 @@ class Xavier : public Initializer {
179179
} // namespace cpp
180180
} // namespace mxnet
181181

182-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_INITIALIZER_H_
182+
#endif // MXNET_CPP_INITIALIZER_H_

cpp-package/include/mxnet-cpp/io.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* \brief definition of io, such as DataIter
55
* \author Zhang Chen
66
*/
7-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_IO_H_
8-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_IO_H_
7+
#ifndef MXNET_CPP_IO_H_
8+
#define MXNET_CPP_IO_H_
99

1010
#include <map>
1111
#include <string>
@@ -124,5 +124,5 @@ class MXDataIter : public DataIter {
124124
} // namespace cpp
125125
} // namespace mxnet
126126

127-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_IO_H_
127+
#endif // MXNET_CPP_IO_H_
128128

cpp-package/include/mxnet-cpp/io.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* \brief implementation of data iter
55
* \author Zhang Chen
66
*/
7-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_IO_HPP_
8-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_IO_HPP_
7+
#ifndef MXNET_CPP_IO_HPP_
8+
#define MXNET_CPP_IO_HPP_
99

1010
#include <string>
1111
#include <vector>
@@ -86,5 +86,5 @@ inline MXDataIter MXDataIter::CreateDataIter() {
8686
} // namespace cpp
8787
} // namespace mxnet
8888

89-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_IO_HPP_
89+
#endif // MXNET_CPP_IO_HPP_
9090

cpp-package/include/mxnet-cpp/kvstore.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Chuntao Hong
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_KVSTORE_H_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_KVSTORE_H_
8+
#ifndef MXNET_CPP_KVSTORE_H_
9+
#define MXNET_CPP_KVSTORE_H_
1010

1111
#include <string>
1212
#include <vector>
@@ -46,4 +46,4 @@ class KVStore {
4646
} // namespace cpp
4747
} // namespace mxnet
4848

49-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_KVSTORE_H_
49+
#endif // MXNET_CPP_KVSTORE_H_

cpp-package/include/mxnet-cpp/kvstore.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include "mxnet-cpp/kvstore.h"
1515
#include "mxnet-cpp/optimizer.h"
1616

17-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_KVSTORE_HPP_
18-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_KVSTORE_HPP_
17+
#ifndef MXNET_CPP_KVSTORE_HPP_
18+
#define MXNET_CPP_KVSTORE_HPP_
1919

2020
namespace mxnet {
2121
namespace cpp {
@@ -175,4 +175,4 @@ inline std::string KVStore::GetRole() {
175175
} // namespace cpp
176176
} // namespace mxnet
177177

178-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_KVSTORE_HPP_
178+
#endif // MXNET_CPP_KVSTORE_HPP_

cpp-package/include/mxnet-cpp/metric.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Zhang Chen
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_METRIC_H_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_METRIC_H_
8+
#ifndef MXNET_CPP_METRIC_H_
9+
#define MXNET_CPP_METRIC_H_
1010

1111
#include <cmath>
1212
#include <string>
@@ -187,5 +187,5 @@ class PSNR : public EvalMetric {
187187
} // namespace cpp
188188
} // namespace mxnet
189189

190-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_METRIC_H_
190+
#endif // MXNET_CPP_METRIC_H_
191191

cpp-package/include/mxnet-cpp/model.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Zhang Chen
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_MODEL_H_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_MODEL_H_
8+
#ifndef MXNET_CPP_MODEL_H_
9+
#define MXNET_CPP_MODEL_H_
1010

1111
#include <string>
1212
#include <vector>
@@ -54,5 +54,5 @@ class FeedForward {
5454
} // namespace cpp
5555
} // namespace mxnet
5656

57-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_MODEL_H_
57+
#endif // MXNET_CPP_MODEL_H_
5858

cpp-package/include/mxnet-cpp/monitor.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Xin Li
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_MONITOR_H_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_MONITOR_H_
8+
#ifndef MXNET_CPP_MONITOR_H_
9+
#define MXNET_CPP_MONITOR_H_
1010

1111
#include <regex>
1212
#include <tuple>
@@ -85,4 +85,4 @@ class Monitor {
8585

8686
} // namespace cpp
8787
} // namespace mxnet
88-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_MONITOR_H_
88+
#endif // MXNET_CPP_MONITOR_H_

cpp-package/include/mxnet-cpp/monitor.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Xin Li
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_MONITOR_HPP_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_MONITOR_HPP_
8+
#ifndef MXNET_CPP_MONITOR_HPP_
9+
#define MXNET_CPP_MONITOR_HPP_
1010

1111
#include <cmath>
1212
#include <sstream>
@@ -103,4 +103,4 @@ inline void Monitor::executor_callback(const char *name, NDArrayHandle handle,
103103

104104
} // namespace cpp
105105
} // namespace mxnet
106-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_MONITOR_HPP_
106+
#endif // MXNET_CPP_MONITOR_HPP_

cpp-package/include/mxnet-cpp/ndarray.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Chuntao Hong, Zhang Chen
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_NDARRAY_H_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_NDARRAY_H_
8+
#ifndef MXNET_CPP_NDARRAY_H_
9+
#define MXNET_CPP_NDARRAY_H_
1010

1111
#include <map>
1212
#include <memory>
@@ -428,4 +428,4 @@ std::ostream& operator<<(std::ostream& out, const NDArray &ndarray);
428428
} // namespace cpp
429429
} // namespace mxnet
430430

431-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_NDARRAY_H_
431+
#endif // MXNET_CPP_NDARRAY_H_

cpp-package/include/mxnet-cpp/ndarray.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Zhang Chen, Chuntao Hong
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_NDARRAY_HPP_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_NDARRAY_HPP_
8+
#ifndef MXNET_CPP_NDARRAY_HPP_
9+
#define MXNET_CPP_NDARRAY_HPP_
1010

1111
#include <algorithm>
1212
#include <map>
@@ -378,4 +378,4 @@ inline std::ostream & operator<<(std::ostream &out, const NDArray &ndarray) {
378378
} // namespace cpp
379379
} // namespace mxnet
380380

381-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_NDARRAY_HPP_
381+
#endif // MXNET_CPP_NDARRAY_HPP_

cpp-package/include/mxnet-cpp/op_map.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Chuntao Hong
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_OP_MAP_H_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_OP_MAP_H_
8+
#ifndef MXNET_CPP_OP_MAP_H_
9+
#define MXNET_CPP_OP_MAP_H_
1010

1111
#include <map>
1212
#include <string>
@@ -89,4 +89,4 @@ class OpMap {
8989
} // namespace cpp
9090
} // namespace mxnet
9191

92-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_OP_MAP_H_
92+
#endif // MXNET_CPP_OP_MAP_H_

cpp-package/include/mxnet-cpp/op_suppl.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Zhang Chen, zhubuntu, Xin Li
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_OP_SUPPL_H_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_OP_SUPPL_H_
8+
#ifndef MXNET_CPP_OP_SUPPL_H_
9+
#define MXNET_CPP_OP_SUPPL_H_
1010

1111
#include <cassert>
1212
#include <string>
@@ -157,5 +157,5 @@ inline Symbol Activation(const std::string& symbol_name,
157157
} // namespace cpp
158158
} // namespace mxnet
159159

160-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_OP_SUPPL_H_
160+
#endif // MXNET_CPP_OP_SUPPL_H_
161161

cpp-package/include/mxnet-cpp/op_util.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Chris Olivier
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_OP_UTIL_H_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_OP_UTIL_H_
8+
#ifndef MXNET_CPP_OP_UTIL_H_
9+
#define MXNET_CPP_OP_UTIL_H_
1010

1111
#include <string>
1212

@@ -43,4 +43,4 @@ inline StreamType& operator << (StreamType& os, const ::caffe::LayerParameter& o
4343
} // namespace cpp
4444
} // namespace mxnet
4545

46-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_OP_UTIL_H_
46+
#endif // MXNET_CPP_OP_UTIL_H_

cpp-package/include/mxnet-cpp/operator.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* \author Chuntao Hong, Zhang Chen
66
*/
77

8-
#ifndef CPP_PACKAGE_INCLUDE_MXNET_CPP_OPERATOR_H_
9-
#define CPP_PACKAGE_INCLUDE_MXNET_CPP_OPERATOR_H_
8+
#ifndef MXNET_CPP_OPERATOR_H_
9+
#define MXNET_CPP_OPERATOR_H_
1010

1111
#include <map>
1212
#include <string>
@@ -188,4 +188,4 @@ class Operator {
188188
} // namespace cpp
189189
} // namespace mxnet
190190

191-
#endif // CPP_PACKAGE_INCLUDE_MXNET_CPP_OPERATOR_H_
191+
#endif // MXNET_CPP_OPERATOR_H_

0 commit comments

Comments
 (0)