Skip to content

Ensure RNNCell variants don't broadcast#4074

Merged
apaszke merged 5 commits intopytorch:masterfrom
zou3519:rnncell-no-broadcast
Dec 11, 2017
Merged

Ensure RNNCell variants don't broadcast#4074
apaszke merged 5 commits intopytorch:masterfrom
zou3519:rnncell-no-broadcast

Conversation

@zou3519
Copy link
Copy Markdown
Contributor

@zou3519 zou3519 commented Dec 7, 2017

Fixes #3789.

Before this change the following behavior occurs:

RNNCell supports input/hidden broadcasting on CPU and GPU
GRUCell and LSTMCell support input/hidden broadcasting on CPU but not GPU

This makes it so that none of them support broadcasting and that a clear error message is thrown.

Test Plan

Unit test to check that runtime error is thrown

@pietern
Copy link
Copy Markdown
Contributor

pietern commented Dec 7, 2017

There was some CI maintenance happening this morning -- retriggering build.

@pytorchbot retest this please

Comment thread test/test_nn.py Outdated
test(nn.RNNCell, bad_hx, hidden_size)
test(nn.GRUCell, bad_hx, hidden_size)
test(nn.LSTMCell, (bad_hx, good_hx), hidden_size)
test(nn.LSTMCell, (good_hx, bad_hx), hidden_size)

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread test/test_nn.py Outdated
test(nn.RNNCell, bad_hx, hidden_size)
test(nn.GRUCell, bad_hx, hidden_size)
test(nn.LSTMCell, (bad_hx, good_hx), hidden_size)
test(nn.LSTMCell, (good_hx, bad_hx), hidden_size)

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread torch/nn/modules/rnn.py Outdated
self.check_batch_size(input, hx[0], '[0]')
self.check_batch_size(input, hx[1], '[1]')
self.check_forward_inputs(input, hx[0], '[0]')
self.check_forward_inputs(input, hx[1], '[1]')

This comment was marked as off-topic.

@apaszke apaszke merged commit 77dfdbf into pytorch:master Dec 11, 2017
@zou3519 zou3519 deleted the rnncell-no-broadcast branch January 3, 2018 19:58
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
* Ensure RNNCell variants don't broadcast

* Fix lint

* Add test for hidden_size=1 in RNNCell no broadcasting test

* Prevent broadcasting for hidden_size and input_size

* Isolate input checking from hidden size checking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants