Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Renames ArrayApi into BaseArrayApi#16

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sdpython merged 1 commit intomainfromaapi
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes fromall 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
86 changes: 43 additions & 43 deletionsonnx_array_api/npx/npx_array_api.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,7 @@ class ArrayApiError(RuntimeError):
pass


classArrayApi:
classBaseArrayApi:
"""
List of supported method by a tensor.
"""
Expand All@@ -36,145 +36,145 @@ def generic_method(self, method_name, *args: Any, **kwargs: Any) -> Any:
f"for class {self.__class__.__name__!r}. "
f"Method 'generic_method' can be overwritten "
f"as well to change the behaviour "
f"for all methods supported by classArrayApi."
f"for all methods supported by classBaseArrayApi."
)

def numpy(self) -> np.ndarray:
return self.generic_method("numpy")

def __neg__(self) -> "ArrayApi":
def __neg__(self) -> "BaseArrayApi":
return self.generic_method("__neg__")

def __invert__(self) -> "ArrayApi":
def __invert__(self) -> "BaseArrayApi":
return self.generic_method("__invert__")

def __add__(self, ov: "ArrayApi") -> "ArrayApi":
def __add__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__add__", ov)

def __radd__(self, ov: "ArrayApi") -> "ArrayApi":
def __radd__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__radd__", ov)

def __sub__(self, ov: "ArrayApi") -> "ArrayApi":
def __sub__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__sub__", ov)

def __rsub__(self, ov: "ArrayApi") -> "ArrayApi":
def __rsub__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__rsub__", ov)

def __mul__(self, ov: "ArrayApi") -> "ArrayApi":
def __mul__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__mul__", ov)

def __rmul__(self, ov: "ArrayApi") -> "ArrayApi":
def __rmul__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__rmul__", ov)

def __matmul__(self, ov: "ArrayApi") -> "ArrayApi":
def __matmul__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__matmul__", ov)

def __truediv__(self, ov: "ArrayApi") -> "ArrayApi":
def __truediv__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__truediv__", ov)

def __rtruediv__(self, ov: "ArrayApi") -> "ArrayApi":
def __rtruediv__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__rtruediv__", ov)

def __mod__(self, ov: "ArrayApi") -> "ArrayApi":
def __mod__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__mod__", ov)

def __rmod__(self, ov: "ArrayApi") -> "ArrayApi":
def __rmod__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__rmod__", ov)

def __pow__(self, ov: "ArrayApi") -> "ArrayApi":
def __pow__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__pow__", ov)

def __rpow__(self, ov: "ArrayApi") -> "ArrayApi":
def __rpow__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__rpow__", ov)

def __lt__(self, ov: "ArrayApi") -> "ArrayApi":
def __lt__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__lt__", ov)

def __le__(self, ov: "ArrayApi") -> "ArrayApi":
def __le__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__le__", ov)

def __gt__(self, ov: "ArrayApi") -> "ArrayApi":
def __gt__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__gt__", ov)

def __ge__(self, ov: "ArrayApi") -> "ArrayApi":
def __ge__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__ge__", ov)

def __eq__(self, ov: "ArrayApi") -> "ArrayApi":
def __eq__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__eq__", ov)

def __ne__(self, ov: "ArrayApi") -> "ArrayApi":
def __ne__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__ne__", ov)

def __lshift__(self, ov: "ArrayApi") -> "ArrayApi":
def __lshift__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__lshift__", ov)

def __rshift__(self, ov: "ArrayApi") -> "ArrayApi":
def __rshift__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__rshift__", ov)

def __and__(self, ov: "ArrayApi") -> "ArrayApi":
def __and__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__and__", ov)

def __rand__(self, ov: "ArrayApi") -> "ArrayApi":
def __rand__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__rand__", ov)

def __or__(self, ov: "ArrayApi") -> "ArrayApi":
def __or__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__or__", ov)

def __ror__(self, ov: "ArrayApi") -> "ArrayApi":
def __ror__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__ror__", ov)

def __xor__(self, ov: "ArrayApi") -> "ArrayApi":
def __xor__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__xor__", ov)

def __rxor__(self, ov: "ArrayApi") -> "ArrayApi":
def __rxor__(self, ov: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("__rxor__", ov)

@property
def T(self) -> "ArrayApi":
def T(self) -> "BaseArrayApi":
return self.generic_method("T")

def astype(self, dtype: Any) -> "ArrayApi":
def astype(self, dtype: Any) -> "BaseArrayApi":
return self.generic_method("astype", dtype)

@property
def shape(self) -> "ArrayApi":
def shape(self) -> "BaseArrayApi":
return self.generic_method("shape")

def reshape(self, shape: "ArrayApi") -> "ArrayApi":
def reshape(self, shape: "BaseArrayApi") -> "BaseArrayApi":
return self.generic_method("reshape", shape)

def sum(
self, axis: OptParType[TupleType[int]] = None, keepdims: ParType[int] = 0
) -> "ArrayApi":
) -> "BaseArrayApi":
return self.generic_method("sum", axis=axis, keepdims=keepdims)

def mean(
self, axis: OptParType[TupleType[int]] = None, keepdims: ParType[int] = 0
) -> "ArrayApi":
) -> "BaseArrayApi":
return self.generic_method("mean", axis=axis, keepdims=keepdims)

def min(
self, axis: OptParType[TupleType[int]] = None, keepdims: ParType[int] = 0
) -> "ArrayApi":
) -> "BaseArrayApi":
return self.generic_method("min", axis=axis, keepdims=keepdims)

def max(
self, axis: OptParType[TupleType[int]] = None, keepdims: ParType[int] = 0
) -> "ArrayApi":
) -> "BaseArrayApi":
return self.generic_method("max", axis=axis, keepdims=keepdims)

def prod(
self, axis: OptParType[TupleType[int]] = None, keepdims: ParType[int] = 0
) -> "ArrayApi":
) -> "BaseArrayApi":
return self.generic_method("prod", axis=axis, keepdims=keepdims)

def copy(self) -> "ArrayApi":
def copy(self) -> "BaseArrayApi":
return self.generic_method("copy")

def flatten(self) -> "ArrayApi":
def flatten(self) -> "BaseArrayApi":
return self.generic_method("flatten")

def __getitem__(self, index: Any) -> "ArrayApi":
def __getitem__(self, index: Any) -> "BaseArrayApi":
return self.generic_method("__getitem__", index)

def __setitem__(self, index: Any, values: Any):
Expand Down
6 changes: 3 additions & 3 deletionsonnx_array_api/npx/npx_functions.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@

from .npx_constants import FUNCTION_DOMAIN
from .npx_core_api import cst, make_tuple, npxapi_inline, npxapi_no_inline, var
from .npx_tensors importArrayApi
from .npx_tensors importBaseArrayApi
from .npx_types import (
DType,
ElemType,
Expand DownExpand Up@@ -173,7 +173,7 @@ def asarray(
raise RuntimeError("Method 'astype' should be used to change the type.")
if order is not None:
raise NotImplementedError(f"order={order!r} not implemented.")
if isinstance(a,ArrayApi):
if isinstance(a,BaseArrayApi):
if copy:
return a.__class__(a, copy=copy)
return a
Expand DownExpand Up@@ -404,7 +404,7 @@ def isdtype(
dtype: DType, kind: Union[DType, str, Tuple[Union[DType, str], ...]]
) -> bool:
"""
See :epkg:`ArrayAPI:isdtype`.
See :epkg:`BaseArrayAPI:isdtype`.
This function is not converted into an onnx graph.
"""
return np_array_api.isdtype(dtype, kind)
Expand Down
10 changes: 5 additions & 5 deletionsonnx_array_api/npx/npx_tensors.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@
import numpy as np
from onnx.helper import np_dtype_to_tensor_dtype

from .npx_array_api importArrayApi, ArrayApiError
from .npx_array_api importBaseArrayApi, ArrayApiError


class JitTensor:
Expand All@@ -14,11 +14,11 @@ class JitTensor:
pass


class EagerTensor(ArrayApi):
class EagerTensor(BaseArrayApi):
"""
Defines a value for a specific eager mode.
An eager tensor must overwrite every call to a method listed in class
:class:`ArrayApi`.
:class:`BaseArrayApi`.
"""

def __iter__(self):
Expand DownExpand Up@@ -215,7 +215,7 @@ def generic_method(self, method_name, *args: Any, **kwargs: Any) -> Any:
return self._generic_method_getitem(method_name, *args, **kwargs)

if method_name == "__setitem__":
returnArrayApi.generic_method(self, method_name, *args, **kwargs)
returnBaseArrayApi.generic_method(self, method_name, *args, **kwargs)

if method_name in {"mean", "sum", "min", "max", "prod"}:
return self._generic_method_reduce(method_name, *args, **kwargs)
Expand All@@ -226,4 +226,4 @@ def generic_method(self, method_name, *args: Any, **kwargs: Any) -> Any:
if method_name.startswith("__") and method_name.endswith("__"):
return self._generic_method_operator(method_name, *args, **kwargs)

returnArrayApi.generic_method(self, method_name, *args, **kwargs)
returnBaseArrayApi.generic_method(self, method_name, *args, **kwargs)
4 changes: 2 additions & 2 deletionsonnx_array_api/npx/npx_var.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@
from onnx import FunctionProto, ModelProto, NodeProto, TensorProto
from onnx.helper import np_dtype_to_tensor_dtype

from .npx_array_api importArrayApi, ArrayApiError
from .npx_array_api importBaseArrayApi, ArrayApiError
from .npx_constants import DEFAULT_OPSETS, ONNX_DOMAIN
from .npx_types import ElemType, OptParType, ParType, TensorType, TupleType

Expand DownExpand Up@@ -181,7 +181,7 @@ def to_onnx(
return onx


class Var(ArrayApi):
class Var(BaseArrayApi):
"""
Defines a variable, a result...

Expand Down
4 changes: 2 additions & 2 deletionsonnx_array_api/ort/ort_tensors.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -231,15 +231,15 @@ def get_ir_version(cls, ir_version):

class EagerOrtTensor(OrtTensor, OrtCommon, EagerTensor):
"""
Defines a value fora specific backend.
Defines a value for:epkg:`onnxruntime` as a backend.
"""

pass


class JitOrtTensor(OrtTensor, OrtCommon, JitTensor):
"""
Defines a value fora specific backend.
Defines a value for:epkg:`onnxruntime` as a backend.
"""

pass

[8]ページ先頭

©2009-2025 Movatter.jp