https://github.com/halide/Halide

sort by:
Revision Author Date Message Commit Date
357a12a Address review comments 13 December 2021, 16:37:12 UTC
ddde625 rounding shift rights should use rounding halving add On x86 currently we lower cast<uint8_t>((cast<uint16_t>(x) + 8) / 16) to: cast<uint8_t>(shift_right(widening_add(x, 8), 4)) This compiles to 8 instructions on x86: Widen each half of the input vector, add 8 to each half-vector, shift each half-vector, then narrow each half-vector. First, this should have been a rounding_shift_right. Some patterns were missing in FindIntrinsics. Second, rounding_shift_right had suboptimal codegen in the case where the second arg is a positive const. On archs without a rounding shift right instruction you can further rewrite this to: shift_right(rounding_halving_add(x, 7), 3) which is just two instructions on x86. 11 December 2021, 15:42:32 UTC
11448b2 Document the usage of llvm::legacy::PassManager (#6491) * Document the usage of llvm::legacy::PassManager There is some confusion about whether this usage is acceptable. TL;DR: it's not just acceptable, it's required for the forseeable future. Add comments to capture this to avoid future such questions. (With great thanks to Alina for pointing me at the relevant LLVM discussion links!) * Add date 10 December 2021, 19:31:01 UTC
7fe1e2c Let lerp lowering incorporate a final cast. (#6480) * Let lerp lowering incorporate a final cast This lets it save a few instructions on x86 and arm. cast(UInt(16), lerp(some_u8s)) produces the following, before and after this PR Before: x86: vmovdqu (%r15,%r13), %xmm4 vpmovzxbw -2(%r15,%r13), %ymm5 vpxor %xmm0, %xmm4, %xmm6 vpmovzxbw %xmm6, %ymm6 vpmovzxbw -1(%r15,%r13), %ymm7 vpmullw %ymm6, %ymm5, %ymm5 vpmovzxbw %xmm4, %ymm4 vpmullw %ymm4, %ymm7, %ymm4 vpaddw %ymm4, %ymm5, %ymm4 vpaddw %ymm1, %ymm4, %ymm4 vpmulhuw %ymm2, %ymm4, %ymm4 vpsrlw $7, %ymm4, %ymm4 vpand %ymm3, %ymm4, %ymm4 vmovdqu %ymm4, (%rbx,%r13,2) addq $16, %r13 decq %r10 jne .LBB0_10 arm: ldr q0, [x17] ldur q2, [x17, #-1] ldur q1, [x17, #-2] subs x0, x0, #1 // =1 mvn v3.16b, v0.16b umull v4.8h, v2.8b, v0.8b umull2 v0.8h, v2.16b, v0.16b umlal v4.8h, v1.8b, v3.8b umlal2 v0.8h, v1.16b, v3.16b urshr v1.8h, v4.8h, #8 urshr v2.8h, v0.8h, #8 raddhn v1.8b, v1.8h, v4.8h raddhn v0.8b, v2.8h, v0.8h ushll v0.8h, v0.8b, #0 ushll v1.8h, v1.8b, #0 add x17, x17, #16 // =16 stp q1, q0, [x18, #-16] add x18, x18, #32 // =32 b.ne .LBB0_10 After: x86: vpmovzxbw -2(%r15,%r13), %ymm3 vmovdqu (%r15,%r13), %xmm4 vpxor %xmm0, %xmm4, %xmm5 vpmovzxbw %xmm5, %ymm5 vpmullw %ymm5, %ymm3, %ymm3 vpmovzxbw -1(%r15,%r13), %ymm5 vpmovzxbw %xmm4, %ymm4 vpmullw %ymm4, %ymm5, %ymm4 vpaddw %ymm4, %ymm3, %ymm3 vpaddw %ymm1, %ymm3, %ymm3 vpmulhuw %ymm2, %ymm3, %ymm3 vpsrlw $7, %ymm3, %ymm3 vmovdqu %ymm3, (%rbp,%r13,2) addq $16, %r13 decq %r10 jne .LBB0_10 arm: ldr q0, [x17] ldur q2, [x17, #-1] ldur q1, [x17, #-2] subs x0, x0, #1 // =1 mvn v3.16b, v0.16b umull v4.8h, v2.8b, v0.8b umull2 v0.8h, v2.16b, v0.16b umlal v4.8h, v1.8b, v3.8b umlal2 v0.8h, v1.16b, v3.16b ursra v4.8h, v4.8h, #8 ursra v0.8h, v0.8h, #8 urshr v1.8h, v4.8h, #8 urshr v0.8h, v0.8h, #8 add x17, x17, #16 // =16 stp q1, q0, [x18, #-16] add x18, x18, #32 // =32 b.ne .LBB0_10 So on X86 we skip a pointless and instruction, and on ARM we get a rounding add and shift right instead of a rounding narrowing add shift right followed by a widen. * Add test * Fix bug in test * Don't produce out-of-range lerp values 10 December 2021, 15:06:30 UTC
bcfd6af Fail if no_bounds_query specified for HL_JIT_TARGET (#6489) * Fail if no_bounds_query specified for HL_JIT_TARGET JIT requires the use of bounds_query; disabling it will almost certainly fail in JIT mode, either with a confusing assert message, or a crash (if you also specify no_asserts). This adds a more useful failure message. * Update Target.cpp 09 December 2021, 23:06:05 UTC
59118de Deal with Printer::scratch (#6469) (#6472) Instead of trying to optimize every Printer instance to use stack (and failing), move the StackPrinter concept into printer.h directly and require opt-in at the point of compilation to use stack instead of malloc. This PR also does a few other drive-by cleanups: - Ensures that all Printer ctors are explicit - Makes some template aliases to make using (e.g.) ErrorPrinter with a custom buffer size slightly cleaner syntax - Have tracing use the `.str()` method, which already deals with MSAN internally - Make all the Printer data members private - Fix some evil code in opencl.cpp that previously used the now-private data members 08 December 2021, 22:12:53 UTC
d089588 Move null check from Printer to halide_string_to_string() The Printer is (currently) usually inlined into every module, so this check is repeated in multiple chunks of code. Since the goal is to avoid crashing when debugging, let's move it to halide_string_to_string() (which will catch all these, and possibly more) and save some code size. (Further improvements in Printer code size on the way; this change seems worthy of considering separately.) 08 December 2021, 19:11:28 UTC
7199e7d Try removing optional buffer added to closure 08 December 2021, 18:53:35 UTC
7992369 Add a fast integer divide that rounds to zero (#6455) * Add a version of fast_integer_divide that rounds towards zero * clang-format * Fix test condition * Clean up debugging code * Add explanatory comment to performance test * Pacify clang tidy 07 December 2021, 16:16:50 UTC
fb305fd `apps/linear_algebra/benchmarks/macros.h`: don't forget SSE guard (#6471) This is breaking i386 build: https://buildd.debian.org/status/fetch.php?pkg=halide&arch=i386&ver=13.0.1-3&stamp=1638786518&raw=0 07 December 2021, 02:15:18 UTC
e0df687 decommissioning StackPrinter (#6470) 06 December 2021, 20:34:44 UTC
392430d Fix Closure API (#6464) The current API requires calling a Visitor from the Closure ctor, which means we implicitly call virtual methods from the class ctor, which is a no-no for a non-final class (see comments on https://github.com/halide/Halide/pull/6443). 02 December 2021, 21:23:25 UTC
0ed461b Add operator<< for Closure (#6443) * Add operator<< for Closure Moves the ad-hoc implementation our of HostClosure::arguments() for easier debugging usage. Also, drive-by elimination of the body of HostClosure ctor, which was identical to the one inherited from Closure. * Update DeviceArgument.cpp * Add explanatory comment 02 December 2021, 18:38:50 UTC
5cf9ae5 Reduce overhead of sampling profiler by having only one thread do it (#6433) * Reduce overhead of sampling profiler by having only one thread do it * Use const ref * One line per member 02 December 2021, 15:04:43 UTC
479d839 Add LinkageType::ExternalPlusArgv (#6452) (#6463) Allows us to skip generating metadata for offloaded hexagon funcs, which will never use it. 02 December 2021, 03:42:04 UTC
4877d26 Tweak Hexagon codegen output to match the pattern in Lower.cpp more accurately (for level 1 vs 2); also prefix the outputs so they are easier to read as Hexagon-specific when debugging (#6461) 01 December 2021, 19:22:00 UTC
c0192ff Re-enable performance_async_gpu for D3D12Compute (#6450) * Re-enable performance_async_gpu for D3D12Compute It's been disabled for ~2 years because of flaky failures (#3586); we should see if the many changes since then have improved things or not. * tickle buildbots 30 November 2021, 06:13:44 UTC
5aeea6a Fixes for c++20 (#6446) Fixes #6445 26 November 2021, 22:32:24 UTC
76c0946 Syntax highlighting for embedded PTX code. (#6447) * Include GPU source kernels in Stmt and StmtHtml file. * Syntax highlighting for embedded PTX code. 26 November 2021, 20:03:24 UTC
3bde22a Include GPU source kernels in Stmt and StmtHtml file. (#6444) 24 November 2021, 20:59:37 UTC
8b68f85 Avoid needless gather in fast_integer_divide lowering (#6441) * Avoid needless gather in fast_integer_divide lowering fast_integer_divide did two lookups, one for a multiplier, and one for a shift. It turns out you can just use count leading zeros to compute a workable shift instead of having to do a lookup. This PR speeds up use of fast_integer_divide in cases where the denominator varies across vector lanes by ~70% or so by avoiding one of the two expensive gathers. * Fix slash direction * Pacify clang-tidy * Use portable bit-counting methods * Cleaner initialization of tables 23 November 2021, 21:13:48 UTC
d12fbd1 Codegen_C: buffer compilation needs to special-case scalar buffers (#6442) The existing code will emit something like `halide_dimension_t foo_buffer_shape[] = {};` for these, which is a zero-length array, which some compilers will (justifiably) say has no effect. We should be able to just use nullptr for the shape in these cases. 23 November 2021, 17:33:38 UTC
59d6da7 Skip custom cuda context test on older GPUs (#6437) 23 November 2021, 17:25:47 UTC
a89041b Ensure that halide_start_clock() is called before halide_current_time_ns() in hexagon_host.cpp (#6438) This oversight was causing an assert with the -debug feature flag enabled (with presumably-misleading timing results as well) 22 November 2021, 21:29:11 UTC
57d1e05 Set up SANITIZER_FLAGS and OPTIMIZE for apps/Makefile.inc (#6435) Minor hygiene to make it easy to build AOT apps with TSAN or ASAN. 22 November 2021, 19:46:52 UTC
2239443 Do target-specific lowering of lerp (#6432) * Do target-specific lowering of lerp Saves instructions on x86. Before #6426 vpaddw %ymm0, %ymm1, %ymm1 vpsrlw $8, %ymm1, %ymm2 vpaddw %ymm2, %ymm1, %ymm1 vpsrlw $8, %ymm1, %ymm1 After #6426 vpsrlw $7, %ymm2, %ymm3 vpand %ymm0, %ymm3, %ymm3 vpsrlw $8, %ymm2, %ymm4 vpaddw %ymm2, %ymm4, %ymm2 vpaddw %ymm3, %ymm2, %ymm2 vpsrlw $7, %ymm2, %ymm3 vpand %ymm0, %ymm3, %ymm3 vpsrlw $8, %ymm2, %ymm2 vpaddw %ymm2, %ymm3, %ymm2 vpand %ymm1, %ymm2, %ymm2 This PR: vpaddw %ymm0, %ymm3, %ymm3 vpmulhuw %ymm1, %ymm3, %ymm3 vpsrlw $7, %ymm3, %ymm3 * Target is a struct 19 November 2021, 22:56:12 UTC
cfd03c9 Don't remap the function name or the target in the metadata (#6430) The remapping is only intended to be used for output argument(s), not the function name; if you have an output with the same name as the function, you can get the metadata emitted with incorrect information. (And remapping the target string is just silly.) This is almost impossible to do currently, but if you construct a Generator just right, you can make it happen. 19 November 2021, 17:41:05 UTC
c3040cb Rewrite integer lerp using intrinsics (#6426) * Rewrite integer lerp using intrinsics * Comment 19 November 2021, 17:10:15 UTC
0e40edc Include LICENSE.txt in package (#6428) Co-authored-by: Ashish Uthama <you@example.com> 18 November 2021, 21:27:53 UTC
36dd10f Fix Introspection issues (#6424) - DWARF v5 has a slightly different header; this recognizes it so we don't fail immediately - Add support for the line_strp form - Allow for a graceful failure if a debug abbreviation is missing; I've only seen this when compiling for TSAN, and I'm honestly not entirely sure if this is a bug in the DWARF generation for those tools vs a subtle flaw in our parsing, but bailing out early and skipping introspection seems kinder than assert-fail. 17 November 2021, 23:14:21 UTC
16fa3ce [hannk] Pacify clang-tidy (#6412) * [hannk] Pacify clang-tidy * One more ASAN fix We must use use_global_gc = false to work properly with the JIT * Revert "One more ASAN fix" This reverts commit 9ed07a70b4a656790236a5ff6966155df823a319. * Rework Op::mutate() to avoid UB 12 November 2021, 23:17:53 UTC
b63f6af [hannk] Fix lower_tflite_fullyconnected (#6414) Fixed the bounds calculation in lower_tflite_fullyconnected() to preserve the invariants expected, and added a testcase that previously failed. 12 November 2021, 20:56:57 UTC
8c2dd5f One more ASAN fix (#6413) We must use use_global_gc = false to work properly with the JIT 12 November 2021, 20:34:14 UTC
0153c6b Revamp Hannk IR (#6379) Refactor Hannk IR and transforms to use a Mutator-based approach 12 November 2021, 16:35:37 UTC
79da2a0 Fix broken ASAN code (#6408) * Fix broken ASAN code Various changes and merges ended up with us using multiple ASAN passes, which was pretty crashy (we just didn't notice because it isn't tested well enough on our buildbots, but is elsewhere). I think we really only want to use the ModuleAddressSanitizerPass (not the non-Module version), which is what Clang does. * set UseAfterScope = true 12 November 2021, 16:34:30 UTC
02a394d x86_cpuid_halide must preserve all 64 bits of rbx/rsi (#6409) The existing code attempts to preserve ebx (since the cpuid instruction can trash it), but it only preserves the lower 32 bits; on 64-bit systems, this (amazingly) usually works OK unless you are compiling in (e.g.) ASAN mode, which can subtly change codegen such that the full 32 bits of rbx must be preserved. I'm genuinely astonished this hasn't bitten us before now! 12 November 2021, 03:25:52 UTC
d763406 Change implementation of round_f* in CodeGen_C to use nearbyint to match CodeGen_LLVM (#6406) 12 November 2021, 01:30:05 UTC
9ff87ce _halide_buffer_crop() needs to check for runtime failures (v2) (#6403) * _halide_buffer_crop() needs to check for runtime failures (v2) (Alternate to #6402) We currently assume that _halide_buffer_crop() will never fail. This is a bad assumption, as it can call device_crop(), which can fail due to unexpected runtime errors, or from a backend simply leaving the device_crop field at the default (unimplemented) case (as is currently the case for the OGLC backend). When this happens, the dst buffer was left in an inconsistent, invalid state (which was what led to the crashes fixed by #6401). This change modifies _halide_buffer_crop() to return nullptr in the event of an error, and ensure that all cropped buffers are checked for null at the right point. (This is not optimal, of course, since the specific error returned by device_crop is getting dropped on the floor, but the existence of an error is no longer ignored.) This addresses at least some of the failure issues we are seeing in performance_async_gpu with the OpenGLCompute backend. (Also: drive-by whitespace fix in CodegenC) * Oops 11 November 2021, 18:04:09 UTC
d343e76 Fix obscure bug in widening let substitution (#6405) Fix obscure bug in widening let substitution 11 November 2021, 17:06:00 UTC
8e34a35 Remove halide_abort_if_false() usage in runtime/metal (#6398) * Remove halide_abort_if_false() usage in runtime/metal This converts all the usage of `halide_abort_if_false()` in runtime/metal into either an explicit runtime check-and-return-error-code (if the check looks plausible), or `halide_debug_assert()` (if the check seems to be stating an invariant that shouldn't be possible in well-structured code). These changes are admittedly subjective, so feedback is especially welcome. Also, driveby change to sync-common.h to use `halide_debug_assert()` rather than a local equivalent. * nits 09 November 2021, 23:10:40 UTC
4f70271 Add defensive checks to halide_buffer_copy_already_locked (#6401) Found while debugging crashes with performance_async_gpu for OpenGLCompute: the 'if' tree wasn't robust enough for malformed buffers being passed, and could attempt to deref and use a null src->device_interface or dst->device_interface in some cases. This patch just improves this function to return an error in these cases (rather than crashing); the fact that we are getting malformed buffers passed to us is likely a separate bug. 09 November 2021, 22:51:05 UTC
b189722 [hannk] Upgrade hannk to use TFLite 2.7.0 by default (#6393) * [hannk] Upgrade hannk to use TFLite 2.7.0 by default * Fix unused-vars warnings 09 November 2021, 21:35:24 UTC
b021f87 Move PyTorch test into standalone tests (#6397) * Move PyTorch test into standalone tests It doesn't need to be internal. Also simplified to use only public API, updated the expected correctness, and avoided the need to have cuda present on the system to test for cuda output (since we can cross-compile to generate the C++ output anywhere). * fixes * Fix Windows text file endings * Update pytorch.cpp * Update pytorch.cpp 09 November 2021, 21:25:26 UTC
4286c78 Drop support for LLVM11 (#6396) * Drop support for LLVM11 With Halide 13 released, we should drop support for LLVM11 in Halide trunk, since we only promise to support LLVM trunk + two releases. * Update packaging.yml * Update config.cmake * Update CMakeLists.txt 09 November 2021, 17:13:09 UTC
d3ea755 Fix OGLC debug builds (#6399) If you try to build and run something with `openglcompute` and `debug`, you may crash with a div-by-zero, because the openglcompute runtime never calls `halide_start_clock()`, and all implementations of `halide_current_time_ns()` assume that it has been called. On (e.g.) OSX, this results in div by zero. This fixes it by inserting the correct call into openglruntime.cpp, and also adding debug-only asserts to all the `halide_current_time_ns()` implementations. (I was tempted to fix this by removing `halide_start_clock()` entirely and just lazily initing the initial value in `halide_current_time_ns()`, but I figured that would likely get pushback...) 09 November 2021, 17:03:17 UTC
d6f1345 Rename halide_assert -> halide_abort_if_false (#6382) * Rename halide_assert -> HALIDDE_CHECK A crashing bug got mistakenly inserted because a new contributor (reasonably) assumed that the `halide_assert()` macro in our runtime code was like a C `assert()` (i.e., something that would vanish in optimized builds). This is not the case; it is a check that happens in all build modes and always triggers an `abort()` if it fires. We should remove any ambiguity about it, so this proposes to rename it to somethingmore like the Google/Abseil-style CHECK() macro, to make it stand out more. (We may want to do a followup to verify that all of the uses really are unrecoverable errors that aren't better handled by returning an error.) * clang-format * Fix for top-of-tree LLVM * Fix for older versions * HALIDE_CHECK -> halide_abort_if_false * Update runtime_internal.h 08 November 2021, 23:13:13 UTC
1312817 Clean up CodeGen_LLVM names to match ASAN nomenclature changes (#6395) 08 November 2021, 22:01:29 UTC
6071cf6 Check results of all runtime function calls (#6389) * Check results of all runtime function calls This cherry-picks just the changes to callsites internal to Halide (and tests) from #6388. (It doesn't attempt to annotate runtime functions to enforce checking the results.) * Update write_debug_image.cpp * Add checks + comment to buffer_copy_aottest * Add comment to gpu_object_lifetime_aottest * Update memory_profiler_mandelbrot_aottest.cpp * Update user_context_insanity_aottest.cpp * Update process.cpp 08 November 2021, 20:13:44 UTC
a798909 Add halide_debug_assert() macro (#6390) * Add halide_debug_assert() macro Also convert usage of halide_assert()/HALIDE_CHECK() in hashmap.h and gpu_context_common.h to halide_debug_assert(), as all the usages looked to be appropriate for debug-mode only. (Rebased version of #6385, which this replaces) * appease clang-format 08 November 2021, 20:13:28 UTC
656c6b5 [hannk] Have CMake emit .s, .stmt, .ll files (#6392) 04 November 2021, 23:00:28 UTC
26ccb54 Support vectorized Select in OpenGLCompute backend (#6371) The ternary operator in GLSL does not work with vector types. While the mix function have overloads to boolean vectors, it is only supported in version 4.5, so it is not exactly portable. To work around this, we use the ternary operator on all elements of the vector type. Necessary for #6348. 04 November 2021, 00:35:13 UTC
c005b9f Support vectorization in OpenGLCompute backend (#6348) * Support vectorization in OpenGLCompute backend This patch adds support for vector load and store operations. First, a pass identifies the buffers whose loads and stores are all dense, aligned, and have the same number of lanes. Such buffers are declared with a vector base type and accessed accordingly. Loads and stores that do not satisfy those criteria are implemented as gathers and scatters from buffers whose base type is scalar. Resolves #4976. Partially resolves #1687. * Move buffer name instead of copy (clang-tidy) 04 November 2021, 00:32:20 UTC
657bb03 Fix for top-of-tree LLVM (#6386) * Fix for top-of-tree LLVM * Fix for older versions 03 November 2021, 23:29:38 UTC
76315a2 Vectorize Ramp in OpenGLCompute backend (#6372) Currently, ramps are generated as a number of independent scalar expressions that are finally gathered into a vector. For instance, indexing in vectorized code is filled with ramps like the following: ``` int _11 = int(1) * int(1); int _12 = _10 + _11; int _13 = int(2) * int(1); int _14 = _10 + _13; int _15 = int(3) * int(1); int _16 = _10 + _15; ivec4 _17 = ivec4(_10, _12, _14, _16); ``` This patch simplifies the generated code using a multiply add expression on a vector containing an arithmetic expression, such that the code is as follows: ``` ivec4 _11 = ivec4(0, 1, 2, 3) * int(1) + _10; ``` This is more performant due to vectorization, more compact, and more readable because the base and the stride are easily identifiable. 03 November 2021, 22:54:44 UTC
2cf3afb [hannk] Fix MeanOp (#6336) * [hannk] Fix MeanOp The `reducing()` method didn't handle negative values for indices, and didn't reverse the value of the axis as we do elsewhere, so results were incorrect. Also, we now parse and save the value of `keep_dims`, though I can't find evidence that it does much of anything: test cases pass different values for it but none of them fail (even though we ignore it), and at least one reference implementation I see doesn't seem to do anything with it. * Remove keep_dims handling for MeanOp 03 November 2021, 22:47:03 UTC
7ec8d70 Convert various halide_assert -> static_assert (#6383) The type-size checks in d3d12compute.cpp don't need to be runtime checks. 03 November 2021, 22:19:15 UTC
a227440 Remove halide_assert() from halide_default_device_wrap_native (#6381) This was inserted in https://github.com/halide/Halide/pull/6310, probably mistakenly, since `halide_assert()` in the Halide runtime is *not* a debug-only assertion). Instead of a controlled runtime failure, we just abort, which is not OK. 03 November 2021, 20:55:28 UTC
415ce0c Fix empty INSTALL_COMMAND in hannk super-build (#6387) * Fix empty INSTALL_COMMAND in hannk super-build * Fix 3.16 missing command * Fix the fix... 03 November 2021, 20:27:46 UTC
0d6b0f5 Fix for top-of-tree LLVM (#6380) 03 November 2021, 16:18:45 UTC
ac2673b Add super-build for cross-compiling HANNK (#6374) * Add super-build for cross-compiling HANNK * Relax CMake version 03 November 2021, 00:57:12 UTC
6070821 Update README for Halide 13. (#6378) 02 November 2021, 19:42:02 UTC
5b8f473 Fix for the crash from #6367 (#6375) * Skip empty boxes * Address the comments 02 November 2021, 15:36:19 UTC
4225eba Add helper for cross-compiling Halide generators. (#6366) * Add helper for cross-compiling Halide generators. Created a new function, `add_halide_generator`, that helps users write correct cross-compiling builds by establishing the following convention for creating a generator named `TARGET`: 1. Define Halide generators and libraries in the same project 2. Assume two builds: a host build and a cross build. 3. When creating a generator, check to see if we can load a pre-built version of the target. 4. If so, just use it. 5. If not, make sure the full Halide package is loaded and create a target for the generator. a. If `CMAKE_CROSSCOMPILING` is set, then _warn_ the user (the variable is unreliable on macOS) that something seems fishy. b. Create export rules for the generator. It creates a package `PACKAGE_NAME` and appends to its `EXPORT_FILE`. c. Create a custom target also named `PACKAGE_NAME` for building the generators. d. Create an alias `${PACKAGE_NAMESPACE}${TARGET}`. 6. Users are expected to use the alias in conjunction `add_halide_library`. Users can test the existence of `TARGET` to determine whether a pre-built one was loaded (and set additional properties if not). 7. Setting `${PACKAGE_NAME}_ROOT` is enough to load pre-built generators. `PACKAGE_NAME` is `${PROJECT_NAME}-halide_generators` by default. `PACKAGE_NAMESPACE` is `${PROJECT_NAME}::halide_generators::` by default. `EXPORT_FILE` is `${PROJECT_BINARY_DIR}/cmake/${PACKAGE_NAME}-config.cmake` by default. Users are free to avoid the helper if it would not fit their workflow. * Make HANNK use the new add_halide_generator helper 01 November 2021, 23:03:09 UTC
f5ce5f3 [hannk] Clean up aliasing (v2) (#6364) * wip * [hannk] Clean up aliasing (v2) The code for aliasing tensors was janky. This cleans it up and makes a clear distinction between aliasing done to overlay buffers with crop-and-translate, vs the aliasing done when we reshape tensors. We no longer allow a given tensor to do both of these, and we give preference to Reshape aliasing first. (Cherry-picked from #6321) * Move alias_type into shared ptr 01 November 2021, 20:40:36 UTC
1a1c97f [hannk] Add support for building/running for wasm (#6361) * [hannk] Allow disabling TFLite+Delegate build in CMake Preparatory work for allowing building of hannk with Emscripten; TFLite (and its dependees) problematic to build in that environment, but this will allow us to build a tflite-parser-only environment. (Note that more work is needed to get this working for wasm, as crosscompiling in CMake is still pretty painful; this work was split out to make subsequent reviews simpler) * [hannk] Add support for building/running for wasm * HANNK_BUILD_TFLITE_DELEGATE -> HANNK_BUILD_TFLITE * Use explicit host build strategy for cross compiling HANNK (#6365) * Ignore local emsdk clone * Fix usage of CMAKE_BUILD_TYPE * Only print the Halide target info once per CMake run * Fix Halide "cmake" target detection for Emscripten * Prefer target_link_options to _link_libraries when applicable * Validate, rather than find, NODE_JS_EXECUTABLE (set by emsdk) * Emscripten already wraps tests with node. * Add dependency on Android logging library. * For cross-compiling, find host tools instead of recursive call. Rather than shelling out via execute_process and potentially guessing the toolchain options wrong, expect to find our host tools (i.e. generators) in a package called "hannk_tools". The package is created by the host build via the CMake export() command. Importing this package in the cross build creates IMPORTED targets with the same names as our generators. We then use these generators rather than creating generators for the target build. * Rework cross-compiling script. * Respond to (easy) reviewer comments. * Add HANNK_AOT_HOST_ONLY option. Use in script. * [hannk] tests should only process .tflite files (#6368) currently, random dotfiles (e.g. .DS_Store on OSX) can creep in, causing bogus failures * Add comment about node wrapping. * Rename hannk_tools to hannk-halide_generators * Add comment about exporting targets. * Bump version to Halide 14.0.0 (#6369) Co-authored-by: Steven Johnson <srj@google.com> Co-authored-by: Alex Reinking <alex_reinking@berkeley.edu> 01 November 2021, 20:28:50 UTC
69d8ef0 Bump version to Halide 14.0.0 (#6369) 30 October 2021, 01:33:50 UTC
3c52df1 [hannk] tests should only process .tflite files (#6368) currently, random dotfiles (e.g. .DS_Store on OSX) can creep in, causing bogus failures 29 October 2021, 23:46:50 UTC
541bc37 [hannk] Allow disabling TFLite+Delegate build in CMake (#6360) * [hannk] Allow disabling TFLite+Delegate build in CMake Preparatory work for allowing building of hannk with Emscripten; TFLite (and its dependees) problematic to build in that environment, but this will allow us to build a tflite-parser-only environment. (Note that more work is needed to get this working for wasm, as crosscompiling in CMake is still pretty painful; this work was split out to make subsequent reviews simpler) * Update hannk_delegate.h * HANNK_BUILD_TFLITE_DELEGATE -> HANNK_BUILD_TFLITE 28 October 2021, 21:14:42 UTC
e10f104 Update Emscripten settings (#6362) The settings we use to build C++ in wasm were slightly out of date now that we've updated our runtime to Node instead of d8. Also drive-by gitignore fix. 28 October 2021, 17:34:27 UTC
1c7388a Allow users to use their own cuda contexts and streams in JIT mode (#6345) * Deprecate JIT runtime override methods that take void * * Make it possible to use custom cuda contexts and streams in JIT mode * Clean up comments * Tolerate null handlers in the JITUserContext These can come up if a JITUserContext is passed to something like copy_to_device before getting fully populated by passing it to a call to realize. * Remove reliance on dlsym in test and reuse the runtime's name resolution mechanism instead * Handle case where cuda and cuda-debug runtime modules both exist This change means we'll only ever create one built-in cuda context in this circumstance. * Slight simplification * Improve comments 28 October 2021, 17:25:58 UTC
4f573bf Add missing widening_absd patterns (#6359) * Add missing widening_absd patterns * Add a comment 28 October 2021, 02:05:29 UTC
8f1ae2a Use Node instead of d8 for Wasm AOT testing (#6356) * Use Node instead of d8 for Wasm AOT testing This requires the right version of Node is installed on your system. Since EMSDK often puts a too-old version of Node in the path, allow overriding via an env var. * wip 27 October 2021, 20:37:00 UTC
34534f5 [hannk] Add missing call to Interpreter::prepare in benchmark app (#6358) 27 October 2021, 20:35:39 UTC
a15ffda Add include for size_t in constants.h (#6353) * Add include for size_t in constants.h * Change to int 27 October 2021, 01:33:39 UTC
86cb6c7 Deprecate JIT runtime override methods that take void * (#6344) * Deprecate JIT runtime override methods that take void * * Clean up comments 26 October 2021, 23:12:52 UTC
6211da9 Add --help flag to rungenmain, fixing #5323 (#6354) 26 October 2021, 23:12:34 UTC
06a37ca Add to various OpVisitors to avoid overload warnings for some compilers (#6337) 26 October 2021, 17:23:23 UTC
47fa87f [hannk] Add a prepare() method for ops and interp (#6338) * [hannk] Add a prepare() method for ops and interp This adds a new method to the Interpreter, and to all ops, which allows the interpreter (and each op) to do any one-time preparation for future executions. Previously this was lumped into either the Interpreter's ctor, or the Ops various other methods, but this has some nice advantages at minimal cost: - Since the new prepare() returns an error value, it allows the Interpreter to do sanity checking at startup and return an error to the caller (rather than simply crashing); this makes using it in some runtime environments less painful. - Ops can use this to prep and cache information for multiple subsequent runs; initially, Conv and DepthwiseConv use this to calculate and cache the alignment requirements they need later on. This is unlikely to be a huge performance hit, but it is likely nonzero, and As an added bonus, this means that e.g. the map_bounds() method is no longer susceptible to runtime failures from Halide bounds queries. * Update interpreter.cpp * Update transforms.cpp * Update transforms.cpp 26 October 2021, 17:22:49 UTC
667836d Harvest IWYU changes for LLVM, WABT (#6341) A couple of minor hygiene changes, extracted from https://github.com/halide/Halide/pull/6251: - Clean up LLVM_Headers.h to uniformly use <> instead of "" and to alphabetize properly - Clean up WABT includes to reflect what we need more accurately 26 October 2021, 17:16:35 UTC
b34919f Fix wrong type in Ramp CodeGen for OpenGLCompute (#6349) The variable type of the Ramp in OpenGLCompute is assigned the type of the base member of the ramp, which is a scalar, while the ramp is a vector. Instead, we should use the type of the ramp instead to take vectorization into account. Partially resolves #1687. 26 October 2021, 17:09:48 UTC
ab57ab1 [hannk] augment SoftmaxOp to allow specifying axis (#6351) (basically equivalent to #6335 but for softmax) 26 October 2021, 17:07:44 UTC
50517cb [hannk] requantize() should never skip the operation (#6350) * [hannk] requantize() should never skip the operation Even if inq == outq, the incoming buffer can contain out-of-range values; we shouldn't try to optimize the op away, since it's cheap. * Update ops.cpp * Update ops.cpp 26 October 2021, 17:07:00 UTC
d6d7bbc Make halide_type_t and halide_type_of constexpr (#6340) * Make halide_type_t and halide_type_of constexpr This allows us to do a bit more at compile time in some cases; e.g., we can more reliably collapse things like `t == halide_type_t(int, 8)` into `t.as_u32() == literal-integer`, avoiding temporaries. It also makes it tractable to to do a `switch` on a series of `halide_type_t`, since we can now use halide_type_t::as_u32() as a constexpr. There were a number of places that did this in an ad-hoc manner previously; I updated those, and also converted at least one more repeated-if clause into a switch. (TBH, I'm not sure if I'm wild about the syntax, though; it is a bit weedy to scan. Suggestions welcome.) * Ensure there are no uninited vars in constexpr funcs * Update HalideRuntime.h 26 October 2021, 17:05:48 UTC
334e27a Specify template parameter of ScopedValue (#6352) 26 October 2021, 05:10:41 UTC
5e374bc Fix default device wrap native function (#6310) * Fix default device wrap native function Currently, an attempt to call device_wrap_native on a target that uses the default device wrap native function will result in an error of type halide_error_device_interface_no_device, namely in the OpenGLCompute and the Hexagon targets. This happens because the default wrap native function calls debug_log_and_validate_buf after the device_interface is set in halide_device_wrap_native but before the device handle is set, which is validated as a bad state. This patch removes the validation call and adds an assert for the handle much like the other wrap_native implementations in other targets. * Use approperiate error code 25 October 2021, 20:34:07 UTC
6d9737d Fix cuda-debug logging: fix incorrect threads_per_core when SM >= 8.0. fix device memory smaller than acutal size. (#6346) 25 October 2021, 20:12:24 UTC
ba81a06 Scheduling directive to set an explicit storage bound (#6327) * bound_allocation scheduling directive * Add a more specific error and test * Add a correctness test for bound_allocation * Remove debug output from test * Move expression * Per dim bound_storage * Update CMakeLists.txt * how hard can it be * Rename the error code * More detailed error message 25 October 2021, 16:22:38 UTC
297c30a Fix Makefile for LLVM11 (#6343) 22 October 2021, 16:30:56 UTC
6c9224a Fix HelloWasm (#6342) - Add workaround for Cross-origin isolation requirements - Add CXXFLAGS to allow benchmarks to compile 21 October 2021, 23:16:36 UTC
0078880 Add support for AMX instructions (#5818) * Add support for AMX tile instructions * Make AMX transform opt-in with memory type * Clean up tiled_matmul test * Handle AMX intrinsic attributes better * Format * Fix test to behave like other tests * Add doc and missing load check * Format * Throw error if user requests AMX for invalid operation * Add Tile lowering pass to makefile * Use spaces in Makefile * Place AMX instrinsics into a separate module (x86_amx.ll) This will only be included if LLVM >= 12 is used to build Halide * Fix CreateAlignedLoad() call in CodeGen_X86 Recent changes in LLVM trunk made the previous calling convention deprecated (and thus compiling with warning/error) * fix exporting to module * add llvm funcs for su, us, uu amx variants * add other amx intrinsics to intrinsic_defs * match with unsigned 8 bit integers This matching happens for the left and right side, each determining whether that side is unsigned or signed. In the end the proper 1024 byte buffer is created with (un)signed. * match for 32 bit integer and guard unsigned amx on llvm 13 * adjust test to cover unsigned tile operations * guard properly with llvm 12 * create explicit error if failed to use tile operations * pass types as template params rather than boolean This makes the intention clearer * clang-format patch * add x86_amx to makefile's runtime components * make tiled_matmul compatible with c++11 * add mattrs required for amx * fix formatting issues * remove outdated FIXME comments * add bf16 tile operations to the runtime * create a schedule that should map to amx * create full amx-bf16 schedule * allow amx operations to yield f32s * accept 32 bit float stores * add support for bf16 * add missing bf16 intrinsics * fix striding error when loading matrix * add checks to verify bf16 result * fix scaling of col_bytes on matmul call * move brace to previous line * derive result type using a function rather than lambda * run clang tidy and format * have tile_store return i32 * make is_3d_tile_index robust to indexing changes * apply formatting suggestions * both first and second can be const qualified * remove trailing whitespace in unformatted section * make requested style changes * rename NewMatmul -> Matmul * fix warning about missing return value * use get_1d_tile_index to handle special case When using `Buffer` instead of `ImageParam` the `Ramp` expression generated is 1D instead of 2D, therefore we recognize this with a special case. The lanes are still matched against the dimensions of the LHS 3d tile lanes. * add correctness test for AMX instructions * correctness part has been separated out * remove unused variables Co-authored-by: John Lawson <john@codeplay.com> Co-authored-by: Thales Sabino <thales@codeplay.com> Co-authored-by: Steven Johnson <srj@google.com> Co-authored-by: Frederik Engels <frederik.engels@codeplay.com> 21 October 2021, 17:52:39 UTC
05107ca Fix WASM datalayout for top-of-tree LLVM (#6339) 21 October 2021, 17:23:31 UTC
ecf69b0 Add support for CUDA capability 8.6 (#6334) * Add support for CUDA capability 8.6 * add assertion to guard LLVM version * fallback to sm80 if LLVM < 13.0 21 October 2021, 04:16:55 UTC
27f975f Add ability to pass a user context in JIT mode (#6313) * Change type of first arg to all JITHandlers and expose struct to users * Make it possible to pass a custom JITUserContext per realize call * More comments * Fix type in python bindings * Fix type in python bindings * Fix more types in python bindings * Add user_context-accepting variants of other realize-like functions * Revert tests back to the way they are on master but with comments explaining why they are the way they are * Add example of passing a custom context to copy_to_host * Revert test to be closer to master. It was that way for a reason * The first arg to get_library_symbol isn't actually a user_context * Add copy_to_device example too * Fix python * Make bad_buf even worse * Comment clarifications 20 October 2021, 22:32:08 UTC
c3641b6 [hannk] augment L2NormOp to allow specifying axis (#6335) 20 October 2021, 00:16:04 UTC
d80bb23 Add a new unsigned division method (#6322) * Add a new unsigned division method It uses averages rounding up instead of averages rounding down, to reduce instruction count on x86. Division by 7 before: vpmulhuw .LCPI0_1(%rip), %ymm0, %ymm1 vpsubw %ymm1, %ymm0, %ymm0 vpsrlw $1, %ymm0, %ymm0 vpaddw %ymm1, %ymm0, %ymm0 vpsrlw $2, %ymm0, %ymm0 Division by 7 after: vpmulhuw .LCPI0_1(%rip), %ymm0, %ymm1 vpavgw %ymm0, %ymm1, %ymm0 vpsrlw $2, %ymm0, %ymm0 * Remove debugging code * Add comment elaborating on why this is a good idea 19 October 2021, 16:43:07 UTC
deeb6bc Rewrite double/triple narrowing from float on ARM (#6305) * Rewrite double/triple narrowing from float on ARM 19 October 2021, 16:40:16 UTC
7613f9d [hannk] Improve GatherOp (#6328) We (mostly) implemented GatherOp for TFLite's Gather op, but missed some things: - There's a batch_dim param for Gather that we were ignoring. I added code to fill it in, but we punt for values != 0, because I haven't yet found a test case that handles it. Should be easy to fill in when we do. - TFLite's GatherNd op (and NNAPI's GATHER op) allow for the indices arg to be multidimensional; I rewrote the code to handle this and it's passing the acceptance tests for NNAPI's cases. (It doesn't yet handle the GatherNd op because, again, I haven't found a good test case. Should be simple to do when we do.) 18 October 2021, 16:55:35 UTC
8d098de [hannk] Restructure BinaryOp to allow adding more temporary types (#6326) Change is a no-op as written, but I'd like to land it so this change doesn't get lost -- it's handy for debugging pipelines that happen to use op/type variants we don't yet support (eg arithmetic on floats), which can unblock the ability to run more tests (albeit not efficiently). 18 October 2021, 16:52:49 UTC
cd8146d [hannk] Fix override annotation in hannk (#6315) Minor hygiene: add explicit override annotations and enable the compiler warnings. (I was about to tweak some of the virtual functions and this has been bothering me for a while.) 18 October 2021, 16:47:48 UTC
923025a [hannk] Fix assert in dconv (#6320) 14 October 2021, 20:27:00 UTC
back to top