Skip to content

Commit 9d9cc4d

Browse files
committed
disable_in_pir_mode
1 parent a2929ec commit 9d9cc4d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

python/paddle/nn/layer/layers.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
from __future__ import annotations
1515

1616
import copy
17+
import functools
1718
import inspect
1819
import re
1920
import typing
2021
import warnings
2122
import weakref
2223
from collections import OrderedDict
2324
from typing import TYPE_CHECKING, Any, Callable, Dict, Union
24-
import functools
2525

2626
import numpy as np
2727
from typing_extensions import Self
@@ -1559,10 +1559,9 @@ def _dygraph_call_func(self, *inputs: Any, **kwargs: Any) -> Any:
15591559

15601560
return outputs
15611561

1562-
15631562
def _init_params_decorator(func):
15641563
"""
1565-
Decorator function that initializes parameters before calling the decorated method.
1564+
Only in dygraph mode, Decorator function that initializes parameters before calling the decorated method.
15661565
15671566
This decorator checks whether each parameter has been initialized using the '_is_initialized' property.
15681567
If any parameter is uninitialized, it calls the 'initialize' method on that parameter.
@@ -1573,11 +1572,14 @@ def _init_params_decorator(func):
15731572
Returns:
15741573
function: A wrapped version of the input function that performs parameter initialization before calling the original function.
15751574
"""
1575+
if in_pir_mode():
1576+
return func
1577+
15761578
@functools.wraps(func)
15771579
def wrapper(self, *args, **kwargs):
15781580
if not self._is_parameters_initialized:
15791581
for _, param in self.named_parameters():
1580-
if not param._is_initialized():
1582+
if not param._is_initialized():
15811583
param.initialize()
15821584
self._is_parameters_initialized = True
15831585

0 commit comments

Comments
 (0)