Skip to content

Commit

Permalink
[PyOV] Consts ops from Tensor
Browse files Browse the repository at this point in the history
  • Loading branch information
akuporos committed Sep 26, 2024
1 parent 36a3bd8 commit cb651bb
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/bindings/python/src/openvino/runtime/opset13/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# SPDX-License-Identifier: Apache-2.0

"""Factory functions for ops added to openvino opset13."""
from functools import partial
from functools import partial, singledispatch
from typing import Literal, Optional, Union
import logging

import numpy as np

log = logging.getLogger(__name__)

from openvino.runtime import Node, Shape, Type, Output
from openvino.runtime import Node, Shape, Type, Output, Tensor
from openvino.runtime.op import Constant, Result
from openvino.runtime.opset1 import convert_like
from openvino.runtime.opset_utils import _get_node_factory
Expand Down Expand Up @@ -271,6 +271,7 @@ def scaled_dot_product_attention(
return _get_node_factory_opset13().create("ScaledDotProductAttention", inputs, attributes)


@singledispatch
@nameable_op
def constant(
value: Union[NumericData, np.number, bool, np.bool_, list],
Expand Down Expand Up @@ -338,6 +339,14 @@ def display_shared_memory_warning(warning_message: str) -> None:
return Constant(_value, shared_memory=_shared_memory)


@constant.register
def _(
tensor: Tensor,
shared_memory: bool = False,
) -> Constant:
return Constant(tensor, shared_memory=shared_memory)


@unary_op
def result(data: Union[Node, Output, NumericData], name: Optional[str] = None) -> Node:
"""Return a node which represents an output of a graph (Model).
Expand Down

0 comments on commit cb651bb

Please sign in to comment.