Skip to content

Commit 3f14a83

Browse files
authored
Update _axclrt.py (#36)
After investigating the issue, I found that the current code directly assigns the C pointer returned from the AxcrustEngineGetOutputNameByIndex function to the name variable. This causes Python to display the raw C pointer address (e.g., <cdata 'char *' 0x8820f70>) instead of the actual string value. The proper solution involves a two-step process: First, store the C pointer in a variable named cffi_name Then, convert the C pointer to a string using axclrt_cffi.string() and decode it as a UTF-8 string with decode("utf-8") This modification ensures that C string pointers are properly converted to Python strings, allowing the correct names to appear in the output results. This approach is consistent with the method already used in the _get_inputs() method. Before change: axengine/_axclrt.py LineNo.279 name = axclrt_lib.axclrtEngineGetOutputNameByIndex(self._info[0], index) After change: axengine/_axclrt.py LineNo.279 cffi_name = axclrt_lib.axclrtEngineGetOutputNameByIndex(self._info[0], index) name = axclrt_cffi.string(cffi_name).decode("utf-8")
1 parent 0c655ac commit 3f14a83

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

axengine/_axclrt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ def _get_outputs(self):
276276
for group in range(self._shape_count):
277277
one_group_io = []
278278
for index in range(axclrt_lib.axclrtEngineGetNumOutputs(self._info[0])):
279-
name = axclrt_lib.axclrtEngineGetOutputNameByIndex(self._info[0], index)
279+
cffi_name = axclrt_lib.axclrtEngineGetOutputNameByIndex(self._info[0], index)
280+
name = axclrt_cffi.string(cffi_name).decode("utf-8")
280281

281282
cffi_dtype = axclrt_cffi.new("axclrtEngineDataType *")
282283
ret = axclrt_lib.axclrtEngineGetOutputDataType(self._info[0], index, cffi_dtype)

0 commit comments

Comments
 (0)