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

New Feature: Halide Program IR Visualizer #7056

Merged
merged 214 commits into from
Jan 31, 2023

Conversation

darya-ver
Copy link
Contributor

New Feature: Halide Program IR Visualizer

This PR is committing a new feature that generates an HTML page, with extension .stmt.viz.html, containing a visualization of Halide's IR. Here is an example of what the HTML page looks like:

Screen Shot 2022-09-23 at 11 29 43 AM

You can also see the actual html page here: https://darya-ver.github.io/files/project_files/visualize_halide_example_blur3x3.html.


File Changes

This PR is changing the following existing files:

  • Makefile: added the new files into SOURCE_FILES and HEADER_FILES.

  • src/CodeGen_LLVM.h // src/CodeGen_LLVM.cpp: added logic in CodeGen_LLVM::visit(const ProducerConsumer *op) and CodeGen_LLVM::visit(const For *op) to add unique identifiers to the markers in the generated LLVM code to more easily map the Halide IR code to the LLVM code.

  • src/Generator.cpp: added logic for -e stmt_viz flag to generate the HTML page. Also added assembly flag if stmt_viz flag is present so that the assembly code is also generated.

  • src/Module.h // src/Module.cpp: added new logic to call Internal::print_to_viz() if the -e stmt_viz flag is present.

This PR is adding the following new files:

  • src/StmtViz.h // src/StmtViz.cpp: this is the main file that calls all other files. It contains the logic to generate the HTML page, and defines in the print_to_viz() function that is called from src/Module.cpp.

  • src/FindStmtCost.h // src/FindStmtCost.cpp: added a new file that contains the logic to find the cost of a Halide statement. This is used to determine the color of the nodes in the visualization.

  • src/GetAssemblyInfoViz.h // src/GetAssemblyInfoViz.cpp: added a new file that contains the logic to copy over the contents of the .s assembly file into a div in the HTML page, and finds the mapping of Halide IR to LLVM code.

  • src/GetStmtHierarchy.h // src/GetStmtHierarchy.cpp: added a new file that contains the logic to generate the statement hierarchy of the nodes in the visualization.

  • src/IRVisualization.h // src/IRVisualization.cpp: added a new file that contains the logic to generate the main visualization in the middle column.


How to Navigate Webpage

Looking at the screenshot above, if you click the information button at the top right of the screen, you will see the following popup, which has information about what each column represents and what features exist within them.

Screen Shot 2022-09-23 at 1 51 06 PM


How to Generate HTML File

To use this new feature, your code needs to be a Generator. Once you compile the generator, run it with the -e stmt_viz flag. This will generate an HTML page in the directory that you've specified in the -o flag, with extension .stmt.viz.html.

For example, if you've compiled a generator called my_generator and you want to generate the HTML page in the bin/ directory, you would run the following command:

./my_generator -e stmt_viz -o bin [rest of the flags]

where [rest of flags] are any another other flags that you need to add to correctly run the generator (like -g, -f, target, etc).


TODO before merging into main

  • Merge the stmt_viz and stmt_html flags into 1 so that we get rid of original IR visualization.

darya-ver and others added 30 commits June 7, 2022 14:46
@steven-johnson steven-johnson requested review from halidebuildbots and removed request for halidebuildbots October 4, 2022 21:48
@steven-johnson steven-johnson added skip_buildbots Synonym for buildbot_test_nothing and removed skip_buildbots Synonym for buildbot_test_nothing labels Oct 4, 2022
@steven-johnson
Copy link
Contributor

This is requesting to merge from an external fork into a local branch, so I don't think we can get the buildbots to run on this correctly. Ideally we should convert this into an 'ordinary' PR to merge it into Halide main branch, but I'll leave that to the original author to deal with lest I mess something up. In the meantime, I've made a sub-branch of this (with no additional changes) in #7062 to get the buildbots to run.

@slomp
Copy link
Contributor

slomp commented Oct 5, 2022

This is requesting to merge from an external fork into a local branch, so I don't think we can get the buildbots to run on this correctly. Ideally we should convert this into an 'ordinary' PR to merge it into Halide main branch, but I'll leave that to the original author to deal with lest I mess something up. In the meantime, I've made a sub-branch of this (with no additional changes) in #7062 to get the buildbots to run.

Yup, the idea is to merge from a fork branch (Darya's own StmtCost feature branch) to the true Halide repo, but in a non-main branch (darya-ver/ir-viz). Once it's there and we address the first batch of reviews, we'll merge, and then create a PR from darya-ver/ir-viz to main, where we can get more comprehensive tests.

@slomp
Copy link
Contributor

slomp commented Oct 5, 2022

@steven-johnson And thanks for running clang-tidy too :-)

src/FindStmtCost.cpp Outdated Show resolved Hide resolved
- If `stmt_viz` flag is used without the `assembly` flag, the compiler throws an error.
- GetAssemblyInfoViz.cpp: replace regex with replace_all
- GetSttmtHierarchy.cpp: Bug fix (line 721). Use raw strings for large literals
- Restricted scope of default statement values
- Added enum type for StmtCostModel. A single cost model config value is specified, instead of multiple booleans.
Copy link
Contributor

@maaz139 maaz139 left a comment

Choose a reason for hiding this comment

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

Addressed most of the comments from other reviews and re-ran the clang-tidy script.

I plan to do some more code revisions but I'll defer those for the next PR (into Halide main).

@abadams
Copy link
Member

abadams commented Oct 28, 2022

Please don't merge yet. I want to do a pass.

@abadams
Copy link
Member

abadams commented Oct 28, 2022

Two big things:

There appear to be a bunch of unrelated wasm and python float16 changes in here.

The header files are missing file-level documentation and doxygen-style non-trivial class and method comments throughout.

@abadams
Copy link
Member

abadams commented Oct 28, 2022

My other big concern is that I don't think computing and showing approximate costs is useful enough to justify the maintenance cost of the big chunk of code that computes it. I can't think of a case where I would find it helpful.

@maaz139
Copy link
Contributor

maaz139 commented Oct 28, 2022

There appear to be a bunch of unrelated wasm and python float16 changes in here.

I traced the changes in wasm and I believe they were pulled into Darya's fork from Halide main. The ir-viz branch that this PR pushes the new code to probably needs to be updated.

The header files are missing file-level documentation and doxygen-style non-trivial class and method comments throughout.

Does it make sense to merge Darya's code into the "ir-viz" branch first and then continue to improve code/documentation?

@abadams
Copy link
Member

abadams commented Oct 28, 2022

Oh I mistakenly thought this was a PR into main. Yeah we can merge then continue to work on it.

@maaz139 maaz139 merged commit 27fcd0a into halide:darya-ver/ir-viz Jan 31, 2023
maaz139 added a commit that referenced this pull request Apr 12, 2023
* placeholder for IR visualization work from Darya Verzhbinsky

* placeholder for IR visualization work from Darya Verzhbinsky

* New Feature: Halide Program IR Visualizer (#7056)

Thanks for the feedback everyone! I will merge this into the ir-viz branch and work on it to get it ready for a PR into main.

* initial commit

* updates

* added curr_loop_depth and changed throws for assert(false)

* split into header/cpp file and added test file

* adding changes to move to adobe laptop

* added git ignore to ignore .vscode

* attemping to get add_custom_lowering_pass() to work, not working yet

* Can now compile to stmt_viz files

* moved files into main src folder and added them to Makefile

* fixed lesson_01_basics.cpp

* pushed updates - very messy code

* got side colors working and hiararchy tree. ready for code cleanup

* cleaned up code. ready for split into .h/.cpp files

* quick comment change

* switched everything into .h/.cpp files

* added CostPreProcessor class and removed def of mutate

* removed definitions of mutate

* added data movement costs and bar at the top

* changed location of tooltip so it doesn't overflow left

* updated cost function for laod/store based on vector size and type

* updated colors of hiararchy tree

* logic for deciding context of variables (messy)

* cleaned up code. waiting for marcos

* added context coloring. cleaned up code a bit

* collapse/expand on hiararchy working

* got depth expansion working for hiararchy

* cleaned up code

* cleaned up code and renamed some funcs/vars

* fixed let hierarchy code and added down arrow to button

* dependency graph stuff (still massive and busy)

* Minor fixes -- please review

* prod/cons built with if stmts and for loops

* exit early if running on a module w/ >1 func

* added var dependency button to mail html

* fixed `add` benchmark and made error printing better

* changed `m_assert` to `internal_error`

* cleanedup dependency graph

* added error for non concrete bounds in prodcons hier

* made arrows change btwn up/down depending on sit.

* fixed text for ConsProd tables to have strings

* added logic for non-set bounds for for loop

* added TODO

* added syntax highlight to strings and ints

* added dotdotdot logic for collapsed children

* fixed small bug where 2nd tree wasn't starting correctly

* changed colors of ... nodes based on parent color

* added if flowchart

* added bools for printing different HTML parts of code

* added different background colors per object

* cleaned up borders of objects

* fixed prodCons spacing and started allocate logic

* removed border for ifthenelse table

* implemented anchoring for prodcons tables

* fixed empty if-stmts

* open and close anchor are now right after one another

* added filename logic for anchors and add blocks for func args

* pass in FindStmtCost instead of reruning traversal

* fixed comment

* heatmap for prodConsHierarchy

* fixed consume values (i think) and changed block colors

* fixed allocate "!is_const_one(op->condition" error

* fixed StmtSizes::visit(const For *op) (variables were Add)

* removed nested-ifs logic (edge case we don't have to worry about)

* changed table headers to only show loop interations and no bubbling up

* get unique values for loads with ramp<int, int, int> only

* fixed !is_const_one(op->condition) in Allocate

* changed allocate table to Dim-1, Dim-2, etc

* (1) store: changed cost (2) load: added global/local (3) allocate: vized memtype (4) prodConsTable: changed to read/write

* BOOTSTAP! added navigation pannel at top

* line numbers!!! and removed tooltip (for now)

* changed style of info buttons

* adjusted and added icons for see-code and info buttons

* removed a comment

* condensed cost color classes

* fixed ifthenelse line numbers

* fixed if if-else anchor names

* changed prodCons from table to div

* adding cost colors for prodConsViz to the left side of div

* made long conditions "..." in ProdConsViz

* adding spacing for prodCons start viz and dependency graph viz

* tooltip!!!! (still a little ugly, but functioning!!)

* removed tooltip arrow and changed background to white

* removed arrow for tooltip and added if-stmt condition tooltip

* added more tooltips to prodCons

* getStmtHierarchy popup implemented :) !!

* moved css var definitions to respective files

* added bubble_up() and multiple modules

* converted some stringstream to string + reordered module functions in viz

* added getStmtHierarchy js working for expanding/collapsing

* calculate color ranges once and not every time

* should be added to previous commit

* changed everything from IRMutator -> IRVisitor

* side by side view on main page

* added expand code / viz buttons functionality

* attempting to switch GetStmtHierarchy to 1 tree with colors on side

* should revert this change later, but need to for now (merging with main)

* added Reinterpret + fixed double graph in StmtHierarchy

* removed omg!!!! for reinterpret

* changed border colors of stmtHierarchy + removed print statements

* visualized assert + added colors to assert + made all info buttons next to colors

* added resize bar

* removed navigation code (sticking to 2col layout)

* changed colors spans to buttons (removed segfault???)

* visualize entire LetStmt and cleaned up GetStmtHierarchy.cpp

* added more info in info-buttons

* added hover to side colors in stmthierarchy

* made collapse buttons resizeBar icons + put see_code_button top right of div

* (1) added code to viz buttons (2) display all if-stmts, even if they are empty (3) fixed store highlight cost span

* added scrollTo for function buttons within modules

* changed info-button style

* (1) added hover over for colors in stmtHierarchy (2) removed =default constructor/destructor (3) changed getStmtHierarchy to string html instead of stringstream

* made sure updated StmtToHtml code was in StmtToViz code

* small style changes

* added see code/viz buttons for module functions

* (1) loop size -> loop span (2) made function names  big in viz (3) load types in name

* removed inline style tags

* added VectorReduce code for stmt hierarchy

* removed scopeName hack to fix previous scope error (hope it's not happening anymore)

* fixed scrollTo if code is hidden

* removed commented out includes

* changed costs to inclusive vs exclusive (still might be a bit broken)

* removed print statements

* fixed loop_depth = 0 error

* (1) tooltips include inclusive and exclusive sizes (2) moved tooltip HTML to FindStmtCost.cpp

* reworked tooltip style

* (1) made getStmtHierarchy *exclusive* costs (2) viuslizing costs for IfThenElse blocks

* visualize For and ProducerConsumer blocks

* got collapse of code to show cumulative color cost

* removed context span button

* removed bubble up code and associated logic (now only read/write for loads and stores)

* change some variables to read/write instead of prod/cons

* fixed range bug

* dense/strided vector load

* removed inline TODO comments

* added loop var for for loops

* made loading MUCHHHH faster!!!!

* (1) fixed function box width in viz (2) fixed collapse/expand button for functions in code

* compile assembly if stmt_viz flag is given

* starting assembly stuff

* got assembly code button working (button is still ugly)

* (1) made assembly button prettier (2) started information bar at top (need to fill in content of info popup)

* added content to information bar button popup

* (1) fixed if statement costs (2) added percentages to cost tables instead of values

* removed output_file_name from ProducerConsumerHierarchy.h and related code in StmtToViz.cpp

* fixed IfThenElse cost if there are nested ifs

* removed dependency graph logic and files

* made tooltip table input vector of pairs so that we can specify order

* made tooltip table input vector of pairs so that we can specify order

* added collapse/expand to viz on right

* (1) collapseCode works now (2) search works in assembly tab

* changed codemirror to ARM assembly highlighting

* start of refactor: commenting and cleanup

* fixed bug!!!!! i think. i hope !!!

* removed Stmt function versions (never run this code on Stmt input, only module)

* changed ProdCons stuff to IRViz

* removed print line for strided vectors (seems to be working now)

* fixed bug!!!!!! changed things back to stringstream, because that wasn't the issue

* have helper functions return strings isntead of being void

* end of refactor (for now) - changed variables from camelCase to snake_case

* fix ... error for collapsing nodes

* fixed div issue + tooltips not being correct location

* added error message for multiple modulse (doesn't currently support)

* fixed spacing for boxBody divs

* removed submodules logic because it's not supported right now

* made assembly marker generation more accurate (added counters to have marker names be unique)

* got 3 columns resizing mostly working (just a little glitchy, good enough for now)

* got assembly button to populate assembly, kind of working

* added assemblyInfoViz.h to makefile

* fixed resize bars for 3 different visualizations

* fixed linewrapping issue with codemirror

* updated spacing for IRVisualization buttons in header

* (1) fixed functionBox button sizing (2) dense vector load -> [Dense, Vector] load

* fixed informationBar spacing

* updated InformationBar content

* removed current_loop_depth from consideration of cost

* changed cost table tooltip: inclusive: show %, exclusive: show raw cost

* simplified cost model

* (1) updated InformationBar w/ info for assembly (2) added assembly by default to third col

* added logic to collapseVizAssembly if curson passes resizeBar

* moved all color range + tooltip logic into IRVisualization

* fixed get_combined_color_range() error

* reordered js/css strings

* changed format and slighly changed content of cost tooltips

* refactor: .h and .cpp files have same order

* refactor: added comments

* refactor: updated internal_error messages

* fixed small import / #ifndef typo

* updated get_loop_iterator to include more binary ops for extent

* reverting some changes I made to get ready for PR

* adding CMake build

* refactoring namespace scoping

* refactoring "endl"

* refactoring header guards and includes

* const vector reference

* ostringstream all the things!

* having a symbol for "canIgnoreVariableName"

* string -> char*, with raw string literal

* internal_error -> internal_assert()

* clang-format

* if-else chain to switch-case block

* Upgrade wabt to 1.0.30 (#7058)

* Add support for float16 buffer in python extension (#7060)

* run clang-tidy and clang-format

* run clang-tidy & clang-format

* run clang-tidy and clang-format, again

* run clang-tidy and clang-format, Phaze III

* Minor PR Revision

- If `stmt_viz` flag is used without the `assembly` flag, the compiler throws an error.
- GetAssemblyInfoViz.cpp: replace regex with replace_all
- GetSttmtHierarchy.cpp: Bug fix (line 721). Use raw strings for large literals
- Restricted scope of default statement values
- Added enum type for StmtCostModel. A single cost model config value is specified, instead of multiple booleans.

* reminder for later

---------

Co-authored-by: Darya Verzhbinsky <dverzhbinsky@adobe.com>
Co-authored-by: Maaz Ahmad <maaz.c10@gmail.com>
Co-authored-by: Marcos Slomp <slomp@adobe.com>
Co-authored-by: Steven Johnson <srj@google.com>
Co-authored-by: Steve Suzuki <shinsuke.suzuki@arm.com>
Co-authored-by: Marcos Slomp <mslomp@gmail.com>

* Refactor 1/N: Moved all static html, css and js code outside of the cpp files to reduce noise

* Refactor 2/N: Broke down StmtToViz Class to two simpler classes

- Disabled legacy StmtToViz implementation
- Introduced three new classes instead:
   - IRVisualizer: generates the output page (WIP)
   - HTMLCodePrinter: prints IR code in HTML (Implementation complete)
   - HTMLVisualizationPrinter: visualizes IR code in HTML (WIP)

* Refactor 3/N: Minor stylesheet and javascript improvements

Thorough refactor of css and js pending

* Fixed resize bars not working properly

* Refactoring Viz tab (WIP)

* Refactored 4/N: Visualization tab complete

Refactored all visualization logic into a single HTMLVisualizationPrinter class

* Refactor 5/N: Javascript and css cleanup

- Visual improvements
- Deleted unnecessary code
- Refactored most of js code

* Refactor 6/N: JS and CSS refactor complete

- Deleted unused code
- Simplified remaining code

* Refactor 7/N: Added assembly support

- Added assembly tab functionality
- Jump to assembly buttons added
- Tooltips added for all buttons

* Refactor 8/N: Deleted info bar

* Refactor 9/N: Deleting code

These classes were simplified and refactored into the new StmtToViz file.

* Remove stale files from build

* Refactor 10/N: Cost model simplified and re-activated

- Cost model is much simpler now
- Re-integrated cost model into code tab
- Re-integration to viz tab pending

* Delete stale cost model code

* Refactor 11/N: Reintegrate cost model into visualization

* Minor fixes

* Update CMakeLists.txt

* Deleting more stale files

* Improved documentation for new code in Codegen_LLVM

* Static HTML, CSS and JS is now stored as large strings

Avoids build shenanigans.

* Fix: Build error for unused variable

* Deleting dead code

* Stmt visualizer should not run on submodules

* Ran clang-format on the PR

* Ran clang-tidy on the PR

* Move boilerplate JS/CSS code into template files

* CMake Build fix: Typo

* Minor bug fix

* Renamed variable to avoid any keyword conflict

* Style fixes

- Removed underscore-prefix on member variables
- Fixed typos in documentation
- Fixed indentation in Makefile

* Replacing `internal_assert(false) << ...` with `internal_error << ...`

* Style improvement: std prefix consistency

* Minor fix: variable had greater scope than necessary

* Renamed `datamovement` to `data_movement` for readability

* Constructor fixes for HTMLCodePrinter, HTMLVizualizationPrinter and IRVisualizer

- Made single parameter constructors explicit
- Made HTMLCodePrinter and HTMLVizualizationPrinter non-moveable and non-copyable

* Typo

* Clang-formatting

* Undo accidental Makefile change

* Improved comments

- Fix type in fn name `compute_all_costs`
- Comments describing class are now in format consistent with rest of the codebase
- Improved comment describing `print_cuda_gpu_source_kernels`

* Replaced spaces with underscores in regex markers printed in assembly

* Minor bug fix for Halide IR Visualizer

Synchronization button from Viz to Code was not working for tail `else` cases.

* Clang format fix

* Assign deterministic node IDs for reproducability

* clang-format and clang-tidy

* Update StmtToViz.cpp

* Minor formatting fix

* Bug fix: ProducerConsumer IDs were not generated correctly

---------

Co-authored-by: Marcos Slomp <slomp@adobe.com>
Co-authored-by: darya-ver <darya99@gmail.com>
Co-authored-by: Darya Verzhbinsky <dverzhbinsky@adobe.com>
Co-authored-by: Steven Johnson <srj@google.com>
Co-authored-by: Steve Suzuki <shinsuke.suzuki@arm.com>
Co-authored-by: Marcos Slomp <mslomp@gmail.com>
ardier pushed a commit to ardier/Halide-mutation that referenced this pull request Mar 3, 2024
* placeholder for IR visualization work from Darya Verzhbinsky

* placeholder for IR visualization work from Darya Verzhbinsky

* New Feature: Halide Program IR Visualizer (halide#7056)

Thanks for the feedback everyone! I will merge this into the ir-viz branch and work on it to get it ready for a PR into main.

* initial commit

* updates

* added curr_loop_depth and changed throws for assert(false)

* split into header/cpp file and added test file

* adding changes to move to adobe laptop

* added git ignore to ignore .vscode

* attemping to get add_custom_lowering_pass() to work, not working yet

* Can now compile to stmt_viz files

* moved files into main src folder and added them to Makefile

* fixed lesson_01_basics.cpp

* pushed updates - very messy code

* got side colors working and hiararchy tree. ready for code cleanup

* cleaned up code. ready for split into .h/.cpp files

* quick comment change

* switched everything into .h/.cpp files

* added CostPreProcessor class and removed def of mutate

* removed definitions of mutate

* added data movement costs and bar at the top

* changed location of tooltip so it doesn't overflow left

* updated cost function for laod/store based on vector size and type

* updated colors of hiararchy tree

* logic for deciding context of variables (messy)

* cleaned up code. waiting for marcos

* added context coloring. cleaned up code a bit

* collapse/expand on hiararchy working

* got depth expansion working for hiararchy

* cleaned up code

* cleaned up code and renamed some funcs/vars

* fixed let hierarchy code and added down arrow to button

* dependency graph stuff (still massive and busy)

* Minor fixes -- please review

* prod/cons built with if stmts and for loops

* exit early if running on a module w/ >1 func

* added var dependency button to mail html

* fixed `add` benchmark and made error printing better

* changed `m_assert` to `internal_error`

* cleanedup dependency graph

* added error for non concrete bounds in prodcons hier

* made arrows change btwn up/down depending on sit.

* fixed text for ConsProd tables to have strings

* added logic for non-set bounds for for loop

* added TODO

* added syntax highlight to strings and ints

* added dotdotdot logic for collapsed children

* fixed small bug where 2nd tree wasn't starting correctly

* changed colors of ... nodes based on parent color

* added if flowchart

* added bools for printing different HTML parts of code

* added different background colors per object

* cleaned up borders of objects

* fixed prodCons spacing and started allocate logic

* removed border for ifthenelse table

* implemented anchoring for prodcons tables

* fixed empty if-stmts

* open and close anchor are now right after one another

* added filename logic for anchors and add blocks for func args

* pass in FindStmtCost instead of reruning traversal

* fixed comment

* heatmap for prodConsHierarchy

* fixed consume values (i think) and changed block colors

* fixed allocate "!is_const_one(op->condition" error

* fixed StmtSizes::visit(const For *op) (variables were Add)

* removed nested-ifs logic (edge case we don't have to worry about)

* changed table headers to only show loop interations and no bubbling up

* get unique values for loads with ramp<int, int, int> only

* fixed !is_const_one(op->condition) in Allocate

* changed allocate table to Dim-1, Dim-2, etc

* (1) store: changed cost (2) load: added global/local (3) allocate: vized memtype (4) prodConsTable: changed to read/write

* BOOTSTAP! added navigation pannel at top

* line numbers!!! and removed tooltip (for now)

* changed style of info buttons

* adjusted and added icons for see-code and info buttons

* removed a comment

* condensed cost color classes

* fixed ifthenelse line numbers

* fixed if if-else anchor names

* changed prodCons from table to div

* adding cost colors for prodConsViz to the left side of div

* made long conditions "..." in ProdConsViz

* adding spacing for prodCons start viz and dependency graph viz

* tooltip!!!! (still a little ugly, but functioning!!)

* removed tooltip arrow and changed background to white

* removed arrow for tooltip and added if-stmt condition tooltip

* added more tooltips to prodCons

* getStmtHierarchy popup implemented :) !!

* moved css var definitions to respective files

* added bubble_up() and multiple modules

* converted some stringstream to string + reordered module functions in viz

* added getStmtHierarchy js working for expanding/collapsing

* calculate color ranges once and not every time

* should be added to previous commit

* changed everything from IRMutator -> IRVisitor

* side by side view on main page

* added expand code / viz buttons functionality

* attempting to switch GetStmtHierarchy to 1 tree with colors on side

* should revert this change later, but need to for now (merging with main)

* added Reinterpret + fixed double graph in StmtHierarchy

* removed omg!!!! for reinterpret

* changed border colors of stmtHierarchy + removed print statements

* visualized assert + added colors to assert + made all info buttons next to colors

* added resize bar

* removed navigation code (sticking to 2col layout)

* changed colors spans to buttons (removed segfault???)

* visualize entire LetStmt and cleaned up GetStmtHierarchy.cpp

* added more info in info-buttons

* added hover to side colors in stmthierarchy

* made collapse buttons resizeBar icons + put see_code_button top right of div

* (1) added code to viz buttons (2) display all if-stmts, even if they are empty (3) fixed store highlight cost span

* added scrollTo for function buttons within modules

* changed info-button style

* (1) added hover over for colors in stmtHierarchy (2) removed =default constructor/destructor (3) changed getStmtHierarchy to string html instead of stringstream

* made sure updated StmtToHtml code was in StmtToViz code

* small style changes

* added see code/viz buttons for module functions

* (1) loop size -> loop span (2) made function names  big in viz (3) load types in name

* removed inline style tags

* added VectorReduce code for stmt hierarchy

* removed scopeName hack to fix previous scope error (hope it's not happening anymore)

* fixed scrollTo if code is hidden

* removed commented out includes

* changed costs to inclusive vs exclusive (still might be a bit broken)

* removed print statements

* fixed loop_depth = 0 error

* (1) tooltips include inclusive and exclusive sizes (2) moved tooltip HTML to FindStmtCost.cpp

* reworked tooltip style

* (1) made getStmtHierarchy *exclusive* costs (2) viuslizing costs for IfThenElse blocks

* visualize For and ProducerConsumer blocks

* got collapse of code to show cumulative color cost

* removed context span button

* removed bubble up code and associated logic (now only read/write for loads and stores)

* change some variables to read/write instead of prod/cons

* fixed range bug

* dense/strided vector load

* removed inline TODO comments

* added loop var for for loops

* made loading MUCHHHH faster!!!!

* (1) fixed function box width in viz (2) fixed collapse/expand button for functions in code

* compile assembly if stmt_viz flag is given

* starting assembly stuff

* got assembly code button working (button is still ugly)

* (1) made assembly button prettier (2) started information bar at top (need to fill in content of info popup)

* added content to information bar button popup

* (1) fixed if statement costs (2) added percentages to cost tables instead of values

* removed output_file_name from ProducerConsumerHierarchy.h and related code in StmtToViz.cpp

* fixed IfThenElse cost if there are nested ifs

* removed dependency graph logic and files

* made tooltip table input vector of pairs so that we can specify order

* made tooltip table input vector of pairs so that we can specify order

* added collapse/expand to viz on right

* (1) collapseCode works now (2) search works in assembly tab

* changed codemirror to ARM assembly highlighting

* start of refactor: commenting and cleanup

* fixed bug!!!!! i think. i hope !!!

* removed Stmt function versions (never run this code on Stmt input, only module)

* changed ProdCons stuff to IRViz

* removed print line for strided vectors (seems to be working now)

* fixed bug!!!!!! changed things back to stringstream, because that wasn't the issue

* have helper functions return strings isntead of being void

* end of refactor (for now) - changed variables from camelCase to snake_case

* fix ... error for collapsing nodes

* fixed div issue + tooltips not being correct location

* added error message for multiple modulse (doesn't currently support)

* fixed spacing for boxBody divs

* removed submodules logic because it's not supported right now

* made assembly marker generation more accurate (added counters to have marker names be unique)

* got 3 columns resizing mostly working (just a little glitchy, good enough for now)

* got assembly button to populate assembly, kind of working

* added assemblyInfoViz.h to makefile

* fixed resize bars for 3 different visualizations

* fixed linewrapping issue with codemirror

* updated spacing for IRVisualization buttons in header

* (1) fixed functionBox button sizing (2) dense vector load -> [Dense, Vector] load

* fixed informationBar spacing

* updated InformationBar content

* removed current_loop_depth from consideration of cost

* changed cost table tooltip: inclusive: show %, exclusive: show raw cost

* simplified cost model

* (1) updated InformationBar w/ info for assembly (2) added assembly by default to third col

* added logic to collapseVizAssembly if curson passes resizeBar

* moved all color range + tooltip logic into IRVisualization

* fixed get_combined_color_range() error

* reordered js/css strings

* changed format and slighly changed content of cost tooltips

* refactor: .h and .cpp files have same order

* refactor: added comments

* refactor: updated internal_error messages

* fixed small import / #ifndef typo

* updated get_loop_iterator to include more binary ops for extent

* reverting some changes I made to get ready for PR

* adding CMake build

* refactoring namespace scoping

* refactoring "endl"

* refactoring header guards and includes

* const vector reference

* ostringstream all the things!

* having a symbol for "canIgnoreVariableName"

* string -> char*, with raw string literal

* internal_error -> internal_assert()

* clang-format

* if-else chain to switch-case block

* Upgrade wabt to 1.0.30 (halide#7058)

* Add support for float16 buffer in python extension (halide#7060)

* run clang-tidy and clang-format

* run clang-tidy & clang-format

* run clang-tidy and clang-format, again

* run clang-tidy and clang-format, Phaze III

* Minor PR Revision

- If `stmt_viz` flag is used without the `assembly` flag, the compiler throws an error.
- GetAssemblyInfoViz.cpp: replace regex with replace_all
- GetSttmtHierarchy.cpp: Bug fix (line 721). Use raw strings for large literals
- Restricted scope of default statement values
- Added enum type for StmtCostModel. A single cost model config value is specified, instead of multiple booleans.

* reminder for later

---------

Co-authored-by: Darya Verzhbinsky <dverzhbinsky@adobe.com>
Co-authored-by: Maaz Ahmad <maaz.c10@gmail.com>
Co-authored-by: Marcos Slomp <slomp@adobe.com>
Co-authored-by: Steven Johnson <srj@google.com>
Co-authored-by: Steve Suzuki <shinsuke.suzuki@arm.com>
Co-authored-by: Marcos Slomp <mslomp@gmail.com>

* Refactor 1/N: Moved all static html, css and js code outside of the cpp files to reduce noise

* Refactor 2/N: Broke down StmtToViz Class to two simpler classes

- Disabled legacy StmtToViz implementation
- Introduced three new classes instead:
   - IRVisualizer: generates the output page (WIP)
   - HTMLCodePrinter: prints IR code in HTML (Implementation complete)
   - HTMLVisualizationPrinter: visualizes IR code in HTML (WIP)

* Refactor 3/N: Minor stylesheet and javascript improvements

Thorough refactor of css and js pending

* Fixed resize bars not working properly

* Refactoring Viz tab (WIP)

* Refactored 4/N: Visualization tab complete

Refactored all visualization logic into a single HTMLVisualizationPrinter class

* Refactor 5/N: Javascript and css cleanup

- Visual improvements
- Deleted unnecessary code
- Refactored most of js code

* Refactor 6/N: JS and CSS refactor complete

- Deleted unused code
- Simplified remaining code

* Refactor 7/N: Added assembly support

- Added assembly tab functionality
- Jump to assembly buttons added
- Tooltips added for all buttons

* Refactor 8/N: Deleted info bar

* Refactor 9/N: Deleting code

These classes were simplified and refactored into the new StmtToViz file.

* Remove stale files from build

* Refactor 10/N: Cost model simplified and re-activated

- Cost model is much simpler now
- Re-integrated cost model into code tab
- Re-integration to viz tab pending

* Delete stale cost model code

* Refactor 11/N: Reintegrate cost model into visualization

* Minor fixes

* Update CMakeLists.txt

* Deleting more stale files

* Improved documentation for new code in Codegen_LLVM

* Static HTML, CSS and JS is now stored as large strings

Avoids build shenanigans.

* Fix: Build error for unused variable

* Deleting dead code

* Stmt visualizer should not run on submodules

* Ran clang-format on the PR

* Ran clang-tidy on the PR

* Move boilerplate JS/CSS code into template files

* CMake Build fix: Typo

* Minor bug fix

* Renamed variable to avoid any keyword conflict

* Style fixes

- Removed underscore-prefix on member variables
- Fixed typos in documentation
- Fixed indentation in Makefile

* Replacing `internal_assert(false) << ...` with `internal_error << ...`

* Style improvement: std prefix consistency

* Minor fix: variable had greater scope than necessary

* Renamed `datamovement` to `data_movement` for readability

* Constructor fixes for HTMLCodePrinter, HTMLVizualizationPrinter and IRVisualizer

- Made single parameter constructors explicit
- Made HTMLCodePrinter and HTMLVizualizationPrinter non-moveable and non-copyable

* Typo

* Clang-formatting

* Undo accidental Makefile change

* Improved comments

- Fix type in fn name `compute_all_costs`
- Comments describing class are now in format consistent with rest of the codebase
- Improved comment describing `print_cuda_gpu_source_kernels`

* Replaced spaces with underscores in regex markers printed in assembly

* Minor bug fix for Halide IR Visualizer

Synchronization button from Viz to Code was not working for tail `else` cases.

* Clang format fix

* Assign deterministic node IDs for reproducability

* clang-format and clang-tidy

* Update StmtToViz.cpp

* Minor formatting fix

* Bug fix: ProducerConsumer IDs were not generated correctly

---------

Co-authored-by: Marcos Slomp <slomp@adobe.com>
Co-authored-by: darya-ver <darya99@gmail.com>
Co-authored-by: Darya Verzhbinsky <dverzhbinsky@adobe.com>
Co-authored-by: Steven Johnson <srj@google.com>
Co-authored-by: Steve Suzuki <shinsuke.suzuki@arm.com>
Co-authored-by: Marcos Slomp <mslomp@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buildbot_test_everything Buildbots should run all available tests on this PR (unless build_test_nothing is set).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants