提交 af440de8 authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Add HasShape mixin

上级 7705b3e6
from abc import abstractmethod
from typing import Any, Optional, Text, TypeVar, Union
from typing import Any, Optional, Text, Tuple, TypeVar, Union
from typing_extensions import TypeAlias
......@@ -257,6 +257,13 @@ class Type(MetaObject):
class HasDataType:
"""A mixing for an `Op` type that has a :attr:`dtype` attribute."""
"""A mixin for a type that has a :attr:`dtype` attribute."""
dtype: str
class HasShape:
"""A mixin for a type that has :attr:`shape` and :attr:`ndim` attributes."""
ndim: int
shape: Tuple[Optional[int], ...]
......@@ -8,7 +8,7 @@ import aesara
from aesara import scalar as aes
from aesara.configdefaults import config
from aesara.graph.basic import Variable
from aesara.graph.type import HasDataType
from aesara.graph.type import HasDataType, HasShape
from aesara.graph.utils import MetaType
from aesara.link.c.type import CType
from aesara.misc.safe_asarray import _asarray
......@@ -48,7 +48,7 @@ dtype_specs_map = {
}
class TensorType(CType, HasDataType):
class TensorType(CType, HasDataType, HasShape):
r"""Symbolic `Type` representing `numpy.ndarray`\s."""
__props__: Tuple[str, ...] = ("dtype", "shape")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论