Skip to content

[OpenVINO backend] Update ndim behavior #21317

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions keras/src/backend/openvino/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

import numpy as np
import openvino as ov
import openvino.runtime.opset14 as ov_opset
import openvino.opset14 as ov_opset
from openvino import Model
from openvino import Tensor
from openvino import compile_model
from openvino.runtime import Type
from openvino import Type

from keras.src import tree
from keras.src.backend.common import KerasVariable
Expand Down
2 changes: 1 addition & 1 deletion keras/src/backend/openvino/math.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import openvino.runtime.opset14 as ov_opset
import openvino.opset14 as ov_opset
from openvino import Type

from keras.src.backend.openvino.core import OpenVINOKerasTensor
Expand Down
2 changes: 1 addition & 1 deletion keras/src/backend/openvino/nn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import openvino.runtime.opset14 as ov_opset
import openvino.opset14 as ov_opset
from openvino import Type

from keras.src import backend
Expand Down
6 changes: 2 additions & 4 deletions keras/src/backend/openvino/numpy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
import openvino.runtime.opset14 as ov_opset
import openvino.opset14 as ov_opset
from openvino import Type

from keras.src.backend import config
Expand Down Expand Up @@ -1167,9 +1167,7 @@ def nan_to_num(x, nan=0.0, posinf=None, neginf=None):

def ndim(x):
x = get_ov_output(x)
x_shape = ov_opset.shape_of(x).output(0)
x_dim = ov_opset.shape_of(x_shape, "i64")
return x_dim
return len(x.get_partial_shape().to_shape())


def nonzero(x):
Expand Down
2 changes: 1 addition & 1 deletion keras/src/backend/openvino/random.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
import openvino.runtime.opset14 as ov_opset
import openvino.opset14 as ov_opset
from openvino import Type

from keras.src.backend.config import floatx
Expand Down
2 changes: 1 addition & 1 deletion keras/src/backend/openvino/trainer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import openvino as ov
import openvino.runtime.opset14 as ov_opset
import openvino.opset14 as ov_opset

from keras.src import backend
from keras.src import callbacks as callbacks_module
Expand Down
Loading