Skip to content

Add validation of shape when re-using a buffer in ExecutionFrame - #1356

Merged
Scott McKay (skottmckay) merged 6 commits into
masterfrom
skottmckay/ImproveDimParamHandlingInBufferReuse
Jul 9, 2019
Merged

Add validation of shape when re-using a buffer in ExecutionFrame#1356
Scott McKay (skottmckay) merged 6 commits into
masterfrom
skottmckay/ImproveDimParamHandlingInBufferReuse

Conversation

@skottmckay

Copy link
Copy Markdown
Contributor

Description:
Validate that the size of the shape matches when re-using a buffer in the execution frame.
Don't consider an empty string to be a matching dim_param value.

Motivation and Context
Issue #1331 involved a model where 'None' was accidentally being used as a dim_param value in multiple places where the values were not equal. 'None' is not a special word, so it was treated as a variable name. Whilst we can't prevent this sort of misuse of dim_param, we can detect when it leads to invalid buffer re-use by validating the number of elements is the same.

Additionally we shouldn't consider an empty string in dim_param to be a valid variable name, so update the allocation planner to not consider two empty strings to be equal.

Add a unit test involving the model from the issue.

Validate shape is compatible at runtime when re-using Tensor.
Remove '*' handling as it is going to be removed from the ONNX spec
Validate shape is compatible at runtime when re-using Tensor.
Remove '*' handling as it is going to be removed from the ONNX spec
@skottmckay
Scott McKay (skottmckay) requested a review from a team as a code owner July 8, 2019 11:02
@skottmckay Scott McKay (skottmckay) changed the title Skottmckay/improve dim param handling in buffer reuse Add validation of shape when re-using a buffer in ExecutionFrame Jul 8, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit:

@yuslepukhin

Copy link
Copy Markdown
Contributor

I have approved it w/o comments bc I participated in debugging and had preliminary discussions with Scott McKay (@skottmckay)

@skottmckay
Scott McKay (skottmckay) merged commit ac6a4af into master Jul 9, 2019
@skottmckay
Scott McKay (skottmckay) deleted the skottmckay/ImproveDimParamHandlingInBufferReuse branch July 9, 2019 05:12
@snnn

Copy link
Copy Markdown
Contributor

Looks like this change broke some models.

Dmitri Smirnov (yuslepukhin) pushed a commit that referenced this pull request Mar 17, 2026
## Quantize: CLI command to quantize input model

Usage:
```bash
  olive quantize                      \
    --model_name_or_path <model-name> \
    --trust_remote_code               \
    --device <cpu|gpu|npu>            \
    --algorithms <awq,gptq>           \
    --data_name <data-name>           \
    --subset <subset-name>            \
    --split <split-name>              \
    --batch_size <batch-size>         \
    --output_path <output-dir>
```

## Checklist before requesting a review
- [x] Add unit tests for this change.
- [x] Make sure all tests can pass.
- [ ] Update documents if necessary.
- [x] Lint and apply fixes to your code by running `lintrunner -a`
- [ ] Is this a user-facing change? If yes, give a description of this
change to be included in the release notes.
- [ ] Is this PR including examples changes? If yes, please remember to
update [example
documentation](https://github.com/microsoft/Olive/blob/main/docs/source/examples.md)
in a follow-up PR.

## (Optional) Issue link
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.

3 participants