You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is interest in enabling a trace_only function as a general ONNX Script feature. #674 (comment). Currently, we have the script: FunctionType -> OnnxFunction decorator that scripts a python function. Should we have a similar decorator for creating a trace only function?
Option 1
Retain script and create a new trace: FunctionType -> TracedOnnxFunction decorator. This is like torch.jit.trace and torch.jit.script, where the difference is we do symbolic tracing. TracedOnnxFunction is something that is OpLike and has scope information which we can use to dynamically generate functions during graph build.
Replace @script with @function, which does scripting by default, and add an option @function(trace=True). This is like tf.function with the jit_compile option (similar only on an api level. tf.function is always tracing I believe).
One of the pros of this option is a more natural representation of an ONNX "function".
Feels like we are only discussing api difference here?
Another key aspect to highlight is that in terms of graph creation. Is it correct to say script is aot compilation while trace is jit compilation, i.e. no onnx graph for trace decorated functions until feeding inputs (tensor can be maybe symbolic, but attributes must be concrete) to it?
Another key aspect to highlight is that in terms of graph creation. Is it correct to say script is aot compilation while trace is jit compilation, i.e. no onnx graph for trace decorated functions until feeding inputs (tensor can be maybe symbolic, but attributes must be concrete) to it?
There is interest in enabling a trace_only function as a general ONNX Script feature. #674 (comment). Currently, we have the
script: FunctionType -> OnnxFunction
decorator that scripts a python function. Should we have a similar decorator for creating a trace only function?Option 1
Retain
script
and create a newtrace: FunctionType -> TracedOnnxFunction
decorator. This is liketorch.jit.trace
andtorch.jit.script
, where the difference is we do symbolic tracing.TracedOnnxFunction
is something that isOpLike
and has scope information which we can use to dynamically generate functions during graph build.Examples
Option 2
Replace
@script
with@function
, which does scripting by default, and add an option@function(trace=True)
. This is liketf.function
with thejit_compile
option (similar only on an api level.tf.function
is always tracing I believe).One of the pros of this option is a more natural representation of an ONNX "function".
Examples
cc @gramalingam @BowenBao @titaiwangms @xadupre @jcwchen @fatcat-z @xiaowuhu @shubhambhokare1
The text was updated successfully, but these errors were encountered: