[luci/service] Support dynamic shape inference for reshape #1
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.
This commit supports dynamic shape inference for reshape operation
Dynamic shape inference algorithm
from: Samsung#13927 (comment), Samsung#13927 (comment)
CircleReshape
always has two inputs:tensor
andshape
.shape
input can beCircleConst
,CircleOutputDummy
, orCircleNode
.shape
input isCircleConst
shape
output_shape
would be staticreshape(tensor, [2, 3]) --> [2, 3]
shape
input isCircleOutputDummy
newShape
)shape
input), propagate the shape of node itselfshape
input isCircleNode
shape
input's size (because the exact shape cannot be determined at compile time)output_shape
would be dynamicreshape(tensor, shape_node(with size 3)) --> [?, ?, ?]
output_shape
and inputtensor
is fully known, that dimension is inferred by the count of the elementsWhen should not infer?
Unknown dimension of
output_shape
is NOT inferred (by theshould_infer
) when:shape
input isCircleNode
. Because if it's not constant, the only thing we can infer at compile time is the size of dimensions.tensor
input is not fully known. Because shape inference of reshape is based on the sameness of elements count.Exclude
Net_Gather_SparseToDense_AddV2_000
from: Samsung#13935 (comment),
FoldSparseToDensePass.cpp
Net_Gather_SparseToDense_AddV2_000
is excluded from optimization test because constant folding ofSparseToDense
is not fully supported.Remaining
own_shape
?from: Samsung#13935 (comment), Samsung#13935 (comment)
The usage of
circle_shape
might seems to be remaining ofown_shape
which should be removed by the new shape inference algorithm.First, this logic is used to support this recipe(
Reshape_003
) which has no attribute, no shape input.I've tried to revise this recipe according to this comment, and have read the related PRs (Samsung#1554, Samsung#1519).
But it was hard to make a policy about no attribute, no shape input case.
So, we decided not to fix another code(importer, recipes) and do it best in shape inference logic.
As a result, I followed the suggestion from Samsung#13927 (comment).
Neg test cases
from: Samsung#13977
Some of the neg test cases might not directly related to the changes that have been made in this PR.
(which means the
false return
andthrows
are not made inCircleReshape.cpp
.)Please tell me if these are inappropriate.
Related: Samsung#13927
Draft: Samsung#13935
Depends on: Samsung#13989
ONE-DCO-1.0-Signed-off-by: Jongwon Yang [email protected]