This repository contains C++ code for nupic.research. See the nupic.research README for more information.
This option is for developers that would like the ability to do incremental builds of the C++ or for those that are using the C++ libraries directly.
mkdir -p build/scripts
cd build/scripts
cmake ../../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../release
Notes:
- This will generate Release build files. For a debug build, change
-DCMAKE_BUILD_TYPE
toDebug
. - If you have dependencies precompiled but not in standard system locations then you can specify where to find them with
-DCMAKE_PREFIX_PATH
(for bin/lib) and-DCMAKE_INCLUDE_PATH
(for header files). - The
-DCMAKE_INSTALL_PREFIX=../release
option shown above is optional, and specifies the location wherenupic.research.core
should be installed. If omitted,nupic.research.core
will be installed in a system location. Using this option is useful when testing versions ofnupic.research.core
language bindings inbindings
. - To use Include What You Use during compilation, pass
-DNUPIC-IWYU=ON
. This requires that IWYU is installed and findable by CMake, with a minimum CMake version of 3.3. IWYU can be installed from https://include-what-you-use.org/ for Windows and Linux, and on OS X using https://github.com/jasonmp85/homebrew-iwyu.
# While still in nupic.research.core/build/scripts
make -j3
Note: The
-j3
option specifies '3' as the maximum number of parallel jobs/threads that Make will use during the build in order to gain speed. However, you can increase this number depending your CPU.
# While still in nupic.research.core/build/scripts
make install
cd ../release/bin
./unit_tests
# From nupic.research.core
cd bindings/py
pip install -r requirements.txt
pip install -e .
Once it is installed, you can import NuPIC bindings library to your python script using:
import nupic.bindings
Any time you change the underlying C++ code, you must repeat the above steps:
# From nupic.research.core/build/scripts
make -j3
make install
# From nupic.research.core
pip install -e .
Suppose you want to add bindings for src/nupic/algorithms/MyCode.cpp
. Follow these steps:
- Create
/bindings/py/src/PyMyCode.hpp
, following the example of other files in that folder.- Implement the function
nupic::py_my_code::add_to
.
- Implement the function
- Call this function in
/bindings/py/src/nupic_module.cpp
.- Import
PyMyCode.hpp
- Call
nupic::py_my_code::add_to
- With these additions, your code is now now available to Python via the
_nupic
module.
- Import
- Explicitly import your code somewhere in
nupic.bindings
- For example, add
bindings/py/nupic/algorithms/my_code.py
, which could containfrom _nupic import my_function, MyClass
- Optional: add Python functions or classes to this file. You may want to subclass
MyClass
and add additional Python logic.
- For example, add
Whenever you change src/nupic/algorithms/MyCode.cpp
, remember to rebuild (make -j3
from build/scripts
, as above), then run pip install -e .
from the folder bindings/py
to rebuild the bindings.
- Open CMake executable.
- Specify the source folder (
$NUPIC_CORE/src
). - Specify the build system folder (
$NUPIC_CORE/build/scripts
), i.e. where IDE solution will be created. - Click
Generate
. - Choose the IDE that interest you (remember that IDE choice is limited to your OS, i.e. Visual Studio is available only on CMake for Windows).
- Open
nupic_research_core.*proj
solution file generated on$NUPIC_CORE/build/scripts
. - Run
ALL_BUILD
project from your IDE.
- Run any
tests_*
project from your IDE (checkoutput
panel to see the results).
Run doxygen, optionally specifying the version as an environment variable:
PROJECT_VERSION=`cat VERSION` doxygen
The results will be written out to the html
directory.