Skip to content

Commit

Permalink
Improve cpp-package example project build files. (apache#13093)
Browse files Browse the repository at this point in the history
1. Change output to build folder.
2. Remove files that not been deleted by make clean.
  • Loading branch information
frankfliu authored and azai91 committed Dec 1, 2018
1 parent 8504c42 commit 26489a8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
6 changes: 4 additions & 2 deletions cpp-package/example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.

prebuild :
@mkdir -p build
$(shell ./get_data.sh)
$(shell cp -r ../../lib ./)
CPPEX_SRC = $(wildcard *.cpp)
Expand All @@ -38,8 +39,9 @@ debug: CPPEX_CFLAGS += -DDEBUG -g
debug: prebuild all



$(CPPEX_EXE):% : %.cpp
$(CXX) -std=c++0x $(CFLAGS) $(CPPEX_CFLAGS) -o $@ $(filter %.cpp %.a, $^) $(CPPEX_EXTRA_LDFLAGS)
$(CXX) -std=c++0x $(CFLAGS) $(CPPEX_CFLAGS) -o build/$@ $(filter %.cpp %.a, $^) $(CPPEX_EXTRA_LDFLAGS)

clean:
rm -f $(CPPEX_EXE)
@rm -rf build
20 changes: 10 additions & 10 deletions cpp-package/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ This directory contains following examples. In order to run the examples, ensure
The example implements the C++ version of AlexNet. The networks trains on MNIST data. The number of epochs can be specified as a command line argument. For example to train with 10 epochs use the following:

```
./alexnet 10
build/alexnet 10
```

### [googlenet.cpp](<https://github.com/apache/incubator-mxnet/blob/master/cpp-package/example/googlenet.cpp>)

The code implements a GoogLeNet/Inception network using the C++ API. The example uses MNIST data to train the network. By default, the example trains the model for 100 epochs. The number of epochs can also be specified in the command line. For example, to train the model for 10 epochs use the following:

```
./googlenet 10
build/googlenet 10
```

### [mlp.cpp](<https://github.com/apache/incubator-mxnet/blob/master/cpp-package/example/mlp.cpp>)
Expand All @@ -44,7 +44,7 @@ The code implements a multilayer perceptron from scratch. The example creates it
To run the example use the following command:

```
./mlp
build/mlp
```

### [mlp_cpu.cpp](<https://github.com/apache/incubator-mxnet/blob/master/cpp-package/example/mlp_cpu.cpp>)
Expand All @@ -53,46 +53,46 @@ The code implements a multilayer perceptron to train the MNIST data. The code de
To run the example use the following command:

```
./mlp_cpu
build/mlp_cpu
```

### [mlp_gpu.cpp](<https://github.com/apache/incubator-mxnet/blob/master/cpp-package/example/mlp_gpu.cpp>)

The code implements a multilayer perceptron to train the MNIST data. The code demonstrates the use of the "SimpleBind" C++ API and MNISTIter. The example is designed to work on GPU. The example does not require command line arguments. To run the example execute following command:

```
./mlp_gpu
build/mlp_gpu
```

### [mlp_csv.cpp](<https://github.com/apache/incubator-mxnet/blob/master/cpp-package/example/mlp_csv.cpp>)

The code implements a multilayer perceptron to train the MNIST data. The code demonstrates the use of the "SimpleBind" C++ API and CSVIter. The CSVIter can iterate data that is in CSV format. The example can be run on CPU or GPU. The example usage is as follows:

```
mlp_csv --train mnist_training_set.csv --test mnist_test_set.csv --epochs 10 --batch_size 100 --hidden_units "128,64,64 [--gpu]"
build/mlp_csv --train mnist_training_set.csv --test mnist_test_set.csv --epochs 10 --batch_size 100 --hidden_units "128,64,64 [--gpu]"
```

### [resnet.cpp](<https://github.com/apache/incubator-mxnet/blob/master/cpp-package/example/resnet.cpp>)

The code implements a resnet model using the C++ API. The model is used to train MNIST data. The number of epochs for training the model can be specified on the command line. By default, model is trained for 100 epochs. For example, to train with 10 epochs use the following command:

```
./resnet 10
build/resnet 10
```

### [lenet.cpp](<https://github.com/apache/incubator-mxnet/blob/master/cpp-package/example/lenet.cpp>)

The code implements a lenet model using the C++ API. It uses MNIST training data in CSV format to train the network. The example does not use built-in CSVIter to read the data from CSV file. The number of epochs can be specified on the command line. By default, the mode is trained for 100,000 epochs. For example, to train with 10 epochs use the following command:

```
./lenet 10
build/lenet 10
```
### [lenet\_with\_mxdataiter.cpp](<https://github.com/apache/incubator-mxnet/blob/master/cpp-package/example/mlp_cpu.cpp>)

The code implements a lenet model using the C++ API. It uses MNIST training data to train the network. The example uses built-in MNISTIter to read the data. The number of epochs can be specified on the command line. By default, the mode is trained for 100 epochs. For example, to train with 10 epochs use the following command:

```
./lenet\_with\_mxdataiter 10
build/lenet_with_mxdataiter 10
```

In addition, there is `run_lenet_with_mxdataiter.sh` that downloads the mnist data and run `lenet_with_mxdataiter` example.
Expand All @@ -102,5 +102,5 @@ In addition, there is `run_lenet_with_mxdataiter.sh` that downloads the mnist da
The code implements an Inception network using the C++ API with batch normalization. The example uses MNIST data to train the network. The model trains for 100 epochs. The example can be run by executing the following command:

```
./inception_bn
build/inception_bn
```
2 changes: 1 addition & 1 deletion cpp-package/example/example.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
CPPEX_SRC = $(wildcard cpp-package/example/*.cpp)
CPPEX_EXE = $(patsubst cpp-package/example/%.cpp, build/cpp-package/example/%, $(CPPEX_SRC))

CPPEX_CFLAGS += -Icpp-package/include -Ibuild/cpp-package/include
CPPEX_CFLAGS += -Icpp-package/include
CPPEX_EXTRA_LDFLAGS := -L$(ROOTDIR)/lib -lmxnet

EXTRA_PACKAGES += cpp-package-example-all
Expand Down

0 comments on commit 26489a8

Please sign in to comment.