Implement a Caffe2 standalone LSTM operator (#17461)
authorAhmed Aly <ahhegazy@fb.com>
Wed, 6 Mar 2019 01:31:51 +0000 (17:31 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 6 Mar 2019 01:34:44 +0000 (17:34 -0800)
commitbfe7a58f6999579715217e5adc375578687c0288
treeac698ed4102c2440267d940e6ba3253be82b5671
parenta478d416203b0e3934e2b1aaa6e05d838be748e7
Implement a Caffe2 standalone LSTM operator (#17461)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17461

Implementing a standalone LSTM Operator in Caffe2 adopted from this Aten implementation: diffusion/FBS/browse/master/fbcode/caffe2/aten/src/ATen/native/RNN.cpp. The most tricky thing in this exercise was that caffe2::Tensor has no copy constructor that made it necessary to implement a custom templated copy constructor for the different Tensor containers used in the code. Also there was no way to use off-the-shelf C2 operators in my code easily so I had to copy some code that is doing basic matmul, cat, split, transpose and linear as utility functions.

Two things missing:

- Profiling this implementation against the current ONNXified LSTM op
- Make this operator available to use in PyTorch

Reviewed By: dzhulgakov

Differential Revision: D14160172

fbshipit-source-id: c33e3f9e8aeae578b64d97593cb031a251216029
caffe2/operators/inference_lstm_op.cc [new file with mode: 0644]
caffe2/operators/inference_lstm_op.h [new file with mode: 0644]
caffe2/operators/lstm_utils.h [new file with mode: 0644]
caffe2/python/test/inference_lstm_op_test.py [new file with mode: 0644]