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

Commit

Permalink
Re-organize based on KK's code
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen committed Oct 6, 2015
1 parent 24184b7 commit 451addc
Show file tree
Hide file tree
Showing 20 changed files with 351 additions and 163 deletions.
7 changes: 7 additions & 0 deletions R-package/.Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\.o$
\.so$
\.dll$
^.*\.Rproj$
^\.Rproj\.user$

README.md
2 changes: 2 additions & 0 deletions R-package/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.Rhistory
R-package.Rproj
10 changes: 6 additions & 4 deletions R-package/mxnet/DESCRIPTION → R-package/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
Package: mxnet
Type: Package
Title: MXNet
Version: 1.0
Version: 0.5
Date: 2015-10-02
Author: Your Name
Maintainer: Your Name <your@email.com>
Author: Qiang Kou
Maintainer: Your <your@email.com>
Description: MXNet is a deep learning framework designed for both efficiency and flexibility. It allows you to mix the flavours of deep learning programs together to maximize the efficiency and your productivity.
License: Apache-2.0
Imports: Rcpp (>= 0.12.1)
URL: https://github.com/dmlc/mxnet
BugReports: https://github.com/dmlc/mxnet/issues
Imports: Rcpp (>= 0.11.1)
LinkingTo: Rcpp
File renamed without changes.
1 change: 1 addition & 0 deletions R-package/R/zzz.r
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loadModule("mxnet", TRUE)
11 changes: 11 additions & 0 deletions R-package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
MXNet R-Package
===============
This is an on-going effort to support mxnet in R, stay tuned.

Bleeding edge Installation
- First build ```../lib/libmxnet.so``` by following [Build Instruction](doc/build.md)
- Set the path to ```lib/libmxnet.so``` in ```LD_LIBRARY_PATH```, you can do it by modify ```~/.bashrc```
```bash
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/path/to/lib/libmxnet.so
```
- Type ```R CMD INSTALL R-package``` in the root folder.
1 change: 1 addition & 0 deletions R-package/demo/00Index
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
basic_ndarray Basic ndarray operations
1 change: 1 addition & 0 deletions R-package/demo/basic_ndarray.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
library(mxnet)
11 changes: 0 additions & 11 deletions R-package/install.sh

This file was deleted.

File renamed without changes.
1 change: 0 additions & 1 deletion R-package/mxnet/R/zzz.r

This file was deleted.

6 changes: 0 additions & 6 deletions R-package/mxnet/src/Makevars

This file was deleted.

57 changes: 0 additions & 57 deletions R-package/mxnet/src/mx_generated_function.hpp

This file was deleted.

64 changes: 0 additions & 64 deletions R-package/mxnet/src/ndarray.cpp

This file was deleted.

20 changes: 0 additions & 20 deletions R-package/mxnet/src/ndarray.hpp

This file was deleted.

24 changes: 24 additions & 0 deletions R-package/src/Makevars
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# _*_ mode: makefile; _*_
PKGROOT=../../

# This file is only used for compilation from github
# It will be replaced by more formal Rpackage structure
# Where PKGROOT moved to root directory

.PHONY: all mxlib
all: $(SHLIB)

$(SHLIB): mxlib
mxlib:
cd $(PKGROOT); make CXX="$(CXX)"; cd -
cp $(PKGROOT)/lib/libmxnet.so libmxnet.so
mkdir -p ../inst
mkdir -p ../inst/libs
cp $(PKGROOT)/lib/libmxnet.so ../inst/libs/libmxnet.so

# Need to add libmxnet.so to LD_LIBRARY_PATH
# TODO: make it install together with mxnet.so
LINKMXNET = -L../inst/libs -lmxnet

PKG_CPPFLAGS = -I$(PKGROOT)/include -I$(PKGROOT)/dmlc-core/include
PKG_LIBS = $(LINKMXNET) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
33 changes: 33 additions & 0 deletions R-package/src/base.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*!
* Copyright (c) 2015 by Contributors
* \file base.h
* \brief Rcpp interface of MXNet
*/
#ifndef MXNET_RCPP_BASE_H_
#define MXNET_RCPP_BASE_H_

#include <Rcpp.h>
#include <mxnet/c_api.h>
// to be removed
#include <dmlc/logging.h>

namespace mxnet {
namespace R {

// change to Rcpp::cerr later, for compatiblity of older version for now
#define RLOG_FATAL LOG(FATAL)

/*!
* \brief protected MXNet C API call, report R error if happens.
* \param func Expression to call.
*/
#define MX_CALL(func) \
{ \
int e = (func); \
if (e != 0) { \
RLOG_FATAL << MXGetLastError(); \
} \
}
} // namespace Rcpp
} // namespace mxnet
#endif // MXNET_RCPP_BASE_H_
8 changes: 8 additions & 0 deletions R-package/src/mxnet.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <Rcpp.h>
#include "./ndarray.h"

RCPP_MODULE(mxnet) {
using namespace mxnet::R; // NOLINT(*)
NDArray::InitRcppModule();
NDArrayFunction::InitRcppModule();
}
Loading

0 comments on commit 451addc

Please sign in to comment.