Skip to content

Conversation

@ShahriarRezghi
Copy link

@yf225 This is L1Loss module. I don't think that _Loss and _WeightedLoss as base Python classes do anything. First one sets reduction type and also takes in reduce parameter which is deprecated. The second one only registers weight parameter. I don't think that we should keep this structure. What do you think?

@pytorchbot pytorchbot added caffe2 module: build Build system issues module: cpp Related to C++ API labels Sep 10, 2019
@ShahriarRezghi ShahriarRezghi changed the title wrote the code C++ Loss Modules Sep 10, 2019
@yf225
Copy link
Contributor

yf225 commented Sep 10, 2019

@ShahriarSS Not keeping _Loss and _WeightedLoss sounds good, and this can likely keep the C++ code simpler.

s.backward();

ASSERT_EQ(output.sizes(), torch::IntArrayRef());
ASSERT_EQ(input.sizes(), input.grad().sizes());
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way we can also check the correctness of output value after loss->forward?

Copy link
Author

Choose a reason for hiding this comment

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

I based this on python's lL1Loss test and I think that it didn't check. What is the expected value here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, I think we can rely on the parity test to make sure the output value is in sync with the Python API.

@yf225
Copy link
Contributor

yf225 commented Sep 10, 2019

I'll also work on enabling parity test for L1Loss, and push the changes to this PR.

@yf225 yf225 removed caffe2 module: build Build system issues labels Sep 10, 2019
@pytorchbot pytorchbot added caffe2 module: build Build system issues labels Sep 10, 2019
@yf225
Copy link
Contributor

yf225 commented Sep 10, 2019

I will rename this PR to [C++ API] L1Loss module to better reflect the scope of changes.

@yf225 yf225 changed the title C++ Loss Modules [C++ API] L1Loss module Sep 10, 2019
@yf225
Copy link
Contributor

yf225 commented Sep 10, 2019

@pytorchbot rebase this please

@yf225 yf225 force-pushed the C++-loss branch 9 times, most recently from 0db0f10 to 25c1855 Compare September 10, 2019 19:28
@yf225
Copy link
Contributor

yf225 commented Sep 10, 2019

@pytorchbot rebase this please

@yf225 yf225 force-pushed the C++-loss branch 9 times, most recently from fc699ab to fa19561 Compare September 10, 2019 23:01
Copy link
Contributor

@yf225 yf225 left a comment

Choose a reason for hiding this comment

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

Thanks a lot @ShahriarSS !

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.

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

@facebook-github-bot
Copy link
Contributor

@yf225 merged this pull request in e048360.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

caffe2 Merged module: build Build system issues module: cpp Related to C++ API module: nn Related to torch.nn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants