You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/03/16 00:39:25 UTC
[GitHub] [incubator-mxnet] haojin2 opened a new pull request #14445: Speedup
SequenceMask on GPU
haojin2 opened a new pull request #14445: Speedup SequenceMask on GPU
URL: https://github.com/apache/incubator-mxnet/pull/14445
## Description ##
As title. Address #14124.
## Checklist ##
### Essentials ###
Please feel free to remove inapplicable items for your PR.
- [x] The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant [JIRA issue](https://issues.apache.org/jira/projects/MXNET/issues) created (except PRs with tiny changes)
- [x] Changes are complete (i.e. I finished coding on this PR)
- [x] All changes have test coverage:
- Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
- Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
- Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
- [x] Code is well-documented:
- For user-facing API changes, API doc string has been updated.
- For new C++ functions in header files, their functionalities and arguments are documented.
- For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
- Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
- [x] To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
### Changes ###
- [x] Customized kernel for GPU
## Comments ##
benchmark results on sample workload from #14124:
forward only: 48.589637756347656 ms -> 0.5544562339782715 ms 87.63x speedup
forward+backward: 97.38378977775574 ms -> 1.224109172821045 ms 79.55x speedup
```Python
import mxnet as mx
ctx = mx.gpu(0)
dshape = (8, 512, 768)
seq_length = [18., 35., 34., 100., 110., 194., 512., 10.]
dtype = 'float16'
import random
from mxnet.test_utils import check_speed, rand_ndarray
mx_data = rand_ndarray(dshape).as_in_context(ctx).astype(dtype)
mx_seq_len = mx.nd.array(seq_length).as_in_context(ctx).astype(dtype)
data = mx.sym.Variable("data")
seq_len = mx.sym.Variable("sequence_length")
mx_sym = mx.sym.SequenceMask(data=data, sequence_length=seq_len, use_sequence_length=True, value=0.0, axis=1)
print(check_speed(mx_sym, typ='forward', location={"data": mx_data, "sequence_length": mx_seq_len}, ctx=ctx, N=1000) * 1000)
print(check_speed(mx_sym, typ='whole', location={"data": mx_data, "sequence_length": mx_seq_len}, ctx=ctx, N=1000) * 1000)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services