microsoft / microsoft/onnxruntime

how to convert a special input?

Open
#23,042 3 comments 0 reactions 0 assignees View on GitHub
feature request
Dominant language
C++
Stars
21.9k
Forks
4.2k
Avg merge
4d 11h
Merged PRs (30d)
184

Description

### Describe the feature request

how to process the cfg_scale?

### Describe scenario use case

vid: This is a torch tensor with the size [91200, 33].
timestep: A tensor with a single float value, like [988.] or [1000.], on ‘npu:1’ with dtype torch.bfloat16.
cfg_scale: **This can be a tensor like [2.] or it can be None.**

vid = torch.randn(91200, 33)
timestep = torch.tensor([988.])
cfg_scale = torch.tensor([2.]) or None

dynamic_axes = {
'vid': {0: 'batch_size'}, # The first dimension of vid is dynamic
'timestep': {0: 'batch_size'}, # The first dimension of timestep is dynamic
**'cfg_scale': ???**
'output': {0: 'batch_size'} # The first dimension of output is dynamic
}

torch.onnx.export(
model,
(vid, timestep, cfg_scale),
"your_model.onnx",
opset_version=17,
do_constant_folding=True,
input_names=['vid', 'timestep', 'cfg_scale'],
output_names=['output'],
dynamic_axes=dynamic_axes
)

how to process the cfg_scale?

Contributor guide

Open the contributing guide

Research direction

Start at the torch.onnx.export example in the issue and trace how its dynamic_axes argument handles cfg_scale when it is a tensor or None. Determine the expected representation for that optional input, then verify the behavior with a focused export example or test using the shown tensor shapes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.