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

Integrate cpp package #5251

Merged
merged 8 commits into from
Mar 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -434,3 +434,13 @@ set(LINT_DIRS include src scripts python)
add_custom_target(mxnet_lint COMMAND ${CMAKE_COMMAND} -DMSVC=${MSVC} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DLINT_DIRS=${LINT_DIRS} -DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} -DPROJECT_NAME=mxnet -P ${PROJECT_SOURCE_DIR}/dmlc-core/cmake/lint.cmake)

add_subdirectory(example/image-classification/predict-cpp)

if(NOT MSVC)
add_custom_command(TARGET mxnet
POST_BUILD
COMMAND cp $<TARGET_FILE:mxnet> .
COMMAND python OpWrapperGenerator.py $<TARGET_FILE_NAME:mxnet>
COMMAND rm $<TARGET_FILE_NAME:mxnet>
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/cpp-package/src/OpWrapperGenerator/
)
endif()
48 changes: 48 additions & 0 deletions cpp-package/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
sudo: false

language: cpp

os:
- linux
# disable for now since clang doesn't support openmp
# - osx

env:
# code analysis
- TASK=lint
# TODO: build example
- TASK=build

# dependent apt packages
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8
# - wget
# - git
# - libcurl4-openssl-dev
# - unzip
# - libatlas-dev
# - libopencv-dev

before_install:

install:
- source tests/travis/setup.sh

script:
- tests/travis/run_test.sh

cache:
directories:
- ${HOME}/.cache/usr

notifications:
# Emails are sent to the committer's git-configured email address by default,
email:
on_success: change
on_failure: always
#slack: dmlc:NmroCzntCiWOuxUZpii40USd
13 changes: 13 additions & 0 deletions cpp-package/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (c) 2015 by Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
11 changes: 11 additions & 0 deletions cpp-package/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ifndef LINT_LANG
LINT_LANG="all"
endif

.PHONY: lint example

lint:
python scripts/lint.py dmlc ${LINT_LANG} include example

example:
make -C example travis
8 changes: 8 additions & 0 deletions cpp-package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# MxNet C++ Package

[![Build Status](https://travis-ci.org/dmlc/MXNet.cpp.svg?branch=master)](https://travis-ci.org/dmlc/MXNet.cpp)
[![Build status](https://ci.appveyor.com/api/projects/status/ckfq6j53sg5ll01d/branch/master?svg=true)](https://ci.appveyor.com/project/lx75249/mxnet-cpp/branch/master)

The examples dir containers examples for you to get started.
The lib dir should contain the compiled mxnet library.
Windows dir contains Visual C++ solution files and project files.
70 changes: 70 additions & 0 deletions cpp-package/example/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
BLAS=-L /opt/openblas/lib -lopenblas -DMSHADOW_USE_CBLAS=1 -DMSHADOW_USE_MKL=0
CUDA=-DMSHADOW_USE_CUDA=1

#COMMFLAGS=-static -static-libgcc -static-libstdc++

CFLAGS=$(COMMFLAGS) -I ../include -Wall -O3 -msse3 -funroll-loops -Wno-unused-parameter -Wno-unknown-pragmas -I ../../nnvm/include -I ../../include -I ../../dmlc-core/include
LDFLAGS=$(COMMFLAGS) -L ../lib/linux -lmxnet $(BLAS) $(CUDA) -pthread

ifneq ($(OS), Windows_NT)
OS := $(shell uname)
endif
ifneq ($(OS), Darwin)
CFLAGS += -fopenmp
LDFLAGS += -lgomp
endif

all: mlp lenet lenet_with_mxdataiter alexnet googlenet resnet

lenet_with_mxdataiter: ./lenet_with_mxdataiter.cpp
$(CXX) -c -std=c++11 $(CFLAGS) $^
$(CXX) $(basename $@).o -o $@ $(LDFLAGS)
-rm -f $(basename $@).o

lenet: ./lenet.cpp
$(CXX) -c -std=c++11 $(CFLAGS) $^
$(CXX) $(basename $@).o -o $@ $(LDFLAGS)
-rm -f $(basename $@).o

mlp: ./mlp.cpp
$(CXX) -c -std=c++11 $(CFLAGS) $^
$(CXX) $(basename $@).o -o $@ $(LDFLAGS)
-rm -f $(basename $@).o

alexnet: ./alexnet.cpp
$(CXX) -c -std=c++11 $(CFLAGS) $^
$(CXX) $(basename $@).o -o $@ $(LDFLAGS)
-rm -f $(basename $@).o

googlenet: ./googlenet.cpp
$(CXX) -c -std=c++11 $(CFLAGS) $^
$(CXX) $(basename $@).o -o $@ $(LDFLAGS)
-rm -f $(basename $@).o

inception_bn: ./inception_bn.cpp
$(CXX) -c -std=c++11 $(CFLAGS) $^
$(CXX) $(basename $@).o -o $@ $(LDFLAGS)
-rm -f $(basename $@).o

resnet: ./resnet.cpp
$(CXX) -c -std=c++11 $(CFLAGS) $^
$(CXX) $(basename $@).o -o $@ $(LDFLAGS)
-rm -f $(basename $@).o

# For simplicity, no link here
travis:
$(CXX) -c -std=c++11 $(CFLAGS) ./mlp.cpp && rm -f mlp.o
$(CXX) -c -std=c++11 $(CFLAGS) ./lenet.cpp && rm -f lenet.o
$(CXX) -c -std=c++11 $(CFLAGS) ./lenet_with_mxdataiter.cpp && rm -f lenet_with_mxdataiter.o
$(CXX) -c -std=c++11 $(CFLAGS) ./alexnet.cpp && rm -f alexnet.o
$(CXX) -c -std=c++11 $(CFLAGS) ./googlenet.cpp && rm -f googlenet.o
$(CXX) -c -std=c++11 $(CFLAGS) ./resnet.cpp && rm -f resnet.o


clean:
-rm -f mlp
-rm -f lenet
-rm -f lenet_with_mxdataiter
-rm -f alexnet
-rm -f googlenet
-rm -f resnet
Loading