Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
bcea1c2
added testdata for curved qr code decoding
APrigarina Oct 15, 2020
a2e3858
Merge pull request #811 from APrigarina:curved_qrcodes_decoding
alalek Oct 23, 2020
1252b83
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Oct 26, 2020
77b41e6
Merge pull request #813 from sl-sergei:test_conv1d
sl-sergei Nov 13, 2020
1bca31c
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Nov 13, 2020
b2c4f02
Add testdata for Gather with multiple outputs
sl-sergei Sep 8, 2020
ec80ca3
add tbmr test data
Nov 16, 2020
d1242e6
Merge pull request #804 from sl-sergei:multi_output_gather
alalek Nov 17, 2020
b4d7f80
Add tests for networks with dynamic input size (parametrized)
sl-sergei Nov 17, 2020
d868dfb
Added testdata for ReduceMax
l-bat Nov 17, 2020
f64b67c
Merge pull request #798 from sl-sergei:named_params_onnx
alalek Nov 17, 2020
5ea764d
Merge pull request #818 from l-bat:update_reducemax
alalek Nov 17, 2020
2d06c0f
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Nov 17, 2020
2f37289
Add tests for Pool1d
sl-sergei Nov 18, 2020
5b792fc
Merge pull request #817 from crownedone:tbmr_features
alalek Nov 18, 2020
3ace03b
Merge pull request #816 from JulienMaille:patch-1
JulienMaille Nov 20, 2020
a97cd55
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Nov 20, 2020
741f660
Merge pull request #820 from sl-sergei:test_pool1d
alalek Nov 24, 2020
7a5c2e9
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
alalek Nov 27, 2020
ffb83ef
Merge remote-tracking branch 'upstream/master' into merge-4.x
alalek Nov 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file added testdata/cv/qrcode/curved/curved_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testdata/cv/qrcode/curved/curved_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testdata/cv/qrcode/curved/curved_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testdata/cv/qrcode/curved/curved_4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testdata/cv/qrcode/curved/curved_5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testdata/cv/qrcode/curved/curved_6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testdata/cv/qrcode/curved/curved_7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testdata/cv/qrcode/curved/curved_8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions testdata/cv/qrcode/curved/dataset_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"test_images": [
{ "image_name": "curved_1.jpg", "x": [ 343, 48, 179, 447 ], "y": [
399, 276, 19, 115 ],
"info": "https://github.com/opencv/opencv" },
{ "image_name": "curved_2.jpg", "x": [ 61, 62, 220, 228 ], "y": [
232, 60, 54, 240 ], "info": "OpenCV" },
{ "image_name": "curved_3.jpg", "x": [ 55, 40, 357, 327 ], "y": [
365, 84, 84, 363 ], "info": "2020" },
{ "image_name": "curved_4.jpg", "x": [ 315, 306, 180, 180 ], "y": [
277, 404, 413, 272 ], "info": "OpenCV" },
{ "image_name": "curved_5.jpg", "x": [ 79, 272, 270, 92 ], "y": [
64, 69, 254, 234 ], "info": "http://q.mcd.com/qc222222" },
{ "image_name": "curved_6.jpg", "x": [ 43, 45, 324, 312 ], "y": [
363, 53, 67, 337 ],
"info": "https://habr.com/ru/company/intel/blog/507382/" },
{ "image_name": "curved_7.jpg", "x": [ 53, 337, 343, 75 ], "y": [
156, 163, 465, 412 ], "info": "2020" },
{ "image_name": "curved_8.jpg", "x": [ 44, 360, 345, 71 ], "y": [
182, 184, 471, 456 ],
"info": "https://habr.com/ru/company/intel/blog/507382/" }
]
}
Binary file added testdata/dnn/onnx/data/input_average_pooling_1d.npy
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_conv1d.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_conv1d_bias.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_conv1d_variable_w_0.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_conv1d_variable_w_1.npy
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed testdata/dnn/onnx/data/input_dynamic_resize_0.npy
Binary file not shown.
Binary file removed testdata/dnn/onnx/data/input_dynamic_resize_1.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_dynamic_resize_10_0.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_dynamic_resize_10_1.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_dynamic_resize_11_0.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_dynamic_resize_11_1.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_dynamic_resize_12_0.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_dynamic_resize_12_1.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_dynamic_resize_9_0.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_dynamic_resize_9_1.npy
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_gather_dynamic_axes.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_gather_multi_output.npy
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_maxpooling_1d.npy
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_pool_conv_1d.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_reduce_max_axis_0.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_reduce_max_axis_1.npy
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_slice_dynamic_axes.npy
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_two_maxpooling_1d.npy
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_average_pooling_1d.npy
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_conv1d.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_conv1d_bias.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_conv1d_variable_w.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_conv1d_variable_wb.npy
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_dynamic_resize_10.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_dynamic_resize_11.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_dynamic_resize_12.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_dynamic_resize_9.npy
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_maxpooling_1d.npy
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_pool_conv_1d.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_reduce_max_axis_0.npy
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_reduce_max_axis_1.npy
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_slice_dynamic_axes.npy
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_two_maxpooling_1d.npy
Binary file not shown.
Binary file not shown.
271 changes: 255 additions & 16 deletions testdata/dnn/onnx/generate_onnx_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import print_function
import torch
from torch.autograd import Variable
from torch.autograd import Variable, Function
import torch.nn.init as init
import torch.nn as nn
import torch.nn.functional as F
Expand All @@ -24,14 +24,14 @@ def assertONNXExpected(binary_pb):
return model_def


def export_to_string(model, inputs, version=None):
def export_to_string(model, inputs, version=None, export_params=False):
f = io.BytesIO()
with torch.no_grad():
torch.onnx.export(model, inputs, f, export_params=True, opset_version=version)
torch.onnx.export(model, inputs, f, export_params=export_params, opset_version=version)
return f.getvalue()


def save_data_and_model(name, input, model, version=None):
def save_data_and_model(name, input, model, version=None, export_params=False):
model.eval()
print(name + " input has sizes", input.shape)
input_files = os.path.join("data", "input_" + name)
Expand All @@ -46,7 +46,7 @@ def save_data_and_model(name, input, model, version=None):

models_files = os.path.join("models", name + ".onnx")

onnx_model_pb = export_to_string(model, input, version)
onnx_model_pb = export_to_string(model, input, version, export_params)
model_def = assertONNXExpected(onnx_model_pb)
with open(models_files, 'wb') as file:
file.write(model_def.SerializeToString())
Expand Down Expand Up @@ -192,7 +192,7 @@ def save_data_and_model_multy_inputs(name, model, *args, **kwargs):

models_files = os.path.join("models", name + ".onnx")

onnx_model_pb = export_to_string(model, (args), version=kwargs.get('version', None))
onnx_model_pb = export_to_string(model, (args), version=kwargs.get('version', None), export_params=kwargs.get('export_params', False))
model_def = assertONNXExpected(onnx_model_pb)
with open(models_files, 'wb') as file:
file.write(model_def.SerializeToString())
Expand Down Expand Up @@ -387,7 +387,7 @@ def forward(self, x):
input = Variable(torch.randn(1, 2, 4, 4))
model = Slice()
save_data_and_model("slice", input, model)
save_data_and_model("slice_opset_11", input, model, opset_version=11)
save_data_and_model("slice_opset_11", input, model, version=11)

class Eltwise(nn.Module):

