Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions paddle/fluid/pir/dialect/op_generator/python_c_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
// Parse Attributes
{attrs}

// Parse input_out if needed
{input_out}

// Check Reminding Params validity if needed
{check_remaining_params_valid}
// Call Pre_Process before calling dygraph function if needed
Expand Down Expand Up @@ -160,6 +163,9 @@
// Parse Attributes
{attrs_py_obj}

// Parse input_out if needed
{input_out}

// Check for mutable attrs
{init_attrs}
{cast_attrs}
Expand Down Expand Up @@ -635,6 +641,13 @@ def _gen_one_impl(self, op_info, op_name):
args=', '.join(input_name_list + attr_name_list),
)
elif len(mutable_attr_name_list) > 0:
get_input_out_str = ""
if (
not op_name[-1:] == "_"
and not op_name[-4:] == "grad"
and "sparse" not in op_name
):
get_input_out_str = "Check_PIR_not_support_out(kwargs);"
ret = MUTABLE_ATTR_API_IMPL_TEMPLATE.format(
api_name=op_name,
check_params_count=self._gen_check_params_count(
Expand All @@ -655,8 +668,16 @@ def _gen_one_impl(self, op_info, op_name):
+ mutable_attr_name_list
+ no_mutable_attr_name_list
),
input_out=get_input_out_str,
)
else:
get_input_out_str = ""
if (
not op_name[-1:] == "_"
and not op_name[-4:] == "grad"
and "sparse" not in op_name
):
get_input_out_str = "Check_PIR_not_support_out(kwargs);"
ret = NO_MUTABLE_ATTR_API_IMPL_TEMPLATE.format(
api_name=op_name,
check_params_count=self._gen_check_params_count(
Expand All @@ -671,6 +692,7 @@ def _gen_one_impl(self, op_info, op_name):
need_check=need_check_params_count
),
pre_process=self._gen_pre_process(pre_process),
input_out=get_input_out_str,
)
ret = re.sub(r' +\n', '', ret)
return ret
Expand Down
14 changes: 14 additions & 0 deletions paddle/fluid/pybind/eager_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3184,4 +3184,18 @@ paddle::optional<Tensor*> GetInputOutTensorFromKwargs(PyObject* kwargs) {
return paddle::none;
}

void Check_PIR_not_support_out(PyObject* kwargs) {
if (!kwargs) {
return;
}
PyObject* obj = PyDict_GetItemString(kwargs, "out");
if (obj) {
static std::once_flag once_flag;
std::call_once(once_flag, [&] {
LOG(WARNING) << "Paddle static graph(PIR) not support input out tensor "
"for now!!!!!";
});
}
}

} // namespace paddle::pybind
2 changes: 2 additions & 0 deletions paddle/fluid/pybind/eager_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ void EagerSetDeviceId();

paddle::optional<Tensor*> GetInputOutTensorFromKwargs(PyObject* kwargs);

void Check_PIR_not_support_out(PyObject* kwargs);

/*----------------------for arg parse-----------------------------*/
paddle::Tensor& GetTensorFromArgsOrKWArgs(
const std::string& op_type,
Expand Down