Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make reductionInferShape conservative to fix gorgonia#384 #411

Merged
merged 2 commits into from
Jun 15, 2020
Merged

Make reductionInferShape conservative to fix gorgonia#384 #411

merged 2 commits into from
Jun 15, 2020

Conversation

wzzhu
Copy link
Contributor

@wzzhu wzzhu commented Jun 11, 2020

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
Copy link

coveralls commented Jun 11, 2020

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
Copy link
Member

chewxy commented Jun 15, 2020

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.

None yet

3 participants