Skip to content
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

Feat/dla vp overflow fix #69

Merged
merged 3 commits into from
Sep 25, 2024

Conversation

vilukissa68
Copy link
Collaborator

Fixes buffer overflow issue with bank switching. Adds some quality of life features to prints. Removes dead code.

@vilukissa68 vilukissa68 mentioned this pull request Sep 24, 2024
@vilukissa68 vilukissa68 requested a review from hegza September 24, 2024 13:33
Copy link
Contributor

@hegza hegza left a comment

Choose a reason for hiding this comment

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

Seems reasonable. Mostly style issues. Fix if you will.

@@ -318,7 +295,7 @@ def cast_long_to_signed_byte(value):
Returns:
byte -- Int Signed value in range -128..127
"""
assert(0 <= value <= 255)
assert(0 <= value <= 255), "Assert failed! Value doesn't fit byte"
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be better expressed as assert(0 <= value <= 0xff)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@@ -333,7 +310,7 @@ def cast_long_to_signed_16(value):
Returns:
byte -- Int Signed value in range -128..127
"""
assert(0 <= value <= 65535)
assert(0 <= value <= 65535), "Assert failed! Value doesn't fit 2 bytes"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, <= 0xffff

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

output[ch][w][h] = data[i]
i = i + 1
return output

def cast_long_to_signed_byte(value):
Copy link
Contributor

Choose a reason for hiding this comment

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

Not part of the review, but I wonder, how did this C-language ABI-specific type names (long) end up in our source tree 😅

Ideally, this would be something like cast_u64_to_i8. Besides, current function name leaves it up to interpretation whether it's a signed or an unsigned long. One has to wonder, why is the signed name-specifier included for the byte but not for the long.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So the logic is that the input value is a Python long type, an integer of (almost) unlimited size. We want to sanitize the longs from Renode and reinterpret them to logical values in the range of -128..127. For naming, i8 would make sense here, but u64 is wrong. I don't know if this answers your question, but it's a necessary evil from working on a byte level in Python with Renode.

@@ -1180,55 +1166,50 @@ def conv2d(self, input_img, kernels, padding, dilation=(1,1), stride=(1,1), padd


# Apply each kernel to input_img
first_pass = True
Copy link
Contributor

Choose a reason for hiding this comment

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

unused?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed

@@ -1274,7 +1255,7 @@ def matsum_element_wise(self, A, B):
if not isinstance(A, list) and not isinstance(B, list):
return A + B

assert len(A) == len(B)
assert len(A) == len(B), "Assert failed! Different sized operands in matsum"
Copy link
Contributor

Choose a reason for hiding this comment

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

Assert style changed with respect to earlier code. Seemed to have parentheses before but not here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Style unified to have parentheses

@vilukissa68 vilukissa68 force-pushed the feat/dla-vp-overflow-fix branch from 2af43f2 to a5b71d7 Compare September 25, 2024 06:58
@vilukissa68 vilukissa68 merged commit 0ee2fb8 into soc-hub-fi:main Sep 25, 2024
6 checks passed
@vilukissa68 vilukissa68 deleted the feat/dla-vp-overflow-fix branch September 25, 2024 07:22
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