Skip to content

Commit

Permalink
Call 'Py_DECREF' after 'using 'PyObject_GetAttrString' in intel driver
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev committed Dec 28, 2024
1 parent 18b8b75 commit f3d4cb9
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions third_party/intel/backend/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,18 @@ def format_of(ty):
}}
// extract kernel metadata
int num_warps = PyLong_AsLong(PyObject_GetAttrString(kernel_metadata, "num_warps"));
int num_ctas = PyLong_AsLong(PyObject_GetAttrString(kernel_metadata, "num_ctas"));
int shared_memory = PyLong_AsLong(PyObject_GetAttrString(kernel_metadata, "shared"));
int threads_per_warp = PyLong_AsLong(PyObject_GetAttrString(kernel_metadata, "threads_per_warp"));
PyObject *num_warps_attr = PyObject_GetAttrString(kernel_metadata, "num_warps");
int num_warps = PyLong_AsLong(num_warps_attr);
Py_DECREF(num_warps_attr);
PyObject *num_ctas_attr = PyObject_GetAttrString(kernel_metadata, "num_ctas");
int num_ctas = PyLong_AsLong(num_ctas_attr);
Py_DECREF(num_ctas_attr);
PyObject *shared_attr = PyObject_GetAttrString(kernel_metadata, "shared");
int shared_memory = PyLong_AsLong(shared_attr);
Py_DECREF(shared_attr);
PyObject *threads_per_warp_attr = PyObject_GetAttrString(kernel_metadata, "threads_per_warp");
int threads_per_warp = PyLong_AsLong(threads_per_warp_attr);
Py_DECREF(threads_per_warp_attr);
// extract cluster dims
PyObject *clusterDim = PyObject_GetAttrString(kernel_metadata, "cluster_dims");
Expand All @@ -434,6 +442,7 @@ def format_of(ty):
int clusterDimX = PyLong_AsLong(PyTuple_GetItem(clusterDim, 0));
int clusterDimY = PyLong_AsLong(PyTuple_GetItem(clusterDim, 1));
int clusterDimZ = PyLong_AsLong(PyTuple_GetItem(clusterDim, 2));
Py_DECREF(clusterDim);
// extract launch metadata
if (launch_enter_hook != Py_None){{
PyObject* args = Py_BuildValue("(O)", launch_metadata);
Expand Down Expand Up @@ -466,9 +475,7 @@ def format_of(ty):
return NULL;
}}
// return None
Py_INCREF(Py_None);
return Py_None;
Py_RETURN_NONE;
}}
static PyMethodDef ModuleMethods[] = {{
Expand Down

0 comments on commit f3d4cb9

Please sign in to comment.