Skip to content

Commit

Permalink
[STFT][Op][Python] Fix STFT Python API to pass attribute (openvinotoo…
Browse files Browse the repository at this point in the history
…lkit#27311)

### Details:
 - Fix STFT Python API to pass "transpose_frames" attribute

### Tickets:
 - 147160
  • Loading branch information
mitruska authored and CuriousPanCake committed Nov 6, 2024
1 parent 727c92c commit 7867f87
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bindings/python/src/openvino/runtime/opset15/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def stft(
:return: The new node performing STFT operation.
"""
inputs = as_nodes(data, window, frame_size, frame_step, name=name)
return _get_node_factory_opset15().create("STFT", inputs)
return _get_node_factory_opset15().create("STFT", inputs, {"transpose_frames": transpose_frames})


@nameable_op
Expand Down
10 changes: 9 additions & 1 deletion src/bindings/python/tests/test_graph/test_create_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -2492,15 +2492,23 @@ def test_stft():
window = ov.parameter([7], name="window", dtype=np.float32)
frame_size = ov.constant(np.array(11, dtype=np.int32))
frame_step = ov.constant(np.array(3, dtype=np.int32))
transpose_frames = True

transpose_frames = False
op = ov_opset15.stft(data, window, frame_size, frame_step, transpose_frames)

assert op.get_type_name() == "STFT"
assert op.get_output_size() == 1
assert op.get_output_element_type(0) == Type.f32
assert op.get_output_shape(0) == [4, 13, 6, 2]

transpose_frames = True
op = ov_opset15.stft(data, window, frame_size, frame_step, transpose_frames)

assert op.get_type_name() == "STFT"
assert op.get_output_size() == 1
assert op.get_output_element_type(0) == Type.f32
assert op.get_output_shape(0) == [4, 6, 13, 2]


def test_search_sorted():
sorted_sequence = ov.parameter([7, 256, 200, 200], name="sorted", dtype=np.float32)
Expand Down

0 comments on commit 7867f87

Please sign in to comment.