Skip to content

Split Transformations between MOC and Common pipelines#7580

Merged
GlebKazantaev merged 5 commits intoopenvinotoolkit:masterfrom
GlebKazantaev:gkazanta/split_transformations
Oct 8, 2021
Merged

Split Transformations between MOC and Common pipelines#7580
GlebKazantaev merged 5 commits intoopenvinotoolkit:masterfrom
GlebKazantaev:gkazanta/split_transformations

Conversation

@GlebKazantaev
Copy link
Copy Markdown
Contributor

@GlebKazantaev GlebKazantaev commented Sep 21, 2021

Motivation

Since we have started to execute nGraph transformations in offline (ModelOptimizer backend stage) we grew up the transformation pipeline (MOCTransformations inside moc_transformations.cpp) which collects all plugin independent transformations that can be executed in offline. This pipeline became very similar to the CommonOptimizations pipeline so every time when we add new common transformation we have to add it to two very common pipelines so it doubles the maintenance cost.
Also as we are moving towards direct model support (FE in runtime) and parity between offline and runtime execution we have to provide the same number of optimizations in runtime that we perform in offline (except some LoadTime critical passes that will remain only in offline). This split of transformations helps us clearly divide plugin independent transformations from others and provide the same transformation pipeline in runtime which we have in offline.

Changes Description

  • CommonOptimizations pipeline was aligned with MOCTransformations pipeline where we gathered all plugin independent transformations. And as a result CommonOptimizations started to execute MOCTransformations inside but without ability to change it outside (from plugin) via PassConfig to prevent plugins from wrong behavior (if transformation needs to be disabled or configured by some plugin means that this transformation shouldn't be in MOCTransformations).
  • MOCTransformations was parametrized by low_precision_enabled key to avoid issues with explicitly marked low-precision sub-graphs where this is not expected. Historically plugins manually handle low-precision sub-graphs by calling DisableConvertConstantFoldingOnConstPath under some condition. So to avoid changes in this behavior we have to skip this step inside moc when we execute it in common optimizations pipeline. But in offline case we have to preserve low-precision sub-graphs by default.

How To Add New Transformation

Plugin Dependent Transformation
If this is plugin dependent transformation and some plugin disables it or parametrize it then we have to put it to CommonOptimizations pipeline or directly into particular plugin.

Common Transformation
If this is a common transformation we need to put it in MOCTransformations pipeline but we always need to remember that this transformation automatically will be executed in offline so we have to follow couple simple rules:

  • If transformation doesn't depend on shapes so it can be registered and executed as usual.
  • If transformation is shape dependent (relies on some shapes in graph) we have to keep it under m_use_shape key, so this transformation will be always applied in runtime but in offline it will be executed only is --static_shape key is specified.
  • If transformations can have two modes: when it works with dynamic shapes with some restrictions and when transformation relies on shapes (full power mode), so it must be parametrized by m_use_shape key or divided into two separate transformations (if dynamic version of this transformation fully covers version with shapes so we can keep only dynamic version). This division helps us to execute as much as possible in offline and to reduce number of transformations application in runtime.

@GlebKazantaev GlebKazantaev force-pushed the gkazanta/split_transformations branch 7 times, most recently from 889323d to 2b1fd71 Compare September 28, 2021 13:15
@GlebKazantaev GlebKazantaev force-pushed the gkazanta/split_transformations branch from 2b1fd71 to 5196c6c Compare October 5, 2021 21:59
@GlebKazantaev GlebKazantaev force-pushed the gkazanta/split_transformations branch from 5196c6c to b703b67 Compare October 6, 2021 15:40
@GlebKazantaev GlebKazantaev marked this pull request as ready for review October 6, 2021 17:03
@GlebKazantaev GlebKazantaev self-assigned this Oct 6, 2021
@GlebKazantaev GlebKazantaev merged commit b80b87b into openvinotoolkit:master Oct 8, 2021
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.

4 participants