MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / GetPyArgumentInfo

Function GetPyArgumentInfo

paddle/fluid/pybind/eager_utils.cc:2846–2877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2844 }
2845}
2846std::pair<PyObject*, ssize_t> GetPyArgumentInfo(const std::string& op_type,
2847 const std::string& arg_name,
2848 PyObject* args,
2849 ssize_t arg_idx,
2850 bool dispensable) {
2851 PyObject* list = PyTuple_GET_ITEM(args, arg_idx);
2852 ssize_t list_len = 0;
2853 if (list == nullptr && !dispensable) {
2854 PADDLE_THROW(common::errors::InvalidArgument(
2855 "%s(): argument '%s' (position %d) must be list of Tensor, but got "
2856 "None",
2857 op_type,
2858 arg_name,
2859 arg_idx));
2860 }
2861 if (list == nullptr || list == Py_None) {
2862 list_len = -1;
2863 } else if (PyList_Check(list)) {
2864 list_len = PyList_Size(list);
2865 } else if (PyTuple_Check(list)) {
2866 list_len = PyTuple_Size(list);
2867 } else {
2868 PADDLE_THROW(common::errors::InvalidArgument(
2869 "%s(): argument '%s' (position %d) must be list of Tensors, but got "
2870 "%s",
2871 op_type,
2872 arg_name,
2873 arg_idx,
2874 (reinterpret_cast<PyTypeObject*>(list->ob_type))->tp_name));
2875 }
2876 return std::make_pair(list, list_len);
2877}
2878
2879std::vector<Tensor>& GetTensorListFromArgsWithBuffer(
2880 const std::string& op_type,

Callers 1

eager_api_run_programFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected