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

Fix issue #337 and #457 #458

Merged
merged 4 commits into from
Nov 21, 2019
Merged

Fix issue #337 and #457 #458

merged 4 commits into from
Nov 21, 2019

Conversation

ryanrhymes
Copy link
Member

This PR changes number type from int32 to int64 in underlying indexing and slicing function. This change affects many c code in owl core, therefore needs careful examination before merge.

@mseri mseri self-assigned this Nov 21, 2019
Copy link
Collaborator

@jzstark jzstark left a comment

Choose a reason for hiding this comment

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

I've tried the new branch and do make test. All tests pass except for the know "sylvester" test.

I then tried the DNNs, including mnist training example, the inception inference, and fast style transfer, and the computation results seem normal.

The only issue I get is that there are several compilation warnings:

dune build @install
      ocamlc src/owl/owl_ndarray_transpose_stub.o
In file included from src/owl/core/owl_ndarray_transpose_stub.c:17:
src/owl/core/owl_ndarray_transpose_impl.h:241:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  sp->n = X->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_ndarray_transpose_stub.c:26:
src/owl/core/owl_ndarray_transpose_impl.h:241:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  sp->n = X->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_ndarray_transpose_stub.c:35:
src/owl/core/owl_ndarray_transpose_impl.h:241:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  sp->n = X->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_ndarray_transpose_stub.c:44:
src/owl/core/owl_ndarray_transpose_impl.h:241:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  sp->n = X->dim;
        ^ ~~~~~~
4 warnings generated.
      ocamlc src/owl/owl_slicing_fancy_stub.o
In file included from src/owl/core/owl_slicing_fancy_stub.c:19:
src/owl/core/owl_slicing_fancy_impl.h:92:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  fp->n = Y->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_slicing_fancy_stub.c:28:
src/owl/core/owl_slicing_fancy_impl.h:92:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  fp->n = Y->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_slicing_fancy_stub.c:37:
src/owl/core/owl_slicing_fancy_impl.h:92:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  fp->n = Y->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_slicing_fancy_stub.c:46:
src/owl/core/owl_slicing_fancy_impl.h:92:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  fp->n = Y->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_slicing_fancy_stub.c:57:
src/owl/core/owl_slicing_fancy_impl.h:92:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  fp->n = Y->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_slicing_fancy_stub.c:66:
src/owl/core/owl_slicing_fancy_impl.h:92:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  fp->n = Y->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_slicing_fancy_stub.c:75:
src/owl/core/owl_slicing_fancy_impl.h:92:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  fp->n = Y->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_slicing_fancy_stub.c:84:
src/owl/core/owl_slicing_fancy_impl.h:92:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  fp->n = Y->dim;
        ^ ~~~~~~
8 warnings generated.
      ocamlc src/owl/owl_slicing_basic_stub.o
In file included from src/owl/core/owl_slicing_basic_stub.c:20:
src/owl/core/owl_slicing_basic_impl.h:239:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  sp->n = Y->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_slicing_basic_stub.c:29:
src/owl/core/owl_slicing_basic_impl.h:239:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  sp->n = Y->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_slicing_basic_stub.c:38:
src/owl/core/owl_slicing_basic_impl.h:239:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  sp->n = Y->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_slicing_basic_stub.c:47:
src/owl/core/owl_slicing_basic_impl.h:239:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  sp->n = Y->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_slicing_basic_stub.c:58:
src/owl/core/owl_slicing_basic_impl.h:239:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  sp->n = Y->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_slicing_basic_stub.c:67:
src/owl/core/owl_slicing_basic_impl.h:239:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  sp->n = Y->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_slicing_basic_stub.c:76:
src/owl/core/owl_slicing_basic_impl.h:239:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  sp->n = Y->dim;
        ^ ~~~~~~
In file included from src/owl/core/owl_slicing_basic_stub.c:85:
src/owl/core/owl_slicing_basic_impl.h:239:9: warning: incompatible pointer types assigning to 'int64_t *' (aka 'long long *') from 'intnat []' [-Wincompatible-pointer-types]
  sp->n = Y->dim;
        ^ ~~~~~~
8 warnings generated.

@mseri
Copy link
Member

mseri commented Nov 21, 2019

Maybe we should use intnat as well. It is defined by the ocaml runtime and chooses between int and long int depending on the arch support: https://github.com/ocaml/ocaml/blob/fe31a0179dd0575f217dcde11ca4dabcc2673c57/runtime/caml/config.h#L127

It is used pervasively in the mmap code in ocaml and would prevent breakage in 32bit arch.

What do you think?

@jzstark
Copy link
Collaborator

jzstark commented Nov 21, 2019

But perhaps sticking with one explicit type would potentially reduce bug? I'm thinking how widely is Owl used on 32bit machines.

@ryanrhymes ryanrhymes merged commit 9789894 into master Nov 21, 2019
This was referenced Nov 21, 2019
@ryanrhymes ryanrhymes deleted the issue337 branch December 4, 2019 12:02
mseri added a commit to mseri/opam-repository that referenced this pull request Feb 25, 2020
CHANGES:

*  Fix bug in _squeeze_broadcast (owlbarn/owl#503)
*  Added the Dawson function (Ndarray + Matrix + Algodiff op) (owlbarn/owl#502)
*  Fix bug in reverse mode gradients of aiso operations and pow (owlbarn/owl#501)
*  Added poisson_rvs to Owl_distribution (owlbarn/owl#499)
*  Draw poisson RVs in Ndarray and Mat modules (owlbarn/owl#498)
*  Broadcast bug for higher order derivatives (owlbarn/owl#495)
*  add sem to dense ndarray and matrix (owlbarn/owl#497)
*  Avoid input duplication with Graph.model and multi-input nn (owlbarn/owl#494)
*  Added Graph.get_subnetwork for constructing subnetworks (owlbarn/owl#491)
*  Make Graph.inputs give unique names to inputs (owlbarn/owl#493)
*  modify nlp interfaces
*  Re-add removed DiffSharp acknowledgment (owlbarn/owl#486)
*  add pretty printer for hypothesis type
*  update lambda neuron (owlbarn/owl#485)
*  fix example due to owlbarn/owl#476
*  Extend base linalg functions to complex numbers (owlbarn/owl#479)
*  [breaking] use a separate module for algodiff instead of ndarray directly (owlbarn/owl#476)
*  temp workaround and unittest (owlbarn/owl#478)
*  [breaking] Interface files for base/dense and base/linalg (owlbarn/owl#472)
*  Port code to dune2 (owlbarn/owl#474)
*  [breaking]  interface files to simplify .mli files in owl/dense (owlbarn/owl#471)
*  Save and load Npy files (owlbarn/owl#470)
*  Owl: relax bounds on base and stdio (owlbarn/owl#469)
*  Merged tests for different AD operations into one big test + autoformat tests with ocamlformat (owlbarn/owl#468)

### 0.7.2 (2019-12-06)

* fourth order finite diff approx to grad
* changes to improve stability of sylv/discrete_lyap
* fix bug in concatenate function
* add mli for owl_base_linalg_generic
* Owl-base linalg routines: LU decomposition  (owlbarn/owl#465)
* bug fixes
* Update owl.opam

### 0.7.1 (2019-11-27)

* Add unit basis
* Fix issue owlbarn/owl#337 and owlbarn/owl#457 (owlbarn/owl#458)
* owl-base: drop seemingly unnecessary dependency on integers (owlbarn/owl#456)

### 0.7.0 (2019-11-14)

* Add unsafe network save (owlbarn/owl#429)
* Sketch Count-Min and Heavy-Hitters
* Various bugfixes
* Owl_io.marshal_to_file: use to_channel
* Do not create .owl folder when loading owl library
* Re-design of exceptions and replace asserts with verify
* Add OWL_DISABLE_LAPACKE_LINKING_FLAG
* Reorganise Algodiff module
* Add parameter support to Zoo
* Two new features in algodiff: eye and linsolve (triangular option) + improved stability of qr and chol
* Implemented solve triangular
* Added linsolve and lq reverse-mode differentiation
* Fix build on archlinux (pkg-config cblas)
* Add median and sort along in ndarray
* Improve stability of lyapunov gradient tests

### 0.6.0 (2019-07-17)

* Add unsafe network save (owlbarn/owl#429)
* Sketch Count-Min and Heavy-Hitters
* Various ugfixes
* Owl_io.marshal_to_file: use to_channel
* Do not create .owl folder when loading owl library
* Re-design of exceptions and replace asserts with verify
* Add OWL_DISABLE_LAPACKE_LINKING_FLAG
* Reorganise Algodiff module
* Add parameter support to Zoo
* Two new features in algodiff: eye and linsolve (triangular option) + improved stability of qr and chol
* Implemented solve triangular
* Added linsolve and lq reverse-mode differentiation
* Fix build on archlinux (pkg-config cblas)
* Add median and sort along in ndarray
* Improve stability of lyapunov gradient tests

### 0.5.0 (2019-03-05)

* Improve building and installation.
* Fix bugs and improve performance.
* Add more functions to Algodiff.
* Split plot module out as sub library.
* Split Tfgraph module out as sub library.

### 0.4.2 (2018-11-10)

* Optimise computation graph module.
* Add some core math functions.
* Fix bugs and improve performance.

### 0.4.1 (2018-11-01)

* Improve the APIs of Dataframe module.
* Add more functions in Utils module.

### 0.4.0 (2018-08-08)

* Fix some bugs and improve performance.
* Introduce computation graph into the functor stack.
* Optimise repeat and tile function in the core.
* Adjust the OpenCL library according to computation graph.
* Improve the API of Dataframe module.
* Add more implementation of convolution operations.
* Add dilated convolution functions.
* Add transposed convolution functions.
* Add more neurons into the Neural module.
* Add more unit tests for core functions.
* Move from `jbuilder` to `dune`
* Assuage many warnings

### 0.3.8 (2018-05-22)

* Add initial support for dataframe functionality.
* Add IO module for Owl's specific file operations.
* Add more helper functions in Array module in Base.
* Add core functions such as one_hot, slide, and etc.
* Fix normalisation neuron in neural network module.
* Fix building, installation, and publishing on OPAM.
* Fix broadcasting issue in Algodiff module.
* Support negative axises in some ndarray functions.
* Add more statistical distribution functions.
* Add another higher level wrapper for CBLAS module.

### 0.3.7 (2018-04-25)

* Fix some bugs and improve performance.
* Fix some docker files for automatic image building.
* Move more pure OCaml implementation to base library.
* Add a new math module to support complex numbers.
* Improve the configuration and building system.
* Improve the automatic documentation building system.
* Change template code into C header files.
* Add initial support for OpenMP with evaluation.
* Tidy up packaging using TOPKG.

### 0.3.6 (2018-03-22)

* Fix some bugs and improve performance.
* Add more unit tests for Ndarray module.
* Add version control in Zoo gist system.
* Add tensor contract operations in Ndarray.
* Add more documentation of various functions.
* Add support of complex numbers of convolution and pooling functions.
* Enhance Owl's own Array submodule in Utils module.
* Fix pretty printer for rank 0 ndarrays.
* Add functions to iterate slices in an ndarray.
* Adjust the structure of OpenCL module.

### 0.3.5 (2018-03-12)

* Add functions for numerical integration.
* Add functions for interoperation.
* Add several root-finding algorithms.
* Introduce Owl's exception module.
* Add more functions in Linalg module.
* Add native convolution function in core.
* Remove Eigen dependency of dense data structure.
* Fix some bugs and improve performance.

### 0.3.4 (2018-02-26)

* Update README, ACKNOWLEDGEMENT, and etc.
* Initial implementation of OpenCL Context module.
* Fix some bugs and improve the performance.
* Add Adam learning rate algorithm in Optimise module.
* Add a number of statistical functions into Stats.
* Enhance View functor and add more functions.
* Include and documentation of NLP modules.
* Add dockerfile for various linux distributions.

### 0.3.3 (2018-02-12)

* Fix some bugs and improve the performance.
* Integrate with Owl's documentation system.
* Add native C implementation of pooling operations.
* Add more operators in Operator module.
* Add more functions in Linalg module.
* Optimise the Base library.
* Add more unit tests.

### 0.3.2 (2018-02-08)

* Fix some bugs and improve the performance.
* Functorise many unit tests and add more tests.
* Rewrite the documentation migrate to Sphinx system.
* Migrate many pure OCaml code into Base library.
* Implement the initial version of Base library.

### 0.3.1 (2018-01-25)

* Design View module as an experimental module for Ndarray.
* Include Mersenne Twister (SFMT) to generate random numbers.
* Implement random number generator of various distributions.
* Implement native functions for maths and stats module.
* Include FFTPACK to provide native support for FFT functions.
* Minimise dependency, remove dependencies on Gsl and etc.
* Implement slicing and indexing as native C functions.
* Use new extended indexing operators for slicing functions.
* Refine ndarray fold function and introduce scan function.
* Reorganise the module structure in the source tree.
* Fix some bugs and enhance the performance of core functions.
* Add another 200+ unit tests.

### 0.3.0 (2017-12-05)

* Migrate to jbuilder building system.
* Unify Dense Ndarray and Matrix types.
* Split Toplevel out as a separate library.
* Redesign Zoo system for recursive importing.
* Simplify the module signature for Ndarray.
* Introduce functions in Ndarray module to support in-place modification.
* Introduce reduction functions to reduce an ndarray to a scalar value.
* Add Lazy functor to support lazy evaluation, dataflow, and incremental computing.
* Implement a new and more powerful pretty printer to support both ndarray and matrix.
* Fix bugs in the core module, improve the performance.

### 0.2.8 (2017-09-02)

* New Linalg module is implemented.
* New neural network module supports both single and double precision.
* New Optimise and Regression module is built atop of Algodiff.
* Experimental Zoo system is introduced as a separate library.
* Enhance core functions and fix some bugs.

### 0.2.7 (2017-07-11)

* Enhance basic math operations for complex numbers.
* Redesign Plot module and add more plotting functions.
* Add more hypothesis test functions in Owl.Stats module.
* Support both numerical and algorithmic differentiation in Algodiff.
* Support both matrices and n-dimensional arrays in Algodiff module.
* Support interoperation of different number types in Ext and new operators.
* Support more flexible slicing, tile, repeat, and concatenate functions.
* Support n-dimensional array of any types in Dense.Ndarray.Any module.
* Support simple feedforward and convolutional neural networks.
* Support experimental distributed and parallel computing.

### 0.2.0 (2017-01-20)

* Support both dense and sparse matrices.
* Support both dense and sparse n-dimensional arrays.
* Support both real and complex numbers.
* Support both single and double precisions.
* Add more vectorised operation: sin, cos, ceil, and etc.
* Add basic unit test framework for Owl.
* Add a couple of Topic modelling algorithms.

### 0.1.0 (2016-11-09)

* Initial architecture of Owl library.
* Basic support for double precision real dense matrices.
* Basic linear functions for dense matrices.
* Basic support for plotting functions.
* SI, MKS, CGS, and CGSM metric system.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants