Articles on RobertoRosmaninho's Bloghttps://blogs.python-gsoc.orgUpdates on different articles published on RobertoRosmaninho's BlogenTue, 24 Aug 2021 18:12:05 +0000Final Reporthttps://blogs.python-gsoc.org/en/robertorosmaninhos-blog/final-report-2/This week I focused in prepare this document and get the last PR approved. Also, I tried to fix the 2 last Issues opened. <h1>GSOC Final Report</h1> <p>After ten weeks of hard work on the project "LLVM Back-end for the Tensor Algebra Compiler" for Google Summer of Code 2021 I was able to develop the following contributions:</p> <ul> <li>Support for branch and loop operations (IfThenElse, While, For)</li> <li>Support for binary and unary operations (Neg, Sub, Div, Rem, Min, Max, And, Or, BitOr, BitAnd)</li> <li>Support for comparison operators (LTE, GTE, LT, GT, EQ, NEQ)</li> <li>Support for other operations (Assign, Cast, Case, Indices property, Comment, BlankLine)</li> <li>Support for booleans</li> <li>Added new tests to assess the correctness of new operations</li> </ul> <p>These contributions allow the basic use of TACO with LLVM like arithmetic operations on sparse or dense tensors passed as command-line arguments with llvm flag or using the TACO C++ Library.</p> <p>The project resulted in 6 Pull Requests and 5 Issues. Five PRs were merged, and one was closed because its content was already been developed by Guilherme, my mentor, on another branch. 3 Issues are still open.</p> <p>The project can be separated into 3 phases:</p> <ul> <li>First impressions and branch update</li> <li>Implementation of Basic Operations</li> <li>Fix old implementation, test writing, and searching for bugs</li> </ul> <p>The first phase was developed in the two first weeks and resulted in the following PRs:</p> <ul> <li><a href="https://github.com/Quansight-Labs/taco/pull/1">Llvm-backend update with Master</a></li> <li><a href="https://github.com/Quansight-Labs/taco/pull/5">Update README.md</a></li> </ul> <p>The first phase was to update the <code>llvm-backend</code> branch that I used on the project with the new alterations on the main, and update the readme with instructions to use TACO with LLVM support using a conda environment.</p> <p>I opened an issue to inform that the LLVM IR generated by TACO lacks information of the target machine when compared with the IR generated by clang:</p> <ul> <li><a href="https://github.com/Quansight-Labs/taco/issues/6">Currently, the llvm module generated does not contains any Target Information, Function Attributes, or Named Metadata</a></li> </ul> <p>This issue was not resolved yet because it doesn't impact the program operation and IR generation.</p> <p>The second and main phase was developed from the third to the eighth week and resulted in the following PRs:</p> <ul> <li><a href="https://github.com/Quansight-Labs/taco/pull/8">Fix 'for' loop: reordering basic blocks of 'For'</a> (not merged)</li> <li><a href="https://github.com/Quansight-Labs/taco/pull/12">Add support for more operations</a></li> <li><a href="https://github.com/Quansight-Labs/taco/pull/16">Add new Operations</a></li> </ul> <p>The main implementation was developed during these weeks with the assistance of my mentor Guilherme Leobas. As mentioned before, the first PR wasn't merged because its content was already been implemented on <a href="https://github.com/Quansight-Labs/taco/pull/7">PR #7</a>. The issues that I opened and solved during these weeks were the following:</p> <ul> <li><a href="https://github.com/Quansight-Labs/taco/issues/11">Allocate op doesn't create malloc greater than 10000*sizeof(int64)</a></li> <li><a href="https://github.com/Quansight-Labs/taco/issues/15">TACO doesn't generate properly LLVM IR for float types</a></li> </ul> <p>The last two weeks of development was used to write new tests, find bugs on corner cases and format the code resulting in the following PRs:</p> <ul> <li><a href="https://github.com/Quansight-Labs/taco/pull/17">Add new tests for llvm-backend</a></li> </ul> <p>The tests were implemented on a separated folder called "llvm-examples" and on gTest, the framework used by taco to automate tests. The following Issues were opened due to bugs found on these tests:</p> <ul> <li><a href="https://github.com/Quansight-Labs/taco/issues/18">TACO doesn't generate an LLVM IR that produces the correct result when specifying just the non-zero values of a tensor</a></li> <li><a href="https://github.com/Quansight-Labs/taco/issues/19">Lack of support for Yield Operation</a></li> </ul> <p>These issues are the start point for future improvements on the project.</p> <p>This experience was excellent, I could learn more about TACO, LLVM, compilers, open-source cooperation, and development. I hope to be able to continue contributing to this project soon.</p>robertogrosmaninho@gmail.com (RobertoRosmaninho)Tue, 24 Aug 2021 18:12:05 +0000https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/final-report-2/Weekly check-in #10https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-10-14/<h2> What did I do this week? </h2> Focused in Yield Support! <h2> Did I get stuck anywhere? </h2> No. :)robertogrosmaninho@gmail.com (RobertoRosmaninho)Thu, 19 Aug 2021 00:14:06 +0000https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-10-14/Weekly check-in #9https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-9-20/<h2> What did I do this week? </h2> This past week, I focused on implementing new llvm tests for TACO's gTest suite. I opened a new PR (#17), which includes more than 15 new tests of dense and sparse expressions. A new bug was found during this implementation: the missing support for realloc expression under Allocate Op. I fixed this bug and all tests implemented are passing now. <h2> What is coming up? </h2> In the last week of GSOC, I will replicate some tests already in use on TACO's gTest framework to generate LLVM IR code and start the implementation of Yield Op. <h2> Did I get stuck anywhere? </h2> No. :)robertogrosmaninho@gmail.com (RobertoRosmaninho)Mon, 09 Aug 2021 14:08:44 +0000https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-9-20/Weekly check-in #9https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-9-18/<h2> What did I do this week? </h2> This past week I only contribute to PR #14 and study the gTest framework to implement new llvm tests for taco CI. Also, a new bug was found: The iterate function used by pack() needs the implementation of Yield Op, which lacks support yet. <h2> What is coming up? </h2> This week I'll focus on implementing new tests on the TACO's gTest suite and study the Yield Op behavior. <h2> Did I get stuck anywhere? </h2> No. :)robertogrosmaninho@gmail.com (RobertoRosmaninho)Wed, 04 Aug 2021 22:30:17 +0000https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-9-18/Weekly check-in #8https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-8-13/<h2> What did I do this week? </h2> This past week I focused on implementing the Allocate Op, which I discovered to be the cause of issues #9 and #11. Mainly, I'm working to store on the original struct the tensor values and indices used on a function. <h2> What is coming up?</h2> This week, I'll focus on finishing this implementation and contribute to PR #14. This PR implements the Allocate OP and enables llvm tests to continuous integration with GitHub Actions. <h2> Did I get stuck anywhere?</h2> Yes, I got stuck in understanding the behavior of Allocate Op, but my mentor was able to help me with this issue.robertogrosmaninho@gmail.com (RobertoRosmaninho)Wed, 28 Jul 2021 19:34:18 +0000https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-8-13/Weekly check-in #7https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-7-19/<h2>What did I do this week?</h2> This week I focused on preparing the PR #12 to be merged into the llvm-backend branch from Quansight-Labs, and finally, it was accepted today! Mainly, I fixed and refactored some pieces of code this week according to my mentor's request, who has been very helpful and attentive! <h2>What is coming up?</h2> Since many operations already had been implemented, this week, I will focus on implementing the Allocate Op, which I already tried a few weeks ago without success. <h2>Did I get stuck anywhere?</h2> No!robertogrosmaninho@gmail.com (RobertoRosmaninho)Tue, 20 Jul 2021 01:58:10 +0000https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-7-19/Weekly check-in #6https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-6-19/<h2>What did I do this week?</h2> This week I focused on creating new tests with sparse and dense tensors. At first, I was hoping to have an opportunity to build and test the implementation of Switch, Case, and Call operations. Instead of implement support for these operations, I had to fix bugs in many others like OR, AND, FOR, IFTHENELSE, NEQ, EQ, LT, GT, etc. I just implemented the support for Cast and Case - to nested IfThenElse. <h2>What is coming up?</h2> I'll prepare a PR to be merged into the llvm-backend branch from Quansight-Labs to finish the first evaluation! <h2>Did I get stuck anywhere?</h2> I couldn't create the support that I was looking for, but I had the opportunity to improve my implementation anyway!robertogrosmaninho@gmail.com (RobertoRosmaninho)Thu, 15 Jul 2021 00:05:34 +0000https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-6-19/Weekly check-in #5https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-5-16/<h2>What did I do this week?</h2> This week I focused on implementing comparison and logic operators like BitAnd, BitOr, And, Or, Eq, Neq, GT, LT, GTE, and LTE. These features were previously set to be implemented at weeks #6 and #7, but it was necessary right now due to its use in conditional operations. <h2>What is coming up?</h2> The next week I'll continue the implementation of conditional branches with Switch Case. Also, I'll implement the support for the Call Function operation. <h2>Did I get stuck anywhere?</h2> Yes! As a consequence of the operation that I'm using to test the support for IfThenElse, I got stuck on Allocate and Assign implementation.robertogrosmaninho@gmail.com (RobertoRosmaninho)Tue, 06 Jul 2021 03:39:57 +0000https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-5-16/Weekly check-in #4https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-4-15/<h2>What did I do this week?</h2> This week I focused on implementing the IfThenElse support. To do it, I had to use the first test, "A(i) = B(i)", but this time with Sparse tensors. As a consequence of this implementation, I had to build support for Indices Property. <h2>What is coming up?</h2> The next week I'll implement some binary operations and comparison operators. <h2>Did I get stuck anywhere?</h2> Yes, I had some difficulty implementing Indices properties, but I quickly solved it with the help of my mentor Guilherme.robertogrosmaninho@gmail.com (RobertoRosmaninho)Tue, 29 Jun 2021 03:41:16 +0000https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-4-15/Weekly check-in #3https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-3-20/<h2> What did I do this week?</h2> This week I focused on testing compiler and run simple programs using the LLVM backend already implemented. I had to Generate the LLVM IR, compile it to assembly, and then use this code in a C program, where I could finally test the implementation. When I executed this test, I realize that the basic blocks of the 'for' loop didn't generate correctly. A second problem emerges with Guilherme's help: a bitwise instruction was missing on a tensor declaration producing errors on assignments. After fixing these bugs a PR was sent by Guilherme and the simple example "A(i) = B(i)" was finally compiling and executing correctly. For now, the "for" loop the way it should. <h2>What is coming up?</h2> This week I'll test some complex examples and investigate if there is any problem with the translation of conditional instructions to LLVM IR. <h2>Did I get stuck anywhere?</h2> Yes, I had some issues executing the code, but mainly my problem was to find what was wrong in the tensor assignment, but these doubts were solved with the precious help of my mentor.robertogrosmaninho@gmail.com (RobertoRosmaninho)Tue, 22 Jun 2021 02:20:01 +0000https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-3-20/Weekly check-in #2https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-2-16/<h2> What did I do this week? </h2> The first few days, I tried to compile simple programs to understand how the LLVM module is generated and after a Google Meet with Guilherme Leobas, some things became clearer and I could finally do this without any further problems. I submitted a PR adding some new build information on TACO`s README.md to help new users and realized that many pieces of LLVM IR are not being generated yet by TACO's LLVM Backend, so I opened an issue on GitHub with the details of this problem and already started to work to fix it. The first part of these problems seems to be related to the target machine since the "Target Triple" and the "Target DataLayout" are missing. Although these problems seems more difficult than I thought, I hope to fix them soon. <h2> What is coming up? </h2> This second week, I'll try to complete the LLVM IR's missing parts, review the code generated by "for" and "while" and fix any possible errors on their implementations. <h2> Did I get stuck anywhere? </h2> Yes! At first, I got stuck in compile simple programs and generated their LLVM IR. Then I got stuck in fixing the missing parts of LLVM that I discussed above.robertogrosmaninho@gmail.com (RobertoRosmaninho)Thu, 17 Jun 2021 12:50:37 +0000https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-2-16/Weekly Check-in #1https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-1-10/Hello everyone! My name is Roberto Rosmaninho, and I'm a third-year undergraduate student at Universidade Federal de Minas Gerais in Brazil, where my major is in Computer Science. I'm glad to participate in Google Summer of Code as a contributor for PyData/Sparse under the Python Software Foundation. I'll complete the implementation of the LLVM Back-end for The Tensor Algebra Compiler (TACO). So far, I only have discussed the design implementation of BinaryOps, new build instructions for the README, and submit a Pull Request to update the branch that already contains the beginning of the Back-end's code. This week I'll study and improve, if necessary, the implementation of the LLVM Module, Function, Block, and Scope! All the discussions are being public on Gitter, so anyone interested in more details can follow my progress from there! Thanks for the interest, and I see you here next week! Best regards, Roberto Rosmaninhorobertogrosmaninho@gmail.com (RobertoRosmaninho)Tue, 08 Jun 2021 02:28:05 +0000https://blogs.python-gsoc.org/en/robertorosmaninhos-blog/weekly-check-in-1-10/