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

Sparse Tensor: request for reviews #7082

Merged
merged 87 commits into from
Aug 22, 2017

Conversation

eric-haibin-lin
Copy link
Member

@eric-haibin-lin eric-haibin-lin commented Jul 18, 2017

Following please find a summary of changes made for sparse tensor feature on CPU.

Note: this PR contains duplicate code in PR #7015

Frontend Interfaces

NDArray Class Hierarchy

-> NDArrayBase (root)
-> NDArray
-> SparseNDArray
-> RowSparseNDArray, CSRNDArray

Sparse Storage Types Overview

Two storage formats are supported: row_sparse and csr.

Functionality Overview

operators with sparse inputs

A list of operators in this PR include:

  • Arithmetics: elemwise_add(row_sparse), dot(csr, row_sparse), dot(csr, dense)
  • Conversion: cast_storage(csr<->dense), cast_storage(row_sparse<->dense)
  • Indexing: sparse_retain(row_sparse), slice(csr)
  • Creation: zeros(row_sparse), zeros(csr)

iterators and IO utils functions

  • NDArrayIter with CSRNDArray
  • LibsvmIter which reads files in libsvm format and produces CSRNDArray
  • load/save RowSparseNDArray/CSRNDArray

kvstore and optimizer with sparse gradient updates

  • sgd_update(row_sparse) and sgd_mom_update(row_sparse) will update rows of the weight where the gradient of the row contains nonzeros.
  • kv.push with row_sparse gradient, which only sends over the nonzero gradients over the network
  • kv.row_sparse_pull with row_ids, which only pulls back a RowSparseNDArray with specified row_id over the network

unsupported functionality

There's a list of basic functionality supported in NDArray, but is either not supported or inefficient in SparseNDArray:

  • get/set an element in CSRNDArray/RowSparseNDArray by index (not supported)
  • reshape in CSRNDArray/RowSparseNDArray (not supported)
  • _slice, _at in CSRNDArray/RowSparseNDArray (not supported)
  • inplace add/sub/mul/div/mod, broadcast_to in CSRNDArray/RowSparseNDArray (not efficient)

Please refer to the TODO list for a list of ongoing/planned operators.

Backend Interfaces

NDArray

NDArray uses storage_type to determine what storage format to use to represent a tensor.

enum NDArrayStorageType {
  kUndefinedStorage = -1,  // undefined storage
  kDefaultStorage,         // dense
  kRowSparseStorage,       // row sparse
  kCSRStorage,             // csr
};

Some of the important interfaces added to NDArray are:

NDArray {
  // constructor
  NDArray(const NDArrayStorageType stype, const TShape &shape, Context ctx,
          bool delay_alloc = true, int dtype = mshadow::default_type_flag,
          std::vector<int> aux_types = {}, std::vector<TShape> aux_shapes = {},
          TShape storage_shape = TShape(mshadow::Shape1(0)))
  // memory allocation
  void CheckAndAllocData(const TShape &storage_shape) const; 
  void CheckAndAllocAuxData(size_t i, const TShape &aux_shape) const;

  struct Chunk {
    Storage::Handle shandle;
    // storage handles for aux data (e.g. indptr, indices)
    std::vector<Storage::Handle> aux_handles;
    NDArrayStorageType storage_type;
    std::vector<int> aux_types;
    TShape storage_shape;
    std::vector<TShape> aux_shapes;
    void CheckAndAllocData(const TShape &shape, int dtype);
    void CheckAndAllocAuxData(size_t i, const TShape &shape);
  };
...

 void CopyFromTo(const NDArray &from, NDArray *to) {
    // if storage_types of from & to don't match, convert to destination storage type
    // perform copy...
 }

Executor and NNVM

operator interface

To deal with tensors of non-default storage, operators need to register with the following interface:

using FComputeEx = std::function<void (
        const nnvm::NodeAttrs& attrs,
        const OpContext& ctx,
        const std::vector<NDArray>& inputs,
        const std::vector<OpReqType>& req,
        const std::vector<NDArray>& outputs)>;

Since memory usage for sparse tensor cannot be calculated during graph binding phase, operator is expected to use CheckAndAllocAuxData and CheckAndAllocData to perform memory allocation for result tensors at runtime.

infer_storage_type pass

Besides FInferShape and FInferType, an operator needs to register FInferStorageType if it involves non-default storage_type. ctx could be used to infer if MKL experimental memory should be used. The attribute __storage_type__ of mx.sym.Variable is read for this pass.

using FInferStorageType = std::function<bool (
        const NodeAttrs& attrs,
        const Context& ctx,
        std::vector<int>* in_attrs,
        std::vector<int>* out_attrs)>;

When binding a graph, InferStorageType pass will be applied to infer graph entries with unknown storage_type. The pass is implemented in MXNet instead of NNVM. infer_type and infer_shape passes are both moved from NNVM to MXNet.

plan_memory pass

For node entries of non-default storage_type, they're annotated with kDynamicStorageID; memory are neither requested nor released. No memory sharing optimization is applied.

memory allocation and sharing

For node entries of kDefaultStorage(i.e. dense storage), memory allocation and sharing is done as usual. For node entries of non-default storage_type, memory allocation is delayed to runtime. No memory sharing is applied to these entries even when shared_exec is provided.

executor dispatch and storage fallback

For each node in graph, if it involves non-default storage in either its inputs or outputs, FComputeExExecutor will be created if FComputeEx attribute is registered.

If FComputeEx is not registered, an FComputeExcutor/FStatefulComputeExcutor will be created, inputs with non-default storage will be converted to NDArrays with default (i.e. dense) storage; the outputs will be converted back to non-default storage if necessary. The converted NDArrays are temporary and will be released when there's no reference to them.

kvstore

Sparse gradient update requires a parameter to be initialized as row_sparse format in kvstore. If an optimizer is registered with FComputeEx, then the update may only involve the rows with non-zero gradients. Gradients are sent in row_sparse format to reduce the stress on network bandwidth.

For distributed training, kRowSparsePushPull mode is introduced so that row ids of the row_sparse gradients are encoded as keys by kvstore workers. When the kvstore server receives the message, it constructs a row_sparse gradient NDArray based on the row ids decoded from it and applies the optimizer to the weight. The memory for parameters are pre-allocated on parameter servers, instead of storing weight row by row.

TODO list

Operators

  • elemwise binary & unary operators (row_sparse): done, to be merged in another PR
    negative, square, abs, sqrt, round, ceil, floor, fix, elemwise_add, elemwise_sub, elemwise_div, elemwise_mul, _maximum, _minimum, _mul_scalar
  • elemwise binary & unary operators (csr): ongoing
    negative, square, broadcast_mul, _mul_scalar
  • inplace broadcast_add, broadcast_sub, _mul_scalar operators
  • broadcast operators (csr)
  • broadcast operators (row_sparse)
  • elemwise operators(csr)
  • _sync_copy_from with scipy.sparse.csr_matrix input
  • asscipy (csr)

kvstore and optimizer

  • lazy initialization - postpone parameter initialization to kvstore server
  • storing row_sparse weight by rows to support weights of > 2 billion rows. This avoid pre-allocating memory for row_sparse weight and reduces memory consumption at kvstore servers.
  • other optimizers for sparse gradient update (e.g. adam)

List of important files

NDArray related files:

  • ndarray.h
  • c_api.h
  • ndarray.cc
  • common/utils.h

Executor related files:

  • c_api_executor.h
  • attach_op_exec_pass.cc
  • graph_attr_types.h
  • op_attr_types.h
  • executor.h
  • graph_executor.h
  • graph_executor.cc
  • infer_graph_attr_pass.cc
  • inplace_addto_detect_pass.cc

Kvstore related files:

from . import op
from .op import CachedOp
from .ndarray import NDArray, array, concatenate, _DTYPE_NP_TO_MX, _DTYPE_MX_TO_NP
from .ndarray import empty, ones, add, arange, divide, equal, full, greater, greater_equal, imdecode
Copy link
Contributor

Choose a reason for hiding this comment

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

It's ok to use wild card import

Copy link
Member Author

Choose a reason for hiding this comment

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

will fix this in next PR

NDArray out = output;
FillZerosRspImpl(s, &out);
return;
}
TShape shape = input.aux_shape(rowsparse::kIdx);
Copy link
Member Author

