-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate name for each member of list arg #571
base: master
Are you sure you want to change the base?
Conversation
/test |
todo: add test |
gen_input_names = [] | ||
unrolled_args = [] | ||
|
||
def append_input_name(prefix: str, arg: Any) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about supporting also dict
and namedtuple types like _normalize_outputs
function in _logic.py?
pytorch-pfn-extras/pytorch_pfn_extras/handler/_logic.py
Lines 27 to 38 in c40cd02
def _normalize_outputs(outputs: Any) -> Dict[str, Any]: | |
target: Dict[str, Any] | |
if isinstance(outputs, tuple) and hasattr(outputs, '_fields'): | |
# namedtuple | |
target = outputs._asdict() # type: ignore[attr-defined] | |
elif isinstance(outputs, dict): | |
target = outputs | |
elif isinstance(outputs, (list, tuple)): | |
target = {str(i): out for i, out in enumerate(outputs)} | |
else: | |
target = {"0": outputs} | |
return target |
Update: I summarized the problem of extending current In short, |
With 6c73264, onnx export with Note that with |
My idea: always unroll args to follow |
…into list_args
memo: Also support list, tuple outputs |
Problem
ppe.onnx.export_testcase
fails with list input. This is because the number ofinput_names
is incorrect. The number of input tensors in the exported onnx is total tensor numbers, notlen(args)
.Reproduction
Error:
torch version: 1.12.0
This PR
Unrolls the input list args and generate names for all tensors.
For example, if the input args is
args=([[a,b],c], d)
, the generated input names arewhereas current master generates names as