Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tools/onnx-graphsurgeon/onnx_graphsurgeon/ir/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ def fold_constants(
size_threshold=None,
should_exclude_node=None,
recurse_functions=True,
ort_session_options=None,
):
"""
Folds constants in-place in the graph. The graph's nodes and functions must be topologically
Expand Down Expand Up @@ -754,7 +755,8 @@ def fold_constants(
recurse_functions (bool):
Whether to fold constants in this graph's Functions.
Defaults to True.

ort_session_options (Optional[onnxruntime.SessionOptions]):
SessionOptions object to be used for ONNX Runtime sessions.
Returns:
self
"""
Expand Down Expand Up @@ -1172,6 +1174,7 @@ def get_out_node_ids():

sess = onnxrt.InferenceSession(
export_onnx(part, do_type_check=False).SerializeToString(),
sess_options = ort_session_options,
providers=ORT_PROVIDERS,
)
values = sess.run(names, {})
Expand Down Expand Up @@ -1254,6 +1257,7 @@ def should_eval_foldable(tensor):
export_onnx(
graph_clone, do_type_check=False
).SerializeToString(),
sess_options = ort_session_options,
providers=ORT_PROVIDERS,
)
values = sess.run(names, {})
Expand Down