Skip to content

[TF FE] Use Convert instead of ConvertLike for Slice stop#36209

Open
evkotov wants to merge 1 commit into
openvinotoolkit:masterfrom
evkotov:CVS-176224-slice-frontend-convert
Open

[TF FE] Use Convert instead of ConvertLike for Slice stop#36209
evkotov wants to merge 1 commit into
openvinotoolkit:masterfrom
evkotov:CVS-176224-slice-frontend-convert

Conversation

@evkotov
Copy link
Copy Markdown
Contributor

@evkotov evkotov commented Jun 3, 2026

Details:

The TF/TFLite Slice translator builds the absolute stop as
Select(Less(size, 0), ConvertLike(ShapeOf(data), size), Add(start, size)).
v8::Slice resolves stop through value-bound propagation (evaluate_both_bounds),
not constant folding. ConvertLike implements only constant_fold, not
evaluate_lower/evaluate_upper, so the bound walk breaks at ConvertLike before
reaching Select. As a result the Slice output stays dynamic even when the data
shape and start/size are static. This later trips consumers that need a static
shape (e.g. read_model fed into NPUW: "to_shape was called on a dynamic shape").

Build the negative-size branch with v0::Convert (to size's element type)
instead of v1::ConvertLike. Convert is value-identical here but already
implements bound evaluation, so bounds propagate through the cascade: Select
resolves its statically-false condition and Slice infers a static output during
validate_and_infer_types(), with no folding pass. This also makes the
size = -1 case static when the data shape is static.

Add a TF frontend test that converts a static-input Slice without MOC and checks
the Slice output stays static.

Tickets:

  • 176224

The TF/TFLite Slice translator builds the absolute `stop` as
Select(Less(size, 0), ConvertLike(ShapeOf(data), size), Add(start, size)).
v8::Slice resolves `stop` through value-bounds propagation
(evaluate_both_bounds), not constant folding. ConvertLike implements only
constant_fold, not evaluate_lower/upper, so the bound walk breaks at
ConvertLike before reaching Select, and the Slice output is left dynamic even
when the data shape and start/size are fully static. This trips downstream
consumers that require a static shape.

Build the negative-size branch with v0::Convert (to size's element type)
instead of v1::ConvertLike. Convert is value-identical here but already
implements bound evaluation, so bounds propagate through the whole cascade:
Select resolves its statically-false condition and Slice infers a static
output during validate_and_infer_types(), with no folding pass. This also
makes the size = -1 ("to end") case static whenever the data shape is static.

Add a TF frontend regression test (slice_static_shape.pbtxt) that converts a
static-input Slice without MOC and asserts the Slice output stays static.
@evkotov evkotov requested review from bumbosiepsak and mvafin June 3, 2026 12:45
@evkotov evkotov self-assigned this Jun 3, 2026
@evkotov evkotov requested a review from a team as a code owner June 3, 2026 12:45
@github-actions github-actions Bot added category: TF FE OpenVINO TensorFlow FrontEnd category: TFL FE OpenVINO TensorFlow Lite FrontEnd labels Jun 3, 2026
// resolve `stop` and keep the output static when the data shape is static.
Output<Node> stop_neg = make_shared<v3::ShapeOf>(input);
stop_neg = make_shared<v1::ConvertLike>(stop_neg, size);
stop_neg = make_shared<v0::Convert>(stop_neg, size.get_element_type());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not good, because size is input to operation, it can be dynamic and can have dynamic type, that is why ConvertLike was used here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: TF FE OpenVINO TensorFlow FrontEnd category: TFL FE OpenVINO TensorFlow Lite FrontEnd

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants