Skip to content

Conversation

@mortbopet
Copy link
Contributor

@mortbopet mortbopet commented Sep 2, 2025

... when checking if a given object is valid for StructType serialization. E.g., bytes objects do not have a __dict__ attribute.

Also fixes bug in struct serialization, where an object's __dict__ array wasn't being considered (even though it is for is_valid). That could e.g. make serializing a dataclass to an ESI struct fail.

... when checking if a given object is valid for `StructType` serialization. E.g., `bytes` objects do not have a `__dict__` attribute.
@mortbopet mortbopet requested a review from teqdruid as a code owner September 2, 2025 09:26
Copy link
Contributor

@teqdruid teqdruid left a comment

Choose a reason for hiding this comment

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

Not strictly related to this PR: we've (I've) played a bit fast and loose with testing, especially the Python API. Now that we've got the ability to create Python types from Python (right?), we could create some pytests to test the type / value system without invoking PyCDE to create a system (manifest). This is even more important for Python APIs since they don't get compiled. I'm less worried about the C++ side as a result of this (and its functionality is significantly simpler) but we definitely need some mechanism to test that better also.


def serialize(self, obj) -> bytearray:
ret = bytearray()
if not isinstance(obj, dict):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is is_valid called before this? If not, it should be. Problem is that it should either be called at the top of the serialize call or be called here and not descend into the inner objects. Or is it better to require the user code to check and put it somewhere in the documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main place where is_valid is called is when writing to a port. Since it (as you mention) is somewhat critical that a given type is_valid when trying to serialize and object, that is_valid call should probably be moved to the serialization function.

@mortbopet
Copy link
Contributor Author

Not strictly related to this PR: we've (I've) played a bit fast and loose with testing, especially the Python API. Now that we've got the ability to create Python types from Python (right?), we could create some pytests to test the type / value system without invoking PyCDE to create a system (manifest). This is even more important for Python APIs since they don't get compiled. I'm less worried about the C++ side as a result of this (and its functionality is significantly simpler) but we definitely need some mechanism to test that better also.

Completely agree. But, before that, we should probably have some dummy backend, such that we can test the ESI runtime proper. I.e., what it'd really like to be able to do is to just open the ESIRuntime subdirectory, and not care at all about building the rest of CIRCT to test it.

@mortbopet mortbopet merged commit 93e43a4 into main Sep 3, 2025
8 checks passed
@mortbopet mortbopet deleted the dev/mpetersen/esi_struct_validity branch September 3, 2025 07:00
@teqdruid
Copy link
Contributor

teqdruid commented Sep 3, 2025

Not strictly related to this PR: we've (I've) played a bit fast and loose with testing, especially the Python API. Now that we've got the ability to create Python types from Python (right?), we could create some pytests to test the type / value system without invoking PyCDE to create a system (manifest). This is even more important for Python APIs since they don't get compiled. I'm less worried about the C++ side as a result of this (and its functionality is significantly simpler) but we definitely need some mechanism to test that better also.

Completely agree. But, before that, we should probably have some dummy backend, such that we can test the ESI runtime proper. I.e., what it'd really like to be able to do is to just open the ESIRuntime subdirectory, and not care at all about building the rest of CIRCT to test it.

We do have a dummy backend (trace) what we don't have is an easy way build an ESI system. The ESI runtime tests could pull down a PyCDE from a package on pypi...

@mortbopet
Copy link
Contributor Author

We do have a dummy backend (trace) what we don't have is an easy way build an ESI system. The ESI runtime tests could pull down a PyCDE from a package on pypi...

In my mind, a proper "dummy" backend also has APIs to dynamically construct the underlying accelerator (99% of the time, it's probably just loopback, but i can imagine an API of that dummy backend which takes an input type, output type, and a lambda, which defines the transformation in between). Then we take PyCDE/complexity out of the equation, and keep everything internral to the ESI runtime project.

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.

3 participants