Skip to content

Commit 0c577d1

Browse files
authored
fix compatibility with previous torch versions (huggingface#863)
1 parent cb32118 commit 0c577d1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

optimum/intel/openvino/utils.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
from transformers import AutoTokenizer, CLIPTokenizer, PreTrainedTokenizer, PreTrainedTokenizerFast
2929
from transformers.onnx.utils import ParameterFormat, compute_serialized_parameters_size
3030

31+
from optimum.intel.utils.import_utils import is_torch_version
32+
3133

3234
logger = logging.getLogger(__name__)
3335

@@ -74,16 +76,16 @@
7476
"i8": torch.int8,
7577
"u8": torch.uint8,
7678
"i16": torch.int16,
77-
"u16": torch.uint16,
7879
"i32": torch.int32,
79-
"u32": torch.uint32,
8080
"i64": torch.int64,
81-
"u64": torch.uint64,
8281
"f16": torch.float16,
8382
"f32": torch.float32,
8483
"f64": torch.float64,
8584
}
8685

86+
if is_torch_version(">=", "2.4.0"):
87+
OV_TO_PT_TYPE.update({"u16": torch.uint16, "u32": torch.uint32, "u64": torch.uint64})
88+
8789

8890
STR_TO_OV_TYPE = {
8991
"boolean": OVType.boolean,

0 commit comments

Comments
 (0)