PIKA665 commited on
Commit
f228d5c
·
verified ·
1 Parent(s): 9ae3530

Update modeling_openpangu_dense.py

Browse files
Files changed (1) hide show
  1. modeling_openpangu_dense.py +7 -6
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
- import torch_npu
35
- from torch_npu.contrib import transfer_to_npu
36
- if "910" in torch.npu.get_device_name():
37
- NPU_ATTN_INFR = True
38
- print("[INFO] torch_npu detected. Using NPU fused infer attention.")
39
- else:
 
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