Expand Down Expand Up @@ -587,7 +587,7 @@ def forward(self, image):
channels = image.size(1)
h = image.size(2)
w = image.size(3)
image = image.view(batch_size, channels*h* (w / 2), -1)
image = image.view(batch_size, channels*h*(w // 2), -1)
return image

input = Variable(torch.randn(1, 2, 3, 4))
Expand Down Expand Up @@ -652,7 +652,21 @@ def forward(self, x, y):
input_0 = Variable(torch.randn(1, 3, 8, 6))
input_1 = Variable(torch.randn(1, 3, 4, 3))
model = DynamicResize()
save_data_and_model_multy_inputs("dynamic_resize", model, input_0, input_1, version=11)
save_data_and_model_multy_inputs("dynamic_resize_9", model, input_0, input_1, version=9)
save_data_and_model_multy_inputs("dynamic_resize_10", model, input_0, input_1, version=10)
save_data_and_model_multy_inputs("dynamic_resize_11", model, input_0, input_1, version=11)

class DynamicResizeScale(nn.Module):
def forward(self, x, y):
up = nn.Upsample(scale_factor=(0.5, 0.5), mode='bilinear')
return up(x) + y

input_0 = Variable(torch.randn(1, 3, 8, 6))
input_1 = Variable(torch.randn(1, 3, 4, 3))
model = DynamicResizeScale()
save_data_and_model_multy_inputs("dynamic_resize_scale_9", model, input_0, input_1, version=9, export_params=True)
save_data_and_model_multy_inputs("dynamic_resize_scale_10", model, input_0, input_1, version=10, export_params=True)
save_data_and_model_multy_inputs("dynamic_resize_scale_11", model, input_0, input_1, version=11, export_params=True)

class ShapeConst(nn.Module):
def __init__(self):
Expand Down Expand Up @@ -813,7 +827,7 @@ def forward(self, x, y):
save_data_and_model_multy_inputs("upsample_unfused_two_inputs_opset9_torch1.4", UpsampleUnfusedTwoInput(), input_0, input_1, version=9)
save_data_and_model_multy_inputs("upsample_unfused_two_inputs_opset11_torch1.4", UpsampleUnfusedTwoInput(), input_0, input_1, version=11)

class FrozenBatchNorm2d(nn.Module):
class FrozenBatchNorm2d(nn.Module):
def __init__(self, n):
super(FrozenBatchNorm2d, self).__init__()
self.register_buffer("weight", torch.ones(n))
Expand All @@ -832,15 +846,15 @@ def forward(self, x):
model = FrozenBatchNorm2d(2)
save_data_and_model("batch_norm_subgraph", x, model)

class GatherScalar(nn.Module):
class GatherScalar(nn.Module):
def forward(self, x):
return x[1]

x = Variable(torch.randn(2))
model = GatherScalar()
save_data_and_model("gather_scalar", x, model)

class Gather(nn.Module):
class Gather(nn.Module):
def forward(self, x):
return x[..., 1]

Expand Down Expand Up @@ -921,11 +935,11 @@ def forward(self, x):
const = torch.zeros(1, self.interm_dim)
const_projected = self.linear_for_const(const)
const_projected = const_projected.expand(2, self.interm_dim)
sum_tanh = torch.tanh(const_projected + x_projected)
sum_tanh = torch.tanh(const_projected + x_projected)
sum_tanh = sum_tanh.reshape(-1, self.interm_dim)
sum_tanh_projected = self.second_linear(sum_tanh)
sum_tanh_projected = sum_tanh_projected.reshape(1, 2)
after_softmax = F.softmax(sum_tanh_projected, dim=1)
after_softmax = F.softmax(sum_tanh_projected, dim=1)
return torch.matmul(after_softmax, x)

x = Variable(torch.rand([1, 2, 2]))
Expand All @@ -944,15 +958,33 @@ def forward(self, x):
model = Power(2)
save_data_and_model("pow2", x, model)

class ReduceMax(nn.Module):
class ReduceMaxGlobal(nn.Module):
def forward(self, x):
out = torch.max(x)
return torch.unsqueeze(out, 0)

x = Variable(torch.randn(1, 3, 2, 2))
model = ReduceMax()
model = ReduceMaxGlobal()
save_data_and_model("reduce_max", x, model)

class ReduceMax(nn.Module):
def __init__(self, axes):
super(ReduceMax, self).__init__()
self.axes = axes

def forward(self, x):
# torch.return_types.max(values, indices)
out = torch.max(x, dim=self.axes, keepdim=False)[0]
return out

x = Variable(torch.randn(1, 3, 2, 2))

model = ReduceMax(axes=0)
save_data_and_model("reduce_max_axis_0", x, model)

model = ReduceMax(axes=1)
save_data_and_model("reduce_max_axis_1", x, model)

class ResizeConv(nn.Module):
def __init__(
self,
Expand Down Expand Up @@ -986,3 +1018,210 @@ def forward(self, x):
x = Variable(torch.randn(1, 3, 2, 2))
model = Scale()
save_data_and_model("scale", x, model)

x = Variable(torch.randn(1, 3, 25))
conv1d = nn.Conv1d(3, 2, kernel_size=3, padding=2, stride=2, dilation=2, bias=False)
save_data_and_model("conv1d", x, conv1d)

x = Variable(torch.randn(1, 3, 25))
conv1d = nn.Conv1d(3, 2, kernel_size=3, padding=0, stride=1, dilation=1, bias=True)
save_data_and_model("conv1d_bias", x, conv1d)

class Conv1d(nn.Module):
def forward(self, x, kernel):
out = F.conv1d(x, kernel, groups=1)
return out

x = Variable(torch.randn(2, 2, 10))
kernel = Variable(torch.randn(2, 2, 2))
model = Conv1d()
save_data_and_model_multy_inputs("conv1d_variable_w", model, x, kernel)

class Conv1dBias(nn.Module):
def forward(self, x, kernel, bias):
batch = x.size(0)
channel = x.size(1)
x = x.view(1, batch*channel, x.size(2))
kernel = kernel.view(batch*channel, 1, 2)
conv = nn.Conv1d(4, 4, kernel_size=2, bias=False, groups=4)
conv.weight = nn.Parameter(kernel)
conv.bias = nn.Parameter(bias)
out = conv(x)
out = out.view(batch, channel, out.size(2))
return out

x = Variable(torch.randn(2, 2, 5))
kernel = Variable(torch.randn(2, 2, 2))
bias = Variable(torch.randn(4))
model = Conv1dBias()
save_data_and_model_multy_inputs("conv1d_variable_wb", model, x, kernel, bias)

class GatherMultiOutput(nn.Module):
def __init__(self, in_dim = 2):
super(GatherMultiOutput, self).__init__()
self.in_dim = in_dim
self.lin_inp = nn.Linear(in_dim, 2, bias=False)
def forward(self, x):
x_projected = self.lin_inp(x).long()
x_gather = x_projected[:,0,:]
x_float1 = x_gather.float()
x_float2 = x_gather.float()
x_float3 = x_gather.float()
return x_float1+x_float2+x_float3

x = Variable(torch.zeros([1, 2, 2]))
model = GatherMultiOutput()
save_data_and_model("gather_multi_output", x, model)

def postprocess_model(model_path, inputs_shapes):
onnx_model = onnx.load(model_path)

def update_inputs_dims(model, input_dims):
"""
This function updates the sizes of dimensions of the model's inputs to the values
provided in input_dims. if the dim value provided is negative, a unique dim_param
will be set for that dimension.
"""
def update_dim(tensor, dim, i, j, dim_param_prefix):
dim_proto = tensor.type.tensor_type.shape.dim[j]
if isinstance(dim, int):
if dim >= 0:
dim_proto.dim_value = dim
else:
dim_proto.dim_param = dim_param_prefix + str(i) + '_' + str(j)
elif isinstance(dim, str):
dim_proto.dim_param = dim
else:
raise ValueError('Only int or str is accepted as dimension value, incorrect type: {}'.format(type(dim)))

for i, input_dim_arr in enumerate(input_dims):
for j, dim in enumerate(input_dim_arr):
update_dim(model.graph.input[i], dim, i, j, 'in_')

onnx.checker.check_model(model)
return model

onnx_model = update_inputs_dims(onnx_model, inputs_shapes)
onnx.save(onnx_model, model_path)

class UnsqueezeAndConv(nn.Module):
def __init__(self):
super(UnsqueezeAndConv, self).__init__()
self.conv = nn.Conv2d(3, 3, kernel_size=1, stride=1, padding=0)
def forward(self, x):
x = x.unsqueeze(axis=0)
out = self.conv(x)
return out

x = Variable(torch.randn(3, 10, 10))
model = UnsqueezeAndConv()
save_data_and_model("unsqueeze_and_conv_dynamic_axes", x, model)
postprocess_model("models/unsqueeze_and_conv_dynamic_axes.onnx", [[3, 'height', 'width']])

class SqueezeAndConv(nn.Module):
def __init__(self):
super(SqueezeAndConv, self).__init__()
self.conv = nn.Conv2d(3, 3, kernel_size=1, stride=1, padding=0)
def forward(self, x):
x = x.squeeze()
out = self.conv(x)
return out

x = Variable(torch.randn(2, 1, 3, 3, 3))
model = SqueezeAndConv()
save_data_and_model("squeeze_and_conv_dynamic_axes", x, model)
postprocess_model("models/squeeze_and_conv_dynamic_axes.onnx", [["batch_size", 1, "channels", 'height', 'width']])

x = Variable(torch.randn(2))
model = GatherScalar()
save_data_and_model("gather_scalar_dynamic_axes", x, model)
postprocess_model("models/gather_scalar_dynamic_axes.onnx", [['shape']])

x = Variable(torch.randn(2, 2, 2, 2))
print(x)
model = Gather()
print(model(x))
print(model(x).shape)
save_data_and_model("gather_dynamic_axes", x, model)
postprocess_model("models/gather_dynamic_axes.onnx", [["batch_size", 2, 'height', 'width']])

input = Variable(torch.randn(1, 2, 4, 4))
model = Slice()
save_data_and_model("slice_dynamic_axes", input, model)
save_data_and_model("slice_opset_11_dynamic_axes", input, model, version=11)
postprocess_model("models/slice_dynamic_axes.onnx", [["batch_size", 2, 'height', 'width']])
postprocess_model("models/slice_opset_11_dynamic_axes.onnx", [["batch_size", 2, 'height', 'width']])

x = Variable(torch.rand(1, 2, 2, 2))
model = ResizeConv(2, 0, 2)
save_data_and_model("resize_opset11_torch1.6_dynamic_axes", x, model, 11)
postprocess_model("models/resize_opset11_torch1.6_dynamic_axes.onnx", [["batch_size", 2, 'height', 'width']])

maxpooling_sigmoid = nn.Sequential(
nn.MaxPool2d(kernel_size=4, stride=2, padding=(1, 2), dilation=1),
nn.Sigmoid()
)
input = Variable(torch.randn(2, 3, 12, 18))
save_data_and_model("maxpooling_sigmoid_dynamic_axes", input, maxpooling_sigmoid)
postprocess_model("models/maxpooling_sigmoid_dynamic_axes.onnx", [[2, 3, 'height', 'width']])

ave_pool = nn.AvgPool2d(kernel_size=3, stride=2, padding=1)
input = Variable(torch.randn(1, 3, 7, 5))
save_data_and_model("average_pooling_dynamic_axes", input, ave_pool)
postprocess_model("models/average_pooling_dynamic_axes.onnx", [[1, 3, 'height', 'width']])

x = Variable(torch.randn(1, 3, 10))
max_pool = nn.MaxPool1d(kernel_size=(5), stride=1, padding=2, dilation=1)
save_data_and_model("maxpooling_1d", x, max_pool)

x = Variable(torch.randn(2, 3, 12))
maxpooling_sigmoid = nn.Sequential(
nn.MaxPool1d(kernel_size=4, stride=2, padding=(2), dilation=1),
nn.Sigmoid()
)
save_data_and_model("maxpooling_sigmoid_1d", x, maxpooling_sigmoid)

x = Variable(torch.randn(2, 3, 12))
maxpool2 = nn.Sequential(
nn.MaxPool1d(kernel_size=5, stride=1, padding=0, dilation=1),
nn.MaxPool1d(kernel_size=3, stride=1, padding=0, dilation=1)
)
save_data_and_model("two_maxpooling_1d", x, maxpool2)

x = Variable(torch.randn(1, 3, 7))
ave_pool = nn.AvgPool1d(kernel_size=3, stride=2, padding=1)
save_data_and_model("average_pooling_1d", x, ave_pool)

class PoolConv1d(nn.Module):

def __init__(self):
super(PoolConv1d, self).__init__()
self.pool = nn.MaxPool1d(3, stride=2, padding=1)
self.conv = nn.Conv1d(2, 2, kernel_size=3, stride=1, padding=1)

def forward(self, x):
x = self.pool(x)
y = self.conv(x)
return y

x = Variable(torch.randn(1, 2, 4))
model = PoolConv1d()
save_data_and_model("pool_conv_1d", x, model)

class Conv1ResizePoold(nn.Module):
def __init__(self):
super(Conv1ResizePoold, self).__init__()
self.pool = nn.MaxPool1d(3, stride=2, padding=1)
self.conv = nn.Conv2d(2, 2, kernel_size=3, stride=1, padding=1)

def forward(self, x):
batch_size = x.size(0)
channels = x.size(1)
x = self.conv(x)
x = x.view(batch_size, channels, -1)
y = self.pool(x)
return y

x = Variable(torch.randn(1, 2, 20, 20))
model = Conv1ResizePoold()
save_data_and_model("conv_resize_pool_1d", x, model)
Binary file added testdata/dnn/onnx/models/average_pooling_1d.onnx
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/models/conv1d.onnx
Binary file not shown.
Binary file added testdata/dnn/onnx/models/conv1d_bias.onnx
Binary file not shown.
Binary file added testdata/dnn/onnx/models/conv1d_variable_w.onnx
Binary file not shown.
Binary file added testdata/dnn/onnx/models/conv1d_variable_wb.onnx
Binary file not shown.
Binary file added testdata/dnn/onnx/models/conv_resize_pool_1d.onnx
Binary file not shown.
Binary file removed testdata/dnn/onnx/models/dynamic_resize.onnx
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/models/dynamic_resize_11.onnx
Binary file not shown.
Binary file added testdata/dnn/onnx/models/dynamic_resize_9.onnx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/models/dynamic_resize_scale_9.onnx
Binary file not shown.
Binary file added testdata/dnn/onnx/models/gather_dynamic_axes.onnx
Binary file not shown.
Binary file added testdata/dnn/onnx/models/gather_multi_output.onnx
Binary file not shown.
Binary file not shown.
Loading