@eric-haibin-lin eric-haibin-lin Jul 18, 2017

Choose a reason for hiding this comment

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

@cjolivier01 maybe you fixed it already but just in case you haven't. This bug may lead to test failure for binary/unary ops

eric-haibin-lin and others added 11 commits July 25, 2017 15:41
* squash

merge with 38f7c55

compiles on GPU

update check alloc:

Checkpoint. Pass elem-sum gpu test

bug fix for copyfromto. sparse sgd test pass on gpu

inefficient implementation for csr copy

update submodule

fix lint

Simple bind with infer storage type (#32)

* Symbol binding for sparse tensor development. (#31)

* Initial checkin

* Add init functions for simple bind in graph_executor

* Add simple_bind c_api

* Add simple bind c-api

* Assign zeros to in_args, arg_grads, and aux_states

* Add simple_bind2 python interface

* Fix python interface bugs

* Interface changes

* Fix

* Fix core dump

* Add bind_ith_exec c_api

* Change simple_bind2

* Fix seg fault

* Finish simple_bind

* Change _bind_ith_exec

* Refactor simple_bind initialization flow for bind

* Consolidate bind and simple_bind graph init flow

* Fix bug

* Clean up

* Add comments

* Clean up

* Clean up

* Minor correction

* Rename APIs in graph executor

* Refactor

* Rebase

* Delete deprecated functions

* Move more front-end work to backend

* Bug fix

* Fix failed tests

* Minor fix

* Fix lint

* Fix lint

* Revert unnecessary changes

* Revert

* Revert

* Clean up

* Fix lint

Conflicts:
	python/mxnet/symbol.py
	src/executor/graph_executor.cc

* Add inferstorage to graph executor

* re-enable tests for sparse embedding with simple_bind

* type switch fix in sparse embedding"
;

change `default` to `default_storage` for cast storage op (#33)

* change default to default_storage

* disable cpp test build temporarily

attempt to fix windows build error, and fix lint (#34)

update nnvm submodule (#37)

Scipy build (#38)

* update nnvm submodule

* add scipy pip install for dockerfile

Python3 unit tests (#39)

* change xrange to range for python3 compatiblity"

* remove more xrange from tests

replace long with int for python3 (#40)

fix the rest of TShape constructor errors (#41)

fix lint (#42)

fix wrong usage of mshadow::Shape1" (#43)

implementation for Csr slice on cpu (#36)

* CPU implementation for CSR

remove seg_len from csr slice

add some docs for slice csr

change indptr, values, etc to be private member

bug fix in sparse embedding

update nnvm submoduel

fix lint

update unit test for sparse nd"

* add const for SliceCsrIndPtr kernel

Fix sparse dot according to the new RSP definition (#35)

* Fix csr dot dns

* Fix sparse dot

* Add fallback and test cases for dot(csr, dns)=dns

* Add int type switch

* Fix

* Fix

* Fix

update mshadow submodule (#44)

Fix dns to rsp (#46)

fix lint (#47)

add runtime storage fallback detection" (#48)

* add runtime storage fallback detection"

* replace cast storage ex with cast storage impl

Fm example (#45)

* update csr slice logic to avoid confusion. add more exmaples.

* add hint to module.update

* more testcases(fallback) for sparse_nd

* add to_csr() and to_rsp() method. More unit test (fallback now)

* add fm test. fix lint

* register sparse sgd under Optim.SGD

* update dmlc-core submoduel

* change indptr to _indptr temporarily. add const ref to fname

fix lint

fix lint; (#51)

Guard gpu cast storage (#50)

* Clean up

* Fix typo

Rearrange unit test files (#52)

fix lint. add scipy for python_test. fix scipy.sparse import error. fix truediv for python3

fix travis test (#54)

* remove pyc files

* add verbose for travis nosetests

cleanup some testing code and enums (#57)

* update Makefile

* refactor test_sparse_operator

* change `default_storage` back to `default`

* remove unused cpp tests

port libsvm parser to mxnet as libsvm iter (#55)

* copied csv iter to libsvm iter

test

libsvm iter draft

handle round batch == false for csr batch loader

code refactoring

add get stype, shape interface to iiter

separate class for sparse iter

add missing file

fix mem corruption'

rename variables

add comments

also read label from libsvm

add test. update docs. update submodule

Conflicts:
	python/mxnet/sparse_ndarray.py

* update submodule

* fix lint

* update test

* revert naming change

add benchmark scritp for dot (#59)

* add benchmark scritp for dot

add gpu option for bench

add get_data funciton for benchmark

print t_sparse, too;

add comment

change nnz to dnesity

add backward

* add comment

update fm test (#62)

introduce CSRNDarray and rowsparseNDarray to python frontend api (#58)

* introduce CSRNDarray and rowsparseNDarray to python frontend api

* temporarily disable fm_module test

fix lint (#64)

fix typo. disable libsvm io test (#65)

Improve dot (#61)

* Init checkin

* Fix

* Adjust dot parallelization methods

* Set num_omp_threads for benchmark from command line

* Fix omp thread number

* Clean up

* Add scipy as dot baseline

* Fix format

sparse_retain op (#66)

* Initial checkin

* Fix bugs

* Add unit test for sparse_retain

* Add example and modify test

add storage cast for outputs that have non-default storage (#67)

fix gpu build (#69)

Fix test_sparse_retain python3 issue (#68)

revert nnvm version

* draft for sgd rsp rsp (#75)

support sgd(rsp, rsp)

support dot(csr, rsp) when rsp is full

add ref to const ndarray params

support sparse embedding with rsp weight'

fix lint

modify embedding backward to produce dense grad

remove invalid_rid for rsp->dns

remove previous embedding op changes

pass sparse embedding test

add STORAGE_TYPE_ASSIGN_CHECK

remove backward storage infer

* fix lint (#78)

* fix lint (#79)

* serial elemwise sum impl (#80)

update module kvstore interface

add other missing params and functions

revert some interface changes

revert some more changes

reomve explicit casting for gradients on kvstore

update Comm interface

update fm example

Conflicts:
	python/mxnet/model.py
	python/mxnet/ndarray.py

* bug fix for initializing module with row_sparse weight (#81)

* bug fix for initializing module with row_sparse weight

* update log message

* Sparse ndarray serialization and deserialization (#77)

* Initial checkin

* Add unit tests

* Fix lint

* Fix lint (#84)

* Sgd with row_sparse weight, dns gradient (#83)

* sgd rsp dns draft

* support sgd_mom(rsp, dns, rsp)

* update doc

* remove cast storage for kv updater

* code refactoring

* update mshadow version (#88)

* csr slice bug fix (#90)

* benchmark dot code refactor (#87)

* q^x6x add some code in benchmark

* refactor

* minor fixes

* fix

* lint fix

* Add unit test (#91)

* add unittest

* minor fix

* remove commented lines

* change test func name

* add test rsp

* kvstore push row sparse (#93)

* Add multi-thread cpu elemwise sum for rsps

* Minor fix

* Add flag to switch between serial and multi-thread kvstore push

* Fix lint in sparse_ndarray.py

* Revert "Fix lint in sparse_ndarray.py"

This reverts commit d7225ec.

* Fix ndarray init in copy(ctx)

* Add env var to control the flow of serial/parallel reduce

* Refactor

* Fix copy ndarray bug

* Fix lint

* Refactor

* Fix windows openmp build failure (#94)

* update mshadow submoduel (#95)

* Revert "update mshadow submoduel (#95)" (#96)

This reverts commit 1a129e4.

* Refactor sparse tensor code (#99)

* Initial checkin test_sparse_ndarray passes

* Fix test failure

* Clean up

* Clean up

* Move init backend op to ndarray_utils

* Fix lint

* Eliminate circular dependency on headers

* More refactor

* Fix gpu build and consolidate Slice for dense and sparse

* Clean up

* More refactor

* Clean up

* Fix gpu build

* Fix comment

* fix pylint (#100)

* Fix refactor sparse gpu test (#104)

* Fix gpu build

* Fix

* Fix gpu test failure

* change idx types from int32 to int64 (#101)

Conflicts:
	python/mxnet/test_utils.py
	tests/python/unittest/test_sparse_operator.py

update mshadow submodule

fix extra quotes in test script

change indptr type to int64

better err message for rsp"

* revert LOG(DEBUG) change (#105)

* fix undefined zeros in optimizer.py (#106)

* move init dns zeros to init_op.h for kvstore to use (#107)

* Refactor cast storage (#109)

* Refactor cast_storage

* Add cast_storage cc and cu files

* Remove redundant comments

* Replace std::accumulate with ParallelAccumulate

* Clean up

* Fix windows build

* Rowsparse kv (#111)

* update kvstore unit test

Conflicts:
	tests/python/unittest/test_kvstore.py

update model/module.py

Conflicts:
	python/mxnet/model.py
	python/mxnet/module/module.py

fix lint

resolve conflict

remove int keys in kvstore

update cast to str function

* fix failed dist_sync_kv test

* bug fix in comm to ensure merged gradient is of the right type

bug fix in comm

* row sparse dist kvstore draft (push only)

row_sparse pull

* add ndarray row sparse shared mem constructor

* code refactoring

* add test for row_sparse weight

bug fix for kv server slicing

add async support

rsolve race condition in kvstore

* resolve error after reb ase

* fix lint (#113)

* rename some python funciton (#114)

* _to_rsp

* _to_csr. raise NotImplementedError

* todense

* fix lint (#115)

enable libsvm uniit test (apache#6839)

remove shared mem slice for csr

add csr ndarray iter test

make osx nose test verbose

disable libsvm iter test

Move InferAttr to mxnet from nnvm (apache#6830)

* Move InferAttr to mxnet from nnvm

Replace nnvm infer attr functions in c_api

Initial checkin

Clean up

Remove nnvm namespace for FInferShape, FInferType, and FInferStorageType

Add new interface for InferStorageType

Revert "Remove nnvm namespace for FInferShape, FInferType, and FInferStorageType"

This reverts commit 8aedf05.

Fix and clean up

Fix lint

Add nnvm changes

Change infer function interface to accept only rvalue reference of graph

Clean up

Flush commits to show up in PR

Add error handling for storage type inference failure

Update nnvm

* Fix pylint

Change idx type switch for aux data (apache#6860)

* Change idx type switch for aux data

* Add mshadow commit

Sparse dot enhancement (apache#6842)

* Initial checkin

Initial checkin

Fix sparse dot test

Fix unitest and add fallback for sparse dot

* Add benchmark code

* Revert "Add benchmark code"

This reverts commit be009fe.

* Fix bug

* Fix storage shape

* Remove unnecessary test code

* Use idx type switch

Implement dot(csr, rsp)=dns and dot(csr.T, rsp)=rsp and refactor (apache#6902)

* Initial checkin

Add dot(csr.T, rsp)=rsp2

Add infer storage for dot(csr, rsp)=dns and dot(csr.T, rsp)=rsp2

* Fix comments

* Replace std::lower_bound with own impl for gpu use too

* Add time profiling

* Revert "Add time profiling"

This reverts commit 8f5bb98.

* Move dot and batch_dot to a single file

* Move dot gpu impl to a .cuh file

* More refactor

* Fix include error

LibsvmIter fix (apache#6898)

* fix bug in libsvm iter which causes mem corruption

* add test for news dataset

* fix wrong path in test

* fix import error for urllib

* update url

* replace bz command with bz module

Optimized gpu dot kernels (apache#6937)

* pulled update to mshadow

* mshadow update

* added optimized gpu kernels for dot(csr,dns)=dns and dot(csr.T,dns)=dns, and unit test

* added __syncwarp to vector kernel and reduced number of writes to shared memory

Refactor sparse tensor code (apache#6955)

* Save stype in frontend to avoid c-api call for stype

* Change storage_type to stype

* Revert "Change storage_type to stype"

This reverts commit 90db7d1.

* Revert "Revert "Change storage_type to stype""

This reverts commit 0932838.

Move ndarray.py, sparse_ndarray.py, ndarray_utils.py, and _ndarray_internal to ndarrary folder

More refactor

Move elementwise sum for rsp to ndarray_function.cc

Remove unnecessary import in ndarray module

Fix pylint

Remove redundant code

Remove _stype from slots

Fix cpp-package build error caused by the change to imperative invoke interface

Use relative import

Remove print line

Rename _ndarray_internal.py to _internal.py

* Relaunch test...

minor bug fix in warp synchronous code (apache#7029)
* move storage type vector from nnvm to mxnet

* update nnvm

* update nnvm
* Use cast_storage when copying ndarrays of different stypes on same context

* Relaunch test
fix lint

fix lint
* skip sparse dot gpu tset. add sparse_nd_zeros gpu test

* remove sparse_retain gpu

Conflicts:
	tests/python/gpu/test_operator_gpu.py
* Fix getting sparse ndarray data/aux_data issues

* Add tests for func csr and row_sparse

* Make get/set data/aux_data thread safe

* Fix a bug

* Fix typo and comment

* More comments

* Correct comment

Conflicts:
	tests/python/gpu/test_operator_gpu.py
* remove check for k dimensional rowsparse tensor

* change var name for rsp sgd operator

* add checks for sparse dot

* bug fix for kdim rowsparse cast storage cpu

* update IdentityLikeRhsComputeEx interface

* remove set_storage_shape from ndarray. support elemwise_add with kdim row_sparse tensor

* use get_with_shape instead of reshape

* update according to comments

Conflicts:
	src/operator/tensor/elemwise_unary_op.h
* add test for broadcast_to

* add comments

Conflicts:
	python/mxnet/base.py
fix bug in rsp add

rsp sync push

race condition for push

fix bug in rsp pull. refactor test

cleanup comments

refactor dist server

fix lint

fix storage shape issue with the new ndarray constructor

data sharding draft;

fix lint. add comment

add support for zeros gradients

use std::upper_bound/lower_bound

remove special init function for rowsparse dist kvstore

temporary support for inplace operators for sparse

add test. fix return type

store kRowSparseNDArray in kv server

remove fcomp_ex sgd with dns weight and rsp gradient

bug fix in sparse retain

sparse pull c_api

revise rowsparse pull api

use engine to compute unique to ensure thread safety

add rowsparse pull to dist-kv

fix lint

add example for rsp_pull

remove name2idx;

add sparse_pull_dict param to module

fix unit test and  c rowid conversion

support str key type in kvstore (apache#6765)

* update kvstore unit test

* update model/module.py

* fix lint

* remove int keys in kvstore

* update cast to str function

* remove _cast_to_str_keys

* fix lint

* always cast to str

Conflicts:
	include/mxnet/c_api.h
	include/mxnet/kvstore.h
	python/mxnet/kvstore.py
	python/mxnet/model.py
	python/mxnet/module/module.py
	src/c_api/c_api.cc
	src/kvstore/kvstore_local.h
	tests/python/unittest/test_kvstore.py

update module API for other submodules

update stypes in kvstore after refactoring

change type of size from size_t to int64_t

add sparse linear regression example

remove sparse_pull_dict from module

fix init_optim for seq_module. update sparse example

resolve conflict for binary add rsp rsp

Conflicts:
	python/mxnet/kvstore.py
	tests/python/unittest/test_kvstore.py
@eric-haibin-lin eric-haibin-lin changed the title [WIP] Sparse Tensor Sparse Tensor: request for reviews Jul 26, 2017
@eric-haibin-lin
Copy link
Member Author

@ZihengJiang @szha @anirudh2290 @stefanhenneking @madjam @cjolivier01
@tqchen @jermainewang @piiswrong @mli @pluskid @ykim362 @formath @reminisce

It's probably not feasible to review all the operators implemented, but I'd appreciate if important changes made to NDArray, executor and kvstore are reviewed. Any help is appreciated!

*/
MXNET_DLL int MXNDArraySyncCopyFromNDArray(NDArrayHandle handle_dst,
const NDArrayHandle handle_src,
const int i);
Copy link
Contributor

@ZihengJiang ZihengJiang Jul 26, 2017

Choose a reason for hiding this comment

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

suggest renaming i to data_idx

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

i could either be used to indicate data or aux_data, not sure if data_idx is a good name either.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with @eric-haibin-lin. As long as it's documented clearly in the comment, it's fine to use i.

@@ -439,12 +846,12 @@ class NDArray {
* \param from the ndarray we want to copy data from
* \param to the target ndarray
* \param priority Priority of the action.
* \param alloc_output whether to allocate memory for the output ndarray
Copy link
Contributor

Choose a reason for hiding this comment

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

removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing this out. will remove this comment, too

@jermainewang
Copy link
Contributor

Great job! Did you consider use the storage format proposed by http://people.csail.mit.edu/fred/tensor-compiler-techreport.pdf ? It seems to me that adding more storage formats is quite tedious (e.g. CSC, BCSR, DCSR, etc.). It will be great that we can define the storage format in a hierarchical way so future extension will be much easier.

stefanhenneking and others added 3 commits July 27, 2017 21:38
* Added gpu implementation for cast_storage dense to csr, unit tests, and benchmark. Additionally, cast_storage interface change to accommodate the need of temporary storage in cuda kernels.

* fixed whitespace

* minor unittest update

* removed whitespace

* add cast storage benchmark params info

Conflicts:
	tests/python/gpu/test_operator_gpu.py
* Add square_sum op

* Add unit test and fix check_numeric_gradient

* Add .cu file and example

* Fix lint

* Remove gpu registration

* Use square_sum in test_module_fm
eric-haibin-lin and others added 17 commits August 16, 2017 22:10
* Add get_synthetic_datasets

* Move to test_utils

* Remove _get_uniform_dataset

* Move validation to its own function

* Refactor the validation code for csr generation

* Make test_powerlaw a nested function

* Change SparseNDArray to CSRNDArray

* Refactoring changes to dot.py

* Fix mxnet test_utils changes

* Remove pdb statement

* Add distribution parameter

* Refactor benchmarking script

* Remove unused code

* Make style changes and remove unused code

* Change typo in comment

* Add transpose support

* Change typo

* 4 decimal points needed for density

* Add rsp support for real datasets

* Correct variable name mini_file_name

* Move wait_to_read outside if

* Seperate out scipy and mxnet logic in bench_dot

* Fix lhs_trans issue

* Move transpose outside measure_cost

* Compute transpose inside measure_cost

* Remove unused variables
* avoid cast_storage in dist-kvstore-server

* add stream arg to mshadow;;copy

* fix copy order
* Register dot, cast_storage, and sparse_retain under mxnet.ndarray.sparse

* Add sparse to symbol namespace

* Delete commented code

* mv sparse_ndarray.py sparse.py

* Clean up

* Change docstring
* remove scipy dependency

* move kvstore checks to backned

* add const to lambda
* add clarification for csr

* cr comments
@piiswrong
Copy link
Contributor

Since this cannot be rebased I'll just squash it into one commit

@piiswrong piiswrong merged commit 0b13631 into apache:master Aug 22, 2017
@eric-haibin-lin eric-haibin-lin deleted the dmlc-sparse-squash branch September 15, 2017 04:56
@fredrikbk
Copy link

fredrikbk commented Sep 22, 2017

Hi @eric-haibin-lin, @jermainewang, @piiswrong, all,

I'm one of the tacoers (or maybe the demonym is tacos?). I know that this pull request is closed, but I wanted to add a comment on taco. We're thinking about taco on GPUs, since it is a requirement for entry for at least ML. We think it can be done, but that it's going to be a fair amount of work to make it fast. We'll likely be working on it this spring.

There's also a preprint for our upcoming OOPSLA paper, which is much better than the tech report, at http://people.csail.mit.edu/fred/tensor-compiler-preprint.pdf.

@goswamig
Copy link
Contributor

goswamig commented Oct 10, 2017

test_kvstore_gpu.test_row_sparse_pull seems to a bit flaky and has been failing randomly for egin recent following builds 475, 482. I'll create an issue for this.
Note that kv_store test runs after the "test test_forward.test_consistency" finishes.

crazy-cat pushed a commit to crazy-cat/incubator-mxnet that referenced this pull request Oct 26, 2017
* [WIP] Sparse Tensor  (apache#5800)

* squash

merge with 38f7c55

compiles on GPU

update check alloc:

Checkpoint. Pass elem-sum gpu test

bug fix for copyfromto. sparse sgd test pass on gpu

inefficient implementation for csr copy

update submodule

fix lint

Simple bind with infer storage type (apache#32)

* Symbol binding for sparse tensor development. (apache#31)

* Initial checkin

* Add init functions for simple bind in graph_executor

* Add simple_bind c_api

* Add simple bind c-api

* Assign zeros to in_args, arg_grads, and aux_states

* Add simple_bind2 python interface

* Fix python interface bugs

* Interface changes

* Fix

* Fix core dump

* Add bind_ith_exec c_api

* Change simple_bind2

* Fix seg fault

* Finish simple_bind

* Change _bind_ith_exec

* Refactor simple_bind initialization flow for bind

* Consolidate bind and simple_bind graph init flow

* Fix bug

* Clean up

* Add comments

* Clean up

* Clean up

* Minor correction

* Rename APIs in graph executor

* Refactor

* Rebase

* Delete deprecated functions

* Move more front-end work to backend

* Bug fix

* Fix failed tests

* Minor fix

* Fix lint

* Fix lint

* Revert unnecessary changes

* Revert

* Revert

* Clean up

* Fix lint

Conflicts:
	python/mxnet/symbol.py
	src/executor/graph_executor.cc

* Add inferstorage to graph executor

* re-enable tests for sparse embedding with simple_bind

* type switch fix in sparse embedding"
;

change `default` to `default_storage` for cast storage op (apache#33)

* change default to default_storage

* disable cpp test build temporarily

attempt to fix windows build error, and fix lint (apache#34)

update nnvm submodule (apache#37)

Scipy build (apache#38)

* update nnvm submodule

* add scipy pip install for dockerfile

Python3 unit tests (apache#39)

* change xrange to range for python3 compatiblity"

* remove more xrange from tests

replace long with int for python3 (apache#40)

fix the rest of TShape constructor errors (apache#41)

fix lint (apache#42)

fix wrong usage of mshadow::Shape1" (apache#43)

implementation for Csr slice on cpu (apache#36)

* CPU implementation for CSR

remove seg_len from csr slice

add some docs for slice csr

change indptr, values, etc to be private member

bug fix in sparse embedding

update nnvm submoduel

fix lint

update unit test for sparse nd"

* add const for SliceCsrIndPtr kernel

Fix sparse dot according to the new RSP definition (apache#35)

* Fix csr dot dns

* Fix sparse dot

* Add fallback and test cases for dot(csr, dns)=dns

* Add int type switch

* Fix

* Fix

* Fix

update mshadow submodule (apache#44)

Fix dns to rsp (apache#46)

fix lint (apache#47)

add runtime storage fallback detection" (apache#48)

* add runtime storage fallback detection"

* replace cast storage ex with cast storage impl

Fm example (apache#45)

* update csr slice logic to avoid confusion. add more exmaples.

* add hint to module.update

* more testcases(fallback) for sparse_nd

* add to_csr() and to_rsp() method. More unit test (fallback now)

* add fm test. fix lint

* register sparse sgd under Optim.SGD

* update dmlc-core submoduel

* change indptr to _indptr temporarily. add const ref to fname

fix lint

fix lint; (apache#51)

Guard gpu cast storage (apache#50)

* Clean up

* Fix typo

Rearrange unit test files (apache#52)

fix lint. add scipy for python_test. fix scipy.sparse import error. fix truediv for python3

fix travis test (apache#54)

* remove pyc files

* add verbose for travis nosetests

cleanup some testing code and enums (apache#57)

* update Makefile

* refactor test_sparse_operator

* change `default_storage` back to `default`

* remove unused cpp tests

port libsvm parser to mxnet as libsvm iter (apache#55)

* copied csv iter to libsvm iter

test

libsvm iter draft

handle round batch == false for csr batch loader

code refactoring

add get stype, shape interface to iiter

separate class for sparse iter

add missing file

fix mem corruption'

rename variables

add comments

also read label from libsvm

add test. update docs. update submodule

Conflicts:
	python/mxnet/sparse_ndarray.py

* update submodule

* fix lint

* update test

* revert naming change

add benchmark scritp for dot (apache#59)

* add benchmark scritp for dot

add gpu option for bench

add get_data funciton for benchmark

print t_sparse, too;

add comment

change nnz to dnesity

add backward

* add comment

update fm test (apache#62)

introduce CSRNDarray and rowsparseNDarray to python frontend api (apache#58)

* introduce CSRNDarray and rowsparseNDarray to python frontend api

* temporarily disable fm_module test

fix lint (apache#64)

fix typo. disable libsvm io test (apache#65)

Improve dot (apache#61)

* Init checkin

* Fix

* Adjust dot parallelization methods

* Set num_omp_threads for benchmark from command line

* Fix omp thread number

* Clean up

* Add scipy as dot baseline

* Fix format

sparse_retain op (apache#66)

* Initial checkin

* Fix bugs

* Add unit test for sparse_retain

* Add example and modify test

add storage cast for outputs that have non-default storage (apache#67)

fix gpu build (apache#69)

Fix test_sparse_retain python3 issue (apache#68)

revert nnvm version

* draft for sgd rsp rsp (apache#75)

support sgd(rsp, rsp)

support dot(csr, rsp) when rsp is full

add ref to const ndarray params

support sparse embedding with rsp weight'

fix lint

modify embedding backward to produce dense grad

remove invalid_rid for rsp->dns

remove previous embedding op changes

pass sparse embedding test

add STORAGE_TYPE_ASSIGN_CHECK

remove backward storage infer

* fix lint (apache#78)

* fix lint (apache#79)

* serial elemwise sum impl (apache#80)

update module kvstore interface

add other missing params and functions

revert some interface changes

revert some more changes

reomve explicit casting for gradients on kvstore

update Comm interface

update fm example

Conflicts:
	python/mxnet/model.py
	python/mxnet/ndarray.py

* bug fix for initializing module with row_sparse weight (apache#81)

* bug fix for initializing module with row_sparse weight

* update log message

* Sparse ndarray serialization and deserialization (apache#77)

* Initial checkin

* Add unit tests

* Fix lint

* Fix lint (apache#84)

* Sgd with row_sparse weight, dns gradient (apache#83)

* sgd rsp dns draft

* support sgd_mom(rsp, dns, rsp)

* update doc

* remove cast storage for kv updater

* code refactoring

* update mshadow version (apache#88)

* csr slice bug fix (apache#90)

* benchmark dot code refactor (apache#87)

* q^x6x add some code in benchmark

* refactor

* minor fixes

* fix

* lint fix

* Add unit test (apache#91)

* add unittest

* minor fix

* remove commented lines

* change test func name

* add test rsp

* kvstore push row sparse (apache#93)

* Add multi-thread cpu elemwise sum for rsps

* Minor fix

* Add flag to switch between serial and multi-thread kvstore push

* Fix lint in sparse_ndarray.py

* Revert "Fix lint in sparse_ndarray.py"

This reverts commit d7225ec.

* Fix ndarray init in copy(ctx)

* Add env var to control the flow of serial/parallel reduce

* Refactor

* Fix copy ndarray bug

* Fix lint

* Refactor

* Fix windows openmp build failure (apache#94)

* update mshadow submoduel (apache#95)

* Revert "update mshadow submoduel (apache#95)" (apache#96)

This reverts commit 1a129e4.

* Refactor sparse tensor code (apache#99)

* Initial checkin test_sparse_ndarray passes

* Fix test failure

* Clean up

* Clean up

* Move init backend op to ndarray_utils

* Fix lint

* Eliminate circular dependency on headers

* More refactor

* Fix gpu build and consolidate Slice for dense and sparse

* Clean up

* More refactor

* Clean up

* Fix gpu build

* Fix comment

* fix pylint (apache#100)

* Fix refactor sparse gpu test (apache#104)

* Fix gpu build

* Fix

* Fix gpu test failure

* change idx types from int32 to int64 (apache#101)

Conflicts:
	python/mxnet/test_utils.py
	tests/python/unittest/test_sparse_operator.py

update mshadow submodule

fix extra quotes in test script

change indptr type to int64

better err message for rsp"

* revert LOG(DEBUG) change (apache#105)

* fix undefined zeros in optimizer.py (apache#106)

* move init dns zeros to init_op.h for kvstore to use (apache#107)

* Refactor cast storage (apache#109)

* Refactor cast_storage

* Add cast_storage cc and cu files

* Remove redundant comments

* Replace std::accumulate with ParallelAccumulate

* Clean up

* Fix windows build

* Rowsparse kv (apache#111)

* update kvstore unit test

Conflicts:
	tests/python/unittest/test_kvstore.py

update model/module.py

Conflicts:
	python/mxnet/model.py
	python/mxnet/module/module.py

fix lint

resolve conflict

remove int keys in kvstore

update cast to str function

* fix failed dist_sync_kv test

* bug fix in comm to ensure merged gradient is of the right type

bug fix in comm

* row sparse dist kvstore draft (push only)

row_sparse pull

* add ndarray row sparse shared mem constructor

* code refactoring

* add test for row_sparse weight

bug fix for kv server slicing

add async support

rsolve race condition in kvstore

* resolve error after reb ase

* fix lint (apache#113)

* rename some python funciton (apache#114)

* _to_rsp

* _to_csr. raise NotImplementedError

* todense

* fix lint (apache#115)

enable libsvm uniit test (apache#6839)

remove shared mem slice for csr

add csr ndarray iter test

make osx nose test verbose

disable libsvm iter test

Move InferAttr to mxnet from nnvm (apache#6830)

* Move InferAttr to mxnet from nnvm

Replace nnvm infer attr functions in c_api

Initial checkin

Clean up

Remove nnvm namespace for FInferShape, FInferType, and FInferStorageType

Add new interface for InferStorageType

Revert "Remove nnvm namespace for FInferShape, FInferType, and FInferStorageType"

This reverts commit 8aedf05.

Fix and clean up

Fix lint

Add nnvm changes

Change infer function interface to accept only rvalue reference of graph

Clean up

Flush commits to show up in PR

Add error handling for storage type inference failure

Update nnvm

* Fix pylint

Change idx type switch for aux data (apache#6860)

* Change idx type switch for aux data

* Add mshadow commit

Sparse dot enhancement (apache#6842)

* Initial checkin

Initial checkin

Fix sparse dot test

Fix unitest and add fallback for sparse dot

* Add benchmark code

* Revert "Add benchmark code"

This reverts commit be009fe.

* Fix bug

* Fix storage shape

* Remove unnecessary test code

* Use idx type switch

Implement dot(csr, rsp)=dns and dot(csr.T, rsp)=rsp and refactor (apache#6902)

* Initial checkin

Add dot(csr.T, rsp)=rsp2

Add infer storage for dot(csr, rsp)=dns and dot(csr.T, rsp)=rsp2

* Fix comments

* Replace std::lower_bound with own impl for gpu use too

* Add time profiling

* Revert "Add time profiling"

This reverts commit 8f5bb98.

* Move dot and batch_dot to a single file

* Move dot gpu impl to a .cuh file

* More refactor

* Fix include error

LibsvmIter fix (apache#6898)

* fix bug in libsvm iter which causes mem corruption

* add test for news dataset

* fix wrong path in test

* fix import error for urllib

* update url

* replace bz command with bz module

Optimized gpu dot kernels (apache#6937)

* pulled update to mshadow

* mshadow update

* added optimized gpu kernels for dot(csr,dns)=dns and dot(csr.T,dns)=dns, and unit test

* added __syncwarp to vector kernel and reduced number of writes to shared memory

Refactor sparse tensor code (apache#6955)

* Save stype in frontend to avoid c-api call for stype

* Change storage_type to stype

* Revert "Change storage_type to stype"

This reverts commit 90db7d1.

* Revert "Revert "Change storage_type to stype""

This reverts commit 0932838.

Move ndarray.py, sparse_ndarray.py, ndarray_utils.py, and _ndarray_internal to ndarrary folder

More refactor

Move elementwise sum for rsp to ndarray_function.cc

Remove unnecessary import in ndarray module

Fix pylint

Remove redundant code

Remove _stype from slots

Fix cpp-package build error caused by the change to imperative invoke interface

Use relative import

Remove print line

Rename _ndarray_internal.py to _internal.py

* Relaunch test...

minor bug fix in warp synchronous code (apache#7029)

* move storage type vector from nnvm to mxnet (apache#7054)

* move storage type vector from nnvm to mxnet

* update nnvm

* update nnvm

* Improve copy sparse tensors (apache#7003)

* Use cast_storage when copying ndarrays of different stypes on same context

* Relaunch test

* fix failed tests. add back 64bit support for dot

fix lint

* bug fix for IdentityComputeRsp

* fix lint

fix lint

fix lint

* add data partition for libsvm iter (apache#7027)

* remove sparse embedding (apache#7165)

* fix ndarray namespace

* remove untested gpu operators (apache#7172)

* skip sparse dot gpu tset. add sparse_nd_zeros gpu test

* remove sparse_retain gpu

Conflicts:
	tests/python/gpu/test_operator_gpu.py

* Fix ndarray aux data issue (apache#7098)

* Fix getting sparse ndarray data/aux_data issues

* Add tests for func csr and row_sparse

* Make get/set data/aux_data thread safe

* Fix a bug

* Fix typo and comment

* More comments

* Correct comment

Conflicts:
	tests/python/gpu/test_operator_gpu.py

* Support K-dimensional row-sparse tensor (apache#7179)

* remove check for k dimensional rowsparse tensor

* change var name for rsp sgd operator

* add checks for sparse dot

* bug fix for kdim rowsparse cast storage cpu

* update IdentityLikeRhsComputeEx interface

* remove set_storage_shape from ndarray. support elemwise_add with kdim row_sparse tensor

* use get_with_shape instead of reshape

* update according to comments

Conflicts:
	src/operator/tensor/elemwise_unary_op.h

* Improve sparse ndarray error message (apache#7181)

* add test for broadcast_to

* add comments

Conflicts:
	python/mxnet/base.py

* construct row_sparse ndarray for dist-async

fix bug in rsp add

rsp sync push

race condition for push

fix bug in rsp pull. refactor test

cleanup comments

refactor dist server

fix lint

fix storage shape issue with the new ndarray constructor

data sharding draft;

fix lint. add comment

add support for zeros gradients

use std::upper_bound/lower_bound

remove special init function for rowsparse dist kvstore

temporary support for inplace operators for sparse

add test. fix return type

store kRowSparseNDArray in kv server

remove fcomp_ex sgd with dns weight and rsp gradient

bug fix in sparse retain

sparse pull c_api

revise rowsparse pull api

use engine to compute unique to ensure thread safety

add rowsparse pull to dist-kv

fix lint

add example for rsp_pull

remove name2idx;

add sparse_pull_dict param to module

fix unit test and  c rowid conversion

support str key type in kvstore (apache#6765)

* update kvstore unit test

* update model/module.py

* fix lint

* remove int keys in kvstore

* update cast to str function

* remove _cast_to_str_keys

* fix lint

* always cast to str

Conflicts:
	include/mxnet/c_api.h
	include/mxnet/kvstore.h
	python/mxnet/kvstore.py
	python/mxnet/model.py
	python/mxnet/module/module.py
	src/c_api/c_api.cc
	src/kvstore/kvstore_local.h
	tests/python/unittest/test_kvstore.py

update module API for other submodules

update stypes in kvstore after refactoring

change type of size from size_t to int64_t

add sparse linear regression example

remove sparse_pull_dict from module

fix init_optim for seq_module. update sparse example

resolve conflict for binary add rsp rsp

Conflicts:
	python/mxnet/kvstore.py
	tests/python/unittest/test_kvstore.py

* fix DotCsrRspRspImpl error message (apache#7191)

* GPU implementation of cast_storage (dense to csr) (apache#7081)

* Added gpu implementation for cast_storage dense to csr, unit tests, and benchmark. Additionally, cast_storage interface change to accommodate the need of temporary storage in cuda kernels.

* fixed whitespace

* minor unittest update

* removed whitespace

* add cast storage benchmark params info

Conflicts:
	tests/python/gpu/test_operator_gpu.py

* Sparse square sum (apache#7206)

* Add square_sum op

* Add unit test and fix check_numeric_gradient

* Add .cu file and example

* Fix lint

* Remove gpu registration

* Use square_sum in test_module_fm

* Modify and Add documentation for mx.nd.zeros (apache#7197)

* Modify and Add documentation for mx.nd.zeros

* Change context to cpu

* Change stype to optional

* Change ordering and remove optional for _zeros_sparse_ndarray

* Expose kWriteInplace for imperative execution (fcompute_ex and fstatefulcompute_ex) (apache#133)

* expose kWriteInplace to FComputeEx and FStatefulComputeEx

* refactor ccode

* remove duplicated test

* Operator add_n for row sparse ndarrays (apache#7244)

* Add add_n op for row-sparse ndarrays and identity FComputeEx

* Fix bug in square_sum

* Remove test_cast_storage_ex from gpu test since it's not implemented yet

* Fix according to the cr

Conflicts:
	src/operator/tensor/elemwise_sum.cc
	src/operator/tensor/elemwise_unary_op.cc
	tests/python/gpu/test_operator_gpu.py

resolve conflict

* GPU implementation of cast_storage (dense to rsp) (apache#7223)

* CastStorageDnsRsp GPU Implementation

* updating function doc and some variable types and names

* adding cuda_get_device_prop() util function

* added rand_shape function for n-dimensional tensors

* updated cast storage unit test

* added dns_to_rsp to cast storage benchmark script

* removing redundant unit test

* fix lint

* minor change in benchmark script

* fix lint

* correct function description

* change storage_type to stype

* changed scope of using namespaces

* changed variable types from index_t to dim_t

* resolve merge conflict in ndarray.load

* Improve StatefulOp/FCompute storage fallback (apache#134)

* test for fcomp fallback

add storage fallback test and optimize fallback logic

rename function, add comments

use std size()

* add autograd test with sparse inputs

* update sparse ndarray api (apache#139)

* support mx.nd.empty for sparse ndarray

Change SparseNDArray to BaseSparseNDArray

support mx.nd.array with BaseSparseNDArray inputs. Update documentation with explicit subclasses of NDArrays

Conflicts:
	python/mxnet/ndarray/__init__.py
	python/mxnet/ndarray/ndarray.py
	python/mxnet/ndarray/sparse_ndarray.py
	tests/python/unittest/test_sparse_ndarray.py

* fix print msg in test

* Handle ograd_stype='row_sparse' for square_sum backward (apache#143)

* Add one kernel for square_sum backward pass to take rsp ograd

* Add kNullOp and change to use type_assign in infer stype fallback

* Sparse retain improvement (apache#138)

* Add one more kernel for sparse retain

* Fix compile

* Change STORAGE_TYPE_ASSIGN_CHECK to type_assign for fallback

* Fix

* Add gpu compile

* ignoring variables in SimpleBind that is used on python's sparse branch for now. (apache#135)

* add bias term to fm test (apache#145)

* update ndarray.nd, remove `invoke` from excluded members (apache#137)

remove __weakref__ from SparseNDArray

add data indice to doc

revert dlpack update

revert mxdoc changes

move methods from BaseSparseNDarray to csrndarray and rwosparse ndarray

* support storage fallback with mutable inputs (apache#147)

* include mutatable inputs in storage fallback. refactor executor

add fallback test for rms prop and adam

fix lint

fix lint

fix test in optimizer

*  update according to comments

* fix unit tests

* fix gpu compilation err

* Code changes based on reviews (apache#144)

* code changes according to review comments

remove executor debug. add doc to optimizer

update sparse sgd test

add dtype option to rand_sparse_ndarray

* overhauled reqs for sparse operators

* patch FCompExFallback with mutable inputs. update test_optimizer with more fallback cases

* change executor debug macro to env var

* add comment

* update doc

* change ndarray.aux_shape() to return const reference

* remove todense to_rsp to_csr. replace with tostype

* replace manual calls to cast_storage with tostype

* disable gpu fallback test for optimizer

* fix lint

* add backward pass for cast_storage. refactor cast_storage test

* rand_sparse_ndarray bug fix

* fix cast_storage for gpu

* disable csr test for fp16

* update row sparse ndarray doc

* update doc

* small edits according to reviews (apache#151)

* fix lint (apache#152)

* add license to all new files in sparse brnach (apache#154)

* Allocate temp data on the fly for some casting operations (apache#149)

* fix utf8 encoding in sparse ndarray

* Extending the GPU dot operator (apache#7226)

* Added GPU DotCsrRspDnsImpl declaration and TODOs

* cleaning up function doc, variable types, and code-style

* minor bug fixes

* enable GPU dot(csr,rsp)=dns unit test

* extend sparse dot unit test

* adding GPU impl of DotCsrRspDns and its kernels

* add TODO

* changed variable types from index_t to dim_t

* fix function description

* added DotCsrRspRspImpl and its kernels (baseline, functionality)

* added DotCsrDnsRspImpl and its kernels (baseline, functionality); plus code documentation

* refactored dot benchmark

* optimized DotCsrTransDnsRsp GPU kernel

* change of dot impl interface to include OpContext, for temp storage

* removing __device__ flag from CPU kernels

* minor fixes and changing variable data types

* minor fixes based on code reviews

Conflicts:
	benchmark/python/sparse_op.py
	tests/python/gpu/test_operator_gpu.py
	tests/python/unittest/test_sparse_operator.py

* Add get_synthetic_dataset function to util (apache#146)

* Add get_synthetic_datasets

* Move to test_utils

* Remove _get_uniform_dataset

* Move validation to its own function

* Refactor the validation code for csr generation

* Make test_powerlaw a nested function

* Change SparseNDArray to CSRNDArray

* Merge with dtype specific changes in test_utils

* temporary fix for batch norm storage fallback (apache#156)

* support random_uniform/normal/gamma with row_sparse output (apache#155)

* add support for initilazer with rowsparse output

* add scalar assignment to row_sparse

* add setitem test to gpu

* Revert "add scalar assignment to row_sparse"

This reverts commit 8aef7a5.

* Revert "add setitem test to gpu"

This reverts commit 3b969ac.

* Square sum backward support one more case (apache#161)

* Add documentation for sparse ops (apache#148)

*  draft doc for sparse op

* add more stype doc for operators

* add doc for cast_storage

* see also cast_storage. remove base sparse ndarray. fix aux_types comemtn

* grammar / spelling fix

* A few fixes (apache#163)

* fix batch norm gpu kernel. register random operators on gpu

* register sparse random op on gpu, too

* Minor fixes sparse ops (apache#160)

* change CPU kernel inline directives, data types, and function doc

* update dot dtype switch to use 32 and 64bit floating point only

* use type_assign instead of STORAGE_TYPE_ASSIGN_CHECK

* added tensor_util-inl.cuh file for common tensor operator GPU kernels

* sparse Adam optimizer (apache#164)

*  add sparse adam

* register gpu op

* add comments

* cr comments

* kvstore.row_sparse_pull for GPU and end-to-end benchmark: CPU vs. multi-GPUs (apache#150)

* Add gpu support for BroadcastRowSparse

* Fix bugs

* Add benchmark script

* Increase output dim size

* Update weight on CPU using single GPU for sparse tensors

* More fix

* Optimize sparse_retain for special case

* Change row sparse pull locations

* Avoid sparse retain on cpu if possible

* Use acc for metric

* Fix misc

* fix bug in adam update (apache#167)

fix a bug in adam update

* change sparse example from regression to classification (apache#165)

* fix python import (apache#166)

* Add waitall to sparse_end2end.py (apache#169)

* Add waitall()

* Add dummy metric option

* Add header license

* Dot script changes (apache#159)

* Add get_synthetic_datasets

* Move to test_utils

* Remove _get_uniform_dataset

* Move validation to its own function

* Refactor the validation code for csr generation

* Make test_powerlaw a nested function

* Change SparseNDArray to CSRNDArray

* Refactoring changes to dot.py

* Fix mxnet test_utils changes

* Remove pdb statement

* Add distribution parameter

* Refactor benchmarking script

* Remove unused code

* Make style changes and remove unused code

* Change typo in comment

* Add transpose support

* Change typo

* 4 decimal points needed for density

* Add rsp support for real datasets

* Correct variable name mini_file_name

* Move wait_to_read outside if

* Seperate out scipy and mxnet logic in bench_dot

* Fix lhs_trans issue

* Move transpose outside measure_cost

* Compute transpose inside measure_cost

* Remove unused variables

* Transpose only if trans_lhs (apache#171)

* fix default val for distribution (apache#172)

* fix lint (apache#175)

* avoid cast_storage in dist-kvstore-server (apache#174)

* avoid cast_storage in dist-kvstore-server

* add stream arg to mshadow;;copy

* fix copy order

* Add sparse namespace to ndarray and symbol (apache#177)

* Register dot, cast_storage, and sparse_retain under mxnet.ndarray.sparse

* Add sparse to symbol namespace

* Delete commented code

* mv sparse_ndarray.py sparse.py

* Clean up

* Change docstring

* changes based on code reviews (apache#176)

* remove scipy dependency

* move kvstore checks to backned

* add const to lambda

* temp fix to ndarray.md (apache#178)

* Fix sparse namespace pylint (apache#179)

* add comments and error msg (apache#181)

* add clarification for csr (apache#182)

* add clarification for csr

* cr comments

* revert change in test util (apache#183)

* fix amalgamation (apache#184)

* fix lint
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet