Skip to content

Commit 5bc2cd9

Browse files
committed
Merge branch 4.x
2 parents 6e01d0c + c324ea9 commit 5bc2cd9

11 files changed

+1602
-299
lines changed

testdata/dnn/download_models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,11 @@ def handle_bad_download(self):
10341034
url='https://github.com/opencv/opencv_zoo/raw/aab69020085e9b6390723b61f9789ec56b96b07e/models/text_recognition_crnn/text_recognition_CRNN_EN_2021sep.onnx',
10351035
sha='dc8c70a52c6880f11859bf074bcd294a45860821',
10361036
filename='text_recognition_CRNN_EN_2021sep.onnx'),
1037+
Model(
1038+
name='RAFT', # See https://github.com/opencv/opencv_zoo/tree/main/models/optical_flow_estimation_raft#raft for source
1039+
url='https://github.com/opencv/opencv_zoo/raw/281d232cd99cd920853106d853c440edd35eb442/models/optical_flow_estimation_raft/optical_flow_estimation_raft_2023aug.onnx',
1040+
sha='8165e43c7bd37cc651f66509532acdb3c292832b',
1041+
filename='onnx/models/optical_flow_estimation_raft_2023aug.onnx'),
10371042
]
10381043

10391044
# Note: models will be downloaded to current working directory
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

testdata/dnn/onnx/generate_onnx_models.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,15 @@ def forward(self, x):
14571457

14581458
save_data_and_model_multy_inputs("einsum_2d", einsum, mat1, mat2, export_params=True)
14591459

1460+
# 2d test case with ellipses
1461+
mat1 = torch.randn(4, 5)
1462+
mat2 = torch.randn(5, 8)
1463+
equation = "...ij, ...jk -> ...ik"
1464+
einsum = Einsum(equation)
1465+
output = einsum(mat1, mat2)
1466+
1467+
save_data_and_model_multy_inputs("einsum_2d_ellipses", einsum, mat1, mat2, export_params=True)
1468+
14601469
# 3d test case
14611470
mat1 = torch.ones(2, 4, 5)
14621471
mat2 = torch.ones(2, 5, 8)
@@ -2519,6 +2528,25 @@ def forward(self, x):
25192528
x = torch.randn(2, 3, 4)
25202529
save_data_and_model("cumsum_3d_dim_2", x, CumSum(dim=2), version=11)
25212530

2531+
# test: CumSum exclusive layer should not be executed inplace
2532+
dims = h.make_node("Constant", inputs=[], outputs=["dims1"], name="node-c1",
2533+
value=h.make_tensor(name="c1v", data_type=onnx.TensorProto.INT64, dims=[], vals=np.asarray([1, ], dtype=np.int64)))
2534+
one = h.make_node("Constant", inputs=[], outputs=["one1"], name="node-c2",
2535+
value=h.make_tensor(name="c2v", data_type=onnx.TensorProto.FLOAT, dims=[], vals=np.asarray([1, ], dtype=np.float32)))
2536+
2537+
mult = h.make_node("Mul", inputs=["input1", "one1"], outputs=["mul_output1"], name="node-m1")
2538+
cumsum = h.make_node("CumSum", inputs=["mul_output1", "dims1"], outputs=["cumsum_output1"], name="node-r1", exclusive=1)
2539+
2540+
graph = h.make_graph([dims, one, mult, cumsum], "graph123",
2541+
[h.make_tensor_value_info("input1", onnx.TensorProto.FLOAT, [1, 3, 1, 1]),],
2542+
[h.make_tensor_value_info("cumsum_output1", onnx.TensorProto.FLOAT, [1, 3, 1, 1])])
2543+
cumsum_model = h.make_model(graph, producer_name="model_cumsum")
2544+
onnx.checker.check_model(cumsum_model)
2545+
2546+
input_np = np.array([1, 2, 3], dtype=np.float32).reshape(1, 3, 1, 1)
2547+
output_np = np.array([0, 1, 3], dtype=np.float32).reshape(1, 3, 1, 1)
2548+
save_data_and_onnx_model("cumsum_exclusive_inplace", input_np, output_np, cumsum_model)
2549+
25222550
# where layer
25232551
class Where(nn.Module):
25242552
def __init__(self, *args, **kwargs):
Binary file not shown.

testdata/dnn/onnx/models/einsum_2d_ellipses.onnx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pytorch2.0.0:�
2+
D
3+
one
4+
two2/Einsum"Einsum*$
5+
equation"...ij, ...jk -> ...ik� torch_jitZ
6+
one
7+

8+

9+
Z
10+
two
11+

12+

13+
b-
14+
2(
15+
&"
16+
Einsum2_dim_0
17+
Einsum2_dim_1B

0 commit comments

Comments
 (0)