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

Add support for printing ASTNode::NODE_CLASS #411

Closed
wants to merge 0 commits into from

Conversation

greenozon
Copy link
Contributor

This fixes the issue #408

@greenozon
Copy link
Contributor Author

it also helps to improve the output for the issue #395

as follows;

before

def GEGLU():
    '''GEGLU'''

...
GEGLU = (GEGLU, 'GEGLU', nn.Module)

after

class GEGLU(nn.Module):

Copy link
Owner

@zrax zrax left a comment

Choose a reason for hiding this comment

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

Please also add a test for this case.

ASTree.cpp Outdated
->func().cast<ASTFunction>()->code();
print_src(code, mod, pyc_output);
}
break;
Copy link
Owner

Choose a reason for hiding this comment

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

This looks like a duplicate of the code in NODE_STORE (starting on line 3146)... It would be good to also replace that block with a call to print_src() to avoid code duplication.

Copy link
Contributor Author

@greenozon greenozon Dec 8, 2023

Choose a reason for hiding this comment

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

Well, I wish there would be just 1 piece of code for both cases, but after some debugging it turned out that those are different a bit..
eg: in original case with NODE_STORE there are 2 objects, one is ASTName (in dest variable) that keeps the class name and other is the code itself (in src variable)
in this case the ASTName is absent, so I"m deducing the class name from the ASTClass object
Just added new commit for that missed printout of class name itself

  1. I tried to create a test case, but to be honest I'm not sure how to create a sample one... when I try to define a class at root level its .pyc jumps into old NODE_STORE case!
    thus I need some help here please

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