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

onnx ver.1.4 is not supported #93

Closed
ZyuZyuZyu opened this issue Feb 21, 2019 · 10 comments
Closed

onnx ver.1.4 is not supported #93

ZyuZyuZyu opened this issue Feb 21, 2019 · 10 comments
Labels
category: MO Model Optimizer question Further information is requested

Comments

@ZyuZyuZyu
Copy link

I am using the Pytorch ver 1.0.0 which is exporting onnx model in ver 1.4.0, directly lead to the upsample operation transfering failed.
the representation of Upsample-op in the older version is now supported looks like
{
'Upsample',
inputs=['X'],
outputs=['Y'],
mode='nearest',
width_scale=2,
height_scale=2,
}
but in the new verison of ONNX, Upsample-op looks like
{
'Upsample',
inputs=['X', 'scales'],
outputs=['Y'],
mode='nearest',
}

Is there a way to modify the model_optimizer source code to make it work tranfering the new ops in ONNX and if yes how can I do it efficiently?

Any advice is welcome !

@shubha-ramani
Copy link

Zyu Zyu what is the exact error which Model Optimizer is giving you for the new version ?

@ZyuZyuZyu
Copy link
Author

@shubha-ramani Thanks for your reply. The error message is 'One/both of widths_scale = {} and height_scale = {} is not defined for Upsampe node {}.' which located on model_optimizer/extensions/front/onnx/upsample_ext.py line 70.

@shubha-ramani
Copy link

Zyu it seems you are right, given the current code located at : https://github.com/opencv/dldt/blob/2018/model-optimizer/extensions/front/onnx/upsample_ext.py
Which does not match the latest PyTorch documentation:
https://pytorch.org/docs/stable/nn.html

I will file a bug. Thank you for using OpenVino.

PS. If you want to hack upsample_ext.py as a temporary workaround and later submit a pull-request yourself feel free.

Shubha

@ZyuZyuZyu
Copy link
Author

@shubha-ramani Thank you for comfirming my work. I'm new to the sourse code here now. I will submit a pull-request as long as I finished this work.

@wuhy08
Copy link

wuhy08 commented Apr 25, 2019

I wonder if there will be timeline to fix this issue. In ONNX, Upsample-9 op supports dynamic scales, which makes "scales" an input instead of an attribute. I didn't find a way to extract the value of input and convert to attribute in model-optimizer. Is there any hint on that?

@Aeroxander
Copy link

@wuhy08 Wondering the same, cause my model has the "Expand" layer what isn't supported < Opset v9

@wuhy08
Copy link

wuhy08 commented Jun 19, 2019

Hi @Aeroxander
I don't have Expand Op in my model so I cannot comment on that. But based on ONNX manual, Expand is just broadcasting. I wonder if you can change that Op to Reshape in the model.

@Aeroxander
Copy link

Aeroxander commented Jun 19, 2019

@wuhy08 I tried it with this issue but I get Blob "37" not found in const blobs during the loading of the ONNX model after the Expand layer is initialized when I try to map the Expand layer to type "Scale".

I'm just not that familiar with adding layers to OpenCV yet and how OpenCV works with broadcasting.
So tried to emulate how Numpy broadcast in this way:

layerParams.blobs.push_back(Mat::ones(blob.cols, blob.rows, blob.type()));
layerParams.type = "Scale";

But then I get the blob not found error.

When I try to map it to "Reshape" instead of "Scale" I get:
Can't create layer 37 of type Expand in function 'cv::dnn::LayerData...

EDIT: Fixed it with adding constBlobs.insert instead of .push_back, but the same issue arises with the "MatMul" layer now. I'm very confused I keep getting these Blobs not found errors

@lazarevevgeny lazarevevgeny added the category: MO Model Optimizer label May 25, 2020
@lazarevevgeny
Copy link
Contributor

@ZyuZyuZyu is this issue still actual?

@lazarevevgeny lazarevevgeny added the question Further information is requested label May 25, 2020
@AnastasiaKazantaeva
Copy link
Contributor

It seems that the issues is not actual anymore as no response. Closing it. Feel free to reopen it or create a new one.

eshoguli pushed a commit to eshoguli/openvino that referenced this issue Jun 1, 2021
* Azure CI: Add "ref: releases/2021/3"

* Fix Klocwork issues in Java

