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.
Reason for changes
Removing the ShapeOf subgraph may lead to the removal of some input edges of operations, and QPS doesn't place FQ on these edges. In this case, the operations are quantized incorrectly because not all required inputs are quantized. These operations don't change their runtime precision in the execution graph, which means we do not have a fully quantized model.
Changes
To resolve the described problem, this PR introduces the following algorithm:
Step 1: Find all nodes belonging to the ShapeOf subgraphs in the graph. Let's denote the found nodes as$S$ . At this step, we don't remove the found subgraphs; we only store the nodes they consist of. See
find_shapeof_subgraphs()
method.Step 2: Check the producers for the specified nodes (currently, we are considering only nodes of the LSTMSequence and Convolution types). If any of these producers are in set$S$ , it means that we will lose this input edge when the ShapeOf subgraph is removed. Therefore, we try to exclude float subgraphs from this ShapeOf subgraph. Let's denote the nodes that are part of such float subgraphs as $P$ . We can see that $P \subset S$ . See
find_preserved_nodes()
method.Step 3: Find all nodes belonging to the Constant subgraphs in the graph. Let's denote the found nodes as$C$ . At this step, we don't remove the found subgraphs; we only store the nodes they consist of. See
find_constant_subgraphs()
method.Step 4: Remove$S \cup C - P$ nodes from the graph.
Related tickets