[MO] Fix fp16 in shapeof subgraphs#4524
Merged
lazarevevgeny merged 25 commits intoopenvinotoolkit:masterfrom Mar 30, 2021
Merged
[MO] Fix fp16 in shapeof subgraphs#4524lazarevevgeny merged 25 commits intoopenvinotoolkit:masterfrom
lazarevevgeny merged 25 commits intoopenvinotoolkit:masterfrom
Conversation
…to MarkShapeOfSubgraphDataType.py
…BFS search staring point to avoid nodeless shapeof subgraphs
…h in MarkAndChangeDataTypeInShapeOfSubgraphs.py, revised Const values in transformations that affect ShapeOf subgraph nodes
mvafin
approved these changes
Mar 1, 2021
iimironov
approved these changes
Mar 1, 2021
lazarevevgeny
suggested changes
Mar 1, 2021
model-optimizer/extensions/middle/ReverseV2ToReverseSequence.py
Outdated
Show resolved
Hide resolved
model-optimizer/extensions/middle/MarkSubgraphsWithCorrectLayout.py
Outdated
Show resolved
Hide resolved
model-optimizer/extensions/middle/MarkAndChangeDataTypeInShapeOfSubgraphs.py
Outdated
Show resolved
Hide resolved
e-nugmanova
reviewed
Mar 3, 2021
achetver
approved these changes
Mar 17, 2021
pavel-esir
commented
Mar 18, 2021
mvafin
approved these changes
Mar 19, 2021
Contributor
Author
|
Updated list of operations with shape inputs. Added new operations: |
lazarevevgeny
suggested changes
Mar 22, 2021
Contributor
|
@pavel-esir , please, resolve merge conflicts. |
# Conflicts: # model-optimizer/extensions/front/ChangeCastOutputType.py # model-optimizer/extensions/middle/MarkSubgraphsWithCorrectLayout.py # model-optimizer/extensions/ops/Cast.py
Contributor
Author
|
resolved all conflicts. @lazarevevgeny @jane-intel please review |
e-nugmanova
approved these changes
Mar 30, 2021
lazarevevgeny
approved these changes
Mar 30, 2021
luo-cheng2021
pushed a commit
to luo-cheng2021/openvino
that referenced
this pull request
Apr 7, 2021
* Initial working solution * moved bfs_search_apply_on_shapeof_subgraph_nodes from utils/graph.py to MarkShapeOfSubgraphDataType.py * Reused bfs from MarkSubgraphsWithCorrectLayout.py * fixed e2e precomit issues: specified correct const data_types, fixed BFS search staring point to avoid nodeless shapeof subgraphs * fixed mxnet_rnnt: added converting all Const nodes in ShapeOf subgraph in MarkAndChangeDataTypeInShapeOfSubgraphs.py, revised Const values in transformations that affect ShapeOf subgraph nodes * reverter ReverseV2ToReverseSequence.py and DecomposeBidirectionalRNNSequence.py * in MarkSubgraphsWithCorrectLayout BFS search beauty applied * apply review comments, returned back 'in_shape_subgraph' attribute * graph condition added * MO IR reader fix for mixed FP16 models, added replacer order placement comment * moved to back phase * new solution with marking nodes from bottom to top (WIP) * successfully tested on back phase * corrected unittest * removed check for start nodes size in bfs * fix transformations that insert f64 to f32 in shape subgraph * corrected log.warning -> log.debug * revised list if shape input operations added unittest for Const shape inputs * applied @lazarevevgeny's comments * licence head corrections
mryzhov
pushed a commit
to mryzhov/openvino
that referenced
this pull request
Apr 23, 2021
* Initial working solution * moved bfs_search_apply_on_shapeof_subgraph_nodes from utils/graph.py to MarkShapeOfSubgraphDataType.py * Reused bfs from MarkSubgraphsWithCorrectLayout.py * fixed e2e precomit issues: specified correct const data_types, fixed BFS search staring point to avoid nodeless shapeof subgraphs * fixed mxnet_rnnt: added converting all Const nodes in ShapeOf subgraph in MarkAndChangeDataTypeInShapeOfSubgraphs.py, revised Const values in transformations that affect ShapeOf subgraph nodes * reverter ReverseV2ToReverseSequence.py and DecomposeBidirectionalRNNSequence.py * in MarkSubgraphsWithCorrectLayout BFS search beauty applied * apply review comments, returned back 'in_shape_subgraph' attribute * graph condition added * MO IR reader fix for mixed FP16 models, added replacer order placement comment * moved to back phase * new solution with marking nodes from bottom to top (WIP) * successfully tested on back phase * corrected unittest * removed check for start nodes size in bfs * fix transformations that insert f64 to f32 in shape subgraph * corrected log.warning -> log.debug * revised list if shape input operations added unittest for Const shape inputs * applied @lazarevevgeny's comments * licence head corrections
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description: For some models
float16precision in shape subgraphs is not sufficient for correct shape calculation - either shape value exceeds max(float16) or we get inaccurate scales values for operations likeInterpolate.In order to unblock such models decided to keep shape calculation in FP32 even if such models are being converted with command
--data_type=FP16. To keep shapes in FP32 the following changes have been made:MarkNodesWithShapeValuesthat goes up from ports of operations that accept shape values (Interpolate:1, Interpolate:2, Reshape:1, etc.) and marks such nodes with'returns_shape_value'attribute'correct_data_type'to prevent converting them to FP16 inconvert_data_type.pyChangeCastOutputTypeto the end of the back phase in order to cover all ShapeOf nodes that could've been inserted during common pipeline transformationsChangeCastOutputTypeif Cast has attrreturns_shape_value==Truethen keep return type float32 even if['cmd_params'].data_type == 'FP16'Tickets: 42771, 44587
Code:
Validation:
Documentation: