Commit Graph
37 Commits
Author SHA1 Message Date
Junru Shao 4bb141d682 [MXNET-684] Add cond operator (#11760)
* Initial commit for `Ifelse`

* Address comments

* Rename ifelse to condition

* API change

* Trigger CI

* Rename condition to cond

* Fix lint
2018-07-23 21:18:17 -07:00
Istvan Fehervari b16f87505a [MXNET-524] Broadcast like operator (#11820)
* Registered the broadcast_like operator with GPU and CPU

Added appropriate shape inference

* Added python interface to ndarray and symbol

* Added python api documentation

* Fixed backward operation

* Added unit tests

* Fixed linting issues

* Added missing api doc
2018-07-20 09:56:16 -07:00
Istvan Fehervari f15b1b88b9 Added the diag() operator (#11643)
* Added np.diag as mxnet operator, WIP

Done:
2d input forward pass
Missing:
1d input forward
all backward

* Added a simple gradient transfer backwards operator for diag

Fixed small typos as well

* Finished backward operation

* Added full support for k

* Finished added the 1D case to the diag operator

Finished function documentation
Added unit tests

* Fixed cpplinter errors in the diag operator

Issues were extra white spaces and include order

* Fixed indentation in diag_op-inl.h

* Changed diag operator tests to use np.diag() as comparison

* Fixed kernel bug in gpu diag operator

* Replaced the min operator with an inline if statement.

* Added diag to ndarray and symbol

* Replaced the type of parameter k from int32 to nnvm::dim

* Added default argument to k in ndarray and symbol

* Fixed ndarray and symbol diag calls

* Fixed the optional k parameter

* Fixed cpp linting error

* Changed test data datatype to float32

* K values resulting into 0-sized diagonals will now throw an exception.

Added matching test case

* Fixed unittest

* Added diag to NDArray and Symbol api doc

* Added missing api doc
2018-07-19 13:26:46 -07:00
Junru Shao 54632bcb38 [MXNET-626] Add while_loop (#11566)
* Add while_loop

* Avoid input/output overlap for nnvm graph cut

* Add more testcases

* Enhance test 4.2

* Add more complicated testcases; Add testcase for nested loop

* Check unused loop_vars in while_loop

* Add testcases for RNN

* Make lint happy

* Make lint happy

* Address TODOs

* Fix flaky test for while_loop

* Address comments

* Improve docstring

* Improve error message

* Add benchmark code

* Update benchmarks

* Allow sparse types

* Make max_iterations default to None

* Add while_loop to docs/api/python/{symbol|ndarray}/contrib.md

* Pad imperative while_loop so that it has the same shape with the symbolic one

* Add example result into the example section

* Remove unused class member

* Rename unittest to test_contrib_control_flow.py

* Update docstring

* Update docstring

* Trigger CI

* Change threshold for assert_almost_equal

* Trigger CI

* Address comments from szha

* Rewrite benchmark code

* Fix sphinx warning
2018-07-18 17:09:10 -07:00
Hao Jin 52dcb19aeb [MXNET-392] Support for a bunch of unary functions for csr matrices (#11559)
* support for relu(csr) = csr

* add support for sign(csr) = csr

* add support for round

* add support for ceil(csr)=csr

* add support for floor(csr)=csr

* add support for trunc(csr)=csr

* add support for fix(csr)=csr

* add support for sqrt(csr)=csr

* add support for cbrt(csr)=csr

* add support for log1p(csr)=csr

* add support for expm1(csr)=csr

* add support for sin(csr)=csr

* add support for tan(csr)=csr

* add support for arcsin(csr)=csr

* add support for arctan(csr)=csr

* add support for degrees(csr)=csr

* add support for radians(csr)=csr

* add support for sinh(csr)=csr

* add support for tanh(csr)=csr

* add support for arcsinh(csr)=csr

* add support for arctanh(csr)=csr

* restore original check_sparse_function func

* add test for fluent and doc

* address code review
2018-07-06 09:57:30 -07:00
Da Zheng 030fbc3c7b [MXNET-432] Add Foreach (#11531)
* Test input a graph.

* Update foreach to execute the subgraph.

* print inputs/outputs in foreach.

* Remove print.

* add test code for foreach.

* exec foreach outside the engine.

* Implements forward of foreach.

* Add support for variable numbers of inputs and outputs.

* Add a python wrapper for foreach.

* Fix the order of inputs.

* add test with lstm.

* hide C version of foreach.

* fix a bug temporarily.

* Test free variables.

* change for the new interface of InputGraph attribute.

* Add attribute to the subgraph.

* Handle free variables.

* Get all input symbols of a subgraph.

* Fix shape, dtype and storage inference.

* reorganize the output of foreach.

* Add a gluon RNN unroll with symbol foreach.

* print unnecessary print.

* have imperative and symbolic foreach.

* Fix an error after moving foreach.

* Fix imperative foreach

* Fix a minor problem.

* Use CachedOp to execute subgraph.

* update TODO.

* make foreach op use FStatefulComputeEx.

TODO we need to change stateful executor to handle subgraph.

* Add backward.

* Fix bugs.

* enable backward test in lstm.

* Fix a bug in foreach backward for free variables.

* change for the new CachedOp.

* Detect the backward computation.

* Fix bugs in foreach.

* fix tests.

* update tests.

* check state shape.

* enable nested foreach.

* remove print.

* fix a bug in test.

* handle infer storage type for backward.

* address comments.

* address comments.

* move some common functions out.

* address comments.

* fix lint.

* Fix lint.

* add doc.

* undo modification in imperative.h

* add doc and remove example code.

* fix lint.

* fix lint.

* Fix lint.

* make nd.foreach and sym.foreach consistent.

* fix compile error.

* address comments.

* update.

* check for loop only works for dense arrays.

* move control flow op out of nn/

* fix include.

* add a test in gluon.

* work for GPU.

* small fix.

* remove subgraph_name

* create loop state for reuse in the future.

* move code.

* Revert "remove subgraph_name"

This reverts commit 977f5624ad0b0dedb9dcb8629f975afc56bb1e1a.

* cut graph.

* rename new var nodes.

* Fix tests.

* Fix bugs caused by ctypes (#29)

* Add save/load json in testcases for foreach (#30)

* support subgraph in stateful executor.

* Fix compilation.

* fix a bug when a subgraph has variable nodes.

* Fix a bug of getting symbols.

* copy var nodes.

* Fix getting op states.

* fix lint error.

* address comments.

* fix lint error.

* simplify the execution of subgraph in the main thread.

* fix lint error.

* avoid waiting for computation in each iteration.

* reuse cached op for inference.

* share memory across mini-batches.

* reuse memory.

reuse memory between iterations in inference.
reuse memory between mini-batches in training.

* add tests for multiple batches.

* remove entry.

* add benchmark for foreach.

* benchmark large batch size.

* Fix the benchmark for GPU.

* address comments.

* update shape/dtype/storage inference.

* update contrib API docs.

* support nested foreach.

* use a single CachedOp for all iterations.

* use large dim.

* update benchmark.

* update benchmark.

* update benchmark.

* update benchmark.

* return symbol arrays correctly in MXSymbolCutSubgraph.

* return symbol arrays in MXSymbolGetInputSymbols.

* fix lint error.

* use cachedop to infer storage in backward.

* fix scala API.

* update comments.

* fix scala.

* fix test.

* fix attribute name.

* move benchmark.

* fix the mapping of operator inputs/outputs and subgraph inputs/outputs.

* add tests for dtype/shape inference.

* reorganize tests.

* fix a bug of cutting NodeEntry.

When two node entries refer to the same output of a node, we should
create only one var node for these two node entries.

* fix lint error.

* handle the case that outputs are inputs.

* handle the case that inputs aren't used.

* handle the case without output data.

* fix a bug in foreach backward.

* fix a bug when there isn't output data.

* Fix lint error.

* test diff Gluon RNN cells.

* test all symbol RNN cells.

* adjust the test precision.

* Fix a bug in getting a list of variable names.

We can't get a list of variable names from a hashtable. The order can't
be guaranteed. Python2 and Python3 output different orders.

* fix lint error.

* Test 1D array.

* fix a bug when subgraph inputs and outputs share NDArray.

* fix.

* fix

* add comments.
2018-07-02 15:26:51 -07:00
Anirudh 33022f82a3 [MXNET-382] Shape and Size Operator (#10889)
* Shape Operator

* cuda

* size op

* lint issues

* docs example

* add docs, change op name to avoid conflict, add convenience confluent
method

* change name to _nd

* fix test cases, add new kernel

* test name fix.

* solve gpu memory problem for size and shape

* get rid of FIgnoreInputs attr of shape_nd

* op name change

* fix

* retrigger CI

* retrigger CI

* retrigger CI

* trigger CI

* fix comments

* cpplint

* nit

* trigger CI
2018-06-29 18:05:38 -07:00
Ziyue Huang 04eb7f1600 [MXNET-394] concat of CSR NDArrays on first dimension (#11024)
* concat of csr ndarrays on first dimension

* update

* update

* trigger

* CR comments

* update docs and sparse op alias

* CR comments

* update

* update
2018-06-10 10:45:41 -07:00
moin 5109b00b24 added ravel/unravel operators (#11025) 2018-05-30 11:59:16 -07:00
Hang Zhang 98e671e2ac [MXNET-411] Add ROI Align (#10852)
* add roi align

* lint

* cpu gpu forward consistent

* roi align from caffe2

* rois and unit-test

* for cpplint

* use pointer instead of reference for lint

* fix

* add docs

* fix vector

* more unit test

* using mshadow

* omp

* omp on channels

* remove omp due to no cpu atomic add

* use lambda func for grads

* knullop return
2018-05-23 11:30:36 -07:00
Haibin Lin 74f104ae99 [MXNET-329] deprecate contrib.SparseEmbedding (#10877)
* deprecate contrib.SparseEmbedding

* update doc

* remove sparse alias for softsign

* remove contrib.SparseEmbedding

* update doc
2018-05-11 10:40:45 -07:00
Hao Jin 35fb9ea109 fix docs for new broadcast operators (#10887) 2018-05-10 13:35:45 -07:00
Anirudh 61f86fcfdc [MXNET-347] Logical Operators AND, XOR, OR (#10679)
* logical and

* logical OR and XOR operators.

* better examples

* nits.

* elemwise operators

* non broadcast examples and tests.

* doc API

* rerun CI
2018-05-01 09:43:38 -07:00
Deokjae Lee 095921e5a1 Add missing functions to ndarray and symbol API doc (#10577) 2018-04-17 21:38:31 -07:00
Joshua Z. Zhang 549fd64518 [MXNET-306] Add slice_like operator (#10491)
* add slice_like and doc

* pass unittest and lint
2018-04-11 15:02:59 -07:00
Hang Zhang 09b880a82f [MXNET-108] Adding BilinearResize2D and AdaptiveAvgPool2d operators (#9688)
* bilinear upsample from PYTorch

* fix cpu backward

* fix indent, add req

* fix lint

* fix lint

* lint

* handle req

* add adaptive avg pooling operator

* rename to bilinear resize

* fix name

* change assertion

* rm unused var

* refactor using mshadow tensor

* rm devicetensor, only using mshadow

* add docs

* naming

* merge

* Revert "merge"

This reverts commit a2a809a17034c6887c1b919764ca0a2e6280e69a.

* add unit test for BilinearResize2D and AdaptiveAvgPool2D

* for test in python2, cast into float

* mv function inside

* link docs

* address the comments

* lint

* add back private ()

*  correct lint

* decleare var

* link params docs

* fix bug

* mv to contrib and upodate docs

* contrib header

* change include path for contrib

* lint

* register to contrib

* lint

* rename width, height, docs

* rename param

* Patch1 (#1)

* two shapes input

* docs

* typo

* lint

* lint
2018-04-09 10:33:37 -07:00
Hao Jin 73a0eb00c6 [MXNET-117] Sparse operator broadcast_mul/div(csr, dense) = csr (#10208)
* support broadcast_mul/div(csr, 1Ddense) = csr

* address code reviews and support broadcast_mul/div(csr, 2Ddense) = csr

* add test for both 1D and 2D dense case

* address code review and fix test error

* address code review and fix test error

* added proper overrides for basic arithmetic functions for sparse tensors.

* fix broadcast dimension

* address code reviews
2018-04-05 12:46:51 -07:00
Deokjae Lee 9bbdc16f95 [MXNET-68] Random shuffle implementation (#10048)
* Random shuffle implementation

This operator randomly shuffles an NDArray along the first axis. The order of the elements in each subarray does not change. For exmaple, if an NDArray `x` is shuffled, the order of the subarrays `x[i]` randomly changes but the order of the elements in each `x[i]` does not change. It is modeled on `numpy.random.shuffle`.

In cpu, the shuffling of an 1D array is delegated to `__gnu_parallel::random_shuffle`, which utilizes openmp, for clang on linux and gcc on any OS and delegated to `std::shuffle` for other platforms. For an multidimensional array, the usual Fisher-Yates shuffling is implemented.

In gpu, it shuffles the array of indices representing the subarrays and then rearrange the elements of the data array according to the shuffled index array. To shuffle the index array, a random key is generated for each index and then the indices are sorted by the keys. The sorting is delegated to mshadow's `SortByKey` which again delegates the call to thrust's `sort_by_key`.

* Refactoring to avoid a preprocessing problem in Windows build

* Cosmetic changes

* Typo

* Adding const keyword at several places

* Fix the bug that integer arrays are not allowed

* Revise the comments to explain the unit test

* Add a check for correct array shape

* Revised unit test with larger arrays

* Replace the custom hash with 'str'

* Fix a bug due to the integer arithmetic in python2

* Revise comments for the unit test

* Fix the invalid fix in the commit f240714c

* Update random.md

* Update random.md
2018-03-20 15:30:30 -07:00
Xingjian Shi 279ccb1c77 [MXNET-58]Layer Normalization in C++ (#10029)
* add layer_norm + fix batch_norm doc

* add test

* add layer normaliation in Gluon

* update

* fix __repr__ + lint

* fix doc

* fix threshold

* fix doc

* fix bug

* enable inplace + fix test

* try to fix test

* fix doc
2018-03-09 17:36:58 -08:00
Ziyue Huang dedfd2d607 sparse regression operators (#9625)
* sparse regression ops

* add elemadd(dns, csr)

* address comments and fix

* replace copy with mshadow_op::identity

* add kWriteInplace check

* elemwise broadcast add

* less template instantiation

* not instantiate broadcast_add

* remove DnsCsrOP instantiation in elemwise_binary

* lint

* remove two regression ops

* enable binary op

* disable binary broadcast

* fix

* duplicate some codes in binary_broadcst

* try to make names short

* try to make names short for infer stype

* disbale sparse broadcst_add

* revert binary broadcast

* update

* disable MAE

* disable DnsCsrOp

* remove IType

* remove binary

* update

* address comments

* update

* try to fix R-test MF

* Revert "try to fix R-test MF"

This reverts commit f6d3e17ea7f5a71d23d81375bf345147a4373a93.

* remove grad_req check for label

* address comments

* trigger CI
2018-03-03 20:13:48 +08:00
Haibin Lin fc9e70bf2d Improve sparse adagrad update (#9651)
* fix adagrad

* add test

* fix lint

* CR comments

* remove raise in python

* enhance unit test

* revert wd changes

* revert dense op changes
2018-03-03 14:12:23 +08:00
Haibin Lin 8e9798cb97 add where op with sparse condition (#9481)
* add where op with csr condition

* remove typo

* fix lint

* fix doc

* rebase

* fix doc

* CR comments

* fix
2018-01-30 19:07:14 -08:00
thinksanky 1fc46e0a2a Broken Link Fixes (#9562)
* fixed broken links from the latest blc check

* added two files in faq from how_to

* removed the two backslahes typo

* git mv files from how_to to faq and fixed the Camel case in security.md
2018-01-25 12:33:02 -08:00
Haibin Lin 461673736d add norm operator for sparse ndarray (#9479)
* add norm(row_sparse)

* add doc

* add example in doc

* address commnts

* rebase

* add knullop check
2018-01-20 16:03:56 -08:00
Haibin Lin 546b73accf Add clarification in sparse api doc (#9282)
* Update sparse.md

* Update sparse.md
2018-01-03 19:46:27 -08:00
Sheng Zha fd45517614 Doc src and fix (#8718)
* add viewcode

* fix formatting
2017-11-19 21:57:15 -08:00
Eric Junyuan Xie a8f79bc6ac fix random docs (#8676) 2017-11-18 21:15:59 -08:00
Haibin Lin 257ad1d90d Doc updates for sparse operators (#8641)
* doc updates

* arithmetics and symbols

* add sparse embed to sym

* fix lint

* minor updates

* remove arithemtic changes

* remove unused test

* fix lint

* add note for optimizers

* misc-updates

* add check_fmt
2017-11-18 13:35:26 -08:00
Anirudh Subramanian 63d5394c41 Add asscipy feature (#8362)
* Add asscipy support and coo format support

* Comment misalignment change

* Add documentation for Sparse NDarray

* Change comment

* Adding comments and support for dtype

* Modifying tests

* Add spsp None check

* Fix lint
2017-11-04 17:10:10 -07:00
Sheng Zha dd3853f997 fluent methods for missed ops (#8329) 2017-10-17 22:57:20 -07:00
Haibin Lin b1d8e7cb79 scipy style sparse ndarray constructor and misc sparse fixes (#8261)
* fix rowsparsepull usage in the example

* update csr_matrix interface

* update rowsparse tutorials

* update csr/rsp constructor code&doc

* doc & bug fixes

* fix empty

* bug fix for desnity=0

* fix lint

* add more unit tests

* reduce test run time

* update infer shape test

* add one more test case with list
2017-10-14 16:19:52 -07:00
Sheng Zha db374b19d8 doc update (#8088)
* doc update

* keep blocks in nn namespace
2017-09-30 11:18:19 -07:00
Haibin Lin 6452fe681e More sparse related docs (#7911)
* more sparse related docs

* fix lint

* fix grammar

* raise exception on unimplemented aux type for sparse
2017-09-27 14:27:20 -07:00
mseeger 68181ef42d Operator linalg_syevd: Symmetric eigendecomposition (#7966) 2017-09-27 11:34:42 -07:00
Yao Wang d3bd262510 Refactor api table of contents (#7840)
* Fix API table of contents

* Add back model
2017-09-10 22:21:15 -07:00
Haibin Lin 2abee10abd correct file path for API reference auto index (#7818)
* correct path for autoindex.js

* correct path for ImageRecordDataset
2017-09-09 15:25:14 -07:00
Haibin Lin 10a72c8275 Python symbol/ndarray api re-org (#7712)
* add ndarray folder

* add sparse.md draft

* update sparse.md

* add contrib, linalg, random to ndarray.md

* add contrib, linalg random to symbol

* add sparse.md

* update notes and op docs for sparse

* remove unused files

* add back random & la

* fix inherited methods for sparse ndarray

* remove speical members

* fix lint

* add contrib

* add random.md
2017-09-07 13:45:21 -07:00