Conversation
c4ff053 to
d225b51
Compare
* New "sparse/size" representation * Full LSTM in C * VSeqLSTM to wrap this data representation + C implementation * Augmentation of the VariableLength decorator with this data representation from an array of tensors * unit tests * speed tests
d225b51 to
8f8677a
Compare
mirandaconrado
requested changes
Jun 4, 2017
Collaborator
mirandaconrado
left a comment
There was a problem hiding this comment.
The code itself looks good in general. There are lots of small changes that I think should be made either for correctness or clarity.
| typedef int THInteger_t; | ||
| typedef void THRNNState; | ||
|
|
||
| #define THRNN_resizeAs_indices(I1, I2) \ |
Collaborator
There was a problem hiding this comment.
Put the code in the macro between brackets for safety.
| #include <omp.h> | ||
| #endif | ||
|
|
||
| /* Set tensor->size[0] MACRO */ |
Collaborator
There was a problem hiding this comment.
Not only first position.
| #define THRNN_LSTM_SET_SIZE(t, dim, newSize) ( t->size[dim] = newSize ) | ||
| #endif | ||
|
|
||
| /* Set tensor->size[0] MACRO */ |
Collaborator
There was a problem hiding this comment.
Not only first and stride.
| // and a LongStorage of default sizes for new individual buffers | ||
| struct THRNN_(buffer)* THRNN_(create_buffer)(THTensor* buf, THLongStorage* default_buffer_sizes) | ||
| { | ||
| THTensor** arr; |
| buffer->sizes = (int*)realloc(buffer->sizes, buffer->len * sizeof(int)); | ||
| buffer->sizes[buffer->len-1] = size; | ||
| buffer->array = (THTensor**)realloc(buffer->array, buffer->len * sizeof(THTensor**)); | ||
| THTensor* new_guy = THTensor_(new)(); |
| self.cgradInput = self.cgradInput:type(first_input:type()) | ||
| self._input = self._input or first_input.new() | ||
| self._input = self._input:type(first_input:type()) | ||
| self._input = self._input or {} |
Collaborator
There was a problem hiding this comment.
self._input will always be defined as a tensor in the last line
| local input = torch.Tensor(seqlen, batchsize, inputsize):uniform() | ||
| local gradOutput = torch.Tensor(seqlen, batchsize, outputsize):uniform() | ||
|
|
||
| local t = torch.Timer() |
Collaborator
There was a problem hiding this comment.
t as replaced by tic/toc
| end | ||
| -- main test | ||
| collectgarbage() | ||
| t:reset() |
| end | ||
| end | ||
|
|
||
| function rnntest.SeqLSTM_vs_VSeqLSTM() |
Collaborator
There was a problem hiding this comment.
This benchmark is duplicated above, except that one uses double and the other float.
| if not testLM then | ||
| for i=1,batchSize do | ||
| input[i] = torch.randn(torch.random(1,maxLength), hiddenSize) | ||
| input[i] = torch.randn(i,hiddenSize)--torch.random(1,maxLength), hiddenSize) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pure C implementation for LSTMs with basic LSTM cell, including pre-multiplication and CUDA-like input format [(sum(T_i)) X outputSize], where T_i are the number of timesteps for each element of the batch, in decreasing value.