File: | .cache/bazel/_bazel_alan/39be661231df2a680c9b74265384c13c/execroot/org_tensorflow/tensorflow/python/framework/python_api_parameter_converter_wrapper.cc |
Warning: | line 33, column 25 PyObject ownership leak with reference count of 1 |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* Copyright 2020 The TensorFlow Authors. All Rights Reserved. | |||
2 | ||||
3 | Licensed under the Apache License, Version 2.0 (the "License"); | |||
4 | you may not use this file except in compliance with the License. | |||
5 | You may obtain a copy of the License at | |||
6 | ||||
7 | http://www.apache.org/licenses/LICENSE-2.0 | |||
8 | ||||
9 | Unless required by applicable law or agreed to in writing, software | |||
10 | distributed under the License is distributed on an "AS IS" BASIS, | |||
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
12 | See the License for the specific language governing permissions and | |||
13 | limitations under the License. | |||
14 | ==============================================================================*/ | |||
15 | // Note: This library is only used by python_api_parameter_converter_test. It | |||
16 | // is not meant to be used in other circumstances. | |||
17 | ||||
18 | #include "pybind11/pybind11.h" | |||
19 | #include "pybind11/pytypes.h" | |||
20 | #include "pybind11/stl.h" | |||
21 | #include "tensorflow/python/framework/python_api_parameter_converter.h" | |||
22 | ||||
23 | namespace py = pybind11; | |||
24 | ||||
25 | namespace tensorflow { | |||
26 | namespace { | |||
27 | ||||
28 | PythonAPIInfo::InferredAttributes Convert( | |||
29 | const PythonAPIInfo& api_info, | |||
30 | const PythonTensorConverter& tensor_converter, py::handle arg_list) { | |||
31 | PythonAPIInfo::InferredAttributes inferred_attrs; | |||
32 | ||||
33 | PyObject* args_fast = PySequence_Fast(arg_list.ptr(), "Expected a list"); | |||
| ||||
| ||||
34 | absl::Span<PyObject*> args_raw(PySequence_Fast_ITEMS(args_fast)(((((((PyObject*)(args_fast))->ob_type))->tp_flags & ((1UL << 25))) != 0) ? ((PyListObject *)(args_fast))-> ob_item : ((PyTupleObject *)(args_fast))->ob_item), | |||
35 | PySequence_Fast_GET_SIZE(args_fast)(((((((PyObject*)(args_fast))->ob_type))->tp_flags & ((1UL << 25))) != 0) ? ((static_cast<void> (0)), (((PyVarObject*)(args_fast))->ob_size)) : (((PyVarObject* )(((static_cast<void> (0)), (PyTupleObject *)(args_fast ))))->ob_size))); | |||
36 | ||||
37 | if (!CopyPythonAPITensorLists(api_info, args_raw)) { | |||
38 | throw py::error_already_set(); | |||
39 | } | |||
40 | if (!ConvertPythonAPIParameters(api_info, tensor_converter, args_raw, | |||
41 | &inferred_attrs)) { | |||
42 | throw py::error_already_set(); | |||
43 | } | |||
44 | ||||
45 | return inferred_attrs; | |||
46 | } | |||
47 | ||||
48 | } // namespace | |||
49 | } // namespace tensorflow | |||
50 | ||||
51 | PYBIND11_MODULE(_pywrap_python_api_parameter_converter, m)static ::pybind11::module_::module_def pybind11_module_def__pywrap_python_api_parameter_converter ; __attribute__ ((__unused__)) static void pybind11_init__pywrap_python_api_parameter_converter (::pybind11::module_ &); extern "C" __attribute__ ((__unused__ )) __attribute__ ((visibility("default"))) PyObject *PyInit__pywrap_python_api_parameter_converter (); extern "C" __attribute__ ((visibility("default"))) PyObject *PyInit__pywrap_python_api_parameter_converter() { { const char *compiled_ver = "3" "." "8"; const char *runtime_ver = Py_GetVersion (); size_t len = std::strlen(compiled_ver); if (std::strncmp( runtime_ver, compiled_ver, len) != 0 || (runtime_ver[len] >= '0' && runtime_ver[len] <= '9')) { PyErr_Format(PyExc_ImportError , "Python version mismatch: module was compiled for Python %s, " "but the interpreter version is incompatible: %s.", compiled_ver , runtime_ver); return nullptr; } } pybind11::detail::get_internals (); auto m = ::pybind11::module_::create_extension_module( "_pywrap_python_api_parameter_converter" , nullptr, &pybind11_module_def__pywrap_python_api_parameter_converter ); try { pybind11_init__pywrap_python_api_parameter_converter (m); return m.ptr(); } catch (pybind11::error_already_set & e) { PyErr_SetString(PyExc_ImportError, e.what()); return nullptr ; } catch (const std::exception &e) { PyErr_SetString(PyExc_ImportError , e.what()); return nullptr; } } void pybind11_init__pywrap_python_api_parameter_converter (::pybind11::module_ &m) { | |||
52 | m.def("Convert", tensorflow::Convert); | |||
53 | } |
1 | #ifndef PySequence_Fast |
2 | struct _object; |
3 | typedef struct _object PyObject; |
4 | PyObject* clang_analyzer_PyObject_New_Reference(); |
5 | PyObject* PySequence_Fast(PyObject *o, const char *m) { |
6 | return clang_analyzer_PyObject_New_Reference(); |
7 | } |
8 | #else |
9 | #warning "API PySequence_Fast is defined as a macro." |
10 | #endif |