Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sparsematrix removal 2 #169

Merged
merged 53 commits into from
Feb 23, 2019
Merged

Sparsematrix removal 2 #169

merged 53 commits into from
Feb 23, 2019

Conversation

breznak
Copy link
Member

@breznak breznak commented Dec 17, 2018

Removes all of math/Sparse*Matrix codes, which are not used;
this code should be replaced with Connections (as in SP #93 ) or Eigen (sparse)Matrix.

  • these changes do not break any public API (NetworkAPI, SP,TM,.. classes)
  • SparseTensor (and dependencies, users)
  • SparseBinaryMatrix
  • rewrite SDRClassifier to use something else than DenseMatrix SDR Classifier without densematrix #170
    • remove DenseMatrix
      • remove SparseMatrix
  • Functions.hpp -- used boost, useful removal for replacing boost with c++17
  • Set -- reprecated for python built-in set()
  • SparseMatrix
  • ArrayAlgo
  • Math

this provides vast modernization of the codebase (no code with ifdefs, hacks, etc) making it much easier to port.

Removes dependency on Boost, so we can get rid of it

Fixes #104
Allowed after #93
Follow-up to #149
Fixes #103
Fixes: #213

@breznak breznak added API_BREAKING_CHANGE code code enhancement, optimization, cleanup..programmer stuff labels Dec 17, 2018
@breznak breznak added this to the cleanup milestone Dec 17, 2018
@breznak breznak self-assigned this Dec 17, 2018
only user SpatialPooler was transformed to use
Connections in #93, now SparseBinaryMatrix is unused.
Removing c++ code, bindings, tests
@breznak breznak mentioned this pull request Dec 17, 2018
3 tasks
used as optimization for python set,
now built-in python set() is used.
This file has long been deprecated.
unused since PR #170 - SDR Classifier uses 2d map
map<int, map<int, double>>
this is all of the custom Sparse*Matrix classes removed,
@breznak
Copy link
Member Author

breznak commented Dec 18, 2018

This should be reviewed after #170 is merged.

@breznak
Copy link
Member Author

breznak commented Dec 19, 2018

@dkeeney @ctrl-z-9000-times Please review, this completes the *Matrix cleanup, all this code has been old and unmaintaned, now is unused and removed. That makes our codebase some 40k LOC lighter.

  • removes unused code from src/math/*Matrix
    • c++ tests
  • relevant bindings
    • py tests

This was not a public facing API, so there are no worries in that regard.

@breznak breznak mentioned this pull request Dec 19, 2018
5 tasks
@breznak
Copy link
Member Author

breznak commented Jan 15, 2019

In other words, “nupic.cpp” should be the nupic core in cpp only

Let's continue this discussion in #216

The sources need to be compiled as position independent code (-fPIC in linux, /MD in windows). If doing C++ only applications you probably don't want that (without -fPIC in Linux, /MT in windows) because you cannot mix modes in a static library. It will probably end up being another build option, defaulting to not compiling for position independent code unless a binding is also requested.

hmm, toggling fPIC based on if bindings are requested does sound as a good solution, on the other hand, is keeping fPIC and linking as a shared lib too much of a problem?

@ctrl-z-9000-times
Copy link
Collaborator

There is one complication I am struggling with at the moment and that is how to build for shared library.

I think your approach is good. Use -fpic for python bindings and no -fpic otherwise. Bonus points for an override flag allowing savvy users to control this themselves.

@breznak breznak added ready and removed on_hold labels Jan 16, 2019
@breznak
Copy link
Member Author

breznak commented Jan 16, 2019

RUN ] ConnectionsPerformanceTest.testTP
0.000528024 in temporal pooler: initialize
ERR: CHECK FAILED: "numDesired > 0" Not enough columns (10) for desired density (0.05). [/Users/distiller/numenta/nupic.core/src/nupic/algorithms/SpatialPooler.cpp line 925]
unknown file: Failure
C++ exception with description "CHECK FAILED: "numDesired > 0" Not enough columns (10) for desired density (0.05)." thrown in the test body.
[ FAILED ] ConnectionsPerformanceTest.testTP (1 ms)

failing test on OSX CI

@breznak breznak mentioned this pull request Jan 16, 2019
@breznak
Copy link
Member Author

breznak commented Jan 16, 2019

@ctrl-z-9000-times @dkeeney this PR is updated and passing again, ready for next round of reviews

Copy link
Collaborator

@ctrl-z-9000-times ctrl-z-9000-times left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Thanh-Binh is right it breaks functionality in Py repo.

I'm not going to approve this PR until we all agree on a plan for dealing with the broken python repo. We don't need to do the plan, just having one is enough for now.

  • We all have different ideas on what to do about the python repo, and no one wants to touch it because it's as messy as this repo was at the start.
  • The python repo is the point-of-entry for all new users. Also everyone prefers using python over C++ until performance becomes a problem.
  • We have no continuous integration for the things which this PR would break, which is a problem in itself but not a blocker for this PR. This PR will not be the first to potentially break the python repo, if it hasn't already been broken by us without our knowledge.

@ctrl-z-9000-times
Copy link
Collaborator

@breznak,

Now that we have a plan for dealing with the broken python repo, this PR can proceed. Before final approval we need a written plan describing:

  • What code this PR breaks (in htm-community/nupic.py),
    • Do a search for all of the classes which you're removing.
  • How it breaks it (just a link to this PR is sufficient),
  • What could hypothetically be done to fix it,
    • Replace SparseMatrix with connections?

Maybe leave these notes in issue #216, or open a new issues as needed?

@breznak
Copy link
Member Author

breznak commented Feb 13, 2019

Thanks, I'll work on this later the week.

FYI, these are total files removed in this PR:

60 files changed, 92 insertions(+), 45280 deletions(-)
delete mode 100644 bindings/py/cpp_src/bindings/math/PyBindSparseTensor.hpp
delete mode 100644 bindings/py/cpp_src/bindings/math/SparseTensorIndex.hpp
delete mode 100644 bindings/py/cpp_src/bindings/math/py_ArrayAlgo.cpp
delete mode 100644 bindings/py/cpp_src/bindings/math/py_Domain.cpp
delete mode 100644 bindings/py/cpp_src/bindings/math/py_Math.cpp
delete mode 100644 bindings/py/cpp_src/bindings/math/py_Set.cpp
delete mode 100644 bindings/py/cpp_src/bindings/math/py_SparseBinaryMatrix.cpp
delete mode 100644 bindings/py/cpp_src/bindings/math/py_SparseMatrix.cpp
delete mode 100644 bindings/py/cpp_src/bindings/math/py_SparseTensor.cpp
delete mode 100755 bindings/py/tests/array_algorithms_test.py
delete mode 100755 bindings/py/tests/cast_mode_test.py
delete mode 100755 bindings/py/tests/sparse_binary_matrix_test.py
delete mode 100755 bindings/py/tests/sparse_matrix_test.py

I'll ignore the bindings, as that repo is not synced to our new bindings anyway.

delete mode 100755 src/nupic/math/ArrayAlgo.hpp
delete mode 100644 src/nupic/math/DenseMatrix.hpp
delete mode 100644 src/nupic/math/Domain.hpp
delete mode 100644 src/nupic/math/Functions.hpp
delete mode 100644 src/nupic/math/Index.hpp
delete mode 100644 src/nupic/math/Set.hpp
delete mode 100644 src/nupic/math/SparseBinaryMatrix.hpp
delete mode 100644 src/nupic/math/SparseMatrix.hpp
delete mode 100644 src/nupic/math/SparseTensor.hpp

These are the focus to check

delete mode 100644 src/test/unit/math/DenseTensorUnitTest.cpp
delete mode 100644 src/test/unit/math/DenseTensorUnitTest.hpp
delete mode 100644 src/test/unit/math/DomainUnitTest.cpp
delete mode 100644 src/test/unit/math/DomainUnitTest.hpp
delete mode 100644 src/test/unit/math/IndexUnitTest.cpp
delete mode 100644 src/test/unit/math/IndexUnitTest.hpp
delete mode 100644 src/test/unit/math/MathsTest.cpp
delete mode 100644 src/test/unit/math/MathsTest.hpp
delete mode 100644 src/test/unit/math/SparseBinaryMatrixTest.cpp
delete mode 100644 src/test/unit/math/SparseMatrixTest.cpp
delete mode 100644 src/test/unit/math/SparseMatrixUnitTest.cpp
delete mode 100644 src/test/unit/math/SparseMatrixUnitTest.hpp
delete mode 100644 src/test/unit/math/SparseTensorUnitTest.cpp
delete mode 100644 src/test/unit/math/SparseTensorUnitTest.hpp

I'll ignore the tests as they match the removed main classes.

dkeeney
dkeeney previously approved these changes Feb 17, 2019
Copy link

@dkeeney dkeeney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you think you are comfortable about how we are going to fix any broken .py modules as we bring them into our repro then I say go ahead and merge.

Conflicts:
	bindings/py/cpp_src/bindings/math/py_SparseBinaryMatrix.cpp
	bindings/py/cpp_src/bindings/math/py_SparseMatrix.cpp
	bindings/py/cpp_src/bindings/math/py_SparseTensor.cpp
	src/nupic/math/Math.hpp
	src/nupic/math/SparseBinaryMatrix.hpp
	src/test/unit/algorithms/Cells4Test.cpp
Copy link
Collaborator

@ctrl-z-9000-times ctrl-z-9000-times left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Thank you Breznak!

@ctrl-z-9000-times ctrl-z-9000-times merged commit a14de71 into master Feb 23, 2019
@breznak breznak deleted the sparsematrix_removal_2 branch February 25, 2019 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code code enhancement, optimization, cleanup..programmer stuff question Further information is requested ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants