Skip to content

Commit dcdc91f

Browse files
authored
[Py FE] Try folding slice axis (#29425)
### Details: - *Fold Reshape during Slice axis translation* ### Tickets: - *DeepSeek R1 related*
1 parent dc06fe4 commit dcdc91f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/frontends/pytorch/src/op/slice.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ OutputVector translate_slice_common(const NodeContext& context,
3333
dim = context.get_input(1);
3434
if (dim.get_partial_shape().rank().is_dynamic() || dim.get_partial_shape().rank().get_length() == 0) {
3535
dim = context.mark_node(std::make_shared<v1::Reshape>(dim, dims_1d_shape, false));
36+
if (const auto axis_const = ov::util::get_constant_from_source(dim)) {
37+
dim = axis_const;
38+
}
3639
}
3740
start_idx = 2;
3841
end_idx = 3;

0 commit comments

Comments
 (0)