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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 72 additions & 72 deletions paddle/fluid/pybind/manual_static_op_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ static PyObject *static_api_parameter(PyObject *self,
PyObject *name_obj = PyTuple_GET_ITEM(args, 0);
std::string name = CastPyArg2String(name_obj, "name", 0);
// Call ir static api
CallStackRecorder callstack_recoder("parameter");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("parameter");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::parameter(name);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();
return ToPyObject(static_api_out);
} catch (...) {
ThrowExceptionToPython(std::current_exception());
Expand All @@ -75,10 +75,10 @@ static PyObject *static_api_set_parameter(PyObject *self,
PyObject *name_obj = PyTuple_GET_ITEM(args, 1);
std::string name = CastPyArg2String(name_obj, "name", 1);
// Call ir static api
CallStackRecorder callstack_recoder("set_parameter");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("set_parameter");
callstack_recorder.Record();
paddle::dialect::set_parameter(parameter, name);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();
Py_RETURN_NONE;
} catch (...) {
ThrowExceptionToPython(std::current_exception());
Expand All @@ -101,10 +101,10 @@ static PyObject *static_api_update_parameter(PyObject *self,
PyObject *name_obj = PyTuple_GET_ITEM(args, 1);
std::string name = CastPyArg2String(name_obj, "name", 1);
// Call ir static api
CallStackRecorder callstack_recoder("uodata_parameter");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("uodata_parameter");
callstack_recorder.Record();
paddle::dialect::update_parameter(parameter, name);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();
Py_RETURN_NONE;
} catch (...) {
ThrowExceptionToPython(std::current_exception());
Expand All @@ -128,10 +128,10 @@ static PyObject *static_api_set_persistable_value(PyObject *self,
PyObject *name_obj = PyTuple_GET_ITEM(args, 1);
std::string name = CastPyArg2String(name_obj, "name", 1);
// Call ir static api
CallStackRecorder callstack_recoder("shadow_output");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("shadow_output");
callstack_recorder.Record();
paddle::dialect::shadow_output(persist_value, name);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();
Py_RETURN_NONE;
} catch (...) {
ThrowExceptionToPython(std::current_exception());
Expand Down Expand Up @@ -160,18 +160,18 @@ PyObject *static_api_full(PyObject *self, PyObject *args, PyObject *kwargs) {
if (PyComplex_Check(value_obj)) {
phi::dtype::complex<float> complex_value =
CastPyArg2Complex(value_obj, "full", 1);
CallStackRecorder callstack_recoder("full");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("full");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::full(
shape, complex_value.real, complex_value.imag, dtype, place);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();
return ToPyObject(static_api_out);
} else {
double value = CastPyArg2Double(value_obj, "full", 1);
CallStackRecorder callstack_recoder("full");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("full");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::full(shape, value, dtype, place);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();
return ToPyObject(static_api_out);
}
} else {
Expand Down Expand Up @@ -209,11 +209,11 @@ PyObject *static_api_full(PyObject *self, PyObject *args, PyObject *kwargs) {
}
}

CallStackRecorder callstack_recoder("full_with_tensor");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("full_with_tensor");
callstack_recorder.Record();
auto static_api_out =
paddle::dialect::full_with_tensor(value, shape, dtype);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();

return ToPyObject(static_api_out);
}
Expand All @@ -236,10 +236,10 @@ static PyObject *static_api_create_array(PyObject *self,
CastPyArg2DataTypeDirectly(dtype_obj, "create_array", 0);

// Call ir static api
CallStackRecorder callstack_recoder("create_array");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("create_array");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::create_array(dtype);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();

return ToPyObject(static_api_out);
} catch (...) {
Expand All @@ -264,10 +264,10 @@ static PyObject *static_api_create_array_like(PyObject *self,
float value = CastPyArg2Float(value_obj, "create_array_like", 1);

// Call ir static api
CallStackRecorder callstack_recoder("create_array_like");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("create_array_like");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::create_array_like(input, value);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();
return ToPyObject(static_api_out);
} catch (...) {
ThrowExceptionToPython(std::current_exception());
Expand All @@ -287,10 +287,10 @@ static PyObject *static_api_array_length(PyObject *self,
auto x = CastPyArg2Value(x_obj, "array_length", 0, false);

// Call ir static api
CallStackRecorder callstack_recoder("array_length");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("array_length");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::array_length(x);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();

return ToPyObject(static_api_out);
} catch (...) {
Expand Down Expand Up @@ -322,10 +322,10 @@ static PyObject *static_api_array_read(PyObject *self,
}

// Call ir static api
CallStackRecorder callstack_recoder("array_read");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("array_read");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::array_read(array, i);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();

return ToPyObject(static_api_out);
} catch (...) {
Expand All @@ -349,10 +349,10 @@ static PyObject *static_api_fetch(PyObject *self,
int col = CastPyArg2Int(PyTuple_GET_ITEM(args, 2), "array_read", 2);

// Call ir static api
CallStackRecorder callstack_recoder("fetch");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("fetch");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::fetch(value, name, col);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();

return ToPyObject(static_api_out);
} catch (...) {
Expand Down Expand Up @@ -386,10 +386,10 @@ static PyObject *static_api_array_write_(PyObject *self,
}

// Call ir static api
CallStackRecorder callstack_recoder("array_write_");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("array_write_");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::array_write_(array, x, i);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();

return ToPyObject(static_api_out);
} catch (...) {
Expand Down Expand Up @@ -428,10 +428,10 @@ static PyObject *static_api_array_to_tensor(PyObject *self,
auto use_stack = CastPyArg2Boolean(use_stack_obj, "array_to_tensor", 2);

// Call ir static api
CallStackRecorder callstack_recoder("array_to_tensor");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("array_to_tensor");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::array_to_tensor(x, axis, use_stack);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();

return ToPyObject(static_api_out);
} catch (...) {
Expand All @@ -451,10 +451,10 @@ PyObject *static_api_add_n_array(PyObject *self,
PyObject *inputs_obj = PyTuple_GET_ITEM(args, 0);
auto inputs = CastPyArg2VectorOfValue(inputs_obj, "add_n", 0, false);

CallStackRecorder callstack_recoder("add_n_array");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("add_n_array");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::add_n_array(inputs);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();

return ToPyObject(static_api_out);
} catch (...) {
Expand Down Expand Up @@ -505,10 +505,10 @@ static PyObject *static_api_slice_array(PyObject *self,
}

// Call ir static api
CallStackRecorder callstack_recoder("slice_array");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("slice_array");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::slice_array(input, starts, ends);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();

return ToPyObject(static_api_out);
} catch (...) {
Expand Down Expand Up @@ -544,10 +544,10 @@ static PyObject *static_api_slice_array_dense(PyObject *self,
starts_tmp, phi::DataType::INT64, phi::CPUPlace());
}
// Call ir static api
CallStackRecorder callstack_recoder("slice_array_dense");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("slice_array_dense");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::slice_array_dense(input, starts);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();

return ToPyObject(static_api_out);
} catch (...) {
Expand Down Expand Up @@ -953,8 +953,8 @@ static PyObject *static_api_run_custom_op(PyObject *self,

argument.AddOutputs(argument_outputs.begin(), argument_outputs.end());
::pir::PassStopGradientsDefaultly(argument);
CallStackRecorder callstack_recoder("run_custom_op");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("run_custom_op");
callstack_recorder.Record();
std::vector<pir::Value> op_results;
pir::Operation *op =
paddle::dialect::ApiBuilder::Instance().GetBuilder()->Build(
Expand All @@ -974,7 +974,7 @@ static PyObject *static_api_run_custom_op(PyObject *self,
op_results.push_back(op->result(i));
}
}
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();
return ToPyObject(op_results);
}

Expand All @@ -999,10 +999,10 @@ static PyObject *builtin_combine_op(PyObject *self,
// Get Value from args
PyObject *x_obj = PyTuple_GET_ITEM(args, 0);
auto x = CastPyArg2VectorOfValue(x_obj, "builtin_combine", 0, false);
CallStackRecorder callstack_recoder("builtin_combine_op");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("builtin_combine_op");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::builtin_combine(x);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();
return ToPyObject(static_api_out);
} catch (...) {
ThrowExceptionToPython(std::current_exception());
Expand All @@ -1019,10 +1019,10 @@ static PyObject *builtin_split_op(PyObject *self,
// Get Value from args
PyObject *x_obj = PyTuple_GET_ITEM(args, 0);
auto x = CastPyArg2Value(x_obj, "builtin_split", 0, false);
CallStackRecorder callstack_recoder("builtin_builtin_split");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("builtin_builtin_split");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::builtin_split(x);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();
return ToPyObject(static_api_out);
} catch (...) {
ThrowExceptionToPython(std::current_exception());
Expand Down Expand Up @@ -1054,11 +1054,11 @@ static PyObject *static_api_fused_gemm_epilogue(PyObject *self,
std::string activation =
CastPyArg2String(activation_obj, "fused_gemm_epilogue", 5);
// Call ir static api
CallStackRecorder callstack_recoder("fused_gemm_epilogue");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("fused_gemm_epilogue");
callstack_recorder.Record();
auto out = paddle::dialect::fused_gemm_epilogue(
x, y, bias, trans_x, trans_y, activation);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();

return ToPyObject(out);
} catch (...) {
Expand All @@ -1081,10 +1081,10 @@ static PyObject *static_api_array_pop(PyObject *self,
auto index = CastPyArg2Int(index_obj, "array_pop", 1);

// Call ir static api
CallStackRecorder callstack_recoder("array_pop");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("array_pop");
callstack_recorder.Record();
auto static_api_out = paddle::dialect::array_pop(input, index);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();
return ToPyObject(static_api_out);
} catch (...) {
ThrowExceptionToPython(std::current_exception());
Expand Down Expand Up @@ -1161,8 +1161,8 @@ static PyObject *static_api_tensorrt_engine(PyObject *self,
std::string converter_debug_info =
CastPyArg2String(converter_debug_info_obj, "converter_debug_info", 6);
// Call ir static api
CallStackRecorder callstack_recoder("tensorrt_engine");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("tensorrt_engine");
callstack_recorder.Record();
auto static_api_out =
paddle::dialect::tensorrt_engine(x,
trt_param,
Expand All @@ -1171,7 +1171,7 @@ static PyObject *static_api_tensorrt_engine(PyObject *self,
outputs_shape,
outputs_dtype,
converter_debug_info);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();
return ToPyObject(static_api_out);
} catch (...) {
ThrowExceptionToPython(std::current_exception());
Expand Down Expand Up @@ -1214,10 +1214,10 @@ static PyObject *share_var(PyObject *self, PyObject *args, PyObject *kwargs) {
// Get Value from args
PyObject *input_obj = PyTuple_GET_ITEM(args, 0);
auto inputs = CastPyArg2VectorOfValue(input_obj, "share_var", 0, false);
CallStackRecorder callstack_recoder("share_var_op");
callstack_recoder.Record();
CallStackRecorder callstack_recorder("share_var_op");
callstack_recorder.Record();
auto share_var_op = paddle::dialect::share_var(inputs);
callstack_recoder.AttachToOps();
callstack_recorder.AttachToOps();
return ToPyObject(share_var_op);
} catch (...) {
ThrowExceptionToPython(std::current_exception());
Expand Down
10 changes: 5 additions & 5 deletions paddle/fluid/pybind/pir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1291,14 +1291,14 @@ const phi::DDim &GetTensorDims(Type type) {
} else if (auto sparse_coo_tensor_type =
type.dyn_cast<SparseCooTensorType>()) {
return sparse_coo_tensor_type.dims();
} else if (auto sparse_csr_tensr_type =
} else if (auto sparse_csr_tensor_type =
type.dyn_cast<SparseCsrTensorType>()) {
return sparse_csr_tensr_type.dims();
return sparse_csr_tensor_type.dims();
} else if (auto dense_array_type = type.dyn_cast<DenseTensorArrayType>()) {
return dense_array_type.dims();
} else {
PADDLE_THROW(common::errors::InvalidArgument(
"Currently, we can only get shape for dense and selsect rows type."));
"Currently, we can only get shape for dense and select rows type."));
}
}
const phi::DDim &GetValueDims(Value value) {
Expand Down Expand Up @@ -3362,7 +3362,7 @@ void BindShapeOrDataDimExprs(pybind11::module *m) {
if (actual.size() != expect.size()) {
LOG(ERROR) << compare_type << " expect size " << expect.size()
<< " is not equal to actual size " << actual.size()
<< " . The detailed infermation is as follows:";
<< " . The detailed information is as follows:";
PrintExpectAndActual(compare_type);
return false;
} else if (actual.empty()) {
Expand All @@ -3383,7 +3383,7 @@ void BindShapeOrDataDimExprs(pybind11::module *m) {
<< compare_type << " expect[" << i
<< "]: " << expect.at(i) << " is not equal to actual["
<< i << "]: " << actual.at(i)
<< " . The detailed infermation is as follows:";
<< " . The detailed information is as follows:";
PrintExpectAndActual(compare_type);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/pybind/pybind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3337,7 +3337,7 @@ All parameter, weight, gradient are variables in Paddle.
} else {
PADDLE_THROW(common::errors::InvalidArgument(
"Invalid argument, key must be one of paddle_op, "
"popart_op, domain or version, but revecived %s",
"popart_op, domain or version, but received %s",
option_key));
}
}
Expand Down