-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
272 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import layerApicase.perf_monitor | ||
import layerApicase.nn_sublayer | ||
import layerApicase.nn_extreme_size | ||
import layerApicase.math_sublayer | ||
import layerApicase.math_extreme_size |
15 changes: 15 additions & 0 deletions
15
framework/e2e/PaddleLT_new/layerApicase/math_extreme_size/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import os | ||
import glob | ||
|
||
# 获取当前文件所在目录 | ||
current_dir = os.path.dirname(__file__) | ||
|
||
# 获取当前目录下所有的 .py 文件路径 | ||
py_files = glob.glob(os.path.join(current_dir, "*.py")) | ||
|
||
# 动态导入所有 .py 文件 | ||
for py_file in py_files: | ||
# 获取文件名(不含扩展名) | ||
module_name = os.path.basename(py_file)[:-3] | ||
# 导入模块 | ||
__import__('layerApicase.math_extreme_size.' + module_name, globals(), locals(), []) |
46 changes: 46 additions & 0 deletions
46
framework/e2e/PaddleLT_new/layerApicase/math_extreme_size/abs_giant_size_func.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import numpy as np | ||
import paddle | ||
|
||
|
||
class LayerCase(paddle.nn.Layer): | ||
""" | ||
case名称: abs_base | ||
api简介: 求绝对值 | ||
""" | ||
|
||
def __init__(self): | ||
super(LayerCase, self).__init__() | ||
|
||
def forward(self, x, ): | ||
""" | ||
forward | ||
""" | ||
|
||
paddle.seed(33) | ||
np.random.seed(33) | ||
out = paddle.abs(x, ) | ||
return out | ||
|
||
|
||
|
||
def create_inputspec(): | ||
inputspec = ( | ||
paddle.static.InputSpec(shape=(-1, -1, -1, -1, -1), dtype=paddle.float32, stop_gradient=False), | ||
) | ||
return inputspec | ||
|
||
def create_tensor_inputs(): | ||
""" | ||
paddle tensor | ||
""" | ||
inputs = (paddle.to_tensor(-1 + (1 - -1) * np.random.random([1024, 256, 128, 100, 2]).astype('float32'), dtype='float32', stop_gradient=False), ) | ||
return inputs | ||
|
||
|
||
def create_numpy_inputs(): | ||
""" | ||
numpy array | ||
""" | ||
inputs = (-1 + (1 - -1) * np.random.random([1024, 256, 128, 100, 2]).astype('float32'), ) | ||
return inputs | ||
|
47 changes: 47 additions & 0 deletions
47
framework/e2e/PaddleLT_new/layerApicase/nn_extreme_size/Conv2D_giant_size_class.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import numpy as np | ||
import paddle | ||
|
||
|
||
class LayerCase(paddle.nn.Layer): | ||
""" | ||
case名称: Conv2D_giant_size_class | ||
api简介: 2维卷积 | ||
""" | ||
|
||
def __init__(self): | ||
super(LayerCase, self).__init__() | ||
self.func = paddle.nn.Conv2D(kernel_size=[3, 3], in_channels=256, out_channels=1, ) | ||
|
||
def forward(self, data, ): | ||
""" | ||
forward | ||
""" | ||
|
||
paddle.seed(33) | ||
np.random.seed(33) | ||
out = self.func(data, ) | ||
return out | ||
|
||
|
||
|
||
def create_inputspec(): | ||
inputspec = ( | ||
paddle.static.InputSpec(shape=(-1, 256, -1, -1), dtype=paddle.float32, stop_gradient=False), | ||
) | ||
return inputspec | ||
|
||
def create_tensor_inputs(): | ||
""" | ||
paddle tensor | ||
""" | ||
inputs = (paddle.to_tensor(-1 + (1 - -1) * np.random.random([1024, 256, 128, 200]).astype('float32'), dtype='float32', stop_gradient=False), ) | ||
return inputs | ||
|
||
|
||
def create_numpy_inputs(): | ||
""" | ||
numpy array | ||
""" | ||
inputs = (-1 + (1 - -1) * np.random.random([1024, 256, 128, 200]).astype('float32'), ) | ||
return inputs | ||
|
15 changes: 15 additions & 0 deletions
15
framework/e2e/PaddleLT_new/layerApicase/nn_extreme_size/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import os | ||
import glob | ||
|
||
# 获取当前文件所在目录 | ||
current_dir = os.path.dirname(__file__) | ||
|
||
# 获取当前目录下所有的 .py 文件路径 | ||
py_files = glob.glob(os.path.join(current_dir, "*.py")) | ||
|
||
# 动态导入所有 .py 文件 | ||
for py_file in py_files: | ||
# 获取文件名(不含扩展名) | ||
module_name = os.path.basename(py_file)[:-3] | ||
# 导入模块 | ||
__import__('layerApicase.nn_extreme_size.' + module_name, globals(), locals(), []) |
15 changes: 15 additions & 0 deletions
15
framework/e2e/PaddleLT_new/torch_case/layerApicase/math_extreme_size/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import os | ||
import glob | ||
|
||
# 获取当前文件所在目录 | ||
current_dir = os.path.dirname(__file__) | ||
|
||
# 获取当前目录下所有的 .py 文件路径 | ||
py_files = glob.glob(os.path.join(current_dir, "*.py")) | ||
|
||
# 动态导入所有 .py 文件 | ||
for py_file in py_files: | ||
# 获取文件名(不含扩展名) | ||
module_name = os.path.basename(py_file)[:-3] | ||
# 导入模块 | ||
__import__('torch_case.layerApicase.math_extreme_size.' + module_name, globals(), locals(), []) |
39 changes: 39 additions & 0 deletions
39
framework/e2e/PaddleLT_new/torch_case/layerApicase/math_extreme_size/abs_giant_size_func.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import numpy as np | ||
import torch | ||
import torch.nn as nn | ||
|
||
|
||
class LayerCase(nn.Module): | ||
""" | ||
case名称: abs_base | ||
api简介: 求绝对值 | ||
""" | ||
|
||
def __init__(self): | ||
super(LayerCase, self).__init__() | ||
|
||
def forward(self, x): | ||
""" | ||
forward | ||
""" | ||
torch.manual_seed(33) | ||
np.random.seed(33) | ||
out = torch.abs(x) | ||
return out | ||
|
||
|
||
def create_tensor_inputs(): | ||
""" | ||
PyTorch tensor | ||
""" | ||
inputs = (torch.tensor((-1 + 2 * np.random.random([1024, 256, 128, 100, 2])).astype(np.float32), dtype=torch.float32, requires_grad=True), ) | ||
return inputs | ||
|
||
|
||
def create_numpy_inputs(): | ||
""" | ||
numpy array | ||
""" | ||
# 生成一个形状为[1024, 256, 128, 100, 2]的随机numpy数组,数据范围在[-1, 1) | ||
inputs = ((-1 + 2 * np.random.random([1024, 256, 128, 100, 2])).astype('float32'),) | ||
return inputs |
39 changes: 39 additions & 0 deletions
39
...ework/e2e/PaddleLT_new/torch_case/layerApicase/nn_extreme_size/Conv2D_giant_size_class.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import numpy as np | ||
import torch | ||
import torch.nn as nn | ||
|
||
|
||
class LayerCase(nn.Module): | ||
""" | ||
case名称: Conv2D_giant_size_class | ||
api简介: 2维卷积 | ||
""" | ||
|
||
def __init__(self): | ||
super(LayerCase, self).__init__() | ||
self.func = nn.Conv2d(in_channels=256, out_channels=1, kernel_size=3, stride=1, padding=1) | ||
|
||
def forward(self, data): | ||
""" | ||
forward | ||
""" | ||
torch.manual_seed(33) | ||
np.random.seed(33) | ||
out = self.func(data) | ||
return out | ||
|
||
|
||
def create_tensor_inputs(): | ||
""" | ||
PyTorch tensor | ||
""" | ||
inputs = (torch.tensor((-1 + 2 * np.random.random([1024, 256, 128, 200])).astype(np.float32), dtype=torch.float32, requires_grad=True), ) | ||
return inputs | ||
|
||
|
||
def create_numpy_inputs(): | ||
""" | ||
numpy array | ||
""" | ||
inputs = ((-1 + 2 * np.random.random([1024, 256, 128, 200])).astype('float32'),) | ||
return inputs |
15 changes: 15 additions & 0 deletions
15
framework/e2e/PaddleLT_new/torch_case/layerApicase/nn_extreme_size/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import os | ||
import glob | ||
|
||
# 获取当前文件所在目录 | ||
current_dir = os.path.dirname(__file__) | ||
|
||
# 获取当前目录下所有的 .py 文件路径 | ||
py_files = glob.glob(os.path.join(current_dir, "*.py")) | ||
|
||
# 动态导入所有 .py 文件 | ||
for py_file in py_files: | ||
# 获取文件名(不含扩展名) | ||
module_name = os.path.basename(py_file)[:-3] | ||
# 导入模块 | ||
__import__('torch_case.layerApicase.nn_extreme_size.' + module_name, globals(), locals(), []) |
39 changes: 39 additions & 0 deletions
39
framework/e2e/PaddleLT_new/torch_case/layerApicase/nn_sublayer/AdaptiveAvgPool3D_8_class.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import numpy as np | ||
import torch | ||
import torch.nn as nn | ||
|
||
|
||
class LayerCase(nn.Module): | ||
""" | ||
case名称: AdaptiveAvgPool3D_8 | ||
api简介: 3维自适应池化 | ||
""" | ||
|
||
def __init__(self): | ||
super(LayerCase, self).__init__() | ||
self.func = nn.AdaptiveAvgPool3d(output_size=(1, 1, 1)) | ||
|
||
def forward(self, data): | ||
""" | ||
forward | ||
""" | ||
torch.manual_seed(33) | ||
np.random.seed(33) | ||
out = self.func(data) | ||
return out | ||
|
||
|
||
def create_tensor_inputs(): | ||
""" | ||
PyTorch tensor | ||
""" | ||
inputs = (torch.tensor(-10 + (10 - -10) * np.random.random([2, 3, 8, 32, 32]).astype('float32'), dtype=torch.float32, requires_grad=True), ) | ||
return inputs | ||
|
||
|
||
def create_numpy_inputs(): | ||
""" | ||
numpy array | ||
""" | ||
inputs = (-10 + (10 - -10) * np.random.random([2, 3, 8, 32, 32]).astype('float32'), ) | ||
return inputs |