Skip to content

Commit

Permalink
Feature Enhancement: Halide IR HTML Visualization (halide#7421)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
7 people authored and ardier committed Mar 3, 2024
1 parent ad9f9ba commit 3d659cb
Show file tree
Hide file tree
Showing 12 changed files with 4,139 additions and 7 deletions.
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ SOURCE_FILES = \
SplitTuples.cpp \
StageStridedLoads.cpp \
StmtToHtml.cpp \
StmtToViz.cpp \
StorageFlattening.cpp \
StorageFolding.cpp \
StrictifyFloat.cpp \
Expand All @@ -585,6 +586,11 @@ SOURCE_FILES = \
CodeGen_C_prologue \
CodeGen_C_vectors

HTML_TEMPLATE_FILES = \
StmtToViz_dependencies \
StmtToViz_javascript \
StmtToViz_stylesheet

# The externally-visible header files that go into making Halide.h.
# Don't include anything here that includes llvm headers.
# Also *don't* include anything that's only used internally (eg SpirvIR.h).
Expand Down Expand Up @@ -734,6 +740,7 @@ HEADER_FILES = \
SplitTuples.h \
StageStridedLoads.h \
StmtToHtml.h \
StmtToViz.h \
StorageFlattening.h \
StorageFolding.h \
StrictifyFloat.h \
Expand Down Expand Up @@ -889,6 +896,7 @@ INITIAL_MODULES = $(RUNTIME_CPP_COMPONENTS:%=$(BUILD_DIR)/initmod.%_32.o) \
$(RUNTIME_CPP_COMPONENTS:%=$(BUILD_DIR)/initmod.%_64_debug.o) \
$(RUNTIME_EXPORTED_INCLUDES:$(INCLUDE_DIR)/%.h=$(BUILD_DIR)/initmod.%_h.o) \
$(C_TEMPLATE_FILES:%=$(BUILD_DIR)/c_template.%.o) \
$(HTML_TEMPLATE_FILES:%=$(BUILD_DIR)/html_template.%.o) \
$(BUILD_DIR)/initmod.inlined_c.o \
$(RUNTIME_LL_COMPONENTS:%=$(BUILD_DIR)/initmod.%_ll.o) \
$(PTX_DEVICE_INITIAL_MODULES:libdevice.%.bc=$(BUILD_DIR)/initmod_ptx.%_ll.o)
Expand Down Expand Up @@ -1131,6 +1139,9 @@ $(BUILD_DIR)/initmod_ptx.%_ll.cpp: $(BIN_DIR)/binary2cpp $(SRC_DIR)/runtime/nvid
$(BUILD_DIR)/c_template.%.cpp: $(BIN_DIR)/binary2cpp $(SRC_DIR)/%.template.cpp
./$(BIN_DIR)/binary2cpp halide_c_template_$* < $(SRC_DIR)/$*.template.cpp > $@

$(BUILD_DIR)/html_template.%.cpp: $(BIN_DIR)/binary2cpp $(SRC_DIR)/irvisualizer/%.template.html
./$(BIN_DIR)/binary2cpp halide_html_template_$* < $(SRC_DIR)/irvisualizer/$*.template.html > $@

$(BIN_DIR)/binary2cpp: $(ROOT_DIR)/tools/binary2cpp.cpp
@mkdir -p $(@D)
$(CXX) $< -o $@
Expand All @@ -1148,6 +1159,9 @@ $(BUILD_DIR)/initmod.%.o: $(BUILD_DIR)/initmod.%.cpp
$(BUILD_DIR)/c_template.%.o: $(BUILD_DIR)/c_template.%.cpp
$(CXX) -c $< -o $@ -MMD -MP -MF $(BUILD_DIR)/$*.d -MT $(BUILD_DIR)/$*.o

$(BUILD_DIR)/html_template.%.o: $(BUILD_DIR)/html_template.%.cpp
$(CXX) -c $< -o $@ -MMD -MP -MF $(BUILD_DIR)/$*.d -MT $(BUILD_DIR)/$*.o

$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp $(BUILD_DIR)/llvm_ok
@mkdir -p $(@D)
$(CXX) $(CXX_FLAGS) -c $< -o $@ -MMD -MP -MF $(BUILD_DIR)/$*.d -MT $(BUILD_DIR)/$*.o
Expand Down
23 changes: 21 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ set(HEADER_FILES
SplitTuples.h
StageStridedLoads.h
StmtToHtml.h
StmtToViz.h
StorageFlattening.h
StorageFolding.h
StrictifyFloat.h
Expand Down Expand Up @@ -329,6 +330,7 @@ set(SOURCE_FILES
SplitTuples.cpp
StageStridedLoads.cpp
StmtToHtml.cpp
StmtToViz.cpp
StorageFlattening.cpp
StorageFolding.cpp
StrictifyFloat.cpp
Expand All @@ -350,11 +352,17 @@ set(SOURCE_FILES
WrapCalls.cpp
)

set(TEMPLATE_FILES
set(C_TEMPLATE_FILES
CodeGen_C_prologue
CodeGen_C_vectors
)

set(HTML_TEMPLATE_FILES
StmtToViz_dependencies
StmtToViz_javascript
StmtToViz_stylesheet
)

##
# Build and import the runtime.
##
Expand All @@ -366,7 +374,7 @@ add_subdirectory(runtime)
##

add_library(Halide_c_templates OBJECT)
foreach (f IN LISTS TEMPLATE_FILES)
foreach (f IN LISTS C_TEMPLATE_FILES)
set(SRC "$<SHELL_PATH:${CMAKE_CURRENT_SOURCE_DIR}/${f}.template.cpp>")
set(DST "c_template.${f}.template.cpp")

Expand All @@ -377,6 +385,17 @@ foreach (f IN LISTS TEMPLATE_FILES)
target_sources(Halide_c_templates PRIVATE ${DST})
endforeach ()

foreach (f IN LISTS HTML_TEMPLATE_FILES)
set(SRC "$<SHELL_PATH:${CMAKE_CURRENT_SOURCE_DIR}/irvisualizer/${f}.template.html>")
set(DST "html_template.${f}.template.cpp")

add_custom_command(OUTPUT "${DST}"
COMMAND binary2cpp "halide_html_template_${f}" < "${SRC}" > "${DST}"
DEPENDS "${SRC}" binary2cpp
VERBATIM)
target_sources(Halide_c_templates PRIVATE ${DST})
endforeach ()

##
# Build the Halide mono-header.
##
Expand Down
13 changes: 9 additions & 4 deletions src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3660,11 +3660,13 @@ void CodeGen_LLVM::return_with_error_code(llvm::Value *error_code) {
}

void CodeGen_LLVM::visit(const ProducerConsumer *op) {
producer_consumer_id++;

string name;
if (op->is_producer) {
name = std::string("produce ") + op->name;
name = std::to_string(producer_consumer_id) + std::string("_produce_") + op->name;
} else {
name = std::string("consume ") + op->name;
name = std::to_string(producer_consumer_id) + std::string("_consume_") + op->name;
}
BasicBlock *produce = BasicBlock::Create(*context, name, function);
builder->CreateBr(produce);
Expand All @@ -3690,9 +3692,12 @@ void CodeGen_LLVM::visit(const For *op) {
BasicBlock *preheader_bb = builder->GetInsertBlock();

// Make a new basic block for the loop
BasicBlock *loop_bb = BasicBlock::Create(*context, std::string("for ") + op->name, function);
for_loop_id++;
BasicBlock *loop_bb = BasicBlock::Create(
*context, std::to_string(for_loop_id) + std::string("_for_") + op->name, function);
// Create the block that comes after the loop
BasicBlock *after_bb = BasicBlock::Create(*context, std::string("end for ") + op->name, function);
BasicBlock *after_bb = BasicBlock::Create(
*context, std::to_string(for_loop_id) + std::string("_end_for_") + op->name, function);

// If min < max, fall through to the loop bb
Value *enter_condition = builder->CreateICmpSLT(min, max);
Expand Down
7 changes: 7 additions & 0 deletions src/CodeGen_LLVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,13 @@ class CodeGen_LLVM : public IRVisitor {
*/
int effective_vscale;

/** Assign a unique ID to each producer-consumer and for-loop node. The IDs
* are printed as comments in assembly and used to link visualizations with
* the generated assembly code within `StmtToViz`
*/
int producer_consumer_id = 0;
int for_loop_id = 0;

/** Embed an instance of halide_filter_metadata_t in the code, using
* the given name (by convention, this should be ${FUNCTIONNAME}_metadata)
* as extern "C" linkage. Note that the return value is a function-returning-
Expand Down
9 changes: 8 additions & 1 deletion src/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ gengen
-e A comma separated list of files to emit. Accepted values are:
[assembly, bitcode, c_header, c_source, cpp_stub, featurization,
llvm_assembly, object, python_extension, pytorch_wrapper, registration,
schedule, static_library, stmt, stmt_html, compiler_log].
schedule, static_library, stmt, stmt_html, stmt_viz, compiler_log].
If omitted, default value is [c_header, static_library, registration].
-p A comma-separated list of shared libraries that will be loaded before the
Expand Down Expand Up @@ -790,6 +790,13 @@ gengen
output_types.insert(OutputFileType::registration);
output_types.insert(OutputFileType::static_library);
} else {
// if emit_flags contains "stmt_viz" but not "assembly", throw an error
bool has_stmt_viz = std::find(emit_flags.begin(), emit_flags.end(), "stmt_viz") != emit_flags.end();
bool has_assembly = std::find(emit_flags.begin(), emit_flags.end(), "assembly") != emit_flags.end();

user_assert(!has_stmt_viz || has_assembly)
<< "Output flag `stmt_viz` requires the `assembly` flag to also be set.";

// Build a reverse lookup table. Allow some legacy aliases on the command line,
// to allow legacy build systems to work more easily.
std::map<std::string, OutputFileType> output_name_to_enum = {
Expand Down
8 changes: 8 additions & 0 deletions src/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "Pipeline.h"
#include "PythonExtensionGen.h"
#include "StmtToHtml.h"
#include "StmtToViz.h"

namespace Halide {
namespace Internal {
Expand Down Expand Up @@ -49,6 +50,7 @@ std::map<OutputFileType, const OutputInfo> get_output_info(const Target &target)
{OutputFileType::static_library, {"static_library", is_windows_coff ? ".lib" : ".a", IsSingle}},
{OutputFileType::stmt, {"stmt", ".stmt", IsMulti}},
{OutputFileType::stmt_html, {"stmt_html", ".stmt.html", IsMulti}},
{OutputFileType::stmt_viz, {"stmt_viz", ".stmt.viz.html", IsMulti}},
};
return ext;
}
Expand Down Expand Up @@ -551,6 +553,7 @@ void Module::compile(const std::map<OutputFileType, std::string> &output_files)
std::map<OutputFileType, std::string> output_files_copy = output_files;
output_files_copy.erase(OutputFileType::stmt);
output_files_copy.erase(OutputFileType::stmt_html);
output_files_copy.erase(OutputFileType::stmt_viz);
resolve_submodules().compile(output_files_copy);
return;
}
Expand Down Expand Up @@ -610,6 +613,11 @@ void Module::compile(const std::map<OutputFileType, std::string> &output_files)
compile_llvm_module_to_llvm_assembly(*llvm_module, *out);
}
}

if (contains(output_files, OutputFileType::stmt_viz)) {
debug(1) << "Module.compile(): stmt_viz " << output_files.at(OutputFileType::stmt_viz) << "\n";
Internal::print_to_viz(output_files.at(OutputFileType::stmt_viz), *this);
}
if (contains(output_files, OutputFileType::function_info_header)) {
debug(1) << "Module.compile(): function_info_header " << output_files.at(OutputFileType::function_info_header) << "\n";
std::ofstream file(output_files.at(OutputFileType::function_info_header));
Expand Down
1 change: 1 addition & 0 deletions src/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum class OutputFileType {
static_library,
stmt,
stmt_html,
stmt_viz,
};

/** Type of linkage a function in a lowered Halide module can have.
Expand Down
Loading

0 comments on commit 3d659cb

Please sign in to comment.