-
Notifications
You must be signed in to change notification settings - Fork 166
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
Added Support for Symbolic func
attribute
#2367
Conversation
Hence something like the following works now
|
The implementation is a surface level implementation right now, we can surely improve or optimize it here and there. |
Instead of:
Let's send a patch to SymEngine to add a function |
I think the |
Yeah returning a string was hackish here and not intended.
What are your thoughts here ? Which |
I think so we already have |
I've made the implementation much easier through the latest commit.
Is transformed into the following through the pass
The only question that remains is what should be the return type of the |
I can see the following ways forward:
Related issue: #2332 This requires a proper design, but for now let's get something going that unblocks us, and then we'll iteratively improve things. I suspect the fundamental issue here is that we are querying the type at runtime, so it's a runtime type. While in LPython so far all types are compile time. I like the approach 2. the most. You can think of all those ASR IntrinsicFunctions like Do you see any problem with this approach? |
You mean approach 2 (did you type 3 by mistake ?) where we implement |
I'll just write down my understanding here so that anyone can correct me if I haven't understood things correctly.
This makes me realize that we only need to focus on the query aspects of things here ( only having a bool output either
Hence we do not have to think about the return type of the func attribute right now (Am I correct ?) !
If my thinking is correct we should be able to map/transform |
Yes, I fixed it. I like approach 2 the most. |
Yes, what you wrote is correct. In the end, did you mean
I would use
I would use
I would use
I would use
I would use |
You meant to add in |
Yes, those |
There are several ways to tackle it, but right now we have not figured out the most cleanest way. To move forward, let's implement it like this:
The alternative implementation:
|
I've tried addressing the func attribute through this method in the latest commit. I think using an internal flag would be a suitable approach here. So now we can do something like the following
And for something that is yet to be implemented
|
The latest commit also adds some simple tests for the same in |
assert(z == x + y) | ||
assert(z1 == True) | ||
assert(z2 == False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to this, let's also add tests like this:
if z.func == Add:
assert True
else:
assert False
as well as:
assert z.func == Add
To ensure that the z.func == Add
idiom works in all the situations:
- assigning to a bool variable (already tested)
- in
if
- in
assert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should still be addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test assert z.func == Add
? I don't see it, unless I missed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remember this and add it in a subsequent pr
Otherwise this is good. |
I've addressed all changes and added relevant tests. I think this is ready. We just need to remember than we are currently hardcoding values (TypeId's) for symbolic classes like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this is fine. Do you want to merge as is, and send improvements in subsequent PRs?
Sure . I will be addressing the |
This Pr tries to add support for the func attribute. I've used a transform the following python program into this respective C code
So essentially we do the following
temp_str
,temp_int
variables and introduce the respective symbols in the symbol tabletemp_int
against integers and updatetemp_str
accordingly