Skip to content
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

torch export to onnx extern data size configurable #1481

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Judyxujj
Copy link
Contributor

This PR adds dyn_dim_min_sizes and dyn_dim_max_sizes to the command line options of tools/torch_export_to_onnx.py . In default, extern data with time dimension size in range [2,25] would be generated for export, which might be too short for the cases where raw wave input is used. Thus these two options can be used to specify the min/max sizes for dim tags with dynamic sizes.

@Judyxujj Judyxujj requested review from albertz and a team as code owners December 22, 2023 15:00
@@ -182,6 +182,13 @@ def main():
parser.add_argument("out_onnx_filename", type=str, help="Filename of the final ONNX model.")
parser.add_argument("--verbosity", default=4, type=int, help="5 for all seqs (default: 4)")
parser.add_argument("--device", type=str, default="cpu", help="'cpu' (default) or 'gpu'.")
parser.add_argument(
"--dyn_dim_min_sizes", type=dict, default=None, help="Specify min sizes for dim tags with dynamic sizes"
Copy link
Member

Choose a reason for hiding this comment

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

Did you test this? What exactly did you pass as argument? I wonder how it would correctly convert it into a dict, and specifically with the right Dim objects as keys?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested it by setting the Dim object like this

time_data_dim = SpatialDim('time:data')
extern_data_dict = {'data': {
        'dim_tags': [
            batch_dim,
            time_data_dim,
            FeatureDim('feat', 1),
        ],
        'dtype': 'float32',
    }}
dyn_dim_max_sizes={time_data_dim:100}

Copy link
Member

Choose a reason for hiding this comment

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

I mean, how did you start this script? How did you pass --dyn_dim_min_sizes when starting the script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants