Skip to content

Output Name Error on _axclrt.py #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025
Merged

Output Name Error on _axclrt.py #36

merged 1 commit into from
Mar 19, 2025

Conversation

nnn112358
Copy link
Contributor

#35

Current code assigns C pointers directly to name, displaying addresses instead of values. Solution: Store pointer in cffi_name, then convert using axclrt_cffi.string().decode("utf-8"). This properly converts C strings to Python strings, matching the approach in _get_inputs().

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")

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")
@BUG1989 BUG1989 requested a review from kalcohol March 19, 2025 08:51
Copy link
Member

@BUG1989 BUG1989 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@BUG1989 BUG1989 merged commit 3f14a83 into AXERA-TECH:main Mar 19, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants