Skip to content

Commit b0258f8

Browse files
authored
Merge branch 'halide:main' into main
2 parents fa20ad1 + 833a219 commit b0258f8

File tree

143 files changed

+3037
-2119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+3037
-2119
lines changed

.devcontainer/Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM ubuntu:24.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt-get update && \
6+
ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && \
7+
apt-get install -y tzdata && \
8+
apt-get install -y \
9+
build-essential \
10+
cmake \
11+
gdb \
12+
git \
13+
gnupg \
14+
libcurl4-openssl-dev \
15+
libedit-dev \
16+
libicu-dev \
17+
libjpeg-dev \
18+
libncurses-dev \
19+
libpng-dev \
20+
lsb-release \
21+
ninja-build \
22+
pkg-config \
23+
python3-dev \
24+
software-properties-common \
25+
wget \
26+
zlib1g-dev && \
27+
wget https://apt.llvm.org/llvm.sh && \
28+
chmod +x llvm.sh && \
29+
./llvm.sh 21 all && \
30+
apt-get install -y liblld-21-dev && \
31+
apt-get clean && \
32+
rm -rf llvm.sh /var/lib/apt/lists/* \

.devcontainer/devcontainer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Default Ubuntu-based DevContainer Template.
2+
// For more customization options, see https://containers.dev/implementors/json_reference
3+
// Also note this file is "JSON with Comments" (JSONC).
4+
{
5+
"name": "Halide",
6+
"build": {
7+
"dockerfile": "Dockerfile"
8+
},
9+
"runArgs": [
10+
"--userns=keep-id",
11+
"--security-opt",
12+
"label=disable"
13+
],
14+
"customizations": {
15+
"jetbrains": {
16+
"backend": "CLion",
17+
"settings": {
18+
// IDE settings can be added via “Show context actions”|“Add currently modified settings from IDE”.
19+
// A complete list of supported settings is also available through auto-completion
20+
},
21+
"plugins": [
22+
// A set of plugin IDs.
23+
// Plugin ID can be found on the corresponding plugin’s page at https://plugins.jetbrains.com.
24+
]
25+
}
26+
},
27+
"features": {
28+
"ghcr.io/devcontainers/features/git": {},
29+
"ghcr.io/devcontainers/features/common-utils": {
30+
"installZsh": false
31+
}
32+
},
33+
// Comment out to connect as the root user.
34+
"remoteUser": "ubuntu",
35+
"containerUser": "root"
36+
}

.github/workflows/pip.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ jobs:
3737
platform_tag: manylinux_x86_64
3838
- os: windows-latest
3939
platform_tag: win_amd64
40-
- os: macos-13
40+
- os: macos-15-intel
4141
platform_tag: macosx_x86_64
42-
- os: macos-14
42+
- os: macos-15
4343
platform_tag: macosx_arm64
4444

4545
env:

apps/bgu/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ $(GENERATOR_BIN)/bgu.generator: bgu_generator.cpp $(GENERATOR_DEPS)
1616

1717
$(BIN)/%/bgu.a: $(GENERATOR_BIN)/bgu.generator
1818
@mkdir -p $(@D)
19-
$< -g bgu -f bgu -o $(BIN)/$* target=$*-no_runtime
19+
$< -g bgu -f bgu -o $(BIN)/$* -e $(GENERATOR_OUTPUTS) target=$*-no_runtime
2020

2121
$(BIN)/%/bgu_auto_schedule.a: $(GENERATOR_BIN)/bgu.generator
2222
@mkdir -p $(@D)
23-
$< -g bgu -f bgu_auto_schedule -o $(BIN)/$* target=$*-no_runtime autoscheduler=Mullapudi2016
23+
$< -g bgu -f bgu_auto_schedule -o $(BIN)/$* -e $(GENERATOR_OUTPUTS) target=$*-no_runtime autoscheduler=Mullapudi2016
2424

2525
$(BIN)/%/runtime.a: $(GENERATOR_BIN)/bgu.generator
2626
@mkdir -p $(@D)

doc/Vulkan.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ To modify the default behavior of the runtime, the following environment
171171
variables can be used to adjust the configuration of the Vulkan backend
172172
at execution time:
173173

174+
`HL_VK_LOADER_LIB=...` can be used to specify the full path and filename
175+
of the Vulkan loader library (e.g. `/usr/local/lib64/libvulkan.so.1`).
176+
This can be useful if you need to override the default search path,
177+
or if the loader is installed in a custom location. If not set, the
178+
runtime will search across a list of known paths.
179+
174180
`HL_VK_LAYERS=...` will tell Halide to choose a suitable Vulkan instance
175181
that supports the given list of layers. If not set, `VK_INSTANCE_LAYERS=...`
176182
will be used instead. If neither are present, Halide will use the first

python_bindings/src/halide/halide_/PyCallable.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,11 @@ class PyCallable {
109109
} else {
110110
argv[slot] = &scalar_storage[slot];
111111

112-
// clang-format off
113-
114-
#define HALIDE_HANDLE_TYPE_DISPATCH(CODE, BITS, TYPE, FIELD) \
115-
case halide_type_t(CODE, BITS).as_u32(): \
116-
scalar_storage[slot].u.FIELD = cast_to<TYPE>(value); \
117-
cci[slot] = Callable::make_scalar_qcci(halide_type_t(CODE, BITS)); \
118-
break;
112+
#define HALIDE_HANDLE_TYPE_DISPATCH(CODE, BITS, TYPE, FIELD) \
113+
case halide_type_t(CODE, BITS).as_u32(): \
114+
scalar_storage[slot].u.FIELD = cast_to<TYPE>(value); \
115+
cci[slot] = Callable::make_scalar_qcci(halide_type_t(CODE, BITS)); \
116+
break;
119117

120118
switch (((halide_type_t)c_arg.type).element_of().as_u32()) {
121119
HALIDE_HANDLE_TYPE_DISPATCH(halide_type_float, 32, float, f32)
@@ -134,9 +132,7 @@ class PyCallable {
134132
_halide_user_assert(0) << "Unsupported type in Callable argument list: " << c_arg.type << "\n";
135133
}
136134

137-
#undef HALIDE_HANDLE_TYPE_DISPATCH
138-
139-
// clang-format on
135+
#undef HALIDE_HANDLE_TYPE_DISPATCH
140136
}
141137
};
142138

python_bindings/src/halide/halide_/PyFunc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ void define_func(py::module &m) {
197197
.def("type", &Func::type)
198198
.def("types", &Func::types)
199199

200+
.def("split_vars", &Func::split_vars)
201+
200202
.def("bound", &Func::bound, py::arg("var"), py::arg("min"), py::arg("extent"))
201203

202204
.def("reorder_storage", (Func & (Func::*)(const std::vector<Var> &)) & Func::reorder_storage, py::arg("dims"))

python_bindings/src/halide/halide_/PyFuncRef.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ void define_func_ref(py::module &m) {
1818
py::class_<FuncRef>(m, "FuncRef")
1919
.def("__getitem__", &FuncRef::operator[])
2020
.def("size", &FuncRef::size)
21-
.def("__len__", &FuncRef::size);
21+
.def("__len__", &FuncRef::size)
22+
.def("type", &FuncRef::type)
23+
.def("types", &FuncRef::types);
2224
add_binary_operators(func_ref_class);
2325
}
2426

python_bindings/src/halide/halide_/PyStage.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ void define_stage(py::module &m) {
1919
.def("rfactor", static_cast<Func (Stage::*)(const RVar &, const Var &)>(&Stage::rfactor),
2020
py::arg("r"), py::arg("v"))
2121

22+
.def("split_vars", [](const Stage &stage) -> py::list {
23+
auto vars = stage.split_vars();
24+
py::list result;
25+
// Return a mixed-type list of Var and RVar objects, instead of
26+
// a list of VarOrRVar objects.
27+
for (const auto &v : vars) {
28+
if (v.is_rvar) {
29+
result.append(py::cast(v.rvar));
30+
} else {
31+
result.append(py::cast(v.var));
32+
}
33+
}
34+
return result;
35+
})
36+
2237
.def("unscheduled", &Stage::unscheduled);
2338

2439
py::implicitly_convertible<Func, Stage>();

python_bindings/test/correctness/basics.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def test_basics():
103103
blur_x.compute_at(blur_y, x).vectorize(x, 8)
104104
blur_y.compile_jit()
105105

106-
107106
def test_basics2():
108107
input = hl.ImageParam(hl.Float(32), 3, "input")
109108
hl.Param(hl.Float(32), "r_sigma", 0.1)
@@ -344,19 +343,30 @@ def test_typed_funcs():
344343
with assert_throws(hl.HalideError, "it is undefined"):
345344
assert f.dimensions() == 0
346345

346+
with assert_throws(hl.HalideError, "it is undefined"):
347+
assert f[x, y].type() == hl.Int(32)
348+
347349
f = hl.Func(hl.Int(32), 2, "f")
348350
assert not f.defined()
349351
assert f.type() == hl.Int(32)
350352
assert f.types() == [hl.Int(32)]
351353
assert f.outputs() == 1
352354
assert f.dimensions() == 2
355+
assert f[x, y].type() == hl.Int(32)
356+
357+
with assert_throws(hl.HalideError, "has not yet been defined"):
358+
# While we can ask for the type of f[x, y], because it's a
359+
# typed Func, we still can't use it as an Expr
360+
g = hl.Func("g")
361+
g[x, y] = f[x, y]
353362

354363
f = hl.Func([hl.Int(32), hl.Float(64)], 3, "f")
355364
assert not f.defined()
356365
with assert_throws(hl.HalideError, "it returns a Tuple"):
357366
assert f.type() == hl.Int(32)
358367

359368
assert f.types() == [hl.Int(32), hl.Float(64)]
369+
assert f[x, y].types() == [hl.Int(32), hl.Float(64)]
360370
assert f.outputs() == 2
361371
assert f.dimensions() == 3
362372

@@ -597,6 +607,31 @@ def test_print_ir():
597607
p = hl.Pipeline()
598608
assert str(p) == "<halide.Pipeline Pipeline()>"
599609

610+
def test_split_vars():
611+
f = hl.Func("f")
612+
(x, xo, xi) = hl.vars("x xo xi")
613+
f[x] = x
614+
r = hl.RDom([(0, 10), (0, 10)], "r")
615+
f[x] += x + r.x + r.y
616+
617+
f.split(x, xo, xi, 8)
618+
619+
vars = f.split_vars()
620+
assert len(vars) == 3
621+
assert vars[0].name() == xi.name()
622+
assert vars[1].name() == xo.name()
623+
assert vars[2].name() == hl.Var.outermost().name()
624+
625+
(rxo, rxi) = (hl.RVar("rxo"), hl.RVar("rxi"))
626+
f.update().split(r.x, rxo, rxi, 4)
627+
628+
vars = f.update().split_vars()
629+
assert len(vars) == 5
630+
assert isinstance(vars[0], hl.RVar) and vars[0].name() == rxi.name()
631+
assert isinstance(vars[1], hl.RVar) and vars[1].name() == rxo.name()
632+
assert isinstance(vars[2], hl.RVar) and vars[2].name() == r.y.name()
633+
assert isinstance(vars[3], hl.Var) and vars[3].name() == x.name()
634+
assert isinstance(vars[4], hl.Var) and vars[4].name() == hl.Var.outermost().name()
600635

601636
if __name__ == "__main__":
602637
test_compiletime_error()
@@ -622,3 +657,4 @@ def test_print_ir():
622657
test_implicit_update_by_int()
623658
test_implicit_update_by_float()
624659
test_print_ir()
660+
test_split_vars()

0 commit comments

Comments
 (0)