Skip to content

Conversation

@soumith
Copy link
Contributor

@soumith soumith commented Feb 21, 2019

Fixes #15508

int cur_target = THLongTensor_fastGetLegacy1dNoScalars(target, i) - TH_INDEX_BASE;

if (cur_target >= 0 && cur_target < n_classes) {
if ((cur_target >= 0 && cur_target < n_classes) || (cur_target == ignore_index)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be better if you move the inner if (cur_target == ignore_index) { block outside this?

@soumith
Copy link
Contributor Author

soumith commented Feb 21, 2019

@pytorchbot rebase this please

@pytorchbot
Copy link
Collaborator

Sorry, I can't rebase this because the author of this PR didn't grant maintainers permission to modify the branch.

Hey @soumith! If you click the Allow edits from maintainers checkbox on the right sidebar, I can rebase PRs automatically from you. Please consider letting me help you out ;)

(To learn more about this bot, see Bot commands.)

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soumith is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

zdevito pushed a commit to zdevito/ATen that referenced this pull request Mar 5, 2019
Summary:
Fixes pytorch/pytorch#15508
Pull Request resolved: pytorch/pytorch#17328

Differential Revision: D14322629

Pulled By: soumith

fbshipit-source-id: 7d02f372be78794782c18affcfc109ce30b1e91c
@soumith soumith deleted the nll_bug branch April 7, 2019 03:57
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.

target out of bounds error in cross entropy

6 participants