Articles on Anutosh's Bloghttps://blogs.python-gsoc.orgUpdates on different articles published on Anutosh's BlogenSun, 13 Aug 2023 03:24:11 +0000Week 12https://blogs.python-gsoc.org/en/anutoshs-blog/week-12-2/<h3>What did I do this week?</h3> <p>During the twelfth and final week of my GSoC project, I focused on completing the remaining tasks for the symbolic ASR pass. This involved adding support for print statements without prior variable assignment, enabling chaining of operators for complex symbolic expressions, implementing <code>assert</code> statements using a new <code>visit_Assert</code> function, and ensuring the freeing of all basic variables through the <code>basic_new_stack</code> function. I also conducted comprehensive testing across different backends (llvm_sym, c_sym, and cpython_sym) to ensure the proper functionality of the symbolic integration tests. Additionally, I engaged in refactoring the symbolic ASR pass to minimize code duplication and enhance the overall structure. Lastly, I discussed potential future work with my mentors, addressing issues such as enabling the FAST flag for symbolic integration tests. As my GSoC journey concluded, I reflected on the challenges and accomplishments, expressing both gratitude and a sense of accomplishment for the past 12 weeks. For a detailed overview of my work during week 12 , you can also go through my personal blog <a href="https://anutosh491.github.io/2023/08/13/week_12.html">GSoC Week 12</a></p> <h3>What will I be doing the next week ?</h3> <p>I shal be working towards framing my final GSoC report for the final evaluation.</p> <h3>Did I get stuck somewhere ?</h3> <p>I did face some challenges while working on the task, but with the help of a fellow experienced contributor, Thirumalai Shaktivel, I was able to overcome them and make good progress.</p>anutosh.bhat.21@gmail.com (Anutosh)Sun, 13 Aug 2023 03:24:11 +0000https://blogs.python-gsoc.org/en/anutoshs-blog/week-12-2/Week 11https://blogs.python-gsoc.org/en/anutoshs-blog/week-11-5/<h3>What did I do this week?</h3> <p>For Week 11, I focused on completing the first part of the symbolic ASR pass, which involved supporting assignment and print statements for symbolic functions and operations. This part was successfully implemented, replicating the functionalities added earlier through the C backend.</p> <p>I worked on several Pull Requests before my midterm evaluations, such as <a href="https://github.com/lcompilers/lpython/pull/1846">#1846</a>, <a href="https://github.com/lcompilers/lpython/pull/1964">#1964</a>, <a href="https://github.com/lcompilers/lpython/pull/2077">#2077</a>, and <a href="https://github.com/lcompilers/lpython/pull/2094">#2094</a>. Now, the same functionalities are achieved through the symbolic pass. For a detailed overview of my work during week 11 , you can also go through my personal blog <a href="https://anutosh491.github.io/2023/08/06/week_11.html">GSoC Week 11</a></p> <h3>What will I be doing the next week ?</h3> <p>As I move into the final week of my GSoC project, I will focus on completing the work on<a href="https://github.com/lcompilers/lpython/pull/2255"> #2255</a> and addressing the mentioned cases. I will ensure that all symbolic tests pass through the symbolic pass and remove any relevant changes made in the C backend, as they will no longer be needed. Excited for what's coming in the final week!</p> <h3>Did I get stuck somewhere ?</h3> <p>I did face some challenges while working on the task, but with the help of a fellow experienced contributor, Thirumalai Shaktivel, I was able to overcome them and make good progress.</p>anutosh.bhat.21@gmail.com (Anutosh)Mon, 07 Aug 2023 03:29:20 +0000https://blogs.python-gsoc.org/en/anutoshs-blog/week-11-5/Week 10https://blogs.python-gsoc.org/en/anutoshs-blog/week-10-4/<h3>What did I do this week?</h3> <p>During Week 10, I worked on the symbolic ASR pass. I addressed the first three points of the tasks (as mentioned in my personal blog <a href="https://anutosh491.github.io/2023/07/29/week_10.html">GSoC Week 10</a>), which involved replacing symbolic variables with CPtr variables, introducing the <code>basic_new_stack</code> function, and changing the function body of <code>main0</code>.</p> <h3>What will I be doing the next week ?</h3> <p>In the next week, I plan to implement the functionality to handle assignment statements through the <code>visit_Assignment</code> function in the <code>replace_symbolic</code> pass. This will involve introducing the <code>basic_const_pi</code> function for the <code>SymbolicPi</code> intrinsic function.</p> <h3>Did I get stuck somewhere ?</h3> <p>I did face some challenges while working on the task, but with the help of a fellow experienced contributor, Thirumalai Shaktivel, I was able to overcome them and make good progress.</p>anutosh.bhat.21@gmail.com (Anutosh)Mon, 31 Jul 2023 18:47:15 +0000https://blogs.python-gsoc.org/en/anutoshs-blog/week-10-4/Week 9https://blogs.python-gsoc.org/en/anutoshs-blog/week-9-3/<h3>What did I do this week?</h3> <p>This week, I focused on extending symbolic support to the LLVM backend, successfully added tests for the <code>basic_new_stack</code> function, and began implementing the Symbolic ASR pass with valuable assistance from Thirumalai Shaktivel and Shaikh Ubaid. For more detailed information y'all can refer my personal blog <a href="https://anutosh491.github.io/2023/07/23/week_09.html">GSoC_week9</a></p> <h3>What will I be doing the next week ?</h3> <p>In the upcoming week, my plan is to complete the implementation of the Symbolic ASR pass, aiming for a robust and fully functional version that can effectively handle symbolic expressions across different backends.</p> <h3>Did I get stuck somewhere ?</h3> <p>Yes, I faced some challenges while framing the ASR pass as it's my first time doing so. However, with the guidance of Thirumalai Shaktivel and Shaikh Ubaid, I am making good progress towards completing the pass.</p>anutosh.bhat.21@gmail.com (Anutosh)Sun, 23 Jul 2023 06:47:24 +0000https://blogs.python-gsoc.org/en/anutoshs-blog/week-9-3/Week 8https://blogs.python-gsoc.org/en/anutoshs-blog/week-8-3/<h3>What did I do this week?</h3> <p>This week, I focused on framing a symbolic ASR pass to extend symbolic support from the C backend to other backends like LLVM. I collaborated with my mentors to understand key concepts and worked on transforming the original ASR to support C calls to SymEngine's C wrapper header file. For more detailed information y'all can refer my personal blog <a href="https://anutosh491.github.io/2023/07/16/week_08.html">GSoC_week8</a></p> <h3>What will I be doing the next week ?</h3> <p>Next week, my plan is to finalize the implementation of the ASR pass and ensure it works seamlessly across different backends. I aim to have a concrete implementation ready by the end of the week.</p> <h3>Did I get stuck somewhere ?</h3> <p>While working on the ASR pass, I faced some challenges in understanding certain concepts like <code>CallReplacerOnExpressionsVisitor</code> and <code>BaseExprReplacer</code>. However, with the guidance of my mentors, I was able to overcome these hurdles and make progress towards the completion of the pass.</p>anutosh.bhat.21@gmail.com (Anutosh)Mon, 17 Jul 2023 05:30:04 +0000https://blogs.python-gsoc.org/en/anutoshs-blog/week-8-3/Week 7https://blogs.python-gsoc.org/en/anutoshs-blog/week-7-3/<h3>What did I do this week?</h3> <p>This week, I focused on completing the first part of my GSoC project. I successfully added support for symbolic expansion, differentiation, and elementary functions in Lpython. I raised pull requests <a href="https://github.com/lcompilers/lpython/pull/2077">#2077</a> and <a href="https://github.com/lcompilers/lpython/pull/2094">#2094</a>, which got reviewed and merged. I also tested the functionality with sample programs and achieved the desired results.For more detailed information, y'all can visit my personal blog <a href="https://anutosh491.github.io/2023/07/09/week_07.html">GSoC Week 7</a></p> <h3>What will I be doing the next week ?</h3> <p>In the next week, I plan to discuss the new implementation plan with my mentors. We will work on framing the ASR pass, which will consolidate the symbolic support into one file and make it compatible with any backend, including C and LLVM. I am excited to dive into this new phase of the project and start implementing the required changes.</p> <h3>Did I get stuck somewhere ?</h3> <p>I didn't encounter any major roadblocks or difficulties this week. However, I am currently working on figuring out the implementation details of the ASR pass and making the necessary C calls to symengine's C wrapper header file. It is a challenging task, but I am confident that with some research and experimentation, I will overcome any obstacles along the way.</p>anutosh.bhat.21@gmail.com (Anutosh)Mon, 10 Jul 2023 03:14:01 +0000https://blogs.python-gsoc.org/en/anutoshs-blog/week-7-3/Week 6https://blogs.python-gsoc.org/en/anutoshs-blog/week-6-4/<h3>What did I do this week?</h3> <p>This week, I implemented a <strong>SymEngineQueue </strong>structure to handle the chaining of symbolic operators and executing print statements without assignment statements. I worked on a pull request that introduced the <strong>SymEngineQueue</strong> structure and got it reviewed and merged. A detailed description of my work can be found in my personal blog <a href="https://anutosh491.github.io/2023/07/02/week_06.html">Week 6</a></p> <p> </p> <h3>What will I be doing the next week ?</h3> <p>In the next week, my plans are to get the current pull request reviewed and merged. I also aim to introduce a couple of elementary functions like <strong>abs</strong> and <strong>sin</strong>. Additionally, I may start adding some support through the<strong> LLVM backend</strong>.</p> <h3>Did I get stuck somewhere ?</h3> <p>Fortunately, I did not encounter any significant challenges or roadblocks during the week. My progress was smooth, and I was able to accomplish the planned tasks without major difficulties</p>anutosh.bhat.21@gmail.com (Anutosh)Wed, 05 Jul 2023 16:09:15 +0000https://blogs.python-gsoc.org/en/anutoshs-blog/week-6-4/Week 5https://blogs.python-gsoc.org/en/anutoshs-blog/week-5-4/<h3>What did I do this week?<br> <br> This week, I successfully merged my first two GSoC pull requests within the first four days. I also introduced additional functionality, including symbolic binary operators and a casting function. As a result, I could solve programs involving symbolic expressions and identified potential issues with print statements and operator chaining. More about this can be found in my personal blog <a href="https://anutosh491.github.io/2023/06/25/week_05.html">here</a>.<br> <br> What will I be doing the next week ?</h3> <h3><br> Moving into the next week, my focus will be on ensuring the generation of correct C code for scenarios involving operator chaining. Additionally, I plan to implement elementary functions like abs and sin. My goal is to open a third pull request with these changes and work towards getting it merged.<br> <br> Did I get stuck somewhere ?</h3> <h3><br> During my progress, I encountered a challenge with achieving compatibility for intrinsic functions that have multiple arguments, such as binary operators. I am currently working on addressing this issue and plan to provide a more detailed explanation in the upcoming week.</h3>anutosh.bhat.21@gmail.com (Anutosh)Thu, 29 Jun 2023 16:25:01 +0000https://blogs.python-gsoc.org/en/anutoshs-blog/week-5-4/Week 4https://blogs.python-gsoc.org/en/anutoshs-blog/week-4-3/<h3>What did I do this week?</h3> <p>This week, I made significant progress in my project. I introduced the <strong><code>SymbolicAdd</code></strong> function as a symbolic binary operator and successfully integrated it with the ASR and the C backend. In addition, I added the <strong><code>pi</code></strong> constant, expanding the range of available symbolic constants. I demonstrated the usage of these features through an example and ensured it worked as an integration test. More about my work during this week can be found in my personal blog <a href="https://anutosh491.github.io/2023/06/18/week_04.html">GSoC: Blog 4</a></p> <p> </p> <h3>What will I be doing the next week ?</h3> <p>In the upcoming week, my plan is twofold. Firstly, I aim to finalize any minor tasks remaining on my first pull request and get it merged into the project. This includes addressing any feedback or making necessary adjustments. Secondly, I intend to open a second pull request, focusing on implementing the casting operation and introducing additional symbolic operators. Furthermore, I plan to incorporate a couple of elementary functions, such as <strong><code>abs</code></strong> and <strong><code>sin</code></strong>, expanding the capabilities of the symbolic computation framework.</p> <h3>Did I get stuck somewhere ?</h3> <p>Fortunately, I did not encounter any significant challenges or roadblocks during the week. My progress was smooth, and I was able to accomplish the planned tasks without major difficulties</p>anutosh.bhat.21@gmail.com (Anutosh)Sun, 18 Jun 2023 13:10:27 +0000https://blogs.python-gsoc.org/en/anutoshs-blog/week-4-3/Week 3https://blogs.python-gsoc.org/en/anutoshs-blog/week-3-4/<h3>What did I do this week?</h3> <p>In a nutshell, I revamped our approach by transitioning from the LLVM backend to the C backend. This change unlocked numerous benefits, including simplified code generation and improved compatibility with C-based tools and libraries. I would highly recommend going through my person blog for more detailed information as to how I generated code through the C backend . A link to it can be found here <a href="https://anutosh491.github.io/2023/06/12/week_03.html">GSoC: Blog 3</a>.<br>  </p> <h3>What will I be doing the next week ?</h3> <p>In the upcoming week, my focus will be on generating accurate C code for symbolic addition operations, introducing additional binary operators, and implementing casting functions for primitive data types.</p> <h3>Did I get stuck somewhere ?</h3> <p>During my journey, I faced a couple of challenges, particularly with handling assignments through SymEngine's C interface. However, after careful exploration and collaboration, I found effective solutions and made necessary adjustments to overcome these obstacles. More about this can be found in my personal blog attached above !</p>anutosh.bhat.21@gmail.com (Anutosh)Mon, 12 Jun 2023 05:15:16 +0000https://blogs.python-gsoc.org/en/anutoshs-blog/week-3-4/Week 2https://blogs.python-gsoc.org/en/anutoshs-blog/week-2-6/<h3>What did I do this week?</h3> <p>During the second week of GSoC, the focus was on adding support for symbolic expressions in the `visit_print` and `visit_assignment` functions. Initially, an attempt was made to implement this using the LLVM backend but encountered strict limitations. As a result, the decision was made to switch to the C backend, which offers advantages such as simpler code generation and compatibility with existing C-based tools. Progress was made in implementing the necessary functions and generating C code to handle symbolic expressions.More detailed information can be found on my person blog here <a href="https://anutosh491.github.io/2023/06/05/week_02.html">GSoC: Week 02</a></p> <h3>What will I be doing the next week ?</h3> <p>Tasks for the upcoming week include addressing details, introducing binary operators for symbolic expressions, and implementing casting functions.<br>  </p> <h3>Did I get stuck somewhere ?</h3> <p>My project does involve a lot of trial and error, hence I am bound to get stuck trying to figure the correct approach but there were no hard blockers as such and I was able to find workarounds wherever I got stuck .</p> <p> </p>anutosh.bhat.21@gmail.com (Anutosh)Mon, 05 Jun 2023 06:23:48 +0000https://blogs.python-gsoc.org/en/anutoshs-blog/week-2-6/Week 1https://blogs.python-gsoc.org/en/anutoshs-blog/week-1-4/<p><strong>As I had discussed with Ondřej, my goal for the first couple of weeks would be to get a basic assignment and print statement working for a`SymbolicExpression` for instance the `Symbol` class from SymPy. So I had to support something like the following</strong></p> <pre><code class="language-python">from lpython import S from sympy import Symbol def main0(): x: S = Symbol('x') print(x) main0()</code></pre> <p> </p> <p><strong>This task would comprise of the following few steps</strong></p> <p>  * Supporting imports from `SymPy` for `CPython`</p> <p>  * Introducing the `SymbolicExpression` ttype</p> <p>  * Introducing `SymbolicSymbol` as an intrinsic function</p> <p>  * Adding support in `visit_print` and `visit_assignment` to handle symbolic expressions</p> <p><br> <strong>I managed to raise a pull request <a href="https://github.com/lcompilers/lpython/pull/1846">1846</a> and address the first 3 steps and I am halfway through with the 4th step. Hence we currently have a decent Abstract Semantic Representation (ASR) of our program above. It goes as follows:</strong></p> <pre><code>[(= (Var 2 x) (IntrinsicFunction SymbolicSymbol [(StringConstant "x" (Character 1 1 () []) )] 0 (SymbolicExpression) () ) () ) (Print () [(Var 2 x)] () () )]</code></pre> <p><strong>Well as of now, I can't claim that I have cracked the solution for the 4th step. As discussed in my weekly meeting with Ondřej, we are still not fully sure as to how we could support the above program in the backend. We are still exploring the most probable and easily achievable approaches . While framing my GSoC proposal, we were more inclined towards framing a pass which would make function calls to `SymEngine's C interface`. But as we were brainstorming during our meet we realized some potential downsides to this approach and hence we tried framing a somewhat newer approach for the same, which goes as follows:</strong></p> <p>  * Skip implementing `instantiate_SymbolicSymbol` and the pass to replace the intrinsic function node.</p> <p>  * Take inspiration from how assignment statements work for the `Complex` ttype in LPython and try extending the `visit_assignment` function for symbolic expressions accordingly.</p> <p>  * Introduce `symengine_str` function similar to how `print_f` for handling print statements.</p> <p><strong>I am halway through this approach and I feel this would be the correct way to go. I will try to resolve these in the 2nd week of my coding period.Finally, I would like to point out some tasks which need to be addressed in Week 2 or the upcoming weeks</strong></p> <p>  * Finish `generate_SymbolicSymbol` function implementation (kept as TODO for now)</p> <p>  * Finish `SymbolicSymbol::verify_args` function implementation (kept as TODO for now)</p> <p>  * Finish `eval_SymbolicSymbol` function implementation (kept as TODO for now)</p> <p><strong>Thank You for going through the blog. I hope you like it. Stick around for what's next to come. Moving into Week 2!</strong></p>anutosh.bhat.21@gmail.com (Anutosh)Thu, 01 Jun 2023 03:38:33 +0000https://blogs.python-gsoc.org/en/anutoshs-blog/week-1-4/