Skip to content

Consider GraphInferenceContext in inference functions: InferenceContext#4632

Merged
jcwchen merged 12 commits intoonnx:mainfrom
jcwchen:jcw/extend-subgraph
Nov 18, 2022
Merged

Consider GraphInferenceContext in inference functions: InferenceContext#4632
jcwchen merged 12 commits intoonnx:mainfrom
jcwchen:jcw/extend-subgraph

Conversation

@jcwchen
Copy link
Copy Markdown
Member

@jcwchen jcwchen commented Nov 2, 2022

Description

  • Consider GraphInferenceContext in inference functions (InferenceContextImpl) to cover more use cases.
  • Add a test to test node with subgraph.
  • TODO in another PR: expose functionProto as well.

Motivation and Context

Follow up for #4409. Further consider GraphInferenceContext for inference function

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
@jcwchen jcwchen added the module: utility Helper modules label Nov 2, 2022
@jcwchen jcwchen requested a review from a team as a code owner November 2, 2022 17:42
Comment thread onnx/cpp2py_export.cc Outdated
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
@jcwchen jcwchen changed the title Expose GraphInferenceContext in Python interface for inference functions Consider GraphInferenceContext in inference functions: InferenceContext Nov 2, 2022
Comment thread onnx/cpp2py_export.cc Outdated
@jcwchen jcwchen changed the title Consider GraphInferenceContext in inference functions: InferenceContext [WIP] Consider GraphInferenceContext in inference functions: InferenceContext Nov 8, 2022
Comment thread onnx/shape_inference.py
Comment thread onnx/cpp2py_export.cc Outdated
@gramalingam
Copy link
Copy Markdown
Contributor

Adding a test-case would be useful

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
@jcwchen jcwchen changed the title [WIP] Consider GraphInferenceContext in inference functions: InferenceContext Consider GraphInferenceContext in inference functions: InferenceContext Nov 14, 2022
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Comment thread onnx/test/inference_function_test.py Fixed
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
@jcwchen jcwchen force-pushed the jcw/extend-subgraph branch from 83be312 to ce5f874 Compare November 17, 2022 17:31
Comment thread onnx/test/inference_function_test.py
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Comment thread onnx/test/inference_function_test.py Outdated
subgraph = make_graph(
[
make_node("Identity", ["loop_state_in"], ["loop_state_out"]),
make_node("Identity", ["input"], ["output"]),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we change this to include an outer-scope variable reference? Like

   make_node("Add", ["input", "outer"], ["output"]),

Comment thread onnx/test/inference_function_test.py
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Comment thread onnx/shape_inference.py Outdated
input_types: Dict[str, onnx.TypeProto],
input_data: Optional[Dict[str, onnx.TensorProto]] = None,
input_sparse_data: Optional[Dict[str, onnx.SparseTensorProto]] = None,
subgraph_opset_imports: Optional[List[onnx.OperatorSetIdProto]] = None,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minor nit: I think opset_imports and ir_version might be sufficient as the parameter names. I realize they are used only for subgraphs, but it is unlikely to cause any confusion or ambiguity to use the shorter name. It will be easier for callers, when they use keyword-arguments.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was in the debate of opset_imports and subgraph_opset_imports, but yes I agreed using shorter name here is cleaner. Just updated. Will merge this PR soon. Thank you for bringing this up!

Copy link
Copy Markdown
Contributor

@gramalingam gramalingam left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Just have one minor comment about naming of parameters.

@jcwchen jcwchen enabled auto-merge (squash) November 18, 2022 17:24
@jcwchen jcwchen merged commit cd6e5db into onnx:main Nov 18, 2022
justinchuby pushed a commit to justinchuby/onnx that referenced this pull request Jan 27, 2023
…xt (onnx#4632)

* Expose GraphInferenceContext in Python interface for inference functions

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* use the same map

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* add opset_imports and handle input_types

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* graph_opset_import to clarify

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* fix lint

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* fix black

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* add a test

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* make_opsetid

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* replace test with Add in subgraph

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* remove unused

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* use shorter name for opset_imports and ir_version

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
broune pushed a commit to broune/onnx that referenced this pull request May 6, 2023
…xt (onnx#4632)

* Expose GraphInferenceContext in Python interface for inference functions

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* use the same map

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* add opset_imports and handle input_types

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* graph_opset_import to clarify

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* fix lint

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* fix black

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* add a test

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* make_opsetid

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* replace test with Add in subgraph

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* remove unused

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* use shorter name for opset_imports and ir_version

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: utility Helper modules

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants