Conversation
|
@tlby Rob, please take a look, thanks! |
tlby
left a comment
There was a problem hiding this comment.
not quite finished reading yet, but I'll wrap up soon. So far, so good though. Nice!
| epsilon => $self->epsilon, | ||
| rescale_grad => $self->rescale_grad | ||
| ); | ||
| use Data::Dumper; |
There was a problem hiding this comment.
yes, will remove, thanks for noticing.
| (blessed $label and $label->isa('AI::MXNet::NDArray::CSR'))) | ||
| and | ||
| ($self->last_batch_handle != 'discard') | ||
| ) |
There was a problem hiding this comment.
"and" and "or" at the same indent depth?
There was a problem hiding this comment.
yep, wrong indentation, will fix.
| $class; | ||
| } | ||
|
|
||
| sub not_implemented { confess "Not implemented" } |
There was a problem hiding this comment.
perhaps "..." is appropriate here? it's kinda standard for declaring abstract functions.
There was a problem hiding this comment.
please elaborate
There was a problem hiding this comment.
from the perl docs:
When Perl 5.12 or later encounters an ellipsis statement, it parses this without error, but if and when you should actually try to execute it, Perl throws an exception with the text Unimplemented
That seems to be highly aligned the Python source such as https://github.com/apache/incubator-mxnet/blob/0fe04e9d778ac9c55e933ff3f21c4ddf28a4a101/python/mxnet/ndarray/sparse.py#L118 as a pattern for the abstract methods subclasses must provide.
Your code isn't wrong, it's just reimplementing a feature the core language already has.
There was a problem hiding this comment.
Thanks man, there's a lot about Perl I still don't know.
| } | ||
|
|
||
| use B; | ||
| sub hash { hex(B::hash(shift)) } |
There was a problem hiding this comment.
Careful with this, remember the hash produced will vary from one run to the next.
There was a problem hiding this comment.
yeah I know, it's the same with Python's hash() call, so it's a feature.
| svs[i] = newSViv((*$1)[i]); | ||
| sv_2mortal(svs[i]); | ||
| } | ||
| myav = av_make(*arg4, svs); |
There was a problem hiding this comment.
I don't think you can guarantee that "arg4" will be a stable variable name for the other parameter in the function that uses this typemap, so this might blow up at some time in the future, but I'll pester you elsewhere for more details.
There was a problem hiding this comment.
I went with this solution because I needed to solve a peculiar problem of making a decision dependent on a particular input state.
You helped me in the past to clean up the swig usage, could you please see if you can come up with a solution later in separate pull that is more stable (I used this technique in another place as well in the past).
There was a problem hiding this comment.
okay, sure. I'll get more details and work out a proposal.
| int delay_alloc, | ||
| int dtype, | ||
| NDArrayHandle *out); | ||
| /*! |
There was a problem hiding this comment.
Does this file have to be updated when c_api is changed each time? Is this not automated?
There was a problem hiding this comment.
It may look like it could be automated but it can not.
It's not just a copy/paste from the c_api.h, it's a SWIG interface file and the variables names are changed to denote a way of how they should be treated to make c api to communicate with perl.
Another file called mxnet_typemaps.i in the dir has actual glue code that depends on the vars.
It's just another version of 'ctypes' .
| } | ||
| } | ||
|
|
||
| sub test_row_sparse_pull |
There was a problem hiding this comment.
Does it include the test case added a few days ago https://github.com/apache/incubator-mxnet/pull/9887/files ?
There was a problem hiding this comment.
yes, I added that test.
|
|
||
| =head2 slice | ||
|
|
||
| Returns a sliced view of this array. |
There was a problem hiding this comment.
The documentation is wrong.. Should be a copy instead of a view. I'll post a PR to fix it (in both perl and python).
* sparse feature. * moved myself to the list of commiters. * changed ImperativeInvoke to ImperativeInvokeEx. * updated MNIFEST * addressed code review * recent python's kvstore sparse changes. * using PDL. * fix docs, trigger tests.
* sparse feature. * moved myself to the list of commiters. * changed ImperativeInvoke to ImperativeInvokeEx. * updated MNIFEST * addressed code review * recent python's kvstore sparse changes. * using PDL. * fix docs, trigger tests.
* sparse feature. * moved myself to the list of commiters. * changed ImperativeInvoke to ImperativeInvokeEx. * updated MNIFEST * addressed code review * recent python's kvstore sparse changes. * using PDL. * fix docs, trigger tests.
Description
Added support for sparse tensors to Perl API
Checklist
Essentials
make lint)Changes
Comments
@eric-haibin-lin
Please check out this for sanity, it all works afaik but I may have missed something really recent.