已合并
[onnx] fix group_norm_silu and rotary_mul onnx api. #31962
shi-jiaxin9创建于 3月18日
[onnx] fix group_norm_silu and rotary_mul onnx api. #31962
已合并
共 6 个文件变更+194-19
| @@ -1,6 +1,7 @@ | |||
| 1 | import os | 1 | import os |
| 2 | import shutil | 2 | import shutil |
| 3 | import math | 3 | import math |
| 4 | +import unittest | ||
| 4 | 5 | ||
| 5 | import torch | 6 | import torch |
| 6 | from torch.nn.parameter import Parameter | 7 | from torch.nn.parameter import Parameter |
| @@ -40,6 +41,7 @@ class TestOnnxOps(TestCase): | |||
| 40 | opset_version=11, input_names=input_names, | 41 | opset_version=11, input_names=input_names, |
| 41 | output_names=output_names) | 42 | output_names=output_names) |
| 42 | 43 | ||
| 44 | + | ||
| 43 | def test_wrapper_npu_linear(self): | 45 | def test_wrapper_npu_linear(self): |
| 44 | class Model(torch.nn.Module): | 46 | class Model(torch.nn.Module): |
| 45 | def __init__(self): | 47 | def __init__(self): |
| @@ -73,6 +75,7 @@ class TestOnnxOps(TestCase): | |||
| 73 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 75 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 74 | onnx_model_name))) | 76 | onnx_model_name))) |
| 75 | 77 | ||
| 78 | + | ||
| 76 | def test_wrapper_npu_transpose(self): | 79 | def test_wrapper_npu_transpose(self): |
| 77 | class Model(torch.nn.Module): | 80 | class Model(torch.nn.Module): |
| 78 | def __init__(self): | 81 | def __init__(self): |
| @@ -93,6 +96,7 @@ class TestOnnxOps(TestCase): | |||
| 93 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 96 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 94 | onnx_model_name))) | 97 | onnx_model_name))) |
| 95 | 98 | ||
| 99 | + | ||
| 96 | def test_wrapper_npu_broadcast(self): | 100 | def test_wrapper_npu_broadcast(self): |
| 97 | class Model(torch.nn.Module): | 101 | class Model(torch.nn.Module): |
| 98 | def __init__(self): | 102 | def __init__(self): |
| @@ -112,6 +116,7 @@ class TestOnnxOps(TestCase): | |||
| 112 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 116 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 113 | onnx_model_name))) | 117 | onnx_model_name))) |
| 114 | 118 | ||
| 119 | + | ||
| 115 | def test_wrapper_npu_conv_transpose2d(self): | 120 | def test_wrapper_npu_conv_transpose2d(self): |
| 116 | class Model(torch.nn.Module): | 121 | class Model(torch.nn.Module): |
| 117 | def __init__(self): | 122 | def __init__(self): |
| @@ -149,6 +154,7 @@ class TestOnnxOps(TestCase): | |||
| 149 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 154 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 150 | onnx_model_name))) | 155 | onnx_model_name))) |
| 151 | 156 | ||
| 157 | + | ||
| 152 | def test_wrapper_npu_conv2d(self): | 158 | def test_wrapper_npu_conv2d(self): |
| 153 | class Model(torch.nn.Module): | 159 | class Model(torch.nn.Module): |
| 154 | def __init__(self): | 160 | def __init__(self): |
| @@ -186,6 +192,7 @@ class TestOnnxOps(TestCase): | |||
| 186 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 192 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 187 | onnx_model_name))) | 193 | onnx_model_name))) |
| 188 | 194 | ||
| 195 | + | ||
| 189 | def test_wrapper_npu_conv3d(self): | 196 | def test_wrapper_npu_conv3d(self): |
| 190 | class Model(torch.nn.Module): | 197 | class Model(torch.nn.Module): |
| 191 | def __init__(self): | 198 | def __init__(self): |
| @@ -226,6 +233,7 @@ class TestOnnxOps(TestCase): | |||
| 226 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 233 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 227 | onnx_model_name))) | 234 | onnx_model_name))) |
| 228 | 235 | ||
| 236 | + | ||
| 229 | def test_wrapper_npu_stride_copy(self): | 237 | def test_wrapper_npu_stride_copy(self): |
| 230 | class Model(torch.nn.Module): | 238 | class Model(torch.nn.Module): |
| 231 | def __init__(self): | 239 | def __init__(self): |
| @@ -247,6 +255,7 @@ class TestOnnxOps(TestCase): | |||
| 247 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 255 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 248 | onnx_model_name))) | 256 | onnx_model_name))) |
| 249 | 257 | ||
| 258 | + | ||
| 250 | def test_wrapper_npu_sort_v2(self): | 259 | def test_wrapper_npu_sort_v2(self): |
| 251 | class Model(torch.nn.Module): | 260 | class Model(torch.nn.Module): |
| 252 | def __init__(self): | 261 | def __init__(self): |
| @@ -267,6 +276,7 @@ class TestOnnxOps(TestCase): | |||
| 267 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 276 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 268 | onnx_model_name))) | 277 | onnx_model_name))) |
| 269 | 278 | ||
| 279 | + | ||
| 270 | def test_wrapper_npu_layer_norm_eval(self): | 280 | def test_wrapper_npu_layer_norm_eval(self): |
| 271 | class Model(torch.nn.Module): | 281 | class Model(torch.nn.Module): |
| 272 | def __init__(self): | 282 | def __init__(self): |
| @@ -303,6 +313,7 @@ class TestOnnxOps(TestCase): | |||
| 303 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 313 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 304 | onnx_model_name))) | 314 | onnx_model_name))) |
| 305 | 315 | ||
| 316 | + | ||
| 306 | def test_wrapper_npu_reshape(self): | 317 | def test_wrapper_npu_reshape(self): |
| 307 | class Model(torch.nn.Module): | 318 | class Model(torch.nn.Module): |
| 308 | def __init__(self): | 319 | def __init__(self): |
| @@ -323,6 +334,7 @@ class TestOnnxOps(TestCase): | |||
| 323 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 334 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 324 | onnx_model_name))) | 335 | onnx_model_name))) |
| 325 | 336 | ||
| 337 | + | ||
| 326 | def test_wrapper_npu_pad(self): | 338 | def test_wrapper_npu_pad(self): |
| 327 | class Model(torch.nn.Module): | 339 | class Model(torch.nn.Module): |
| 328 | def __init__(self): | 340 | def __init__(self): |
| @@ -343,6 +355,7 @@ class TestOnnxOps(TestCase): | |||
| 343 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 355 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 344 | onnx_model_name))) | 356 | onnx_model_name))) |
| 345 | 357 | ||
| 358 | + | ||
| 346 | def test_wrapper_npu_convolution(self): | 359 | def test_wrapper_npu_convolution(self): |
| 347 | class Model(torch.nn.Module): | 360 | class Model(torch.nn.Module): |
| 348 | def __init__(self): | 361 | def __init__(self): |
| @@ -379,6 +392,7 @@ class TestOnnxOps(TestCase): | |||
| 379 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 392 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 380 | onnx_model_name))) | 393 | onnx_model_name))) |
| 381 | 394 | ||
| 395 | + | ||
| 382 | def test_wrapper_npu_convolution_transpose(self): | 396 | def test_wrapper_npu_convolution_transpose(self): |
| 383 | class Model(torch.nn.Module): | 397 | class Model(torch.nn.Module): |
| 384 | def __init__(self): | 398 | def __init__(self): |
| @@ -415,6 +429,7 @@ class TestOnnxOps(TestCase): | |||
| 415 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 429 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 416 | onnx_model_name))) | 430 | onnx_model_name))) |
| 417 | 431 | ||
| 432 | + | ||
| 418 | def test_wrapper_npu_confusion_transpose(self): | 433 | def test_wrapper_npu_confusion_transpose(self): |
| 419 | class Model(torch.nn.Module): | 434 | class Model(torch.nn.Module): |
| 420 | def __init__(self): | 435 | def __init__(self): |
| @@ -436,6 +451,7 @@ class TestOnnxOps(TestCase): | |||
| 436 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 451 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 437 | onnx_model_name))) | 452 | onnx_model_name))) |
| 438 | 453 | ||
| 454 | + | ||
| 439 | def test_wrapper_npu_max(self): | 455 | def test_wrapper_npu_max(self): |
| 440 | class Model(torch.nn.Module): | 456 | class Model(torch.nn.Module): |
| 441 | def __init__(self): | 457 | def __init__(self): |
| @@ -456,6 +472,7 @@ class TestOnnxOps(TestCase): | |||
| 456 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 472 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 457 | onnx_model_name))) | 473 | onnx_model_name))) |
| 458 | 474 | ||
| 475 | + | ||
| 459 | def test_wrapper_npu_bmmV2(self): | 476 | def test_wrapper_npu_bmmV2(self): |
| 460 | class Model(torch.nn.Module): | 477 | class Model(torch.nn.Module): |
| 461 | def __init__(self): | 478 | def __init__(self): |
| @@ -477,6 +494,7 @@ class TestOnnxOps(TestCase): | |||
| 477 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 494 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 478 | onnx_model_name))) | 495 | onnx_model_name))) |
| 479 | 496 | ||
| 497 | + | ||
| 480 | def test_wrapper_npu_dtype_cast(self): | 498 | def test_wrapper_npu_dtype_cast(self): |
| 481 | class Model(torch.nn.Module): | 499 | class Model(torch.nn.Module): |
| 482 | def __init__(self): | 500 | def __init__(self): |
| @@ -495,6 +513,7 @@ class TestOnnxOps(TestCase): | |||
| 495 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 513 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 496 | onnx_model_name))) | 514 | onnx_model_name))) |
| 497 | 515 | ||
| 516 | + | ||
| 498 | def test_wrapper_npu_silu(self): | 517 | def test_wrapper_npu_silu(self): |
| 499 | class Model(torch.nn.Module): | 518 | class Model(torch.nn.Module): |
| 500 | def __init__(self): | 519 | def __init__(self): |
| @@ -513,6 +532,7 @@ class TestOnnxOps(TestCase): | |||
| 513 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 532 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 514 | onnx_model_name))) | 533 | onnx_model_name))) |
| 515 | 534 | ||
| 535 | + | ||
| 516 | def test_wrapper_npu_min(self): | 536 | def test_wrapper_npu_min(self): |
| 517 | class Model(torch.nn.Module): | 537 | class Model(torch.nn.Module): |
| 518 | def __init__(self): | 538 | def __init__(self): |
| @@ -533,6 +553,7 @@ class TestOnnxOps(TestCase): | |||
| 533 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 553 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 534 | onnx_model_name))) | 554 | onnx_model_name))) |
| 535 | 555 | ||
| 556 | + | ||
| 536 | def test_wrapper_npu_fused_attention_layernorm_qkv_fwd(self): | 557 | def test_wrapper_npu_fused_attention_layernorm_qkv_fwd(self): |
| 537 | class Model(torch.nn.Module): | 558 | class Model(torch.nn.Module): |
| 538 | def __init__(self): | 559 | def __init__(self): |
| @@ -45,6 +45,7 @@ class TestOnnxOps(TestCase): | |||
| 45 | input_names=input_names, | 45 | input_names=input_names, |
| 46 | output_names=output_names) | 46 | output_names=output_names) |
| 47 | 47 | ||
| 48 | + | ||
| 48 | def test_wrapper_npu_one_hot(self): | 49 | def test_wrapper_npu_one_hot(self): |
| 49 | class Model(torch.nn.Module): | 50 | class Model(torch.nn.Module): |
| 50 | def __init__(self): | 51 | def __init__(self): |
| @@ -65,6 +66,7 @@ class TestOnnxOps(TestCase): | |||
| 65 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 66 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 66 | onnx_model_name))) | 67 | onnx_model_name))) |
| 67 | 68 | ||
| 69 | + | ||
| 68 | def test_wrapper_npu_slice(self): | 70 | def test_wrapper_npu_slice(self): |
| 69 | class Model(torch.nn.Module): | 71 | class Model(torch.nn.Module): |
| 70 | def __init__(self): | 72 | def __init__(self): |
| @@ -86,6 +88,7 @@ class TestOnnxOps(TestCase): | |||
| 86 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 88 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 87 | onnx_model_name))) | 89 | onnx_model_name))) |
| 88 | 90 | ||
| 91 | + | ||
| 89 | def test_wrapper_npu_roi_align(self): | 92 | def test_wrapper_npu_roi_align(self): |
| 90 | class Model(torch.nn.Module): | 93 | class Model(torch.nn.Module): |
| 91 | def __init__(self): | 94 | def __init__(self): |
| @@ -112,6 +115,7 @@ class TestOnnxOps(TestCase): | |||
| 112 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 115 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 113 | onnx_model_name))) | 116 | onnx_model_name))) |
| 114 | 117 | ||
| 118 | + | ||
| 115 | def test_wrapper_npu_iou(self): | 119 | def test_wrapper_npu_iou(self): |
| 116 | class Model(torch.nn.Module): | 120 | class Model(torch.nn.Module): |
| 117 | def __init__(self): | 121 | def __init__(self): |
| @@ -163,6 +167,7 @@ class TestOnnxOps(TestCase): | |||
| 163 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 167 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 164 | onnx_model_name))) | 168 | onnx_model_name))) |
| 165 | 169 | ||
| 170 | + | ||
| 166 | def test_wrapper_npu_fast_gelu(self): | 171 | def test_wrapper_npu_fast_gelu(self): |
| 167 | class Model(torch.nn.Module): | 172 | class Model(torch.nn.Module): |
| 168 | def __init__(self): | 173 | def __init__(self): |
| @@ -183,6 +188,7 @@ class TestOnnxOps(TestCase): | |||
| 183 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 188 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 184 | onnx_model_name))) | 189 | onnx_model_name))) |
| 185 | 190 | ||
| 191 | + | ||
| 186 | 192 | ||
| 187 | def test_wrapper_npu_geglu(self): | 193 | def test_wrapper_npu_geglu(self): |
| 188 | class Model(torch.nn.Module): | 194 | class Model(torch.nn.Module): |
| @@ -203,6 +209,7 @@ class TestOnnxOps(TestCase): | |||
| 203 | assert(os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 209 | assert(os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 204 | onnx_model_name))) | 210 | onnx_model_name))) |
| 205 | 211 | ||
| 212 | + | ||
| 206 | def test_wrapper_npu_multi_head_attention(self): | 213 | def test_wrapper_npu_multi_head_attention(self): |
| 207 | class Model(torch.nn.Module): | 214 | class Model(torch.nn.Module): |
| 208 | def __init__(self): | 215 | def __init__(self): |
| @@ -292,6 +299,7 @@ class TestOnnxOps(TestCase): | |||
| 292 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 299 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 293 | onnx_model_name))) | 300 | onnx_model_name))) |
| 294 | 301 | ||
| 302 | + | ||
| 295 | def test_wrapper_npu_diou(self): | 303 | def test_wrapper_npu_diou(self): |
| 296 | class Model(torch.nn.Module): | 304 | class Model(torch.nn.Module): |
| 297 | def __init__(self): | 305 | def __init__(self): |
| @@ -318,6 +326,7 @@ class TestOnnxOps(TestCase): | |||
| 318 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 326 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 319 | onnx_model_name))) | 327 | onnx_model_name))) |
| 320 | 328 | ||
| 329 | + | ||
| 321 | def test_wrapper_npu_ciou(self): | 330 | def test_wrapper_npu_ciou(self): |
| 322 | class Model(torch.nn.Module): | 331 | class Model(torch.nn.Module): |
| 323 | def __init__(self): | 332 | def __init__(self): |
| @@ -338,6 +347,7 @@ class TestOnnxOps(TestCase): | |||
| 338 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 347 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 339 | onnx_model_name))) | 348 | onnx_model_name))) |
| 340 | 349 | ||
| 350 | + | ||
| 341 | def test_wrapper_npu_giou(self): | 351 | def test_wrapper_npu_giou(self): |
| 342 | class Model(torch.nn.Module): | 352 | class Model(torch.nn.Module): |
| 343 | def __init__(self): | 353 | def __init__(self): |
| @@ -364,6 +374,7 @@ class TestOnnxOps(TestCase): | |||
| 364 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 374 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 365 | onnx_model_name))) | 375 | onnx_model_name))) |
| 366 | 376 | ||
| 377 | + | ||
| 367 | def test_wrapper_npu_deformable_conv2d(self): | 378 | def test_wrapper_npu_deformable_conv2d(self): |
| 368 | class Model(torch.nn.Module): | 379 | class Model(torch.nn.Module): |
| 369 | def __init__(self): | 380 | def __init__(self): |
| @@ -386,6 +397,7 @@ class TestOnnxOps(TestCase): | |||
| 386 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 397 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 387 | onnx_model_name))) | 398 | onnx_model_name))) |
| 388 | 399 | ||
| 400 | + | ||
| 389 | def test_wrapper_npu_format_cast(self): | 401 | def test_wrapper_npu_format_cast(self): |
| 390 | class Model(torch.nn.Module): | 402 | class Model(torch.nn.Module): |
| 391 | def __init__(self): | 403 | def __init__(self): |
| @@ -405,6 +417,7 @@ class TestOnnxOps(TestCase): | |||
| 405 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 417 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 406 | onnx_model_name))) | 418 | onnx_model_name))) |
| 407 | 419 | ||
| 420 | + | ||
| 408 | def test_wrapper_npu_softmax_cross_entropy_with_logits(self): | 421 | def test_wrapper_npu_softmax_cross_entropy_with_logits(self): |
| 409 | class Model(torch.nn.Module): | 422 | class Model(torch.nn.Module): |
| 410 | def __init__(self): | 423 | def __init__(self): |
| @@ -425,6 +438,7 @@ class TestOnnxOps(TestCase): | |||
| 425 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 438 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 426 | onnx_model_name))) | 439 | onnx_model_name))) |
| 427 | 440 | ||
| 441 | + | ||
| 428 | def test_wrapper_npu_ps_roi_pooling(self): | 442 | def test_wrapper_npu_ps_roi_pooling(self): |
| 429 | class Model(torch.nn.Module): | 443 | class Model(torch.nn.Module): |
| 430 | def __init__(self): | 444 | def __init__(self): |
| @@ -452,6 +466,7 @@ class TestOnnxOps(TestCase): | |||
| 452 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 466 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 453 | onnx_model_name))) | 467 | onnx_model_name))) |
| 454 | 468 | ||
| 469 | + | ||
| 455 | def test_wrapper_npu_grid_assign_positive(self): | 470 | def test_wrapper_npu_grid_assign_positive(self): |
| 456 | class Model(torch.nn.Module): | 471 | class Model(torch.nn.Module): |
| 457 | def __init__(self): | 472 | def __init__(self): |
| @@ -512,6 +527,7 @@ class TestOnnxOps(TestCase): | |||
| 512 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 527 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 513 | onnx_model_name))) | 528 | onnx_model_name))) |
| 514 | 529 | ||
| 530 | + | ||
| 515 | def test_wrapper_npu_sign_bits_unpack(self): | 531 | def test_wrapper_npu_sign_bits_unpack(self): |
| 516 | class Model(torch.nn.Module): | 532 | class Model(torch.nn.Module): |
| 517 | def __init__(self): | 533 | def __init__(self): |
| @@ -533,6 +549,7 @@ class TestOnnxOps(TestCase): | |||
| 533 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 549 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 534 | onnx_model_name))) | 550 | onnx_model_name))) |
| 535 | 551 | ||
| 552 | + | ||
| 536 | def test_wrapper_npu_ptiou(self): | 553 | def test_wrapper_npu_ptiou(self): |
| 537 | class Model(torch.nn.Module): | 554 | class Model(torch.nn.Module): |
| 538 | def __init__(self): | 555 | def __init__(self): |
| @@ -559,6 +576,7 @@ class TestOnnxOps(TestCase): | |||
| 559 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 576 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 560 | onnx_model_name))) | 577 | onnx_model_name))) |
| 561 | 578 | ||
| 579 | + | ||
| 562 | def test_wrapper_npu_normalize_batch(self): | 580 | def test_wrapper_npu_normalize_batch(self): |
| 563 | class Model(torch.nn.Module): | 581 | class Model(torch.nn.Module): |
| 564 | def __init__(self): | 582 | def __init__(self): |
| @@ -580,6 +598,7 @@ class TestOnnxOps(TestCase): | |||
| 580 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 598 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 581 | onnx_model_name))) | 599 | onnx_model_name))) |
| 582 | 600 | ||
| 601 | + | ||
| 583 | def test_wrapper_npu_nms_v4(self): | 602 | def test_wrapper_npu_nms_v4(self): |
| 584 | class Model(torch.nn.Module): | 603 | class Model(torch.nn.Module): |
| 585 | def __init__(self): | 604 | def __init__(self): |
| @@ -606,6 +625,7 @@ class TestOnnxOps(TestCase): | |||
| 606 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 625 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 607 | onnx_model_name))) | 626 | onnx_model_name))) |
| 608 | 627 | ||
| 628 | + | ||
| 609 | def test_wrapper_npu_bounding_box_decode(self): | 629 | def test_wrapper_npu_bounding_box_decode(self): |
| 610 | class Model(torch.nn.Module): | 630 | class Model(torch.nn.Module): |
| 611 | def __init__(self): | 631 | def __init__(self): |
| @@ -628,6 +648,7 @@ class TestOnnxOps(TestCase): | |||
| 628 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 648 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 629 | onnx_model_name))) | 649 | onnx_model_name))) |
| 630 | 650 | ||
| 651 | + | ||
| 631 | def test_wrapper_npu_bounding_box_encode(self): | 652 | def test_wrapper_npu_bounding_box_encode(self): |
| 632 | class Model(torch.nn.Module): | 653 | class Model(torch.nn.Module): |
| 633 | def __init__(self): | 654 | def __init__(self): |
| @@ -650,6 +671,7 @@ class TestOnnxOps(TestCase): | |||
| 650 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 671 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 651 | onnx_model_name))) | 672 | onnx_model_name))) |
| 652 | 673 | ||
| 674 | + | ||
| 653 | def test_wrapper_npu_nms_with_mask(self): | 675 | def test_wrapper_npu_nms_with_mask(self): |
| 654 | class Model(torch.nn.Module): | 676 | class Model(torch.nn.Module): |
| 655 | def __init__(self): | 677 | def __init__(self): |
| @@ -672,6 +694,7 @@ class TestOnnxOps(TestCase): | |||
| 672 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 694 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 673 | onnx_model_name))) | 695 | onnx_model_name))) |
| 674 | 696 | ||
| 697 | + | ||
| 675 | def test_wrapper_npu_rotated_iou(self): | 698 | def test_wrapper_npu_rotated_iou(self): |
| 676 | class Model(torch.nn.Module): | 699 | class Model(torch.nn.Module): |
| 677 | def __init__(self): | 700 | def __init__(self): |
| @@ -702,6 +725,7 @@ class TestOnnxOps(TestCase): | |||
| 702 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 725 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 703 | onnx_model_name))) | 726 | onnx_model_name))) |
| 704 | 727 | ||
| 728 | + | ||
| 705 | def test_wrapper_npu_rotated_overlaps(self): | 729 | def test_wrapper_npu_rotated_overlaps(self): |
| 706 | class Model(torch.nn.Module): | 730 | class Model(torch.nn.Module): |
| 707 | def __init__(self): | 731 | def __init__(self): |
| @@ -731,6 +755,7 @@ class TestOnnxOps(TestCase): | |||
| 731 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 755 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 732 | onnx_model_name))) | 756 | onnx_model_name))) |
| 733 | 757 | ||
| 758 | + | ||
| 734 | def test_wrapper_npu_rotated_box_decode(self): | 759 | def test_wrapper_npu_rotated_box_decode(self): |
| 735 | class Model(torch.nn.Module): | 760 | class Model(torch.nn.Module): |
| 736 | def __init__(self): | 761 | def __init__(self): |
| @@ -755,6 +780,7 @@ class TestOnnxOps(TestCase): | |||
| 755 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 780 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 756 | onnx_model_name))) | 781 | onnx_model_name))) |
| 757 | 782 | ||
| 783 | + | ||
| 758 | def test_wrapper_npu_rotated_box_encode(self): | 784 | def test_wrapper_npu_rotated_box_encode(self): |
| 759 | class Model(torch.nn.Module): | 785 | class Model(torch.nn.Module): |
| 760 | def __init__(self): | 786 | def __init__(self): |
| @@ -779,6 +805,7 @@ class TestOnnxOps(TestCase): | |||
| 779 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 805 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 780 | onnx_model_name))) | 806 | onnx_model_name))) |
| 781 | 807 | ||
| 808 | + | ||
| 782 | def test_wrapper_npu_yolo_boxes_encode(self): | 809 | def test_wrapper_npu_yolo_boxes_encode(self): |
| 783 | class Model(torch.nn.Module): | 810 | class Model(torch.nn.Module): |
| 784 | def __init__(self): | 811 | def __init__(self): |
| @@ -801,6 +828,7 @@ class TestOnnxOps(TestCase): | |||
| 801 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 828 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 802 | onnx_model_name))) | 829 | onnx_model_name))) |
| 803 | 830 | ||
| 831 | + | ||
| 804 | def test_wrapper_npu_masked_fill_range(self): | 832 | def test_wrapper_npu_masked_fill_range(self): |
| 805 | class Model(torch.nn.Module): | 833 | class Model(torch.nn.Module): |
| 806 | def __init__(self): | 834 | def __init__(self): |
| @@ -824,6 +852,7 @@ class TestOnnxOps(TestCase): | |||
| 824 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 852 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 825 | onnx_model_name))) | 853 | onnx_model_name))) |
| 826 | 854 | ||
| 855 | + | ||
| 827 | def test_wrapper_npu_anchor_response_flags(self): | 856 | def test_wrapper_npu_anchor_response_flags(self): |
| 828 | class Model(torch.nn.Module): | 857 | class Model(torch.nn.Module): |
| 829 | def __init__(self): | 858 | def __init__(self): |
| @@ -843,6 +872,7 @@ class TestOnnxOps(TestCase): | |||
| 843 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 872 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 844 | onnx_model_name))) | 873 | onnx_model_name))) |
| 845 | 874 | ||
| 875 | + | ||
| 846 | def test_wrapper_npu_indexing(self): | 876 | def test_wrapper_npu_indexing(self): |
| 847 | class Model(torch.nn.Module): | 877 | class Model(torch.nn.Module): |
| 848 | def __init__(self): | 878 | def __init__(self): |
| @@ -863,6 +893,7 @@ class TestOnnxOps(TestCase): | |||
| 863 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 893 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 864 | onnx_model_name))) | 894 | onnx_model_name))) |
| 865 | 895 | ||
| 896 | + | ||
| 866 | def test_wrapper_npu_sign_bits_pack(self): | 897 | def test_wrapper_npu_sign_bits_pack(self): |
| 867 | class Model(torch.nn.Module): | 898 | class Model(torch.nn.Module): |
| 868 | def __init__(self): | 899 | def __init__(self): |
| @@ -884,6 +915,7 @@ class TestOnnxOps(TestCase): | |||
| 884 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 915 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 885 | onnx_model_name))) | 916 | onnx_model_name))) |
| 886 | 917 | ||
| 918 | + | ||
| 887 | def test_wrapper_npu_stride_add(self): | 919 | def test_wrapper_npu_stride_add(self): |
| 888 | class Model(torch.nn.Module): | 920 | class Model(torch.nn.Module): |
| 889 | def __init__(self): | 921 | def __init__(self): |
| @@ -905,6 +937,7 @@ class TestOnnxOps(TestCase): | |||
| 905 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 937 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 906 | onnx_model_name))) | 938 | onnx_model_name))) |
| 907 | 939 | ||
| 940 | + | ||
| 908 | def test_wrapper_npu_lstm_cell(self): | 941 | def test_wrapper_npu_lstm_cell(self): |
| 909 | class Model(torch.nn.Module): | 942 | class Model(torch.nn.Module): |
| 910 | def __init__(self): | 943 | def __init__(self): |
| @@ -956,6 +989,7 @@ class TestOnnxOps(TestCase): | |||
| 956 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 989 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 957 | onnx_model_name))) | 990 | onnx_model_name))) |
| 958 | 991 | ||
| 992 | + | ||
| 959 | def test_wrapper_npu_lstm(self): | 993 | def test_wrapper_npu_lstm(self): |
| 960 | class Model(torch.nn.Module): | 994 | class Model(torch.nn.Module): |
| 961 | def __init__(self): | 995 | def __init__(self): |
| @@ -1012,6 +1046,7 @@ class TestOnnxOps(TestCase): | |||
| 1012 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1046 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1013 | onnx_model_name))) | 1047 | onnx_model_name))) |
| 1014 | 1048 | ||
| 1049 | + | ||
| 1015 | def test_wrapper_npu_gru(self): | 1050 | def test_wrapper_npu_gru(self): |
| 1016 | class Model(torch.nn.Module): | 1051 | class Model(torch.nn.Module): |
| 1017 | def __init__(self): | 1052 | def __init__(self): |
| @@ -1061,7 +1096,8 @@ class TestOnnxOps(TestCase): | |||
| 1061 | export_onnx(onnx_model_name) | 1096 | export_onnx(onnx_model_name) |
| 1062 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1097 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1063 | onnx_model_name))) | 1098 | onnx_model_name))) |
| 1064 | - | 1099 | + |
| 1100 | + | ||
| 1065 | def test_wrapper_npu_dropout_with_add_softmax(self): | 1101 | def test_wrapper_npu_dropout_with_add_softmax(self): |
| 1066 | class Model(torch.nn.Module): | 1102 | class Model(torch.nn.Module): |
| 1067 | def __init__(self): | 1103 | def __init__(self): |
| @@ -1086,6 +1122,7 @@ class TestOnnxOps(TestCase): | |||
| 1086 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1122 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1087 | onnx_model_name))) | 1123 | onnx_model_name))) |
| 1088 | 1124 | ||
| 1125 | + | ||
| 1089 | def test_wrapper_npu_scaled_masked_softmax(self): | 1126 | def test_wrapper_npu_scaled_masked_softmax(self): |
| 1090 | class Model(torch.nn.Module): | 1127 | class Model(torch.nn.Module): |
| 1091 | def __init__(self): | 1128 | def __init__(self): |
| @@ -1108,7 +1145,8 @@ class TestOnnxOps(TestCase): | |||
| 1108 | export_onnx(onnx_model_name) | 1145 | export_onnx(onnx_model_name) |
| 1109 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1146 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1110 | onnx_model_name))) | 1147 | onnx_model_name))) |
| 1111 | - | 1148 | + |
| 1149 | + | ||
| 1112 | 1150 | ||
| 1113 | def test_wrapper_npu_moe_compute_expert_tokens(self): | 1151 | def test_wrapper_npu_moe_compute_expert_tokens(self): |
| 1114 | class Model(torch.nn.Module): | 1152 | class Model(torch.nn.Module): |
| @@ -1130,6 +1168,7 @@ class TestOnnxOps(TestCase): | |||
| 1130 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1168 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1131 | onnx_model_name))) | 1169 | onnx_model_name))) |
| 1132 | 1170 | ||
| 1171 | + | ||
| 1133 | def test_wrapper_npu_mish(self): | 1172 | def test_wrapper_npu_mish(self): |
| 1134 | class Model(torch.nn.Module): | 1173 | class Model(torch.nn.Module): |
| 1135 | def __init__(self): | 1174 | def __init__(self): |
| @@ -1149,6 +1188,7 @@ class TestOnnxOps(TestCase): | |||
| 1149 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1188 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1150 | onnx_model_name))) | 1189 | onnx_model_name))) |
| 1151 | 1190 | ||
| 1191 | + | ||
| 1152 | 1192 | ||
| 1153 | def test_wrapper_npu_deep_norm(self): | 1193 | def test_wrapper_npu_deep_norm(self): |
| 1154 | class Model(torch.nn.Module): | 1194 | class Model(torch.nn.Module): |
| @@ -1174,6 +1214,7 @@ class TestOnnxOps(TestCase): | |||
| 1174 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1214 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1175 | onnx_model_name))) | 1215 | onnx_model_name))) |
| 1176 | 1216 | ||
| 1217 | + | ||
| 1177 | 1218 | ||
| 1178 | def test_wrapper_npu_rms_norm(self): | 1219 | def test_wrapper_npu_rms_norm(self): |
| 1179 | class Model(torch.nn.Module): | 1220 | class Model(torch.nn.Module): |
| @@ -1196,6 +1237,7 @@ class TestOnnxOps(TestCase): | |||
| 1196 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1237 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1197 | onnx_model_name))) | 1238 | onnx_model_name))) |
| 1198 | 1239 | ||
| 1240 | + | ||
| 1199 | 1241 | ||
| 1200 | def test_wrapper_npu_add_rms_norm(self): | 1242 | def test_wrapper_npu_add_rms_norm(self): |
| 1201 | class Model(torch.nn.Module): | 1243 | class Model(torch.nn.Module): |
| @@ -1219,6 +1261,7 @@ class TestOnnxOps(TestCase): | |||
| 1219 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1261 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1220 | onnx_model_name))) | 1262 | onnx_model_name))) |
| 1221 | 1263 | ||
| 1264 | + | ||
| 1222 | 1265 | ||
| 1223 | def test_wrapper_npu_rotary_mul(self): | 1266 | def test_wrapper_npu_rotary_mul(self): |
| 1224 | class Model(torch.nn.Module): | 1267 | class Model(torch.nn.Module): |
| @@ -1240,6 +1283,7 @@ class TestOnnxOps(TestCase): | |||
| 1240 | export_onnx(onnx_model_name) | 1283 | export_onnx(onnx_model_name) |
| 1241 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) | 1284 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) |
| 1242 | 1285 | ||
| 1286 | + | ||
| 1243 | 1287 | ||
| 1244 | def test_wrapper_npu_masked_softmax_with_rel_pos_bias(self): | 1288 | def test_wrapper_npu_masked_softmax_with_rel_pos_bias(self): |
| 1245 | class Model(torch.nn.Module): | 1289 | class Model(torch.nn.Module): |
| @@ -1263,6 +1307,7 @@ class TestOnnxOps(TestCase): | |||
| 1263 | export_onnx(onnx_model_name) | 1307 | export_onnx(onnx_model_name) |
| 1264 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) | 1308 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) |
| 1265 | 1309 | ||
| 1310 | + | ||
| 1266 | 1311 | ||
| 1267 | def test_wrapper_npu_dynamic_quant(self): | 1312 | def test_wrapper_npu_dynamic_quant(self): |
| 1268 | class Model(torch.nn.Module): | 1313 | class Model(torch.nn.Module): |
| @@ -1284,6 +1329,7 @@ class TestOnnxOps(TestCase): | |||
| 1284 | export_onnx(onnx_model_name) | 1329 | export_onnx(onnx_model_name) |
| 1285 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) | 1330 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) |
| 1286 | 1331 | ||
| 1332 | + | ||
| 1287 | 1333 | ||
| 1288 | def test_wrapper_npu_dynamic_quant_with_group_index(self): | 1334 | def test_wrapper_npu_dynamic_quant_with_group_index(self): |
| 1289 | class Model(torch.nn.Module): | 1335 | class Model(torch.nn.Module): |
| @@ -1312,7 +1358,8 @@ class TestOnnxOps(TestCase): | |||
| 1312 | onnx_model_name = "model_npu_dynamic_quant.onnx" | 1358 | onnx_model_name = "model_npu_dynamic_quant.onnx" |
| 1313 | export_onnx(onnx_model_name) | 1359 | export_onnx(onnx_model_name) |
| 1314 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) | 1360 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) |
| 1315 | - | 1361 | + |
| 1362 | + | ||
| 1316 | 1363 | ||
| 1317 | def test_wrapper_npu_dynamic_quant_asymmetric(self): | 1364 | def test_wrapper_npu_dynamic_quant_asymmetric(self): |
| 1318 | class Model(torch.nn.Module): | 1365 | class Model(torch.nn.Module): |
| @@ -1342,6 +1389,7 @@ class TestOnnxOps(TestCase): | |||
| 1342 | export_onnx(onnx_model_name) | 1389 | export_onnx(onnx_model_name) |
| 1343 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) | 1390 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) |
| 1344 | 1391 | ||
| 1392 | + | ||
| 1345 | 1393 | ||
| 1346 | def test_wrapper_npu_weight_quant_batchmatmul(self): | 1394 | def test_wrapper_npu_weight_quant_batchmatmul(self): |
| 1347 | class Model(torch.nn.Module): | 1395 | class Model(torch.nn.Module): |
| @@ -1364,6 +1412,7 @@ class TestOnnxOps(TestCase): | |||
| 1364 | export_onnx(onnx_model_name) | 1412 | export_onnx(onnx_model_name) |
| 1365 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) | 1413 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) |
| 1366 | 1414 | ||
| 1415 | + | ||
| 1367 | 1416 | ||
| 1368 | def test_wrapper_npu_anti_quant(self): | 1417 | def test_wrapper_npu_anti_quant(self): |
| 1369 | class Model(torch.nn.Module): | 1418 | class Model(torch.nn.Module): |
| @@ -1385,6 +1434,7 @@ class TestOnnxOps(TestCase): | |||
| 1385 | export_onnx(onnx_model_name) | 1434 | export_onnx(onnx_model_name) |
| 1386 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) | 1435 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) |
| 1387 | 1436 | ||
| 1437 | + | ||
| 1388 | def test_wrapper_npu_quantize(self): | 1438 | def test_wrapper_npu_quantize(self): |
| 1389 | class Model(torch.nn.Module): | 1439 | class Model(torch.nn.Module): |
| 1390 | def __init__(self): | 1440 | def __init__(self): |
| @@ -1408,6 +1458,7 @@ class TestOnnxOps(TestCase): | |||
| 1408 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1458 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1409 | onnx_model_name))) | 1459 | onnx_model_name))) |
| 1410 | 1460 | ||
| 1461 | + | ||
| 1411 | 1462 | ||
| 1412 | def test_wrapper_npu_group_quant(self): | 1463 | def test_wrapper_npu_group_quant(self): |
| 1413 | class Model(torch.nn.Module): | 1464 | class Model(torch.nn.Module): |
| @@ -1434,6 +1485,7 @@ class TestOnnxOps(TestCase): | |||
| 1434 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1485 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1435 | onnx_model_name))) | 1486 | onnx_model_name))) |
| 1436 | 1487 | ||
| 1488 | + | ||
| 1437 | 1489 | ||
| 1438 | def test_wrapper_npu_moe_finalize_routing(self): | 1490 | def test_wrapper_npu_moe_finalize_routing(self): |
| 1439 | class Model(torch.nn.Module): | 1491 | class Model(torch.nn.Module): |
| @@ -1466,6 +1518,7 @@ class TestOnnxOps(TestCase): | |||
| 1466 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1518 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1467 | onnx_model_name))) | 1519 | onnx_model_name))) |
| 1468 | 1520 | ||
| 1521 | + | ||
| 1469 | 1522 | ||
| 1470 | def test_wrapper_npu_moe_finalize_routing_v2(self): | 1523 | def test_wrapper_npu_moe_finalize_routing_v2(self): |
| 1471 | class Model(torch.nn.Module): | 1524 | class Model(torch.nn.Module): |
| @@ -1500,6 +1553,7 @@ class TestOnnxOps(TestCase): | |||
| 1500 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1553 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1501 | onnx_model_name))) | 1554 | onnx_model_name))) |
| 1502 | 1555 | ||
| 1556 | + | ||
| 1503 | 1557 | ||
| 1504 | def test_wrapper_npu_gelu(self): | 1558 | def test_wrapper_npu_gelu(self): |
| 1505 | class Model(torch.nn.Module): | 1559 | class Model(torch.nn.Module): |
| @@ -100,7 +100,6 @@ test/onnx/test_fx_to_onnx.py | |||
| 100 | test/onnx/error_reproduction.py | 100 | test/onnx/error_reproduction.py |
| 101 | test/onnx/test_fx_type_promotion.py | 101 | test/onnx/test_fx_type_promotion.py |
| 102 | test/onnx/test_models_onnxruntime.py | 102 | test/onnx/test_models_onnxruntime.py |
| 103 | -test/onnx/test_models_quantized_onnxruntime.py | ||
| 104 | test/onnx/test_onnx_opset.py | 103 | test/onnx/test_onnx_opset.py |
| 105 | test/onnx/test_onnxscript_runtime.py | 104 | test/onnx/test_onnxscript_runtime.py |
| 106 | test/onnx/test_op_consistency.py | 105 | test/onnx/test_op_consistency.py |
| @@ -2163,7 +2163,7 @@ | |||
| 2163 | "signature": "(self, rois, spatial_scale, pooled_height, pooled_width, sample_num, roi_end_mode)" | 2163 | "signature": "(self, rois, spatial_scale, pooled_height, pooled_width, sample_num, roi_end_mode)" |
| 2164 | }, | 2164 | }, |
| 2165 | "torch_npu.npu_rotary_mul": { | 2165 | "torch_npu.npu_rotary_mul": { |
| 2166 | - "signature": "(x, r1, r2)" | 2166 | + "signature": "(input, r1, r2, rotary_mode='half')" |
| 2167 | }, | 2167 | }, |
| 2168 | "torch_npu.npu_rotated_iou": { | 2168 | "torch_npu.npu_rotated_iou": { |
| 2169 | "signature": "(self, query_boxes, trans=False, mode=0, is_cross=True, v_threshold=0.0, e_threshold=0.0)" | 2169 | "signature": "(self, query_boxes, trans=False, mode=0, is_cross=True, v_threshold=0.0, e_threshold=0.0)" |
| @@ -2232,7 +2232,7 @@ | |||
| 2232 | "signature": "(sorted_experts, num_experts=1)" | 2232 | "signature": "(sorted_experts, num_experts=1)" |
| 2233 | }, | 2233 | }, |
| 2234 | "torch_npu.npu_group_norm_silu": { | 2234 | "torch_npu.npu_group_norm_silu": { |
| 2235 | - "signature": "(x, gamma, beta, group, eps=1e-05)" | 2235 | + "signature": "(input, weight, bias, group, eps=1e-05)" |
| 2236 | }, | 2236 | }, |
| 2237 | "torch_npu.npu_gelu": { | 2237 | "torch_npu.npu_gelu": { |
| 2238 | "signature": "(x, approximate='none')" | 2238 | "signature": "(x, approximate='none')" |
| @@ -30753,6 +30753,84 @@ | |||
| 30753 | "test_custom_op_fallthrough (__main__.TestUtilityFuns_opset_19)": ["", [""]], | 30753 | "test_custom_op_fallthrough (__main__.TestUtilityFuns_opset_19)": ["", [""]], |
| 30754 | "test_custom_op_fallthrough (__main__.TestUtilityFuns_opset_20)": ["", [""]], | 30754 | "test_custom_op_fallthrough (__main__.TestUtilityFuns_opset_20)": ["", [""]], |
| 30755 | "test_custom_op_fallthrough (__main__.TestUtilityFuns_opset_9)": ["", [""]], | 30755 | "test_custom_op_fallthrough (__main__.TestUtilityFuns_opset_9)": ["", [""]], |
| 30756 | + "test_verbose (__main__.TestUtilityFuns_opset_9)": ["", [""]], | ||
| 30757 | + "test_verbose (__main__.TestUtilityFuns_opset_10)": ["", [""]], | ||
| 30758 | + "test_verbose (__main__.TestUtilityFuns_opset_11)": ["", [""]], | ||
| 30759 | + "test_verbose (__main__.TestUtilityFuns_opset_12)": ["", [""]], | ||
| 30760 | + "test_verbose (__main__.TestUtilityFuns_opset_13)": ["", [""]], | ||
| 30761 | + "test_verbose (__main__.TestUtilityFuns_opset_14)": ["", [""]], | ||
| 30762 | + "test_verbose (__main__.TestUtilityFuns_opset_15)": ["", [""]], | ||
| 30763 | + "test_verbose (__main__.TestUtilityFuns_opset_16)": ["", [""]], | ||
| 30764 | + "test_verbose (__main__.TestUtilityFuns_opset_17)": ["", [""]], | ||
| 30765 | + "test_verbose (__main__.TestUtilityFuns_opset_18)": ["", [""]], | ||
| 30766 | + "test_verbose (__main__.TestUtilityFuns_opset_19)": ["", [""]], | ||
| 30767 | + "test_verbose (__main__.TestUtilityFuns_opset_20)": ["", [""]], | ||
| 30768 | + "test_api_compatibility (__main__.TestPublicApiCompatibility)": ["", [""]], | ||
| 30769 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_13_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30770 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_13_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30771 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_13_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30772 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_13_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30773 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_14_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30774 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_14_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30775 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_14_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30776 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_14_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30777 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_15_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30778 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_15_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30779 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_15_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30780 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_15_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30781 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_16_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30782 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_16_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30783 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_16_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30784 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_16_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30785 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_17_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30786 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_17_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30787 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_17_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30788 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_17_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30789 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_18_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30790 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_18_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30791 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_18_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30792 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_18_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30793 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_19_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30794 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_19_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30795 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_19_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30796 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_19_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30797 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_20_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30798 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_20_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30799 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_20_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30800 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_20_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30801 | + "test_mobilenet_v3 (__main__.TestQuantizedModelsONNXRuntime_is_script_False)": ["", [""]], | ||
| 30802 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_13_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30803 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_13_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30804 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_13_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30805 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_13_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30806 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_14_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30807 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_14_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30808 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_14_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30809 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_14_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30810 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_15_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30811 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_15_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30812 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_15_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30813 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_15_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30814 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_16_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30815 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_16_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30816 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_16_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30817 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_16_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30818 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_17_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30819 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_17_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30820 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_17_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30821 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_17_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30822 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_18_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30823 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_18_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30824 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_18_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30825 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_18_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30826 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_19_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30827 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_19_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30828 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_19_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30829 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_19_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30830 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_20_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30831 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_20_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30832 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_20_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 30833 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_20_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 30756 | "test_check_inplace_nn_ReLU_npu_float64 (__main__.TestModulePRIVATEUSE1)": ["", ["A2"]], | 30834 | "test_check_inplace_nn_ReLU_npu_float64 (__main__.TestModulePRIVATEUSE1)": ["", ["A2"]], |
| 30757 | "test_cpu_gpu_parity_nn_ReLU_npu_float64 (__main__.TestModulePRIVATEUSE1)": ["", ["A2"]], | 30835 | "test_cpu_gpu_parity_nn_ReLU_npu_float64 (__main__.TestModulePRIVATEUSE1)": ["", ["A2"]], |
| 30758 | "test_cpu_gpu_parity_nn_Tanh_npu_float64 (__main__.TestModulePRIVATEUSE1)": ["", ["A2"]], | 30836 | "test_cpu_gpu_parity_nn_Tanh_npu_float64 (__main__.TestModulePRIVATEUSE1)": ["", ["A2"]], |
| @@ -137,10 +137,17 @@ class _NPUGroupNormSiluOP(torch.autograd.Function): | |||
| 137 | 137 | ||
| 138 | def symbolic(g, self: Tensor, gamma: Optional[Tensor], beta: Optional[Tensor], | 138 | def symbolic(g, self: Tensor, gamma: Optional[Tensor], beta: Optional[Tensor], |
| 139 | group: int, eps: float = 0.00001): | 139 | group: int, eps: float = 0.00001): |
| 140 | + self_sizes = self.type().sizes() | ||
| 141 | + self_dims = len(self_sizes) | ||
| 142 | + if (self_dims < 2): | ||
| 143 | + raise ValueError("self dim must be larger than 2, but got ", self_dims, pta_error(ErrCode.VALUE)) | ||
| 144 | + | ||
| 145 | + shape_c = self_sizes[1] | ||
| 146 | + self_dtype = self.type().dtype() | ||
| 140 | if gamma is None: | 147 | if gamma is None: |
| 141 | - gamma = g.op("Constant", value_t=torch.tensor([]).to(torch.float)) | 148 | + gamma = g.op("Constant", value_t=torch.ones([shape_c], dtype=self_dtype)) |
| 142 | if beta is None: | 149 | if beta is None: |
| 143 | - beta = g.op("Constant", value_t=torch.tensor([]).to(torch.float)) | 150 | + beta = g.op("Constant", value_t=torch.zeros([shape_c], dtype=self_dtype)) |
| 144 | return g.op("npu::NPUGroupNormSilu", self, gamma, beta, group_i=group, eps_f=eps, | 151 | return g.op("npu::NPUGroupNormSilu", self, gamma, beta, group_i=group, eps_f=eps, |
| 145 | outputs=3) | 152 | outputs=3) |
| 146 | 153 | ||
| @@ -660,8 +667,8 @@ class _NPURotaryMulOP(torch.autograd.Function): | |||
| 660 | return torch.ops.npu.npu_rotary_mul(*args, **kwargs) | 667 | return torch.ops.npu.npu_rotary_mul(*args, **kwargs) |
| 661 | 668 | ||
| 662 | 669 | ||
| 663 | - def symbolic(g, x: Tensor, r1: Tensor, r2: Tensor): | 670 | + def symbolic(g, x: Tensor, r1: Tensor, r2: Tensor, rotary_mode: str = "half"): |
| 664 | - return g.op("npu::NPURotaryMul", x, r1, r2) | 671 | + return g.op("npu::NPURotaryMul", x, r1, r2, rotary_mode_s=rotary_mode) |
| 665 | 672 | ||
| 666 | 673 | ||
| 667 | class _NPUPromptFlashAttentionOP(torch.autograd.Function): | 674 | class _NPUPromptFlashAttentionOP(torch.autograd.Function): |
| @@ -935,16 +942,32 @@ class _NPUMoeFinalizeRoutingV2OP(torch.autograd.Function): | |||
| 935 | skip2: Optional[Tensor], bias: Optional[Tensor], | 942 | skip2: Optional[Tensor], bias: Optional[Tensor], |
| 936 | scales: Optional[Tensor], expanded_src_to_dst_row: Tensor, | 943 | scales: Optional[Tensor], expanded_src_to_dst_row: Tensor, |
| 937 | export_for_source_row: Optional[Tensor], drop_pad_mode: int = 0): | 944 | export_for_source_row: Optional[Tensor], drop_pad_mode: int = 0): |
| 945 | + expanded_permuted_rows_sizes = expanded_permuted_rows.type().sizes() | ||
| 946 | + expanded_permuted_rows_dims = len(expanded_permuted_rows_sizes) | ||
| 947 | + if (expanded_permuted_rows_dims < 2): | ||
| 948 | + raise ValueError("expanded_permuted_rows dim must be larger than 2, but got ", expanded_permuted_rows_dims, | ||
| 949 | + pta_error(ErrCode.VALUE)) | ||
| 950 | + | ||
| 951 | + rows_k, h, k = expanded_permuted_rows_sizes[0], expanded_permuted_rows_sizes[1], 1 | ||
| 952 | + if scales is not None: | ||
| 953 | + scales_sizes = scales.type().sizes() | ||
| 954 | + scales_dims = len(scales_sizes) | ||
| 955 | + if (scales_dims < 2): | ||
| 956 | + raise ValueError("scales dim must be larger than 2, but got ", scales_dims, pta_error(ErrCode.VALUE)) | ||
| 957 | + k = scales_sizes[1] | ||
| 958 | + | ||
| 959 | + rows = rows_k // k | ||
| 960 | + expanded_permuted_rows_dtype = expanded_permuted_rows.type().dtype() | ||
| 938 | if skip1 is None: | 961 | if skip1 is None: |
| 939 | - skip1 = g.op("Constant", value_t=torch.tensor([]).to(torch.float)) | 962 | + skip1 = g.op("Constant", value_t=torch.zeros([rows, h], dtype=expanded_permuted_rows_dtype)) |
| 940 | if skip2 is None: | 963 | if skip2 is None: |
| 941 | - skip2 = g.op("Constant", value_t=torch.tensor([]).to(torch.float)) | 964 | + skip2 = g.op("Constant", value_t=torch.zeros([rows, h], dtype=expanded_permuted_rows_dtype)) |
| 942 | if bias is None: | 965 | if bias is None: |
| 943 | - bias = g.op("Constant", value_t=torch.tensor([]).to(torch.float)) | 966 | + bias = g.op("Constant", value_t=torch.zeros([1, h], dtype=expanded_permuted_rows_dtype)) |
| 944 | if scales is None: | 967 | if scales is None: |
| 945 | - scales = g.op("Constant", value_t=torch.tensor([]).to(torch.float)) | 968 | + scales = g.op("Constant", value_t=torch.ones([rows, k], dtype=expanded_permuted_rows_dtype)) |
| 946 | if export_for_source_row is None: | 969 | if export_for_source_row is None: |
| 947 | - export_for_source_row = g.op("Constant", value_t=torch.tensor([]).to(torch.int32)) | 970 | + export_for_source_row = g.op("Constant", value_t=torch.zeros([rows, k], dtype=torch.int32)) |
| 948 | return g.op("npu::NPUMoeFinalizeRoutingV2", expanded_permuted_rows, expanded_src_to_dst_row, skip1, skip2, bias, | 971 | return g.op("npu::NPUMoeFinalizeRoutingV2", expanded_permuted_rows, expanded_src_to_dst_row, skip1, skip2, bias, |
| 949 | scales, export_for_source_row, drop_pad_mode_i=drop_pad_mode) | 972 | scales, export_for_source_row, drop_pad_mode_i=drop_pad_mode) |
| 950 | 973 | ||
| @@ -1066,8 +1089,8 @@ def _wrapper_npu_deep_norm(self, gx, beta, gamma, alpha=0.3, epsilon=1e-6): | |||
| 1066 | return _NPUDeepNormOP.apply(self, gx, beta, gamma, alpha, epsilon) | 1089 | return _NPUDeepNormOP.apply(self, gx, beta, gamma, alpha, epsilon) |
| 1067 | 1090 | ||
| 1068 | 1091 | ||
| 1069 | -def _wrapper_npu_group_norm_silu(x, gamma, beta, group, eps=0.00001): | 1092 | +def _wrapper_npu_group_norm_silu(input, weight, bias, group, eps=0.00001): |
| 1070 | - return _NPUGroupNormSiluOP.apply(x, gamma, beta, group, eps) | 1093 | + return _NPUGroupNormSiluOP.apply(input, weight, bias, group, eps) |
| 1071 | 1094 | ||
| 1072 | 1095 | ||
| 1073 | def _wrapper_npu_ifmr(data, data_min, data_max, cumsum, min_percentile, max_percentile, | 1096 | def _wrapper_npu_ifmr(data, data_min, data_max, cumsum, min_percentile, max_percentile, |
| @@ -1216,8 +1239,8 @@ def _wrapper_npu_mish(self): | |||
| 1216 | return _NPUMishOP.apply(self) | 1239 | return _NPUMishOP.apply(self) |
| 1217 | 1240 | ||
| 1218 | 1241 | ||
| 1219 | -def _wrapper_npu_rotary_mul(x, r1, r2): | 1242 | +def _wrapper_npu_rotary_mul(input, r1, r2, rotary_mode="half"): |
| 1220 | - return _NPURotaryMulOP.apply(x, r1, r2) | 1243 | + return _NPURotaryMulOP.apply(input, r1, r2, rotary_mode) |
| 1221 | 1244 | ||
| 1222 | 1245 | ||
| 1223 | def _wrapper_npu_prompt_flash_attention(self, query, key, value, padding_mask, atten_mask, pse_shift, actual_seq_lengths, | 1246 | def _wrapper_npu_prompt_flash_attention(self, query, key, value, padding_mask, atten_mask, pse_shift, actual_seq_lengths, |