-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[C++ Frontend] Kaiming Initialization #14718
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you build PyTorch from source (see CONTRIBUTING.md), there will be a test_api binary in the build folder (use find test_api if you can't find it). You can filter tests by using `test_api --gtest_filter="TestSuite.TestCase" -- see https://github.com/abseil/googletest/blob/master/googletest/docs/primer.md. You'd want to add your test here
|
Hi @goldsborough, any update on this PR? |
|
Sorry for the delay, I've made the changes but haven't quite figured out how to run the tests. I'll try to get them running ASAP. I'd be interested in adding tests to this PR. |
|
@JoshVarty where are you getting stuck? Have you located the |
|
@goldsborough I can't seem to find the binary, but I do see a folder called I'm running: Which returns: P.S. I believe there's a PyTorch Slack right? If it's easier, we could discuss this build stuff there. I sent a couple emails to slack@pytorch.org last week but I haven't heard back. |
|
You should run |
|
I wanted to reimplement these tests in C++ but I'm having trouble because those tests use Is there a similar implementation in C++? Or would I essentially be looking at re-implementing this SciPy functionality? If I'd have to reimplement it, it may be better to create a new issue and discuss that approach there. One positive is that it would also allow us to test the |
|
@JoshVarty One thing you can do is verify that the output in C++ matches that in Python. We do this for the optimizers for example: https://github.com/pytorch/pytorch/blob/master/test/cpp/api/optim_baseline.py For this, you'd write a small PyTorch script that generates a C++ header file containing some constants for every test case, and then include that header in the C++ test file, and compare the output of the same code in C++ to the Python outputs you generated. What do you think of this idea? |
|
@goldsborough is this ready to go? |
|
@ezyang It is not because there are no tests yet. @JoshVarty are you still interested in wrapping up this PR by adding some tests? It looks great so far, thanks for your work. |
|
Yeah I would like to add the tests. I haven't had much time to look at this over the holidays but I anticipate I'll have some free time this week to look at it again. |
|
Hi. |
|
I wiped my Ubuntu partition and started from scratch and that seems to have got everything working again. I've started the baselines and will create the C++ tests shortly. |
|
@JoshVarty Could you pull master into your branch to fix the macos test errors? Thanks :) |
|
@yf225 I merged |
|
@JoshVarty the current CI errors are unrelated and can be ignored @goldsborough @fmassa do you think the tests look good and the PR is ready to go? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @JoshVarty, thanks! I left a few comments on things that could be improved, like the lambdas in init.cpp and moving the other nn::init-related tests into init.cpp. I'll approve it already, and merge it once you have time for the last few fixes
|
@goldsborough This is probably good for another review if you get a minute. I think the only outstanding issue is my comment/question about how to handle the lambdas. |
|
Looks great, I'll land it tomorrow. Thanks again! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@goldsborough is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@goldsborough is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@goldsborough is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

/cc @goldsborough
Working on #14582
The corresponding python implementations are at: pytorch/torch/nn/init.py
Here is my initial implementation of Kaiming Initialization. I have not been able to figure out how to successfully run tests locally so I haven't added any yet.
A couple questions:
python setup.py test? Can I run just a subset of the tests somehow?