Skip to content

Conversation

@yf225
Copy link
Contributor

@yf225 yf225 commented Sep 8, 2019

This PR makes the following improvements to C++ API parity test harness:

  1. Remove options_args since we can get the list of options from the Python module constructor args.
  2. Add test for mapping int or tuple in Python module constructor args to ExpandingArray in C++ module options.
  3. Use regex to split up e.g. (1, {2, 3}, 4) into ['1', '{2, 3}', '4'] for cpp_default_constructor_args.
  4. Add options arg accessor tests in _test_torch_nn_module_ctor_args.

We will be able to merge #24160 and #24860 after these improvements.

@yf225 yf225 requested a review from zou3519 September 8, 2019 04:30
Copy link
Contributor

@zou3519 zou3519 left a comment

Choose a reason for hiding this comment

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

lgtm. Had some minor nits (feel free to ignore them all) and some questions (mostly things I'm curious about)

else:
raise RuntimeError("Unexpected input type: {}".format(type(example_inputs)))

# We set all inputs to torch.nn module to requires grad, so that the backward test can always be run.
Copy link
Contributor

Choose a reason for hiding this comment

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

(no action items) You could also just turn requires_grad on if dtype is not integral, but I'm not sure that is sufficient and we can worry about that later when parity tests are added for the Embedding layers

module_qualified_name='torch::nn::{}'.format(module_name),
module_option=cpp_module_option)
module_option=cpp_module_option,
extra_stmts=''.join(extra_stmts))
Copy link
Contributor

Choose a reason for hiding this comment

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

Now for some reading comprehension: what happens if the C++ module has an extra option that the python module doesn't have?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am planning to change the internal data structure of all C++ module / optimizer options to a map, after which we will be able to check for extra C++ module options by removing all the known options from the map and see if there is anything left.

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 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.

@yf225 has imported 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 d7d3aed.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants