Browse Source

style(mge): change the pad opr doc and format

GitOrigin-RevId: 7b20e96519
release-1.6
Megvii Engine Team 3 years ago
parent
commit
ffcb4dacd9
2 changed files with 10 additions and 13 deletions
  1. +4
    -12
      imperative/python/megengine/functional/nn.py
  2. +6
    -1
      imperative/python/megengine/module/padding.py

+ 4
- 12
imperative/python/megengine/functional/nn.py View File

@@ -1595,24 +1595,16 @@ def sliding_window_transpose(
def pad( def pad(
src: Tensor, src: Tensor,
pad_witdth: Tuple[Tuple[int, int], ...], pad_witdth: Tuple[Tuple[int, int], ...],
mode: str = "CONSTANT",
mode: str = "constant",
constant_value: float = 0.0, constant_value: float = 0.0,
) -> Tensor: ) -> Tensor:
""" """
pad
Pad is python warpper for padding opr in megbrain, can padding in random one of the max 7 dimensions.
Supported constant, edge(replicate) and reflect mode, constatnt is the default mode.
""" """
p_offsets = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] p_offsets = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]


assert mode in [
"constant",
"CONSTANT",
"edge",
"EDGE",
"replicate",
"REPLICATE",
"reflect",
"REFLECT",
]
assert mode.lower() in ["constant", "edge", "replicate", "reflect"]


if mode.lower() == "edge": if mode.lower() == "edge":
mode = "replicate" mode = "replicate"


+ 6
- 1
imperative/python/megengine/module/padding.py View File

@@ -5,10 +5,15 @@ from .module import Module




class Pad(Module): class Pad(Module):
"""
Pad is python warpper for padding opr in megbrain, can padding in random one of the max 7 dimensions.
Supported constant, edge(replicate) and reflect mode, constatnt is the default mode.
"""

def __init__( def __init__(
self, self,
pad_witdth: Tuple[Tuple[int, int], ...], pad_witdth: Tuple[Tuple[int, int], ...],
mode: str = "CONSTANT",
mode: str = "constant",
constant_val: float = 0.0, constant_val: float = 0.0,
): ):
super().__init__() super().__init__()


Loading…
Cancel
Save