Skip to content

Commit e79da77

Browse files
authored
Fix transformers version v4.38 compatibility (#657)
1 parent 91e635e commit e79da77

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

optimum/intel/neural_compressor/trainer.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
is_accelerate_available,
6363
is_apex_available,
6464
is_sagemaker_mp_enabled,
65-
is_torch_xla_available,
6665
logging,
6766
)
6867

@@ -73,6 +72,12 @@
7372
from .configuration import INCConfig
7473

7574

75+
if is_transformers_version(">=", "4.39.0"):
76+
from transformers.utils import is_torch_xla_available
77+
else:
78+
from transformers.utils import is_torch_tpu_available as is_torch_xla_available
79+
80+
7681
if is_accelerate_available():
7782
from accelerate import __version__ as accelerate_version
7883
from accelerate import skip_first_batches

optimum/intel/openvino/trainer.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
is_accelerate_available,
8181
is_apex_available,
8282
is_sagemaker_mp_enabled,
83-
is_torch_xla_available,
8483
logging,
8584
)
8685

@@ -101,6 +100,11 @@
101100
)
102101

103102

103+
if is_transformers_version(">=", "4.39.0"):
104+
from transformers.utils import is_torch_xla_available
105+
else:
106+
from transformers.utils import is_torch_tpu_available as is_torch_xla_available
107+
104108
if is_accelerate_available():
105109
from accelerate import __version__ as accelerate_version
106110
from accelerate import skip_first_batches

0 commit comments

Comments
 (0)