Skip to content

Commit

Permalink
[Typing][A-54,A-55,A-56] Add type annotations for `paddle/nn/function…
Browse files Browse the repository at this point in the history
…al/{activation.py, common.py, conv.py}` (PaddlePaddle#65191)


---------

Co-authored-by: SigureMo <sigure.qaq@gmail.com>
  • Loading branch information
2 people authored and co63oc committed Jun 25, 2024
1 parent 5c991f7 commit 987e933
Show file tree
Hide file tree
Showing 6 changed files with 367 additions and 172 deletions.
13 changes: 12 additions & 1 deletion python/paddle/_typing/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@
# limitations under the License.
from __future__ import annotations

from typing import TYPE_CHECKING, Any, List, Sequence, Tuple, TypeVar, Union
from typing import (
TYPE_CHECKING,
Any,
List,
Literal,
Sequence,
Tuple,
TypeVar,
Union,
)

import numpy as np
import numpy.typing as npt
Expand Down Expand Up @@ -44,3 +53,5 @@
NumbericSequence = Sequence[Numberic]
NestedNumbericSequence: TypeAlias = NestedSequence[Numberic]
TensorOrTensors: TypeAlias = Union["Tensor", Sequence["Tensor"]]

PaddingMode: TypeAlias = Literal['valid', 'same', 'VALID', 'SAME']
2 changes: 1 addition & 1 deletion python/paddle/_typing/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Note: Do not confrom to predefined naming style in pylint.
DataLayout0D: TypeAlias = Literal["NC"]
DataLayout1D: TypeAlias = Literal["NCL", "NLC"]
DataLayout2D: TypeAlias = Literal["NCHW", "NHCW"]
DataLayout2D: TypeAlias = Literal["NCHW", "NHWC"]
DataLayout3D: TypeAlias = Literal["NCDHW", "NDHWC"]

DataLayoutND: TypeAlias = Union[
Expand Down
Loading

0 comments on commit 987e933

Please sign in to comment.