Skip to content

Commit

Permalink
[Py OV] Add op to openvino module (#27902)
Browse files Browse the repository at this point in the history
### Details:
- copy `openvino/runtime/op/` to `openvino`. `op/` is not initialized in
`openvino/runtime/__init__.py`. Update inits in openvino/runtime/op/
- update rule `src/openvino/runtime/*/ops.py: VNE001,VNE003` in
_setup.cfg_
- For opset 1 - 16:
  - move `runtime/opsetx/ops.py`. 
  - update opsetx inits to import from new ops.py location. 
  - add `runtime/opsetx/ops/__init__.py`.
- initialize opsets in openvino init
- add imports for opset14-16 to `openvino/runtime/__init__.py`
- adds possibility to import opsets directly:
```python
import openvino.opset13 as ops
param = ops.parameter([10])
```
or
```python
import openvino as ov
param = ov.opset13.parameter([10])
```


### Tickets:
 - CVS-129458

---------

Signed-off-by: Alicja Miloszewska <[email protected]>
  • Loading branch information
almilosz authored Dec 10, 2024
1 parent 773c214 commit 1be5963
Show file tree
Hide file tree
Showing 73 changed files with 5,243 additions and 2,408 deletions.
2 changes: 1 addition & 1 deletion src/bindings/python/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ show_source = True
docstring-convention = google
enable-extensions = G
per-file-ignores =
src/openvino/runtime/*/ops.py: VNE001,VNE003
src/openvino/*/ops.py: VNE001,VNE003
src/openvino/preprocess/torchvision/*: N801, VNE001
*__init__.py: F401

Expand Down
18 changes: 18 additions & 0 deletions src/bindings/python/src/openvino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@
from openvino._pyopenvino import RemoteTensor
from openvino._pyopenvino import Op

# Import opsets
from openvino import opset1
from openvino import opset2
from openvino import opset3
from openvino import opset4
from openvino import opset5
from openvino import opset6
from openvino import opset7
from openvino import opset8
from openvino import opset9
from openvino import opset10
from openvino import opset11
from openvino import opset12
from openvino import opset13
from openvino import opset14
from openvino import opset15
from openvino import opset16

# libva related:
from openvino._pyopenvino import VAContext
from openvino._pyopenvino import VASurfaceTensor
Expand Down
19 changes: 19 additions & 0 deletions src/bindings/python/src/openvino/op/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2018-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

"""
Package: openvino.op
Low level wrappers for the c++ api in ov::op.
"""

# flake8: noqa

from openvino._pyopenvino.op import Constant
from openvino._pyopenvino.op import assign
from openvino._pyopenvino.op import _PagedAttentionExtension
from openvino._pyopenvino.op import Parameter
from openvino._pyopenvino.op import if_op
from openvino._pyopenvino.op import loop
from openvino._pyopenvino.op import tensor_iterator
from openvino._pyopenvino.op import read_value
from openvino._pyopenvino.op import Result
22 changes: 22 additions & 0 deletions src/bindings/python/src/openvino/op/util/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (C) 2018-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

"""
Package: openvino.op.util
Low level wrappers for the c++ api in ov::op::util.
"""
# flake8: noqa

from openvino._pyopenvino.op.util import UnaryElementwiseArithmetic
from openvino._pyopenvino.op.util import BinaryElementwiseComparison
from openvino._pyopenvino.op.util import BinaryElementwiseArithmetic
from openvino._pyopenvino.op.util import BinaryElementwiseLogical
from openvino._pyopenvino.op.util import ArithmeticReduction
from openvino._pyopenvino.op.util import IndexReduction
from openvino._pyopenvino.op.util import VariableInfo
from openvino._pyopenvino.op.util import Variable
from openvino._pyopenvino.op.util import MergedInputDescription
from openvino._pyopenvino.op.util import InvariantInputDescription
from openvino._pyopenvino.op.util import SliceInputDescription
from openvino._pyopenvino.op.util import ConcatOutputDescription
from openvino._pyopenvino.op.util import BodyOutputDescription
111 changes: 111 additions & 0 deletions src/bindings/python/src/openvino/opset1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

from openvino.opset1.ops import absolute
from openvino.opset1.ops import absolute as abs
from openvino.opset1.ops import acos
from openvino.opset1.ops import add
from openvino.opset1.ops import asin
from openvino.opset1.ops import atan
from openvino.opset1.ops import avg_pool
from openvino.opset1.ops import batch_norm_inference
from openvino.opset1.ops import binary_convolution
from openvino.opset1.ops import broadcast
from openvino.opset1.ops import ceiling
from openvino.opset1.ops import ceiling as ceil
from openvino.opset1.ops import clamp
from openvino.opset1.ops import concat
from openvino.opset1.ops import constant
from openvino.opset1.ops import convert
from openvino.opset1.ops import convert_like
from openvino.opset1.ops import convolution
from openvino.opset1.ops import convolution_backprop_data
from openvino.opset1.ops import cos
from openvino.opset1.ops import cosh
from openvino.opset1.ops import ctc_greedy_decoder
from openvino.opset1.ops import deformable_convolution
from openvino.opset1.ops import deformable_psroi_pooling
from openvino.opset1.ops import depth_to_space
from openvino.opset1.ops import detection_output
from openvino.opset1.ops import divide
from openvino.opset1.ops import elu
from openvino.opset1.ops import equal
from openvino.opset1.ops import erf
from openvino.opset1.ops import exp
from openvino.opset1.ops import fake_quantize
from openvino.opset1.ops import floor
from openvino.opset1.ops import floor_mod
from openvino.opset1.ops import gather
from openvino.opset1.ops import gather_tree
from openvino.opset1.ops import greater
from openvino.opset1.ops import greater_equal
from openvino.opset1.ops import grn
from openvino.opset1.ops import group_convolution
from openvino.opset1.ops import group_convolution_backprop_data
from openvino.opset1.ops import hard_sigmoid
from openvino.opset1.ops import interpolate
from openvino.opset1.ops import less
from openvino.opset1.ops import less_equal
from openvino.opset1.ops import log
from openvino.opset1.ops import logical_and
from openvino.opset1.ops import logical_not
from openvino.opset1.ops import logical_or
from openvino.opset1.ops import logical_xor
from openvino.opset1.ops import lrn
from openvino.opset1.ops import lstm_cell
from openvino.opset1.ops import matmul
from openvino.opset1.ops import max_pool
from openvino.opset1.ops import maximum
from openvino.opset1.ops import minimum
from openvino.opset1.ops import mod
from openvino.opset1.ops import multiply
from openvino.opset1.ops import negative
from openvino.opset1.ops import non_max_suppression
from openvino.opset1.ops import normalize_l2
from openvino.opset1.ops import not_equal
from openvino.opset1.ops import one_hot
from openvino.opset1.ops import pad
from openvino.opset1.ops import parameter
from openvino.opset1.ops import power
from openvino.opset1.ops import prelu
from openvino.opset1.ops import prior_box
from openvino.opset1.ops import prior_box_clustered
from openvino.opset1.ops import psroi_pooling
from openvino.opset1.ops import proposal
from openvino.opset1.ops import range
from openvino.opset1.ops import reduce_logical_and
from openvino.opset1.ops import reduce_logical_or
from openvino.opset1.ops import reduce_max
from openvino.opset1.ops import reduce_mean
from openvino.opset1.ops import reduce_min
from openvino.opset1.ops import reduce_prod
from openvino.opset1.ops import reduce_sum
from openvino.opset1.ops import region_yolo
from openvino.opset1.ops import relu
from openvino.opset1.ops import reshape
from openvino.opset1.ops import result
from openvino.opset1.ops import reverse_sequence
from openvino.opset1.ops import select
from openvino.opset1.ops import selu
from openvino.opset1.ops import shape_of
from openvino.opset1.ops import sigmoid
from openvino.opset1.ops import sign
from openvino.opset1.ops import sin
from openvino.opset1.ops import sinh
from openvino.opset1.ops import softmax
from openvino.opset1.ops import space_to_depth
from openvino.opset1.ops import split
from openvino.opset1.ops import sqrt
from openvino.opset1.ops import squared_difference
from openvino.opset1.ops import squeeze
from openvino.opset1.ops import strided_slice
from openvino.opset1.ops import subtract
from openvino.opset1.ops import tan
from openvino.opset1.ops import tanh
from openvino.opset1.ops import tensor_iterator
from openvino.opset1.ops import tile
from openvino.opset1.ops import topk
from openvino.opset1.ops import transpose
from openvino.opset1.ops import unsqueeze
from openvino.opset1.ops import variadic_split
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from functools import partial

from openvino.runtime import Node, PartialShape, Type
from openvino.runtime.op import Constant, Parameter, tensor_iterator
from openvino.op import Constant, Parameter, tensor_iterator
from openvino.runtime.opset_utils import _get_node_factory
from openvino.runtime.utils.decorators import binary_op, nameable_op, unary_op
from openvino.runtime.utils.input_validation import (
Expand Down
179 changes: 179 additions & 0 deletions src/bindings/python/src/openvino/opset10/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

from openvino.opset1.ops import absolute
from openvino.opset1.ops import absolute as abs
from openvino.opset1.ops import acos
from openvino.opset4.ops import acosh
from openvino.opset8.ops import adaptive_avg_pool
from openvino.opset8.ops import adaptive_max_pool
from openvino.opset1.ops import add
from openvino.opset1.ops import asin
from openvino.opset4.ops import asinh
from openvino.opset6.ops import assign
from openvino.opset1.ops import atan
from openvino.opset4.ops import atanh
from openvino.opset1.ops import avg_pool
from openvino.opset5.ops import batch_norm_inference
from openvino.opset2.ops import batch_to_space
from openvino.opset1.ops import binary_convolution
from openvino.opset3.ops import broadcast
from openvino.opset3.ops import bucketize
from openvino.opset1.ops import ceiling
from openvino.opset1.ops import ceiling as ceil
from openvino.opset1.ops import clamp
from openvino.opset1.ops import concat
from openvino.opset1.ops import constant
from openvino.opset1.ops import convert
from openvino.opset1.ops import convert_like
from openvino.opset1.ops import convolution
from openvino.opset1.ops import convolution_backprop_data
from openvino.opset1.ops import cos
from openvino.opset1.ops import cosh
from openvino.opset1.ops import ctc_greedy_decoder
from openvino.opset6.ops import ctc_greedy_decoder_seq_len
from openvino.opset4.ops import ctc_loss
from openvino.opset3.ops import cum_sum
from openvino.opset3.ops import cum_sum as cumsum
from openvino.opset8.ops import deformable_convolution
from openvino.opset1.ops import deformable_psroi_pooling
from openvino.opset1.ops import depth_to_space
from openvino.opset8.ops import detection_output
from openvino.opset7.ops import dft
from openvino.opset1.ops import divide
from openvino.opset7.ops import einsum
from openvino.opset1.ops import elu
from openvino.opset3.ops import embedding_bag_offsets_sum
from openvino.opset3.ops import embedding_bag_packed_sum
from openvino.opset3.ops import embedding_segments_sum
from openvino.opset3.ops import extract_image_patches
from openvino.opset1.ops import equal
from openvino.opset1.ops import erf
from openvino.opset1.ops import exp
from openvino.opset9.ops import eye
from openvino.opset1.ops import fake_quantize
from openvino.opset1.ops import floor
from openvino.opset1.ops import floor_mod
from openvino.opset8.ops import gather
from openvino.opset6.ops import gather_elements
from openvino.opset8.ops import gather_nd
from openvino.opset1.ops import gather_tree
from openvino.opset7.ops import gelu
from openvino.opset9.ops import generate_proposals
from openvino.opset1.ops import greater
from openvino.opset1.ops import greater_equal
from openvino.opset9.ops import grid_sample
from openvino.opset1.ops import grn
from openvino.opset1.ops import group_convolution
from openvino.opset1.ops import group_convolution_backprop_data
from openvino.opset3.ops import gru_cell
from openvino.opset5.ops import gru_sequence
from openvino.opset1.ops import hard_sigmoid
from openvino.opset5.ops import hsigmoid
from openvino.opset4.ops import hswish
from openvino.opset7.ops import idft
from openvino.opset8.ops import if_op
from openvino.opset10.ops import interpolate
from openvino.opset9.ops import irdft
from openvino.opset10.ops import is_finite
from openvino.opset10.ops import is_inf
from openvino.opset10.ops import is_nan
from openvino.opset8.ops import i420_to_bgr
from openvino.opset8.ops import i420_to_rgb
from openvino.opset1.ops import less
from openvino.opset1.ops import less_equal
from openvino.opset1.ops import log
from openvino.opset1.ops import logical_and
from openvino.opset1.ops import logical_not
from openvino.opset1.ops import logical_or
from openvino.opset1.ops import logical_xor
from openvino.opset5.ops import log_softmax
from openvino.opset5.ops import loop
from openvino.opset1.ops import lrn
from openvino.opset4.ops import lstm_cell
from openvino.opset5.ops import lstm_sequence
from openvino.opset1.ops import matmul
from openvino.opset8.ops import matrix_nms
from openvino.opset8.ops import max_pool
from openvino.opset1.ops import maximum
from openvino.opset1.ops import minimum
from openvino.opset4.ops import mish
from openvino.opset1.ops import mod
from openvino.opset9.ops import multiclass_nms
from openvino.opset1.ops import multiply
from openvino.opset6.ops import mvn
from openvino.opset1.ops import negative
from openvino.opset9.ops import non_max_suppression
from openvino.opset3.ops import non_zero
from openvino.opset1.ops import normalize_l2
from openvino.opset1.ops import not_equal
from openvino.opset8.ops import nv12_to_bgr
from openvino.opset8.ops import nv12_to_rgb
from openvino.opset1.ops import one_hot
from openvino.opset1.ops import pad
from openvino.opset1.ops import parameter
from openvino.opset1.ops import power
from openvino.opset1.ops import prelu
from openvino.opset8.ops import prior_box
from openvino.opset1.ops import prior_box_clustered
from openvino.opset1.ops import psroi_pooling
from openvino.opset4.ops import proposal
from openvino.opset1.ops import range
from openvino.opset8.ops import random_uniform
from openvino.opset9.ops import rdft
from openvino.opset6.ops import read_value
from openvino.opset4.ops import reduce_l1
from openvino.opset4.ops import reduce_l2
from openvino.opset1.ops import reduce_logical_and
from openvino.opset1.ops import reduce_logical_or
from openvino.opset1.ops import reduce_max
from openvino.opset1.ops import reduce_mean
from openvino.opset1.ops import reduce_min
from openvino.opset1.ops import reduce_prod
from openvino.opset1.ops import reduce_sum
from openvino.opset1.ops import region_yolo
from openvino.opset2.ops import reorg_yolo
from openvino.opset1.ops import relu
from openvino.opset1.ops import reshape
from openvino.opset1.ops import result
from openvino.opset1.ops import reverse_sequence
from openvino.opset3.ops import rnn_cell
from openvino.opset5.ops import rnn_sequence
from openvino.opset9.ops import roi_align
from openvino.opset2.ops import roi_pooling
from openvino.opset7.ops import roll
from openvino.opset5.ops import round
from openvino.opset3.ops import scatter_elements_update
from openvino.opset4.ops import scatter_nd_update
from openvino.opset3.ops import scatter_update
from openvino.opset1.ops import select
from openvino.opset1.ops import selu
from openvino.opset3.ops import shape_of
from openvino.opset3.ops import shuffle_channels
from openvino.opset1.ops import sigmoid
from openvino.opset1.ops import sign
from openvino.opset1.ops import sin
from openvino.opset1.ops import sinh
from openvino.opset8.ops import slice
from openvino.opset8.ops import softmax
from openvino.opset4.ops import softplus
from openvino.opset9.ops import softsign
from openvino.opset2.ops import space_to_batch
from openvino.opset1.ops import space_to_depth
from openvino.opset1.ops import split
from openvino.opset1.ops import sqrt
from openvino.opset1.ops import squared_difference
from openvino.opset1.ops import squeeze
from openvino.opset1.ops import strided_slice
from openvino.opset1.ops import subtract
from openvino.opset4.ops import swish
from openvino.opset1.ops import tan
from openvino.opset1.ops import tanh
from openvino.opset1.ops import tensor_iterator
from openvino.opset1.ops import tile
from openvino.opset3.ops import topk
from openvino.opset1.ops import transpose
from openvino.opset10.ops import unique
from openvino.opset1.ops import unsqueeze
from openvino.opset1.ops import variadic_split
Loading

0 comments on commit 1be5963

Please sign in to comment.