Skip to content

[JIT] Store schema in serialized modules and check arguments in function call#10872

Closed
goldsborough wants to merge 2 commits intopytorch:masterfrom
goldsborough:check-custom-ops
Closed

[JIT] Store schema in serialized modules and check arguments in function call#10872
goldsborough wants to merge 2 commits intopytorch:masterfrom
goldsborough:check-custom-ops

Conversation

@goldsborough
Copy link
Contributor

This PR adds argument checking for script method invocation from C++. For this I had to:

  1. The schema of a method is currently not serialized in script modules, so we now store the function schema in the doc_string field of the ONNX proto. Upon loading of a serialized script module, we parse the schema into the structured C++ form and assign it to the loaded method,
  2. Inside Method::operator(), we now verify the number and types of arguments.

CC @li-roy

@zdevito

@goldsborough goldsborough added the oncall: jit Add this issue/PR to JIT oncall triage queue label Aug 24, 2018
@goldsborough goldsborough force-pushed the check-custom-ops branch 2 times, most recently from c79774b to cca3f1c Compare August 27, 2018 20:57
Copy link
Contributor

@zdevito zdevito 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. There are two small fixes.

This comment was marked as off-topic.

This comment was marked as off-topic.

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.

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

Add test for missing argument

Always store schema

Add default arguments to method input and warn against default arguments on export
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.

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

}
types.push_back(std::move(type));
}
void parseArgumentType(Argument& arg) {

This comment was marked as off-topic.

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.

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

@goldsborough goldsborough deleted the check-custom-ops branch August 29, 2018 16:04
template<typename ... T>
static TupleTypePtr create( T&& ... all ) {
return TupleTypePtr(new TupleType( std::forward<T>(all)... ));
static TupleTypePtr create(std::vector<TypePtr> types) {

This comment was marked as off-topic.

This comment was marked as off-topic.

PenghuiCheng pushed a commit to PenghuiCheng/pytorch that referenced this pull request Sep 11, 2018
…ll (pytorch#10872)

Summary:
This PR adds argument checking for script method invocation from C++. For this I had to:
1. The schema of a method is currently not serialized in script modules, so we now store the function schema in the `doc_string` field of the ONNX proto. Upon loading of a serialized script module, we parse the schema into the structured C++ form and assign it to the loaded method,
2. Inside `Method::operator()`, we now verify the number and types of arguments.

CC The controller you requested could not be found.

zdevito
Pull Request resolved: pytorch#10872

Differential Revision: D9521219

Pulled By: goldsborough

fbshipit-source-id: 5cb3d710af6f500e7579dad176652c9b11a0487d
@ezyang ezyang added the merged label Jun 26, 2019
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.

5 participants