Skip to content

Conversation

@driazati
Copy link
Contributor

@driazati driazati commented Mar 19, 2019

Previously to get a list of parameters this code was just putting them in the reverse order in which they were defined, which is not always right. This PR allows parameter lists to define the order themselves. To do this parameter lists need to have a corresponding function that provides the names of the parameters.

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Mar 19, 2019
Copy link
Contributor

@eellison eellison left a comment

Choose a reason for hiding this comment

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

Sorry what exactly was the issue previously and what is the new behavior?

ConstantParameterList(std::shared_ptr<Module> module)
: module_(std::move(module)) {}
ConstantParameterList(std::shared_ptr<Module> module, py::list params)
: module_(std::move(module)), params_(std::move(params)) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe convert & store the params to std::string here ? i imagine that's less overhead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It'd be more since it would duplicate the strings, the py::list is just a thin wrapper around a Python list with the same reference semantics

return self._flat_weights

def _get_flat_weights_names(self):
all_weights = [[weight for weight in weights] for weights in self._all_weights]
Copy link
Contributor

Choose a reason for hiding this comment

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

imo the 4 weight(s) on one line is kidn of confusing


def _get_flat_weights_names(self):
all_weights = [[weight for weight in weights] for weights in self._all_weights]
return [p for layerparams in all_weights for p in layerparams]
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto with the two layerparams / ps

davidriazati added 2 commits March 21, 2019 11:15
@driazati
Copy link
Contributor Author

driazati commented Apr 2, 2019

@eellison clarified reasons in PR message

@driazati driazati requested review from eellison and suo April 4, 2019 17:18
Copy link
Contributor

@eellison eellison left a comment

Choose a reason for hiding this comment

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

Looks good, a little hard to follow.

@_parameter_list
def get_flat_weights(self):
def _get_flat_weights_names(self):
return [weight for weights in self._all_weights for weight in weights]
Copy link
Contributor

Choose a reason for hiding this comment

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

do you mean rewriting? This is hard to read

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.

@driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

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.

@driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

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.

@driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@driazati merged this pull request in f543563.

zhangguanheng66 pushed a commit to zhangguanheng66/pytorch that referenced this pull request May 6, 2019
Summary:
Previously to get a list of parameters this code was just putting them in the reverse order in which they were defined, which is not always right. This PR allows parameter lists to define the order themselves. To do this parameter lists need to have a corresponding function that provides the names of the parameters.
Pull Request resolved: pytorch#18198

Differential Revision: D14966270

Pulled By: driazati

fbshipit-source-id: 59331aa59408660069785906304b2088c19534b2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants