Skip to content

Commit e5b7afd

Browse files
committed
fix import
1 parent 0dbde50 commit e5b7afd

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

optimum/exporters/ipex/llama_functions.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@
1515
import math
1616
from typing import List, Optional, Tuple, Union
1717

18+
import intel_extension_for_pytorch as ipex
1819
import torch
19-
from intel_extension_for_pytorch.llm.modules import linear2SiluMul, linearAdd
20+
from packaging import version
2021
from torch import nn
2122
from transformers.modeling_attn_mask_utils import _prepare_4d_causal_attention_mask
2223
from transformers.modeling_outputs import BaseModelOutputWithPast
2324
from transformers.models.llama.modeling_llama import repeat_kv
2425

2526

27+
if version.parse(ipex.__version__) > version.parse("2.3.0"):
28+
from intel_extension_for_pytorch.llm.modules import linear2SiluMul, linearAdd
29+
30+
2631
def llama_layer_norm_forward(self, hidden_states):
2732
return torch.ops.torch_ipex.rmsnorm(hidden_states, self.weight, self.variance_epsilon)
2833

optimum/exporters/ipex/model_patcher.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from intel_extension_for_pytorch.llm.modules import ApplyRotaryEmbedding, IndirectAccessKVCache
15+
import intel_extension_for_pytorch as ipex
16+
from packaging import version
1617
from transformers.models.llama.modeling_llama import (
1718
LlamaAttention,
1819
LlamaDecoderLayer,
@@ -29,6 +30,10 @@
2930
)
3031

3132

33+
if version.parse(ipex.__version__) > version.parse("2.3.0"):
34+
from intel_extension_for_pytorch.llm.modules import ApplyRotaryEmbedding, IndirectAccessKVCache
35+
36+
3237
IPEX_EXPORTED_ARCH = ("LlamaForCausalLM",)
3338
IPEX_EXPORTED_TASK = ("text-generation",)
3439

0 commit comments

Comments
 (0)