* Updated arm plugin build script (openvinotoolkit#65)

* Fix some Klocwork issues

* Update README.md (openvinotoolkit#76)

* Fixed Convolution fusion (openvinotoolkit#84)

* Remove MO deps from mo_pytorch module (openvinotoolkit#93)

Co-authored-by: azhogov <[email protected]>
Co-authored-by: Dmitry Kurtaev <[email protected]>
Co-authored-by: Aleksandr Voron <[email protected]>
Co-authored-by: Liubov Batanina <[email protected]>
mvafin pushed a commit to mvafin/openvino that referenced this issue Jun 22, 2021
mvafin added a commit to mvafin/openvino that referenced this issue Jan 11, 2023
ilya-lavrenov pushed a commit that referenced this issue Jan 18, 2023
* WIP

* update input validation

* upsample_nearest2d and upsample_bilinear2d support

* support leaky_relu add test for inplace relu

* update tests, add handler for ListConstruct

* Do not create extra outputs in main body

* add positive case with non-default value

* update testing

* update test, handle non constant size and scale

* remove ie_device

* add aten::group_norm support

* refactoring

* Enable aten::reshape_as operator and add layer test

* more tests

* Fix typo in test

* Resolve conflicts

* fix code style

* expand init version

* expand_as and tests

* add transposed convolutions support

* add tests

* initial support pad

* add circular

* update for differenced in rang

* cleanup

* refactor

* more tests

* apply review comments

* Add split+listunpack transformation

* Add split+getitem transformation

* Add test cases

* fix typo

* Minor fixes

* Apply suggestions from code review

Co-authored-by: Maxim Vafin <[email protected]>

* Apply suggestions from code review

* Small fix

* Support converting models without freezing

* support BoolTensor and masked_fill

* add support aten::rsqrt and test for sqrt

* add cumsum and type_as

* support clamp

* support more matrix operations

* add tests

* Add aten::adaptive_avg_pool3d and layer test

* Change to rank

* fix code style in utils.hpp

* Update src/frontends/pytorch/src/op_table.cpp

Co-authored-by: Sergey Lyalin <[email protected]>

* fix code style

* add tests

* add xfail

* remove unnecessary broadcast

* Changes required by style formater

* aten::_convolution_mode

* Changes requested by a reviewer

* remove code duplication

* add aten::unbind transformation

* full, zeros and ones

* Support getattr list and unrolling nested ifs

* Remove line change

* Enable back freezing in layer tests

* Add aten::norm operator and layer test

* Small fix in layer test

* add aten::roll

* add empty line

* Typo fix

* fix style

* fix style v2

* add pytorch frontend to wheel

* Support all types of numeric norms

* add check for dynamic shapes

* remove random change

* merge statements

* add min and max ops support

* aten::max and aten::min

* move axes range creation to utils

* add transformation for tuple results, update tests

* fix copyright

* aten::var

* add test and translation for numel

* ignore aten::clone

* Add layer test for aten::add operator

* Fix typo

* Remove redundant import

* Add parameter name in forward method

* fix code style

* apply review comments

* Add size+slice+listunpack transform

* Add append listunpack transformation

* Register transformation

* aten::where

* update realization

* Fix issue with getitem

* Fix getitem

* Add layer test for aten::view operator

* Add tests for listunpack

* add test for aten::div

* fix style

* update aten::adaptive_max_pool2d

* fix style

* add aten::floor_divide

* aten::addmm support alpha and beta with different dtype

* nonzero

* Change test name

* update test cases to include other dtypes

* aten::arange

* prim::max transformation for ListConstruct

* rename op

* generalize conv2d implementation for conv1d and conv3d

* aten::unsqueeze_ and tests for aten::unsqueeze (#70)

* add aten::le, aten::ge and tests for other tensor comparision ops (#74)

* add support trigonometry ops (#73)

* support aten::upsample_bicubic2d, aten::ceil, aten::floor (#72)

Co-authored-by: Maxim Vafin <[email protected]>

* extend and add tests for avg_pool and max_pool

* extend tests and constant filling ops

* fix as_tensor and full ops

* aten::repeat

* fix code style

* aten::im2col (#61)

* aten::im2col

* remove debug prints, add number of elements check

* fix failed tests

* move helper function

* use split

* Update src/frontends/pytorch/src/op/im2col.cpp

Co-authored-by: Maxim Vafin <[email protected]>

* fix code style

Co-authored-by: Maxim Vafin <[email protected]>

* Update src/frontends/pytorch/src/utils.cpp

Co-authored-by: Maxim Vafin <[email protected]>

* fix code style

* revert removeinf floordiv, add floor_divide file

* Fix merge issue

* reduce code duplication

* refactor

* Add len operator with layer test

* update clamp to support mixed precision and add support torch.long for constants

* aten::selu

* add trunc mode to div

* add else statement

* Add test case to layer test

* Fix submodules (#88)

* update test file

* fix namings

* execute in fp64 and convert back to initial precision

* Revert set_output_size to master. Small fix in If validate

* Fix build and code style

* fix failed tests

* Add torchvision::nms operator and layer test

* Change requested by a reviewer

* Remove div test

* convert constants to input type

* Mark some cases in div tests as xfail (#93)

* Small refactoring (#94)

* Small refactoring

* Fix type

* Fix python codestyle

* Incremental fix code style (#95)

* Fix style (#96)

* Fix copyright

* Fix code style

* Branch clean up (#97)

* Optimize includes and force opset10 (#98)

* Optimize includes

* Force opset10 in pt fe

* Fix codestyle (#99)

* Fix style

* Fix clang codestyle

* Fix cerr with debug log

* Update src/bindings/python/src/pyopenvino/frontend/pytorch/decoder.cpp

* Add pytorch dependency only if pytorch frontend is enabled

* Update src/bindings/python/src/pyopenvino/CMakeLists.txt

* Add layer tests to precommit (#100)

* Add layer tests to precommit

* Remove accidentally added files

* Apply code style on layer tests

* batch norm tests and fixes

* move default weight and bias to else block

* reduce code duplication

* Changes requested by a reviewer

* Changes requested by a reviewer

* Remove dependency from pytorch in pyopenvino (#102)

* Remove dependency from pytorch when fe is disabled

* Change docstring

* Remove pytorch FE dependency from pyopenvino

* Apply codestyle (#107)

* Apply codestyle

* Remove commented line

* Apply suggestions from code review

Co-authored-by: Roman Kazantsev <[email protected]>

* Fix mock FE test (#108)

* Fix mock PE test (#111)

* Revert changes in StridedSlice (#114)

* Small refactoring (#116)

* Small refactoring

* Fix codestyle

* Apply suggestions from code review

Co-authored-by: Roman Kazantsev <[email protected]>

* Apply suggestions from code review

* Update src/frontends/pytorch/src/op/group_norm.cpp

* Fix cmake copyright define (#117)

* Update src/frontends/pytorch/src/op/arange.cpp

* Apply suggestions from code review

* Update build configs (#120)

* FIx build configs

* Update type cast in full.cpp

* Apply review feedback (#121)

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Roman Kazantsev <[email protected]>

* Fix issue after master merge (#122)

* Fix issue after master merge

* Fix build

Co-authored-by: eaidova <[email protected]>
Co-authored-by: bszmelcz <[email protected]>
Co-authored-by: Sergey Lyalin <[email protected]>
Co-authored-by: sikorsl1 <[email protected]>
Co-authored-by: Leonard Sikorski <[email protected]>
Co-authored-by: Mateusz <[email protected]>
Co-authored-by: Roman Kazantsev <[email protected]>
jane-intel referenced this issue in jane-intel/openvino Jan 19, 2023
* WIP

* update input validation

* upsample_nearest2d and upsample_bilinear2d support

* support leaky_relu add test for inplace relu

* update tests, add handler for ListConstruct

* Do not create extra outputs in main body

* add positive case with non-default value

* update testing

* update test, handle non constant size and scale

* remove ie_device

* add aten::group_norm support

* refactoring

* Enable aten::reshape_as operator and add layer test

* more tests

* Fix typo in test

* Resolve conflicts

* fix code style

* expand init version

* expand_as and tests

* add transposed convolutions support

* add tests

* initial support pad

* add circular

* update for differenced in rang

* cleanup

* refactor

* more tests

* apply review comments

* Add split+listunpack transformation

* Add split+getitem transformation

* Add test cases

* fix typo

* Minor fixes

* Apply suggestions from code review

Co-authored-by: Maxim Vafin <[email protected]>

* Apply suggestions from code review

* Small fix

* Support converting models without freezing

* support BoolTensor and masked_fill

* add support aten::rsqrt and test for sqrt

* add cumsum and type_as

* support clamp

* support more matrix operations

* add tests

* Add aten::adaptive_avg_pool3d and layer test

* Change to rank

* fix code style in utils.hpp

* Update src/frontends/pytorch/src/op_table.cpp

Co-authored-by: Sergey Lyalin <[email protected]>

* fix code style

* add tests

* add xfail

* remove unnecessary broadcast

* Changes required by style formater

* aten::_convolution_mode

* Changes requested by a reviewer

* remove code duplication

* add aten::unbind transformation

* full, zeros and ones

* Support getattr list and unrolling nested ifs

* Remove line change

* Enable back freezing in layer tests

* Add aten::norm operator and layer test

* Small fix in layer test

* add aten::roll

* add empty line

* Typo fix

* fix style

* fix style v2

* add pytorch frontend to wheel

* Support all types of numeric norms

* add check for dynamic shapes

* remove random change

* merge statements

* add min and max ops support

* aten::max and aten::min

* move axes range creation to utils

* add transformation for tuple results, update tests

* fix copyright

* aten::var

* add test and translation for numel

* ignore aten::clone

* Add layer test for aten::add operator

* Fix typo

* Remove redundant import

* Add parameter name in forward method

* fix code style

* apply review comments

* Add size+slice+listunpack transform

* Add append listunpack transformation

* Register transformation

* aten::where

* update realization

* Fix issue with getitem

* Fix getitem

* Add layer test for aten::view operator

* Add tests for listunpack

* add test for aten::div

* fix style

* update aten::adaptive_max_pool2d

* fix style

* add aten::floor_divide

* aten::addmm support alpha and beta with different dtype

* nonzero

* Change test name

* update test cases to include other dtypes

* aten::arange

* prim::max transformation for ListConstruct

* rename op

* generalize conv2d implementation for conv1d and conv3d

* aten::unsqueeze_ and tests for aten::unsqueeze (#70)

* add aten::le, aten::ge and tests for other tensor comparision ops (#74)

* add support trigonometry ops (#73)

* support aten::upsample_bicubic2d, aten::ceil, aten::floor (#72)

Co-authored-by: Maxim Vafin <[email protected]>

* extend and add tests for avg_pool and max_pool

* extend tests and constant filling ops

* fix as_tensor and full ops

* aten::repeat

* fix code style

* aten::im2col (#61)

* aten::im2col

* remove debug prints, add number of elements check

* fix failed tests

* move helper function

* use split

* Update src/frontends/pytorch/src/op/im2col.cpp

Co-authored-by: Maxim Vafin <[email protected]>

* fix code style

Co-authored-by: Maxim Vafin <[email protected]>

* Update src/frontends/pytorch/src/utils.cpp

Co-authored-by: Maxim Vafin <[email protected]>

* fix code style

* revert removeinf floordiv, add floor_divide file

* Fix merge issue

* reduce code duplication

* refactor

* Add len operator with layer test

* update clamp to support mixed precision and add support torch.long for constants

* aten::selu

* add trunc mode to div

* add else statement

* Add test case to layer test

* Fix submodules (#88)

* update test file

* fix namings

* execute in fp64 and convert back to initial precision

* Revert set_output_size to master. Small fix in If validate

* Fix build and code style

* fix failed tests

* Add torchvision::nms operator and layer test

* Change requested by a reviewer

* Remove div test

* convert constants to input type

* Mark some cases in div tests as xfail (#93)

* Small refactoring (#94)

* Small refactoring

* Fix type

* Fix python codestyle

* Incremental fix code style (#95)

* Fix style (#96)

* Fix copyright

* Fix code style

* Branch clean up (#97)

* Optimize includes and force opset10 (#98)

* Optimize includes

* Force opset10 in pt fe

* Fix codestyle (#99)

* Fix style

* Fix clang codestyle

* Fix cerr with debug log

* Update src/bindings/python/src/pyopenvino/frontend/pytorch/decoder.cpp

* Add pytorch dependency only if pytorch frontend is enabled

* Update src/bindings/python/src/pyopenvino/CMakeLists.txt

* Add layer tests to precommit (#100)

* Add layer tests to precommit

* Remove accidentally added files

* Apply code style on layer tests

* batch norm tests and fixes

* move default weight and bias to else block

* reduce code duplication

* Changes requested by a reviewer

* Changes requested by a reviewer

* Remove dependency from pytorch in pyopenvino (#102)

* Remove dependency from pytorch when fe is disabled

* Change docstring

* Remove pytorch FE dependency from pyopenvino

* Apply codestyle (#107)

* Apply codestyle

* Remove commented line

* Apply suggestions from code review

Co-authored-by: Roman Kazantsev <[email protected]>

* Fix mock FE test (#108)

* Fix mock PE test (#111)

* Revert changes in StridedSlice (#114)

* Small refactoring (#116)

* Small refactoring

* Fix codestyle

* Apply suggestions from code review

Co-authored-by: Roman Kazantsev <[email protected]>

* Apply suggestions from code review

* Update src/frontends/pytorch/src/op/group_norm.cpp

* Fix cmake copyright define (#117)

* Update src/frontends/pytorch/src/op/arange.cpp

* Apply suggestions from code review

* Update build configs (#120)

* FIx build configs

* Update type cast in full.cpp

* Apply review feedback (#121)

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Roman Kazantsev <[email protected]>

* Fix issue after master merge (#122)

* Fix issue after master merge

* Fix build

Co-authored-by: eaidova <[email protected]>
Co-authored-by: bszmelcz <[email protected]>
Co-authored-by: Sergey Lyalin <[email protected]>
Co-authored-by: sikorsl1 <[email protected]>
Co-authored-by: Leonard Sikorski <[email protected]>
Co-authored-by: Mateusz <[email protected]>
Co-authored-by: Roman Kazantsev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: MO Model Optimizer question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants