Skip to content

Commit

Permalink
fix use paddle.incubate.jit.inference(model) errors (#9016)
Browse files Browse the repository at this point in the history
* fix use paddle.incubate.jit.inference(model) errors

* fix jit_inference function

* fix jit_inference function

* fix jit_inference function

* fix jit_inference function

* fix jit_inference function

* fix jit_inference function

* fix jit_inference function

* fix jit_inference function

* fix jit_inference function

* fix jit_inference function

* fix jit_inference function
  • Loading branch information
chang-wenbin authored Sep 6, 2024
1 parent ce0c0e7 commit 2150ae3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions paddlenlp/transformers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ def adapt_stale_fwd_patch(self, name, value):
"StaticFunction"
):
return value

# NOTE(changwenbin & zhoukangkang):
# When use model = paddle.incubate.jit.inference(model), it reportes errors, we fix it here.
# is_inference_mode API is only avaliable in PaddlePaddle develop,so we add a try except.
try:
from paddle.incubate.jit import is_inference_mode

if is_inference_mode(value):
return value
except:
pass

if hasattr(inspect, "getfullargspec"):
(
patch_spec_args,
Expand Down

0 comments on commit 2150ae3

Please sign in to comment.