8000 Make reductionInferShape conservative to fix gorgonia#384 by wzzhu · Pull Request #411 · gorgonia/gorgonia · GitHub
[go: up one dir, main page]

Skip to content

Make reductionInferShape conservative to fix gorgonia#384 - #411

Merged
chewxy merged 2 commits into
gorgonia:masterfrom
wzzhu:master
Jun 15, 2020
Merged

chewxy merged 2 commits into
gorgonia:masterfrom
wzzhu:master

Conversation

@wzzhu
@wzzhu wzzhu commented Jun 11, 2020
Copy link
Copy Markdown
Contributor

The reductionInferShape currently doesn't respect along initially.
It aggressively squeezes dimensions. Not only does it affect normal tensor operation, but also it breaks the backprop autoDiff algorithm sometimes when the network containing BroadcastAdd, resulting in crash when calling Grad().

The change tries to strictly respect the parameter along, e.g.,
(100, 1) along 0, reduction to shape (1) instead ()
(1, 64, 1, 64) along 3 will reduce to (1, 64, 1)
(64, 1, 3, 2) along (2,3) will reduce to (64, 1).

Fixed unit tests.

The reductionInferShape currently doesn't respect along initially.
It aggressively squeezes dimensions. Not only does it affect normal tensor operation, but also it breaks the backprop autoDiff algorithm sometimes when the network containing BroadcastAdd, resulting in crash when calling Grad().

The change tries to strictly respect the parameter along, e.g.,
(100, 1) along 0, reduction to shape (1) instead ()
(1, 64, 1, 64) along 3 will reduce to (1, 64, 1)
(64, 1, 3, 2) along (2,3) will reduce to (64, 1).

Fixed unit tests.
@coveralls
coveralls commented Jun 11, 2020 •
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.04%) to 64.481% when pulling 3c91bdc on wzzhu:master into 0153235 on gorgonia:master.

After changing reductionType to subtract len(along) from reduction op, SumOp's dimension need to be adjusted with it. Otherwise SymDiff will crash for Sum in calcBroadcastShap.
@chewxy
chewxy commented Jun 15, 2020
Copy link
Copy Markdown
Member

LGTM. Sorry for the late review. Life has been nuts and I barely have time at the computer

@chewxy
chewxy merged commit 15014b3 into gorgonia:master Jun 15, 2020
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

0