-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from zpye/halide
add Halide support
- Loading branch information
Showing
6 changed files
with
120 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "Halide.h" | ||
|
||
class HalideUpsampleNearest : public Halide::Generator<HalideUpsampleNearest> { | ||
public: | ||
Input<float> scale_x{"scale_x"}; | ||
Input<float> scale_y{"scale_y"}; | ||
|
||
Input<Halide::Buffer<float, 4>> input{"input"}; | ||
|
||
Output<Halide::Buffer<float, 4>> output{"output"}; | ||
|
||
Halide::Var b, y, x, c; | ||
|
||
void generate() { | ||
Halide::Expr x_scale = | ||
Halide::cast<int32_t>(Halide::cast<float>(x) * scale_x); | ||
Halide::Expr y_scale = | ||
Halide::cast<int32_t>(Halide::cast<float>(y) * scale_y); | ||
|
||
// TODO: schedule | ||
output(c, x, y, b) = input(c, x_scale, y_scale, b); | ||
} | ||
}; | ||
|
||
HALIDE_REGISTER_GENERATOR(HalideUpsampleNearest, halide_upsample_nearest) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
target("halide_upsample_nearest") | ||
set_kind("binary") | ||
set_targetdir("$(buildir)/") | ||
add_files("halide_upsample_nearest.cc", "$(env HALIDE_ROOT)/share/Halide/tools/GenGen.cpp") | ||
add_options("halide") | ||
|
||
after_build(function () | ||
os.run("xmake run halide_upsample_nearest -g halide_upsample_nearest -o . -f halide_upsample_nearest target=host") | ||
end) | ||
|
||
target("halide_layers") | ||
set_kind("headeronly") | ||
add_defines("USE_HALIDE", { public = true }) | ||
add_includedirs("$(env HALIDE_ROOT)/include/", "$(buildir)/", { public = true }) | ||
add_linkdirs("$(buildir)/", { public = true }) | ||
add_links("halide_upsample_nearest", { public = true }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters