-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[OP][CPU] Fix SliceScatter issues with non-constant slice params #27482
base: master
Are you sure you want to change the base?
[OP][CPU] Fix SliceScatter issues with non-constant slice params #27482
Conversation
…ution Signed-off-by: Mateusz Mikolajczyk <[email protected]>
Signed-off-by: Mateusz Mikolajczyk <[email protected]>
Signed-off-by: Mateusz Mikolajczyk <[email protected]>
if (!execPtr && !Node::isDynamic) { | ||
// SliceScatter due to not having data dependency on shape may not call prepareParams when start/stop/step values are non-constant in Static execution. | ||
StridedSlice::prepareParams(); | ||
} else if (!execPtr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same logic could be implemented without duplication of the !execPtr
check.
As the comment is related to the SliceScatter
op, shouldn't the attrs.isSliceScatterOp
be checked as well?
Also is there a chance that the prepareParams
will not initialize the execPtr
and it will be still a nullptr
after?
if (!execPtr && !Node::isDynamic) { | |
// SliceScatter due to not having data dependency on shape may not call prepareParams when start/stop/step values are non-constant in Static execution. | |
StridedSlice::prepareParams(); | |
} else if (!execPtr) { | |
if (!execPtr) { | |
if (attrs.isSliceScatterOp && !isDynamicNode()) { | |
// SliceScatter due to not having data dependency on shape may not call prepareParams when start/stop/step values are non-constant in Static execution. | |
StridedSlice::prepareParams(); | |
} else { | |
OPENVINO_THROW(errorPrefix, "doesn't have compiled executor!"); |
Is it a final solution or temp fix for the issue described in the comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking for isSliceScatter op may not be needed, instead it would make more sense to check for const inputs. for start/stop/step.
For other slice ops prepareParams is called in 2 ways:
- If params are const then prepareParams will be called by createPrimitive,
- If params are not const, createPrimitive will not be called, however since Slice/StridedSlice requires values from params to determine output shape, this node will be dynamic, thus it will call prepareParams in updateDynamicParams
In SliceScatter there is a problem with option 2 because output shape doesn't depend on data. So this would be an workaround for case where all inputs would have static shapes (node is static so no updateDynamicParams) and start/stop/step would be non-constant (prepareParams cannot be called during createPrimitive due to depending on const value).
As for final solution, I guess it may benefit from some changes to StridedSliceCommonExecutor since with static shapes, some calculations could be prepared in createPrimitive stage.
Signed-off-by: MATEUSZ MIKOLAJCZYK <[email protected]>
@maxnick Could you please take a look from CPU side? |
Signed-off-by: MATEUSZ MIKOLAJCZYK <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM shape inference core part.
@mitruska , do you have any further comments or suggestions? |
No further comments |
if (!execPtr) { | ||
if (!isDynamicNode() && !hasConstAttrInputs) { | ||
// SliceScatter due to not having data dependency on shape may not call prepareParams when start/stop/step values are non-constant in Static execution. | ||
// In Slice and SliceScatter op, prepareParams would be called by createPrimitive (if const inputs) or by updateDynamicParams in case of dynamic node. | ||
StridedSlice::prepareParams(); | ||
} else { | ||
OPENVINO_THROW(errorPrefix, "doesn't have compiled executor!"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the data on the corresponding inputs are not constant, it means that the executor must be reinitialized every inference call, as the data in variables may be updated each inference. If the tests pass, that means that either the test converge is still not sufficient, or there is no real data dependency and the executor may be created at the compilation stage.
src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice_scatter.cpp
Outdated
Show resolved
Hide resolved
@@ -83,7 +83,13 @@ class SliceScatterLayerCPUTest : public testing::WithParamInterface<SliceScatter | |||
in_data); | |||
} else { | |||
// Fill the slice input2~input5 with specified data. | |||
tensor = ov::Tensor{ov::element::i64, targetInputStaticShapes[i], inputValues[i - 2]}; | |||
auto inputValue = inputValues[i - 2]; | |||
if (!inputValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please elaborate on the reason behind introducing this check? It looks like the current test configuration doesn't provide null pointers. But if it does, an input tensor is created but not initialized with valid values. So what is the expectation of using such an input?
const auto param = ov::as_type_ptr<const ov::op::v0::Parameter>(funcInput.get_node_shared_ptr()); | ||
tensor = ov::Tensor{ov::element::i64, targetInputStaticShapes[i]}; | ||
} else { | ||
tensor = ov::Tensor{ov::element::i64, targetInputStaticShapes[i], inputValue}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this is the reason why the tests don't cover the main issue, as is being resolved in this PR. The thing is that the SL tests in the static shapes configuration perform only one inference, thus the values on the variable inputs don't really change from infer to infer and SL tests don't spot the issue. But if we had had such tests, they would have revealed the design flaw of the current solution solution (please see the comment regarding execute
method implementation). So apparently the SL tests should be extended to cover such a use case: the values on the variable inputs actually changes each inference. To this end even a dedicated test class may be introduced, when necessary.
Signed-off-by: Mateusz Mikolajczyk <[email protected]>
…into mateuszm/slicescatter/cpu_bugfix Signed-off-by: Mateusz Mikolajczyk <[email protected]>
Signed-off-by: Mateusz Mikolajczyk <[email protected]>
This PR will be closed in a week because of 2 weeks of no activity. |
Details:
Tickets: