|
@@ -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" |
|
|