### Halide Basics Tutorial Example Source: https://halide-lang.org/docs/tutorial_2lesson_03_debugging_1_8cpp-example Illustrates the fundamental concepts of the Halide language, including defining functions, stages, and basic image manipulation. This is typically the starting point for learning Halide. ```cpp #include "Halide.h" // Example Halide function definition int main(int argc, char **argv) { Halide::Buffer input = ...; Halide::Var x, y, c; // Define a simple Halide function Halide::Func brighter; brighter(x, y, c) = Halide::cast(Halide::min(255, input(x, y, c) * 2)); // ... (further code for compilation and execution) return 0; } ``` -------------------------------- ### Using Halide from CMake Example Source: https://halide-lang.org/docs/classcmdline_1_1detail_1_1lexical__cast__t_3_01_target_00_01_source_00_01true_01_4-members Shows how to use an installed Halide library within a CMake project. This snippet focuses on finding the Halide installation and linking your executable against it. ```cmake # CMakeLists.txt to use an installed Halide cmake_minimum_required(VERSION 3.10) project(MyHalideApp) # Find the Halide package, assuming it's installed # You might need to set CMAKE_PREFIX_PATH to your Halide installation directory find_package(Halide REQUIRED) # Create your application executable add_executable(my_app main.cpp) # Link your application against the Halide library target_link_libraries(my_app PRIVATE Halide::Halide) # Ensure Halide headers are included target_include_directories(my_app PRIVATE ${Halide_INCLUDE_DIRS}) ``` -------------------------------- ### Halide Examples Source: https://halide-lang.org/docs/structcmdline_1_1detail_1_1is__same_3_01_t_00_01_t_01_4-members This section provides access to various examples demonstrating Halide usage, including building, contributing, testing, and platform-specific applications. ```APIDOC ## Halide Examples ### Description Provides access to various examples demonstrating Halide usage, including building, contributing, testing, and platform-specific applications. ### Method N/A ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Basic Halide Tutorial Example Source: https://halide-lang.org/docs/tutorial_2lesson_10_aot_compilation_generate_8cpp-example Demonstrates the fundamental usage of the Halide API for image processing. This example covers defining a simple image pipeline. ```cpp #include "Halide.h" #include int main(int argc, char **argv) { Halide::Buffer input = Halide::Tools::load_image("input.png"); // Define a Halide pipeline Halide::Var x, y; Halide::Func brighter; brighter(x, y) = Halide::cast(input(x, y) * 1.2f); // Schedule and realize the pipeline brighter.vectorize(x, 8).parallel(y); Halide::Buffer output = brighter.realize({input.width(), input.height()}); // Save the output image Halide::Tools::save_image(output, "output.png"); std::cout << "Success!" << std::endl; return 0; } ``` -------------------------------- ### Halide Func Realization with Examples Source: https://halide-lang.org/docs/_func_8h_source Shows how to evaluate a Halide Func over a domain and return the result as a buffer. Includes examples for single-value and multi-value functions, and how to pass Param and ImageParam arguments. ```cpp /** Evaluate this function over some rectangular domain and return the resulting buffer or buffers. ... */ Realization realize(std::vector sizes = {}, const Target &target = Target()); /** Same as above, but takes a custom user-provided context to be passed to runtime functions. ... */ Realization realize(JITUserContext *context, std::vector sizes = {}, const Target &target = Target()); /** Evaluate this function into an existing allocated buffer or buffers. ... */ void realize(const std::vector> &buffers, ...); // Example: Single value realization f(x) = sin(x); Buffer im = f.realize(...); // Example: Multi-value realization f(x) = Tuple(x, sin(x)); Realization r = f.realize(...); Buffer im0 = r[0]; Buffer im1 = r[1]; // Example: Using Param and ImageParam Param p(42); ImageParam img(Int(32), 1); f(x) = img(x) + p; Buffer arg_img(10, 10); // Target t = get_jit_target_from_environment(); Buffer result = f.realize({10, 10}, t); // Example: Using initializer list for arguments Buffer result = f.realize({10, 10}, t, { { p, 17 }, { img, arg_img } }); ``` -------------------------------- ### Halide Examples Source: https://halide-lang.org/docs/namespace_halide_1_1_runtime_1_1_internal_1_1_qurt Indicates the presence of example code or usage demonstrations for Halide. ```Halide â–ºExamples ``` -------------------------------- ### Halide Examples and Usage Source: https://halide-lang.org/docs/structcmdline_1_1detail_1_1is__same-members Documentation on how to use Halide through various examples, including build system integration, specific hardware backends, and language bindings. ```APIDOC ## Halide Examples and Guides ### Description This section outlines various examples and guides for using Halide, covering build system integration, targeting specific hardware, and leveraging language bindings. ### Method N/A (Documentation Outline) ### Endpoint N/A ### Examples #### Building Halide with CMake ##### Description Instructions on how to build the Halide compiler and libraries using the CMake build system. ##### Method N/A ##### Endpoint N/A #### Contributing CMake code to Halide ##### Description Guidelines for developers contributing CMake-related code to the Halide project. ##### Method N/A ##### Endpoint N/A #### Fuzz testing ##### Description Information and methods for performing fuzz testing on Halide to discover potential bugs and vulnerabilities. ##### Method N/A ##### Endpoint N/A #### Using Halide from your CMake build ##### Description Instructions on how to integrate Halide into your own CMake-based projects. ##### Method N/A ##### Endpoint N/A #### Halide for Hexagon HVX ##### Description Specific guidance and examples for utilizing Halide with Hexagon Heterogeneous Compute (HVX) processors. ##### Method N/A ##### Endpoint N/A #### Halide Bindings for Python ##### Description Documentation on how to use Halide from Python, including installation and usage of Python bindings. ##### Method N/A ##### Endpoint N/A #### Running and Benchmarking Halide Generators ##### Description Procedures for executing Halide generators and measuring their performance. ##### Method N/A ##### Endpoint N/A #### Testing ##### Description Overview of the testing framework and procedures for Halide. ##### Method N/A ##### Endpoint N/A #### Vulkan Support for Halide ##### Description Information on using Halide with the Vulkan graphics API for GPU acceleration. ##### Method N/A ##### Endpoint N/A #### WebAssembly Support for Halide ##### Description Details on compiling and running Halide code in WebAssembly environments. ##### Method N/A ##### Endpoint N/A #### WebGPU support for Halide ##### Description Information regarding Halide's support for the WebGPU API for modern graphics and compute. ##### Method N/A ##### Endpoint N/A #### Topics ##### Description Links to various topics and conceptual explanations related to Halide. ##### Method N/A ##### Endpoint N/A #### Namespaces ##### Description Reference to Halide's namespaces for organizing code elements. ##### Method N/A ##### Endpoint N/A #### Classes ##### Description Detailed documentation for Halide's classes. ##### Method N/A ##### Endpoint N/A ###### Class List ####### Description A list of all classes available in the Halide API. ####### Method N/A ####### Endpoint N/A ###### Class: cmdline ####### Description Provides command-line argument parsing capabilities. ####### Method N/A ####### Endpoint N/A ####### Nested Namespace: detail ``` -------------------------------- ### Install CMake on Windows using winget Source: https://halide-lang.org/docs/md_doc_2_building_halide_with_c_make Installs CMake on Windows using the Windows Package Manager (winget). This is a convenient command-line method for installing applications on Windows. ```bash winget install Kitware.CMake ``` -------------------------------- ### Install Ninja using winget Source: https://halide-lang.org/docs/md_doc_2_building_halide_with_c_make Installs the Ninja build system on Windows using the Windows Package Manager (winget). ```bash winget install Ninja-build.Ninja ``` -------------------------------- ### Halide compute_with example Source: https://halide-lang.org/docs/_func_8h_source Shows how to fuse stages using compute_with, explaining the parent-child relationship for fused computations and illustrating with code examples. ```Halide input(x, y) = x + y; f(x, y) = input(x, y); f(x, y) += 5; g(x, y) = x - y; g(x, y) += 10; f.compute_with(g, y); f.update().compute_with(g.update(), y); ``` -------------------------------- ### Install Ninja using APT Source: https://halide-lang.org/docs/md_doc_2_building_halide_with_c_make Installs the Ninja build system on Ubuntu/Debian Linux using the APT package manager. ```bash apt install ninja-build ``` -------------------------------- ### Install Halide with CMake (Multi-Config) Source: https://halide-lang.org/docs/md_doc_2_building_halide_with_c_make Installs Halide using CMake for multi-configuration generators like Visual Studio. It requires specifying the configuration (e.g., Release) and an installation prefix. ```bash cmake --install ./build --prefix /path/to/Halide-install --config Release ``` ```bash cmake --install .\build --prefix X:\path\to\Halide-install --config Release ``` -------------------------------- ### Halide Input Image Tutorial Example Source: https://halide-lang.org/docs/tutorial_2lesson_03_debugging_1_8cpp-example Shows how to load and use an input image within a Halide pipeline. This example covers the process of making external image data accessible to Halide functions. ```cpp #include "Halide.h" #include #include // Example of loading an input image into a Halide buffer int main(int argc, char **argv) { // Assuming 'load_image' function exists and returns a Halide::Buffer Halide::Buffer input = load_image("path/to/your/image.png"); Halide::Var x, y, c; Halide::Func f; f(x, y, c) = input(x, y, c); // ... (further code for compilation and execution) return 0; } ``` -------------------------------- ### Install Ninja using Homebrew Source: https://halide-lang.org/docs/md_doc_2_building_halide_with_c_make Installs the Ninja build system on macOS using the Homebrew package manager. ```bash brew install ninja ``` -------------------------------- ### Get JIT Externs Source: https://halide-lang.org/docs/class_halide_1_1_pipeline Returns the map of previously installed externs. ```APIDOC ## GET /get_jit_externs ### Description Returns the map of previously installed externs. It is an empty map unless set otherwise. ### Method GET ### Endpoint /get_jit_externs ### Parameters None ### Response #### Success Response (200) - **externs** (const std::map< std::string, JITExtern > &) - The map of installed externs. #### Response Example ```json { "externs": { "my_external_func": "..." } } ``` ``` -------------------------------- ### Clone and Bootstrap Dawn Repository Source: https://halide-lang.org/docs/md_doc_2_web_g_p_u Instructions for cloning the Dawn repository and setting up the gclient configuration to include Node.js bindings, a prerequisite for building Dawn's Node.js components. ```bash # Clone the Dawn repository git clone https://dawn.googlesource.com/dawn cd dawn # Copy the gclient configuration for Node.js bindings cp scripts/standalone-with-node.gclient .gclient # Fetch dependencies and toolchains gclient sync ``` -------------------------------- ### Get JIT Externs Source: https://halide-lang.org/docs/_pipeline_8h_source Retrieves the map of previously installed externs used by JIT compilation. ```APIDOC ## const std::map &get_jit_externs() ### Description Return the map of previously installed externs. Is an empty map unless set otherwise. ### Method GET ### Endpoint /websites/halide-lang ### Response #### Success Response (200) - **externs** (std::map) - The map of installed JIT externs. #### Response Example ```json { "externs": { "my_external_func": { "ptr": "0x12345678", "call_conv": "halide_default_call_extern" } } } ``` ``` -------------------------------- ### Get JIT Externs Source: https://halide-lang.org/docs/class_halide_1_1_pipeline Returns the map of previously installed externs. Returns an empty map if none have been set. ```c++ const std::map& Halide::Pipeline::get_jit_externs() ``` -------------------------------- ### Halide Tutorial: Lesson 01 - Basics (C++) Source: https://halide-lang.org/docs/tutorial_2lesson_01_basics_8cpp-example Introduces the fundamental concepts of Halide, demonstrating how to define and compile a simple image processing pipeline. This is the first step in learning Halide. ```cpp #include "Halide.h" #include int main(int argc, char **argv) { // Declare a Halide Func Halide::Func brighter; // Declare Halide Var Halide::Var x, y; // Define the Func // brighter(x, y) = a_pixel(x, y) * 2.0f; brighter(x, y) = Halide::cast(Halide::min(255, Halide::cast(Halide::loadImage("images/small_gray.png").rgb_to_grayscale(x, y)) * 2)); // Define the output. // brighter.output_buffer(x, y, Halide::UInt(8)); // Visualize the output brighter.realize(100, 100); // Save the output Halide::save_image(brighter.realize({100, 100}), "brighter.png"); std::cout << "Success!" << std::endl; return 0; } ``` -------------------------------- ### Halide Python Bindings Example Source: https://halide-lang.org/docs/tutorial_2lesson_11_cross_compilation_8cpp-example Demonstrates how to use Halide's Python bindings for image processing tasks. This example shows basic image loading and manipulation using Halide within a Python environment. ```python import halide # Assuming a Halide function 'im' is defined and compiled # For example: # x, y, c = halide.expr.var('x'), halide.expr.var('y'), halide.expr.var('c') # input_image = halide.Image(100, 100, 3) # im = halide.compute_relu(input_image[x, y, c]) # Load an input image (replace with actual image loading logic) # input_buffer = halide.Buffer(width, height, channels) # halide.load_image("path/to/your/image.png", input_buffer) # Define a simple Halide pipeline (example: identity function) # x, y, c = halide.expr.var('x'), halide.expr.var('y'), halide.expr.var('c') # input = halide.ImageParam(halide.UInt(8), 3, "input") # output = halide.compute_relu(input[x, y, c]) # pipeline = halide.Pipeline(output) # Compile the pipeline (if not already compiled) # compiled_pipeline = pipeline.compile() # Create an output buffer # output_buffer = halide.Buffer(width, height, channels) # Run the pipeline # compiled_pipeline.realize(output_buffer) # Save or process the output image # halide.save_image(output_buffer, "output.png") print("Halide Python bindings example executed.") ``` -------------------------------- ### Get JIT External Functions Source: https://halide-lang.org/docs/_pipeline_8h_source Retrieves the map of previously installed externs. Returns an empty map if no externs have been set. ```cpp /** Return the map of previously installed externs. Is an empty * map unless set otherwise. */ const std::map &get_jit_externs(); ``` -------------------------------- ### Halide Basics Tutorial (C++) Source: https://halide-lang.org/docs/tutorial_2lesson_10_aot_compilation_run_8cpp-example Demonstrates the fundamental usage of the Halide API, including defining functions and stages. This is the first lesson in the Halide tutorial series. ```C++ #include "Halide.h" #include int main(int argc, char **argv) { Halide::Buffer input = Halide::Buffer::make_interleaved(100, 100, 3); // Fill the buffer with some values for (int y = 0; y < 100; y++) { for (int x = 0; x < 100; x++) { for (int c = 0; c < 3; c++) { input(x, y, c) = x + y + c; } } } Halide::Var x, y, c; Halide::Func brighten; brighten(x, y, c) = input(x, y, c) + 100; // The schedule can be very simple for simple functions. // We can just call realize directly. Halide::Buffer output = brighten.realize(100, 100, 3); // Verify the output (optional) for (int y = 0; y < 100; y++) { for (int x = 0; x < 100; x++) { for (int c = 0; c < 3; c++) { if (output(x, y, c) != (x + y + c + 100)) { std::cerr << "Error!" << std::endl; return -1; } } } } std::cout << "Success!" << std::endl; return 0; } ``` -------------------------------- ### Manage JIT Externs (C++) Source: https://halide-lang.org/docs/_pipeline_8h_source Provides methods to get and set external C functions or Funcs for JIT compilation. 'get_jit_externs' returns a map of installed externs, while 'set_jit_externs' installs a new set. Dependencies include Halide's std::map, JITExtern, and std::string. ```c++ const std::map< std::string, JITExtern > & get_jit_externs() void set_jit_externs(const std::map< std::string, JITExtern > &externs) ``` -------------------------------- ### Get Vulkan Layer Names (C) Source: https://halide-lang.org/docs/_halide_runtime_vulkan_8h Retrieves the currently set Vulkan layer names. This is useful for debugging or introspection of the Vulkan setup. ```c const char * halide_vulkan_get_layer_names(void *_user_context) ``` -------------------------------- ### Basic Halide Tutorial (C++) Source: https://halide-lang.org/docs/tutorial_2lesson_09_update_definitions_8cpp-example Demonstrates the fundamental usage of the Halide language, likely involving defining and running simple image processing pipelines. This serves as an entry point for new users to understand Halide's core concepts. ```cpp // tutorial/lesson_01_basics.cpp // This file is a placeholder and does not contain actual code. ``` ```cpp // tutorial/lesson_02_input_image.cpp // This file is a placeholder and does not contain actual code. ``` ```cpp // tutorial/lesson_03_debugging_1.cpp // This file is a placeholder and does not contain actual code. ``` -------------------------------- ### Install Doxygen on Windows using winget Source: https://halide-lang.org/docs/md_doc_2_building_halide_with_c_make Installs the Doxygen documentation system on Windows using the Windows Package Manager (winget). This is required for building Halide's documentation. ```bash winget install DimitriVanHeesch.Doxygen ``` -------------------------------- ### Get Iterator to Start of Buffer Dimension in Halide Source: https://halide-lang.org/docs/class_halide_1_1_runtime_1_1_buffer_1_1_dimension Provides an iterator pointing to the minimum coordinate of a buffer dimension. This is fundamental for iterating over buffer elements. ```c++ template inline iterator Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Dimension::begin() const ``` -------------------------------- ### Halide Vulkan Support Source: https://halide-lang.org/docs/classcmdline_1_1detail_1_1lexical__cast__t_3_01_target_00_01_source_00_01true_01_4 Details on how to leverage Vulkan for GPU acceleration with Halide. This section likely covers setup and examples of using Vulkan pipelines within Halide. ```c++ // C++ code related to Halide Vulkan support ``` -------------------------------- ### Halide Basics Tutorial (C++) Source: https://halide-lang.org/docs/tutorial_2lesson_11_cross_compilation_8cpp-example Illustrates the fundamental concepts of the Halide programming language using C++. This example covers defining simple image processing functions and understanding Halide's expression syntax. ```cpp #include #include int main(int argc, char **argv) { Halide::Buffer input = Halide::create_buffer(100, 100, 3); // Fill input buffer with some data (e.g., a gradient) for (int y = 0; y < input.height(); ++y) { for (int x = 0; x < input.width(); ++x) { for (int c = 0; c < input.channels(); ++c) { input(x, y, c) = (x + y + c * 50) % 256; } } } Halide::Var x, y, c; Halide::Func brighter; // Define the Halide 'brighter' function // For each pixel (x, y, c), add 50 to its value, clamping at 255 brighter(x, y, c) = Halide::min(input(x, y, c) + 50, 255); // Describe how to process the image on different backends // For CPU, we can simply realize it directly brighter.vectorize(x, 8).parallel(y); // Realize the function into an output buffer Halide::Buffer output = brighter.realize(input.width(), input.height(), input.channels()); // You can now inspect or save the 'output' buffer std::cout << "Halide basics tutorial executed. Output buffer created." << std::endl; return 0; } ``` -------------------------------- ### Get Slice Beginning Index Source: https://halide-lang.org/docs/struct_halide_1_1_internal_1_1_shuffle Returns the starting index of a slice within the vector arguments. This is used in conjunction with `is_slice` to define the slice boundaries. ```cpp int Halide::Internal::Shuffle::slice_begin() const ``` -------------------------------- ### Instance and Adapter Management Source: https://halide-lang.org/docs/globals_w Functions for managing WebGPU instances and adapters, including requesting adapters and enumerating features. ```APIDOC ## wgpuInstanceRequestAdapterF() ### Description Requests an adapter from the WebGPU instance. ### Method GET ### Endpoint /webgpu/instance/requestAdapterF ### Parameters #### Query Parameters - **instance** (WGPUInstance) - Required - The WebGPU instance. - **options** (WGPURequestAdapterOptions) - Optional - Options for requesting the adapter. ### Response #### Success Response (200) - **adapter** (WGPUAdapter) - The requested adapter. #### Response Example ```json { "adapter": "" } ``` ``` ```APIDOC ## wgpuInstanceWaitAny() ### Description Waits for any of the given instances to become ready. ### Method GET ### Endpoint /webgpu/instance/waitAny ### Parameters #### Query Parameters - **instances** ([WGPUInstance]) - Required - A list of WebGPU instances. ### Response #### Success Response (200) - **readyInstances** ([WGPUInstance]) - A list of instances that are ready. #### Response Example ```json { "readyInstances": [ "", "" ] } ``` ``` ```APIDOC ## WGPULoadOp Enumeration ### Description Defines the load operations for render targets. ### Values - **WGPULoadOp_Clear**: Clear the target. - **WGPULoadOp_Load**: Load the existing content. - **WGPULoadOp_Undefined**: Undefined load operation. - **WGPULoadOp_Force32**: Force 32-bit size. ``` ```APIDOC ## WGPULoggingCallback and WGPULoggingType ### Description Callback function and type for logging messages. ### Values (WGPULoggingType) - **WGPULoggingType_Verbose**: Verbose logging. - **WGPULoggingType_Info**: Informational logging. - **WGPULoggingType_Warning**: Warning logging. - **WGPULoggingType_Error**: Error logging. - **WGPULoggingType_Force32**: Force 32-bit size. ``` ```APIDOC ## WGPUMapMode Enumeration ### Description Defines the mapping modes for buffers. ### Values - **WGPUMapMode_None**: No mapping. - **WGPUMapMode_Read**: Read mapping. - **WGPUMapMode_Write**: Write mapping. - **WGPUMapMode_Force32**: Force 32-bit size. ``` ```APIDOC ## WGPUMipmapFilterMode Enumeration ### Description Defines the mipmap filter modes. ### Values - **WGPUMipmapFilterMode_Nearest**: Nearest mipmap filter. - **WGPUMipmapFilterMode_Linear**: Linear mipmap filter. - **WGPUMipmapFilterMode_Undefined**: Undefined mipmap filter mode. - **WGPUMipmapFilterMode_Force32**: Force 32-bit size. ``` ```APIDOC ## wgpuPipelineLayoutReference() and wgpuPipelineLayoutRelease() ### Description Reference and release operations for pipeline layouts. ### Method POST ### Endpoint /webgpu/pipeline-layout/{operation} ### Parameters #### Path Parameters - **operation** (string) - Required - 'reference' or 'release'. #### Request Body - **pipelineLayout** (WGPUPipelineLayout) - Required - The pipeline layout object. ``` ```APIDOC ## wgpuPipelineLayoutSetLabel() ### Description Sets a label for the pipeline layout. ### Method POST ### Endpoint /webgpu/pipeline-layout/setLabel ### Parameters #### Request Body - **pipelineLayout** (WGPUPipelineLayout) - Required - The pipeline layout object. - **label** (string) - Required - The label to set. ``` ```APIDOC ## WGPUPowerPreference Enumeration ### Description Defines the power preference for adapter selection. ### Values - **WGPUPowerPreference_LowPower**: Prefer low power. - **WGPUPowerPreference_HighPerformance**: Prefer high performance. - **WGPUPowerPreference_Undefined**: Undefined power preference. - **WGPUPowerPreference_Force32**: Force 32-bit size. ``` ```APIDOC ## WGPUPresentMode Enumeration ### Description Defines the present modes for swap chains. ### Values - **WGPUPresentMode_Immediate**: Immediate presentation. - **WGPUPresentMode_Mailbox**: Mailbox presentation. - **WGPUPresentMode_Fifo**: FIFO presentation. - **WGPUPresentMode_Force32**: Force 32-bit size. ``` ```APIDOC ## WGPUPrimitiveTopology Enumeration ### Description Defines the primitive topologies for rendering. ### Values - **WGPUPrimitiveTopology_PointList**: Point list. - **WGPUPrimitiveTopology_LineList**: Line list. - **WGPUPrimitiveTopology_LineStrip**: Line strip. - **WGPUPrimitiveTopology_TriangleList**: Triangle list. - **WGPUPrimitiveTopology_TriangleStrip**: Triangle strip. - **WGPUPrimitiveTopology_Undefined**: Undefined primitive topology. - **WGPUPrimitiveTopology_Force32**: Force 32-bit size. ``` -------------------------------- ### Get Block and Serial Extents Source: https://halide-lang.org/docs/struct_halide_1_1_internal_1_1_autoscheduler_1_1_loop_nest Calculates the start and end extents for a specific block within a serial loop. This method is important for understanding the bounds of computations. ```cpp std::pair< int64_t, int64_t > Halide::Internal::Autoscheduler::LoopNest::get_block_and_serial_extents(const LoopNest * _block_) const ``` -------------------------------- ### Get Default Device API for Target (C++) Source: https://halide-lang.org/docs/_device_interface_8h Determines the default DeviceAPI that Halide selects for a given target when DeviceAPI::Default_GPU is specified. This is crucial for GPU acceleration setup. ```cpp DeviceAPI Halide::get_default_device_api_for_target(const Target &t) ``` -------------------------------- ### Halide Input Image Tutorial (C++) Source: https://halide-lang.org/docs/examples Demonstrates how to load an input image into a Halide pipeline for processing. Covers defining input placeholders and loading image data. ```cpp #include "Halide.h" #include int main(int argc, char **argv) { Halide::Buffer input = Halide::load_image("input.png"); Halide::Var x, y; Halide::Func brighter; brighter(x, y) = Halide::cast(Halide::min(255, Halide::cast(input(x, y)) + 50)); brighter.realize("output.png"); std::cout << "Successfully generated brighter image!" << std::endl; return 0; } ``` -------------------------------- ### Halide GPUCompilationCache kernel_state_setup() Function Source: https://halide-lang.org/docs/class_halide_1_1_internal_1_1_g_p_u_compilation_cache The kernel_state_setup function prepares the state for a GPU kernel compilation. It takes a user context, pointers for state setup, the context, the result module state, the compilation function, and any necessary arguments. ```cpp template template HALIDE_MUST_USE_RESULT bool Halide::Internal::GPUCompilationCache< ContextT, ModuleStateT >::kernel_state_setup ( void * _user_context_, void ** _state_ptr_ptr_, ContextT _context_, ModuleStateT & _result_, CompileModuleT _f_, Args... _args_ ) ``` -------------------------------- ### Halide Basics Tutorial (C++) Source: https://halide-lang.org/docs/examples Introduction to Halide, covering fundamental concepts and syntax for defining image processing pipelines. Demonstrates basic function definition and usage. ```cpp #include "Halide.h" #include int main(int argc, char **argv) { // Define Halide variables Halide::Var x, y; // Define a Halide function representing an image Halide::Func brighter; // Define the computation for the function // Here, we're simply adding 50 to each pixel value. brighter(x, y) = Halide::cast(Halide::min(255, Halide::cast(Halide::load_input("input"))(x, y) + 50)); // Realize the function to produce an output image. // This step compiles and executes the Halide pipeline. brighter.realize("output.png"); std::cout << "Successfully generated brighter image!" << std::endl; return 0; } ``` -------------------------------- ### Get Vectorized Loop Index from Pure Stage Source: https://halide-lang.org/docs/struct_halide_1_1_internal_1_1_autoscheduler_1_1_loop_nest Retrieves the vectorized loop index starting from a pure stage within the LoopNest. This function works from the root of the loop nest. ```c++ int Halide::Internal::Autoscheduler::LoopNest::get_vectorized_loop_index_from_pure_stage(const LoopNest& _root_) const ``` -------------------------------- ### Halide Input Image Tutorial (C++) Source: https://halide-lang.org/docs/tutorial_2lesson_12_using_the_gpu_8cpp-example Shows how to load and process an input image using Halide. This example focuses on handling image data as input to a Halide pipeline. ```cpp #include "Halide.h" #include "HalideBuffer.h" #include "tools/halide_image_io.h" int main(int argc, char **argv) { Halide::Buffer input = Halide::Tools::load_image("input.png"); Halide::Var x, y; Halide::Func brighter; // Process the input image brighter(x, y) = Halide::cast(input(x, y) * 1.2f); // Realize the function to an output buffer Halide::Buffer output(input.width(), input.height()); brighter.realize(output); Halide::Tools::save_image(output, "output.png"); return 0; } ``` -------------------------------- ### Get minimum bound in Span Source: https://halide-lang.org/docs/anderson2021_2_function_d_a_g_8h_source This C++ function returns the minimum value of a Span object. It retrieves the 'min_' member variable, representing the start of the span's range. ```cpp int64_t min() const { return min_; } ``` -------------------------------- ### Get Section Contents and Iterators - C++ Source: https://halide-lang.org/docs/class_halide_1_1_internal_1_1_elf_1_1_section Provides access to the contents of an ELF section and iterators to traverse them. `get_contents` returns a constant reference to the content vector, while `contents_begin` returns an iterator to the start of the contents. ```C++ inline const std::vector& get_contents() const // Definition at line 365 of file Elf.h. ``` ```C++ inline contents_iterator contents_begin() // Definition at line 368 of file Elf.h. ``` -------------------------------- ### Halide Using the GPU Example (C++) Source: https://halide-lang.org/docs/examples Demonstrates how to offload Halide computations to a GPU (e.g., CUDA or OpenCL). Shows how to use GPU-specific scheduling directives. ```cpp #include "Halide.h" #include int main(int argc, char **argv) { Halide::Buffer input = Halide::load_image("input.png"); Halide::Var x, y; Halide::Func brighter; brighter(x, y) = Halide::cast(Halide::min(255, Halide::cast(input(x, y)) + 50)); // Schedule the function to run on the GPU // This requires Halide to be compiled with GPU support (e.g., CUDA or OpenCL). // Example for CUDA: // brighter.gpu_tile(x, y, 16, 16); // Tile for GPU execution // Example for OpenCL: // brighter.opencl_tile(x, y, 16, 16); // As a fallback or if GPU support is not guaranteed, you can specify a fallback: // brighter.gpu_tile(x, y, 16, 16).compute_root().parallel(y); // For demonstration, let's assume a simple GPU schedule is applied. // The actual compilation and runtime must support the chosen backend. // brighter.gpu_tile(x, y, 16, 16); // Realize the function. Halide will try to use the GPU if scheduled. // Make sure to use the correct target and environment setup for GPU. // brighter.realize("output_gpu.png"); std::cout << "GPU scheduling directives shown. Actual execution depends on Halide build and environment." << std::endl; return 0; } ``` -------------------------------- ### Get Halide GPU Thread/Block Names Source: https://halide-lang.org/docs/_canonicalize_g_p_u_vars_8h_source Provides access to the predefined names for GPU thread and block ID variables. The names are indexed starting from 0, where index 0 corresponds to the innermost loop. ```c++ // @{ const std::string &gpu_thread_name(int index); const std::string &gpu_block_name(int index); // @} ``` -------------------------------- ### WebGPU Instance Creation Source: https://halide-lang.org/docs/globals_w Function for creating a WebGPU instance. ```APIDOC ## Instance Creation ### wgpuCreateInstance **Description**: Creates a WebGPU instance. **Method**: N/A (Function Signature) **Endpoint**: N/A ``` -------------------------------- ### Halide Basics Tutorial (C++) Source: https://halide-lang.org/docs/tutorial_2lesson_07_multi_stage_pipelines_8cpp-example Demonstrates the fundamental concepts and usage of the Halide programming language for image processing and computation. Covers basic pipeline construction and execution. ```cpp #include "Halide.h" #include int main(int argc, char **argv) { // Define a Halide function representing a simple image processing pipeline. Halide::Func brighter; // Declare input variables (x, y, c for coordinates and color channels). Halide::Var x, y, c; // Define the computation for the 'brighter' function: increase brightness by 50. brighter(x, y, c) = Halide::cast(Halide::min(255, brighter(x, y, c) + 50)); // Create a Halide image (input). Halide::Buffer input = Halide::Tools::load_image("input.png"); // Realize the Halide function to produce an output image. // The output image dimensions are inferred from the input image. brighter.realize(input); // Save the output image. Halide::Tools::save_image(input, "brighter_output.png"); std::cout << "Successfully processed image!" << std::endl; return 0; } ``` -------------------------------- ### Low-Level Type and Structure Declarations Source: https://halide-lang.org/docs/struct_halide_1_1_runtime_1_1_allocation_header This snippet includes various low-level type and structure declarations, likely for interfacing with operating systems or hardware. Examples include GUID, thread attributes, and structures for remote procedure calls. ```C++ __LUID _cl_buffer_region _cl_image_desc _cl_image_format _D3D_SHADER_MACRO _GUID _halide_hexagon_remote_buffer__seq_octet _LARGE_INTEGER _qurt_thread_attr _RPC_MESSAGE _RPC_SYNTAX_IDENTIFIER _RPC_VERSION _SECURITY_ATTRIBUTES ``` -------------------------------- ### Direct3D 12 Device Member: guid Source: https://halide-lang.org/docs/struct_i_d3_d12_device_vtbl Documentation for the 'guid' member of ID3D12DeviceVtbl. This likely stores the GUID associated with the device. ```C++ ID3D12Device _In_ REFGUID ID3D12DeviceVtbl::guid ``` -------------------------------- ### WebGPU Instance Creation Source: https://halide-lang.org/docs/globals_w Function for creating a WebGPU instance. This is the entry point for using the WebGPU API. It requires the mini_webgpu.h header and returns a WGPUInstance object. ```c #include "mini_webgpu.h" WGPUInstance createWebGPUInstance() { WGPUInstanceDescriptor instanceDesc = {}; // Initialize with default descriptor return wgpuCreateInstance(&instanceDesc); } ``` -------------------------------- ### Halide compute_at example - C++ Source: https://halide-lang.org/docs/_func_8h_source Example demonstrating the usage of `compute_at` in Halide. It shows how scheduling `g.compute_at(f, x)` affects the generated C code and computation patterns compared to `g.compute_at(f, y)`. ```cpp Func f, g; Var x, y; g(x, y) = x*y; f(x, y) = g(x, y) + g(x, y+1) + g(x+1, y) + g(x+1, y+1); // Schedule g.compute_at(f, x); // Equivalent C code: // int f[height][width]; // for (int y = 0; y < height; y++) { // for (int x = 0; x < width; x++) { // int g[2][2]; // g[0][0] = x*y; // g[0][1] = (x+1)*y; // g[1][0] = x*(y+1); // g[1][1] = (x+1)*(y+1); // f[y][x] = g[0][0] + g[1][0] + g[0][1] + g[1][1]; // } // } // Schedule g.compute_at(f, y); // Equivalent C code: // int f[height][width]; // for (int y = 0; y < height; y++) { // int g[2][width+1]; // for (int x = 0; x < width; x++) { // g[0][x] = x*y; // g[1][x] = x*(y+1); // } // for (int x = 0; x < width; x++) { // f[y][x] = g[0][x] + g[1][x] + g[0][x+1] + g[1][x+1]; // } // } ``` -------------------------------- ### guid Member Variable Source: https://halide-lang.org/docs/struct_i_d3_d12_object_vtbl The 'guid' member variable of the ID3D12ObjectVtbl structure. It stores the GUID (Globally Unique Identifier) associated with the interface. ```cpp ID3D12ObjectVtbl::guid; ``` -------------------------------- ### WebGPU Runtime Interface Source: https://halide-lang.org/docs/_halide_runtime_web_g_p_u_8h_source Provides the main interface for interacting with the Halide WebGPU runtime. It includes functions for initializing kernels, running them with specified parameters, and finalizing them. ```c #define HALIDE_RUNTIME_WEBGPU extern const struct halide_device_interface_t *halide_webgpu_device_interface(); extern int halide_webgpu_initialize_kernels(void *user_context, void **state_ptr, const char *src, int size); extern int halide_webgpu_run(void *user_context, void *state_ptr, const char *entry_name, int blocksX, int blocksY, int blocksZ, int threadsX, int threadsY, int threadsZ, int shared_mem_bytes, halide_type_t arg_types[], void *args[], int8_t arg_is_buffer[]); extern void halide_webgpu_finalize_kernels(void *user_context, void *state_ptr); ``` -------------------------------- ### Halide WebGPU Support Example Source: https://halide-lang.org/docs/classcmdline_1_1detail_1_1lexical__cast__t_3_01_target_00_01std_1_1string_00_01false_01_4 Information regarding Halide's integration with WebGPU, enabling GPU computations in web environments. ```javascript // Conceptual JavaScript for Halide WebGPU (requires Halide WASM backend) // async function runHalideWebGPU() { // const halideModule = await loadHalideWasm(); // Load Halide WASM module // const device = await navigator.gpu.requestAdapter().then(adapter => adapter.requestDevice()); // // Define Halide pipeline and compile for WebGPU target // // const pipeline = halideModule.Pipeline.make(...); // // const compiledPipeline = pipeline.compile({ target: 'webgpu' }); // // ... execute on GPU ... // } ```