Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion testdata/dnn/download_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,16 @@ def is_archive(self):
],
sha='462f15d668c046d38e27d3df01fe8142dd004cb4',
filename='onnx/models/yolov8x.onnx'),

Model(
name='yolov9t',
url='https://dl.opencv.org/models/yolov9/yolov9t.onnx',
sha='330292f15e1b312b11ce58e70a9e455d54415fa3',
filename='onnx/models/yolov9t.onnx'),
Model(
name='yolov10s',
url='https://dl.opencv.org/models/yolov10/yolov10s.onnx',
sha='5311212e431912a27d5f54b3a5277bc573890a99',
filename='onnx/models/yolov10s.onnx'),
Model(
name='yolo_nas_s',
url='https://dl.opencv.org/models/yolo-nas/yolo_nas_s.onnx',
Expand Down
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BxJ�x��?h��>��z?�j@$ �?�.z��8s?b��hdӽ�9�>(�>�%�?^�B?�0�= B�>]ת>�=�?R�iJ�>�Z�/d#��S'?�K]?��=��C@�(��Hm;= �?�2�?��?��>���>�Ec������!��� >*z�?��?�Oƾmǚ��6��&õ�gڿ��?�x�FKྙ[��� G?4�ο��Y�L=e��> �����k��QN�>.:�=�ݚ>�b"�6���
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ByJ��?�K�>��Q?A�@t��? V$���I?�W��uB���>�d�=��?VQ?V��=q��>�~W>�Q�?�x�G>d�+�8^_�$��>�o2?�.�ޓ@�3ٽxD�<+7����?п�?24�=I�z>jL*��'A������=D�?D�?��
�|��
��B����KR�?h@�:U�Z����?T��;%��;�)����>�f�����a�J�>�s=��?>��*�S �
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BxJ�x��?h��>��z?�j@$ �?�.z��8s?b��hdӽ�9�>(�>�%�?^�B?�0�= B�>]ת>�=�?R�iJ�>�Z�/d#��S'?�K]?��=��C@�(��Hm;= �?�2�?��?��>���>�Ec������!��� >*z�?��?�Oƾmǚ��6��&õ�gڿ��?�x�FKྙ[��� G?4�ο��Y�L=e��> �����k��QN�>.:�=�ݚ>�b"�6���
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ByJ��?�K�>��Q?A�@t��? V$���I?�W��uB���>�d�=��?VQ?V��=q��>�~W>�Q�?�x�G>d�+�8^_�$��>�o2?�.�ޓ@�3ٽxD�<+7����?п�?24�=I�z>jL*��'A������=D�?D�?��
�|��
��B����KR�?h@�:U�Z����?T��;%��;�)����>�f�����a�J�>�s=��?>��*�S �
Expand Down
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BxJ�x��?h��>��z?�j@$ �?�.z��8s?b��hdӽ�9�>(�>�%�?^�B?�0�= B�>]ת>�=�?R�iJ�>�Z�/d#��S'?�K]?��=��C@�(��Hm;= �?�2�?��?��>���>�Ec������!��� >*z�?��?�Oƾmǚ��6��&õ�gڿ��?�x�FKྙ[��� G?4�ο��Y�L=e��> �����k��QN�>.:�=�ݚ>�b"�6���
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BxJ�x��?h��>��z?�j@$ �?�.z��8s?b��hdӽ�9�>(�>�%�?^�B?�0�= B�>]ת>�=�?R�iJ�>�Z�/d#��S'?�K]?��=��C@�(��Hm;= �?�2�?��?��>���>�Ec������!��� >*z�?��?�Oƾmǚ��6��&õ�gڿ��?�x�FKྙ[��� G?4�ο��Y�L=e��> �����k��QN�>.:�=�ݚ>�b"�6���
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/input_unflatten.npy
Binary file not shown.
Binary file not shown.
Binary file added testdata/dnn/onnx/data/output_unflatten.npy
Binary file not shown.
41 changes: 41 additions & 0 deletions testdata/dnn/onnx/generate_onnx_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,47 @@ def forward(self, x):
save_data_and_model("einsum_transpose", mat, einsum, export_params=True)


class TorchAttentionLayer(nn.Module):
def __init__(self, embed_dim=6, num_heads=1):
super(TorchAttentionLayer, self).__init__()
self.attention = nn.MultiheadAttention(
embed_dim=embed_dim,
num_heads=num_heads,
bias=True,
batch_first=True)
def forward(self, x):
return self.attention(x, x, x)[0]

num_heads = 1
batch_size = 2
num_tokens = 5
emb_dim = 6
model = TorchAttentionLayer(embed_dim=emb_dim, num_heads=num_heads).eval()

x = torch.rand(batch_size, num_tokens, emb_dim)
with torch.no_grad():
output = model(x)

save_data_and_model("pytorch_attention_single_head", x, model, export_params=True)
class Unflatten(torch.nn.Module):
def __init__(self, E, times):
super(Unflatten, self).__init__()
self.E = E
self.times = times

def forward(self, x):
return x.unflatten(-1, (self.times, self.E))

unflatten_dim = 5
times = 3
model = Unflatten(unflatten_dim, times).eval()

x = torch.rand(10, 3, unflatten_dim * times)
with torch.no_grad():
output = model(x)

save_data_and_model("unflatten", x, model, export_params=True)

def _extract_value_info(x, name, type_proto=None): # type: (Union[List[Any], np.ndarray, None], Text, Optional[TypeProto]) -> onnx.ValueInfoProto
if type_proto is None:
if x is None:
Expand Down
Binary file not shown.
Binary file added testdata/dnn/onnx/models/unflatten.onnx
Binary file not shown.