Update modeling_openpangu_dense.py
Browse files
modeling_openpangu_dense.py
CHANGED
|
@@ -31,12 +31,13 @@ from typing import Callable, Optional, Union
|
|
| 31 |
import torch
|
| 32 |
from torch import nn
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
| 40 |
NPU_ATTN_INFR = False
|
| 41 |
|
| 42 |
from transformers.activations import ACT2FN
|
|
|
|
| 31 |
import torch
|
| 32 |
from torch import nn
|
| 33 |
|
| 34 |
+
try:
|
| 35 |
+
import torch_npu
|
| 36 |
+
from torch_npu.contrib import transfer_to_npu
|
| 37 |
+
if "910" in torch.npu.get_device_name():
|
| 38 |
+
NPU_ATTN_INFR = True
|
| 39 |
+
print("[INFO] torch_npu detected. Using NPU fused infer attention.")
|
| 40 |
+
except ImportError:
|
| 41 |
NPU_ATTN_INFR = False
|
| 42 |
|
| 43 |
from transformers.activations import ACT2FN
|