├── priv └── VERSION ├── .tool-versions ├── embedded_devices └── live_nx_iree │ ├── priv │ ├── repo │ │ ├── migrations │ │ │ └── .formatter.exs │ │ └── seeds.exs │ └── static │ │ ├── favicon.ico │ │ └── robots.txt │ ├── test │ ├── test_helper.exs │ ├── live_nx_iree_web │ │ └── controllers │ │ │ ├── page_controller_test.exs │ │ │ ├── error_json_test.exs │ │ │ └── error_html_test.exs │ └── support │ │ ├── conn_case.ex │ │ └── data_case.ex │ ├── lib │ ├── live_nx_iree │ │ ├── mailer.ex │ │ ├── repo.ex │ │ └── application.ex │ ├── live_nx_iree_web │ │ ├── live │ │ │ ├── home_live │ │ │ │ └── home_live.html.heex │ │ │ ├── camera_live │ │ │ │ └── camera_live.html.heex │ │ │ ├── home_live.swiftui.ex │ │ │ ├── camera_live.swiftui.ex │ │ │ └── swiftui │ │ │ │ ├── home_live.swiftui.neex │ │ │ │ └── camera_live.swiftui.neex │ │ ├── components │ │ │ ├── layouts_swiftui │ │ │ │ ├── app.swiftui.neex │ │ │ │ └── root.swiftui.neex │ │ │ ├── layouts.swiftui.ex │ │ │ ├── layouts.ex │ │ │ └── layouts │ │ │ │ ├── root.html.heex │ │ │ │ └── app.html.heex │ │ ├── controllers │ │ │ ├── page_controller.ex │ │ │ ├── page_html.ex │ │ │ ├── error_json.ex │ │ │ └── error_html.ex │ │ ├── gettext.ex │ │ ├── styles │ │ │ └── app.swiftui.ex │ │ ├── router.ex │ │ └── endpoint.ex │ └── live_nx_iree.ex │ ├── native │ └── swiftui │ │ ├── LiveNxIREE │ │ ├── Assets.xcassets │ │ │ ├── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── 128-mac.png │ │ │ │ ├── 16-mac.png │ │ │ │ ├── 256-mac.png │ │ │ │ ├── 32-mac.png │ │ │ │ ├── 512-mac.png │ │ │ │ ├── 64-mac.png │ │ │ │ ├── AppIcon.jpg │ │ │ │ ├── 1024-mac.png │ │ │ │ ├── 256-mac 1.png │ │ │ │ ├── 32-mac 1.png │ │ │ │ ├── 512-mac 1.png │ │ │ │ ├── AppIcon 1.jpg │ │ │ │ └── Contents.json │ │ ├── Preview Content │ │ │ └── Preview Assets.xcassets │ │ │ │ └── Contents.json │ │ ├── nx_iree │ │ │ ├── lib │ │ │ │ ├── host │ │ │ │ │ └── libnx_iree_runtime.so │ │ │ │ ├── ios │ │ │ │ │ └── libnx_iree_runtime.so │ │ │ │ ├── tvos │ │ │ │ │ └── libnx_iree_runtime.so │ │ │ │ ├── visionos │ │ │ │ │ └── libnx_iree_runtime.so │ │ │ │ ├── ios_simulator │ │ │ │ │ └── libnx_iree_runtime.so │ │ │ │ ├── tvos_simulator │ │ │ │ │ └── libnx_iree_runtime.so │ │ │ │ └── visionos_simulator │ │ │ │ │ └── libnx_iree_runtime.so │ │ │ └── include │ │ │ │ └── iree │ │ │ │ ├── hal │ │ │ │ ├── drivers │ │ │ │ │ ├── cuda │ │ │ │ │ │ ├── cuda_headers.h │ │ │ │ │ │ ├── nccl_headers.h │ │ │ │ │ │ ├── registration │ │ │ │ │ │ │ └── driver_module.h │ │ │ │ │ │ ├── nop_executable_cache.h │ │ │ │ │ │ └── cuda_allocator.h │ │ │ │ │ ├── hip │ │ │ │ │ │ ├── rccl_headers.h │ │ │ │ │ │ ├── registration │ │ │ │ │ │ │ └── driver_module.h │ │ │ │ │ │ ├── nop_executable_cache.h │ │ │ │ │ │ ├── hip_allocator.h │ │ │ │ │ │ └── hip_headers.h │ │ │ │ │ ├── vulkan │ │ │ │ │ │ ├── vulkan_driver.h │ │ │ │ │ │ ├── registration │ │ │ │ │ │ │ └── driver_module.h │ │ │ │ │ │ ├── native_event.h │ │ │ │ │ │ ├── nop_executable_cache.h │ │ │ │ │ │ ├── native_allocator.h │ │ │ │ │ │ ├── vulkan_device.h │ │ │ │ │ │ ├── direct_command_queue.h │ │ │ │ │ │ ├── debug_reporter.h │ │ │ │ │ │ ├── sparse_buffer.h │ │ │ │ │ │ └── native_semaphore.h │ │ │ │ │ ├── metal │ │ │ │ │ │ ├── registration │ │ │ │ │ │ │ └── driver_module.h │ │ │ │ │ │ ├── nop_executable_cache.h │ │ │ │ │ │ ├── metal_device.h │ │ │ │ │ │ ├── metal_buffer.h │ │ │ │ │ │ ├── direct_allocator.h │ │ │ │ │ │ └── shared_event.h │ │ │ │ │ ├── local_sync │ │ │ │ │ │ ├── registration │ │ │ │ │ │ │ └── driver_module.h │ │ │ │ │ │ ├── sync_event.h │ │ │ │ │ │ ├── sync_driver.h │ │ │ │ │ │ └── sync_device.h │ │ │ │ │ ├── local_task │ │ │ │ │ │ ├── registration │ │ │ │ │ │ │ └── driver_module.h │ │ │ │ │ │ ├── task_event.h │ │ │ │ │ │ ├── task_queue_state.h │ │ │ │ │ │ └── task_driver.h │ │ │ │ │ └── init.h │ │ │ │ ├── utils │ │ │ │ │ ├── libmpi_dynamic_symbols.h │ │ │ │ │ ├── debug_allocator.h │ │ │ │ │ ├── allocators.h │ │ │ │ │ └── mpi_channel_provider.h │ │ │ │ ├── local │ │ │ │ │ ├── executable_environment.h │ │ │ │ │ ├── loaders │ │ │ │ │ │ ├── embedded_elf_loader.h │ │ │ │ │ │ ├── system_library_loader.h │ │ │ │ │ │ └── static_library_loader.h │ │ │ │ │ ├── local_executable_cache.h │ │ │ │ │ ├── plugins │ │ │ │ │ │ └── static_plugin.h │ │ │ │ │ └── executable_library_demo.h │ │ │ │ ├── queue.h │ │ │ │ ├── api.h │ │ │ │ └── buffer_heap_impl.h │ │ │ │ ├── builtins │ │ │ │ └── ukernel │ │ │ │ │ ├── tools │ │ │ │ │ ├── memcpy_benchmark.h │ │ │ │ │ ├── benchmark.h │ │ │ │ │ └── test.h │ │ │ │ │ ├── api.h │ │ │ │ │ ├── arch │ │ │ │ │ ├── arm_64 │ │ │ │ │ │ ├── unpack_arm_64_internal.h │ │ │ │ │ │ ├── mmt4d_arm_64_internal.h │ │ │ │ │ │ └── pack_arm_64_internal.h │ │ │ │ │ └── x86_64 │ │ │ │ │ │ ├── unpack_x86_64_internal.h │ │ │ │ │ │ ├── mmt4d_x86_64_internal.h │ │ │ │ │ │ └── pack_x86_64_internal.h │ │ │ │ │ ├── unpack.h │ │ │ │ │ ├── query_tile_sizes_internal.h │ │ │ │ │ ├── query_tile_sizes.h │ │ │ │ │ ├── mmt4d.h │ │ │ │ │ └── pack.h │ │ │ │ ├── testing │ │ │ │ └── gtest.h │ │ │ │ ├── base │ │ │ │ ├── internal │ │ │ │ │ ├── time.h │ │ │ │ │ └── flatcc │ │ │ │ │ │ ├── building.h │ │ │ │ │ │ ├── parsing.h │ │ │ │ │ │ └── debugging.h │ │ │ │ └── loop_emscripten.h │ │ │ │ ├── runtime │ │ │ │ └── api.h │ │ │ │ ├── modules │ │ │ │ ├── check │ │ │ │ │ └── module.h │ │ │ │ ├── vmvx │ │ │ │ │ └── module.h │ │ │ │ ├── io │ │ │ │ │ └── parameters │ │ │ │ │ │ └── module.h │ │ │ │ └── hal │ │ │ │ │ ├── loader │ │ │ │ │ └── module.h │ │ │ │ │ ├── inline │ │ │ │ │ └── module.h │ │ │ │ │ ├── utils │ │ │ │ │ └── buffer_diagnostics.h │ │ │ │ │ └── module.h │ │ │ │ ├── io │ │ │ │ ├── formats │ │ │ │ │ ├── irpa │ │ │ │ │ │ └── irpa_parser.h │ │ │ │ │ ├── gguf │ │ │ │ │ │ └── gguf_parser.h │ │ │ │ │ ├── parser_registry.h │ │ │ │ │ └── safetensors │ │ │ │ │ │ └── safetensors_parser.h │ │ │ │ ├── memory_stream.h │ │ │ │ ├── scope_map.h │ │ │ │ ├── parameter_index_provider.h │ │ │ │ └── vec_stream.h │ │ │ │ ├── tooling │ │ │ │ ├── instrument_util.h │ │ │ │ ├── parameter_util.h │ │ │ │ ├── modules │ │ │ │ │ └── resolver.h │ │ │ │ ├── comparison.h │ │ │ │ └── function_util.h │ │ │ │ └── vm │ │ │ │ ├── bytecode │ │ │ │ ├── module.h │ │ │ │ ├── archive.h │ │ │ │ ├── utils │ │ │ │ │ └── features.h │ │ │ │ └── verifier.h │ │ │ │ ├── api.h │ │ │ │ ├── ops_emitc.h │ │ │ │ ├── shims_emitc.h │ │ │ │ └── dynamic │ │ │ │ └── module.h │ │ ├── NxIREECppBridge.swift │ │ ├── LiveNxIREE.swift │ │ ├── ConnectingView.swift │ │ ├── LiveNxIREE-Bridging-Header.h │ │ ├── DisconnectedView.swift │ │ ├── ContentView.swift │ │ ├── NxAddon │ │ │ └── ImageView.swift │ │ ├── c_src │ │ │ └── nx_iree.h │ │ └── ReconnectingView.swift │ │ ├── BuildArtifacts │ │ └── libnx_iree_runtime.so │ │ └── LiveNxIREE.xcodeproj │ │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcuserdata │ │ │ └── paulo.valente.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ └── paulo.valente.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist │ ├── assets │ ├── css │ │ └── app.css │ └── js │ │ └── app.js │ ├── .formatter.exs │ ├── install_nx_iree.sh │ ├── README.md │ ├── config │ ├── prod.exs │ └── test.exs │ └── .gitignore ├── config └── config.exs ├── .formatter.exs ├── CHANGELOG.md ├── scripts ├── build_linux.sh ├── build_mac_arm.sh └── clone_iree.sh ├── lib ├── nx_iree │ ├── application.ex │ ├── module.ex │ ├── native.ex │ └── mix_helpers.exs └── mix │ └── tasks │ └── nx_iree │ └── native_download.ex ├── test ├── test_helper.exs └── nx_iree │ ├── native_test.exs │ └── nx_test.exs ├── README.md ├── .gitignore ├── compiler.exs ├── cmake ├── CMakeLists.txt └── modules │ └── default │ └── CMakeLists.txt ├── axon.exs └── run.exs /priv/VERSION: -------------------------------------------------------------------------------- 1 | 0.0.2-pre.0 -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | elixir 1.17.0-otp-26 2 | erlang 26.0.2 3 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/priv/repo/migrations/.formatter.exs: -------------------------------------------------------------------------------- 1 | [ 2 | import_deps: [:ecto_sql], 3 | inputs: ["*.exs"] 4 | ] 5 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | Ecto.Adapters.SQL.Sandbox.mode(LiveNxIREE.Repo, :manual) 3 | -------------------------------------------------------------------------------- /config/config.exs: -------------------------------------------------------------------------------- 1 | import Config 2 | 3 | if config_env() == :test do 4 | config :nx_iree, :add_backend_on_inspect, false 5 | end 6 | -------------------------------------------------------------------------------- /.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["{mix,.formatter}.exs", "{liveview_native,config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## v0.0.1 (2024-10-04) 4 | 5 | First release, including an Nx.Defn compiler and companion Nx.Backend. 6 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree/mailer.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREE.Mailer do 2 | use Swoosh.Mailer, otp_app: :live_nx_iree 3 | end 4 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/live/home_live/home_live.html.heex: -------------------------------------------------------------------------------- 1 | <.header> 2 | Listing Contexts 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/components/layouts_swiftui/app.swiftui.neex: -------------------------------------------------------------------------------- 1 | <.flash_group flash={@flash} /> 2 | <%= @inner_content %> -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/live/camera_live/camera_live.html.heex: -------------------------------------------------------------------------------- 1 | <.header> 2 | Listing Contexts 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/priv/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/priv/static/favicon.ico -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree/repo.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREE.Repo do 2 | use Ecto.Repo, 3 | otp_app: :live_nx_iree, 4 | adapter: Ecto.Adapters.Postgres 5 | end 6 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/live/home_live.swiftui.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.HomeLive.SwiftUI do 2 | use LiveNxIREENative, [:render_component, format: :swiftui] 3 | end 4 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/live/camera_live.swiftui.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.CameraLive.SwiftUI do 2 | use LiveNxIREENative, [:render_component, format: :swiftui] 3 | end 4 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/assets/css/app.css: -------------------------------------------------------------------------------- 1 | @import "tailwindcss/base"; 2 | @import "tailwindcss/components"; 3 | @import "tailwindcss/utilities"; 4 | 5 | /* This file is for your main application CSS */ 6 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/BuildArtifacts/libnx_iree_runtime.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/BuildArtifacts/libnx_iree_runtime.so -------------------------------------------------------------------------------- /scripts/build_linux.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | for IREE_BUILD_TARGET in "host" 4 | do 5 | 6 | SCRIPT_DIR=$(dirname "$0") 7 | 8 | ${SCRIPT_DIR}/build_and_package.sh --target=${IREE_BUILD_TARGET} 9 | 10 | done -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/components/layouts.swiftui.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.Layouts.SwiftUI do 2 | use LiveNxIREENative, [:layout, format: :swiftui] 3 | 4 | embed_templates "layouts_swiftui/*" 5 | end 6 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/components/layouts_swiftui/root.swiftui.neex: -------------------------------------------------------------------------------- 1 | <.csrf_token /> 2 | 3 | 4 | <%= @inner_content %> 5 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/lib/host/libnx_iree_runtime.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/lib/host/libnx_iree_runtime.so -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/lib/ios/libnx_iree_runtime.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/lib/ios/libnx_iree_runtime.so -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/lib/tvos/libnx_iree_runtime.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/lib/tvos/libnx_iree_runtime.so -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/lib/visionos/libnx_iree_runtime.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/lib/visionos/libnx_iree_runtime.so -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/128-mac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/128-mac.png -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/16-mac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/16-mac.png -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/256-mac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/256-mac.png -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/32-mac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/32-mac.png -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/512-mac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/512-mac.png -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/64-mac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/64-mac.png -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/AppIcon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/AppIcon.jpg -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/1024-mac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/1024-mac.png -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/256-mac 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/256-mac 1.png -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/32-mac 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/32-mac 1.png -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/512-mac 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/512-mac 1.png -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/AppIcon 1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/AppIcon 1.jpg -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/lib/ios_simulator/libnx_iree_runtime.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/lib/ios_simulator/libnx_iree_runtime.so -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/lib/tvos_simulator/libnx_iree_runtime.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/lib/tvos_simulator/libnx_iree_runtime.so -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/lib/visionos_simulator/libnx_iree_runtime.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/lib/visionos_simulator/libnx_iree_runtime.so -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/NxIREECppBridge.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NxIREECppBridge.swift 3 | // LiveNxIREE 4 | // 5 | // Created by Paulo.Valente on 8/22/24. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct NxIREECppBridge { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/priv/static/robots.txt: -------------------------------------------------------------------------------- 1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/.formatter.exs: -------------------------------------------------------------------------------- 1 | [ 2 | import_deps: [:ecto, :ecto_sql, :phoenix], 3 | subdirectories: ["priv/*/migrations"], 4 | plugins: [Phoenix.LiveView.HTMLFormatter], 5 | inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"] 6 | ] 7 | -------------------------------------------------------------------------------- /scripts/build_mac_arm.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | for IREE_BUILD_TARGET in "host" "ios" "ios_simulator" "visionos" "visionos_simulator" "tvos" "tvos_simulator" 4 | do 5 | 6 | SCRIPT_DIR=$(dirname "$0") 7 | 8 | ${SCRIPT_DIR}/build_and_package.sh --target=${IREE_BUILD_TARGET} 9 | 10 | done -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/LiveNxIREE.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LiveNxIREE.swift 3 | // LiveNxIREE 4 | // 5 | 6 | import SwiftUI 7 | 8 | @main 9 | struct LiveNxIREE: App { 10 | var body: some Scene { 11 | WindowGroup { 12 | ContentView() 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/ConnectingView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConnectingView.swift 3 | // ConnectingView 4 | // 5 | 6 | import SwiftUI 7 | 8 | struct ConnectingView: View { 9 | var body: some View { 10 | ProgressView() 11 | } 12 | } 13 | 14 | #Preview { 15 | ConnectingView() 16 | } 17 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREE do 2 | @moduledoc """ 3 | LiveNxIREE keeps the contexts that define your domain 4 | and business logic. 5 | 6 | Contexts are also responsible for managing your data, regardless 7 | if it comes from the database, an external API or others. 8 | """ 9 | end 10 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/test/live_nx_iree_web/controllers/page_controller_test.exs: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.PageControllerTest do 2 | use LiveNxIREEWeb.ConnCase 3 | 4 | test "GET /", %{conn: conn} do 5 | conn = get(conn, ~p"/") 6 | assert html_response(conn, 200) =~ "Peace of mind from prototype to production" 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/controllers/page_controller.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.PageController do 2 | use LiveNxIREEWeb, :controller 3 | 4 | def home(conn, _params) do 5 | # The home page is often custom made, 6 | # so skip the default app layout. 7 | render(conn, :home, layout: false) 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE.xcodeproj/project.xcworkspace/xcuserdata/paulo.valente.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-nx/nx_iree/HEAD/embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE.xcodeproj/project.xcworkspace/xcuserdata/paulo.valente.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/controllers/page_html.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.PageHTML do 2 | @moduledoc """ 3 | This module contains pages rendered by PageController. 4 | 5 | See the `page_html` directory for all templates available. 6 | """ 7 | use LiveNxIREEWeb, :html 8 | 9 | embed_templates "page_html/*" 10 | end 11 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/LiveNxIREE-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // NxIREE-Bridging-Header.h 3 | // LiveNxIREE 4 | // 5 | // Created by Paulo.Valente on 8/21/24. 6 | // 7 | 8 | #ifndef NxIREE_Bridging_Header_h 9 | #define NxIREE_Bridging_Header_h 10 | 11 | #include "c_src/nx_iree.h" 12 | 13 | #endif /* NxIREE_Bridging_Header_h */ 14 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/nx_iree/application.ex: -------------------------------------------------------------------------------- 1 | defmodule NxIREE.Application do 2 | @moduledoc false 3 | 4 | use Application 5 | 6 | def start(_type, _args) do 7 | children = [] 8 | 9 | :ok = NxIREE.Device.init() 10 | {:ok, _instance} = NxIREE.VM.create_instance() 11 | 12 | Supervisor.start_link(children, strategy: :one_for_one, name: NxIREE.Supervisor) 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/priv/repo/seeds.exs: -------------------------------------------------------------------------------- 1 | # Script for populating the database. You can run it as: 2 | # 3 | # mix run priv/repo/seeds.exs 4 | # 5 | # Inside the script, you can read and write to any of your 6 | # repositories directly: 7 | # 8 | # LiveNxIREE.Repo.insert!(%LiveNxIREE.SomeSchema{}) 9 | # 10 | # We recommend using the bang functions (`insert!`, `update!` 11 | # and so on) as they will fail if something goes wrong. 12 | -------------------------------------------------------------------------------- /lib/nx_iree/module.ex: -------------------------------------------------------------------------------- 1 | defmodule NxIREE.Module do 2 | @doc """ 3 | Holds the bytecode and other metadata for a compiled MLIR module. 4 | """ 5 | 6 | defstruct [:bytecode, :compilation_flags, :mlir_module, :output_container] 7 | 8 | @type t :: %__MODULE__{ 9 | bytecode: String.t(), 10 | compilation_flags: list(String.t()), 11 | mlir_module: String.t(), 12 | output_container: term() 13 | } 14 | end 15 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/live/swiftui/home_live.swiftui.neex: -------------------------------------------------------------------------------- 1 | 11 | 12 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/test/live_nx_iree_web/controllers/error_json_test.exs: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.ErrorJSONTest do 2 | use LiveNxIREEWeb.ConnCase, async: true 3 | 4 | test "renders 404" do 5 | assert LiveNxIREEWeb.ErrorJSON.render("404.json", %{}) == %{errors: %{detail: "Not Found"}} 6 | end 7 | 8 | test "renders 500" do 9 | assert LiveNxIREEWeb.ErrorJSON.render("500.json", %{}) == 10 | %{errors: %{detail: "Internal Server Error"}} 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/live/swiftui/camera_live.swiftui.neex: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/cuda/cuda_headers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_CUDA_CUDA_HEADERS_H_ 8 | #define IREE_HAL_DRIVERS_CUDA_CUDA_HEADERS_H_ 9 | 10 | #include "cuda.h" // IWYU pragma: export 11 | 12 | #endif // IREE_HAL_DRIVERS_CUDA_CUDA_HEADERS_H_ 13 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/test/live_nx_iree_web/controllers/error_html_test.exs: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.ErrorHTMLTest do 2 | use LiveNxIREEWeb.ConnCase, async: true 3 | 4 | # Bring render_to_string/4 for testing custom views 5 | import Phoenix.Template 6 | 7 | test "renders 404.html" do 8 | assert render_to_string(LiveNxIREEWeb.ErrorHTML, "404", "html", []) == "Not Found" 9 | end 10 | 11 | test "renders 500.html" do 12 | assert render_to_string(LiveNxIREEWeb.ErrorHTML, "500", "html", []) == "Internal Server Error" 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/hip/rccl_headers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_HIP_RCCL_HEADERS_H_ 8 | #define IREE_HAL_DRIVERS_HIP_RCCL_HEADERS_H_ 9 | 10 | #include "third_party/rccl/rccl.h" // IWYU pragma: export 11 | 12 | #endif // IREE_HAL_DRIVERS_HIP_RCCL_HEADERS_H_ 13 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/components/layouts.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.Layouts do 2 | @moduledoc """ 3 | This module holds different layouts used by your application. 4 | 5 | See the `layouts` directory for all templates available. 6 | The "root" layout is a skeleton rendered as part of the 7 | application router. The "app" layout is set as the default 8 | layout on both `use LiveNxIREEWeb, :controller` and 9 | `use LiveNxIREEWeb, :live_view`. 10 | """ 11 | use LiveNxIREEWeb, :html 12 | 13 | embed_templates "layouts/*" 14 | end 15 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/cuda/nccl_headers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_CUDA_NCCL_HEADERS_H_ 8 | #define IREE_HAL_DRIVERS_CUDA_NCCL_HEADERS_H_ 9 | 10 | #include "third_party/nccl/nccl.h" // IWYU pragma: export 11 | 12 | #endif // IREE_HAL_DRIVERS_CUDA_NCCL_HEADERS_H_ 13 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/tools/memcpy_benchmark.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_TOOLS_MEMCPY_BENCHMARK_H_ 8 | #define IREE_BUILTINS_UKERNEL_TOOLS_MEMCPY_BENCHMARK_H_ 9 | 10 | #include 11 | 12 | void iree_uk_benchmark_register_memcpy(int64_t working_set_size); 13 | 14 | #endif // IREE_BUILTINS_UKERNEL_TOOLS_MEMCPY_BENCHMARK_H_ 15 | -------------------------------------------------------------------------------- /test/test_helper.exs: -------------------------------------------------------------------------------- 1 | flags = [ 2 | "--iree-input-type=stablehlo_xla", 3 | "--iree-execution-model=async-internal" 4 | ] 5 | 6 | driver = System.get_env("NX_IREE_DEFAULT_DRIVER") || "local-sync" 7 | # runtime_options = nil 8 | runtime_options = [device: NxIREE.Device.find_default_device(driver)] 9 | 10 | Nx.Defn.global_default_options( 11 | compiler: NxIREE.Compiler, 12 | iree_compiler_flags: flags, 13 | iree_runtime_options: runtime_options 14 | ) 15 | 16 | Nx.global_default_backend(NxIREE.Backend) 17 | 18 | if System.get_env("DEBUG") do 19 | IO.gets("Press Enter to continue - PID: #{System.pid()}") 20 | end 21 | 22 | ExUnit.start() 23 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/api.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_API_H_ 8 | #define IREE_BUILTINS_UKERNEL_API_H_ 9 | 10 | #include "iree/builtins/ukernel/mmt4d.h" 11 | #include "iree/builtins/ukernel/pack.h" 12 | #include "iree/builtins/ukernel/query_tile_sizes.h" 13 | #include "iree/builtins/ukernel/unpack.h" 14 | 15 | #endif // IREE_BUILTINS_UKERNEL_API_H_ 16 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/arch/arm_64/unpack_arm_64_internal.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_ARCH_ARM_64_UNPACK_ARM_64_INTERNAL_H_ 8 | #define IREE_BUILTINS_UKERNEL_ARCH_ARM_64_UNPACK_ARM_64_INTERNAL_H_ 9 | 10 | #include "iree/builtins/ukernel/unpack_internal.h" 11 | 12 | IREE_UK_UNPACK_TILE_FUNC_DECL(iree_uk_unpack_tile_8x8_x32_arm_64_direct) 13 | 14 | #endif // IREE_BUILTINS_UKERNEL_ARCH_ARM_64_UNPACK_ARM_64_INTERNAL_H_ 15 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/install_nx_iree.sh: -------------------------------------------------------------------------------- 1 | 2 | mv native/swiftui/LiveNxIREE/nx_iree native/swiftui/LiveNxIREE/nx_iree_old 3 | 4 | for platform in host ios ios_simulator tvos tvos_simulator visionos visionos_simulator; do 5 | mix nx_iree.native_download --platform $platform --output-dir native/swiftui/LiveNxIREE/nx_iree/lib/$platform 6 | 7 | if [ $platform == "host" ]; then 8 | mv native/swiftui/LiveNxIREE/nx_iree/lib/host/include native/swiftui/LiveNxIREE/nx_iree/ 9 | else 10 | rm -rf native/swiftui/LiveNxIREE/nx_iree/lib/$platform/include 11 | fi 12 | 13 | rm native/swiftui/LiveNxIREE/nx_iree/lib/$platform/nx_iree-embedded-macos-$platform.tar.gz 14 | done 15 | 16 | rm -rf native/swiftui/LiveNxIREE/nx_iree_old 17 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/components/layouts/root.html.heex: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | <.live_title suffix=" · Phoenix Framework"> 8 | <%= assigns[:page_title] || "LiveNxIREE" %> 9 | 10 | 11 | 13 | 14 | 15 | <%= @inner_content %> 16 | 17 | 18 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/README.md: -------------------------------------------------------------------------------- 1 | # LiveNxIREE 2 | 3 | To start your Phoenix server: 4 | 5 | * Run `mix setup` to install and setup dependencies 6 | * Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server` 7 | 8 | Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. 9 | 10 | Ready to run in production? Please [check our deployment guides](https://hexdocs.pm/phoenix/deployment.html). 11 | 12 | ## Learn more 13 | 14 | * Official website: https://www.phoenixframework.org/ 15 | * Guides: https://hexdocs.pm/phoenix/overview.html 16 | * Docs: https://hexdocs.pm/phoenix 17 | * Forum: https://elixirforum.com/c/phoenix-forum 18 | * Source: https://github.com/phoenixframework/phoenix 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NxIREE 2 | 3 | Companion library to [EXLA](https://github.com/elixir-nx/exla), providing bindings for the [IREE](https://iree.dev) runtime for MLIR. 4 | 5 | MLIR modules can be obtained from Nx functions by calling `EXLA.to_mlir_module/2` on them. 6 | 7 | ## Installation 8 | 9 | If [available in Hex](https://hex.pm/docs/publish), the package can be installed 10 | by adding `nx_iree` to your list of dependencies in `mix.exs`: 11 | 12 | ```elixir 13 | def deps do 14 | [ 15 | {:nx_iree, "~> 0.1.0"} 16 | ] 17 | end 18 | ``` 19 | 20 | Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) 21 | and published on [HexDocs](https://hexdocs.pm). Once published, the docs can 22 | be found at . 23 | 24 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/controllers/error_json.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.ErrorJSON do 2 | @moduledoc """ 3 | This module is invoked by your endpoint in case of errors on JSON requests. 4 | 5 | See config/config.exs. 6 | """ 7 | 8 | # If you want to customize a particular status code, 9 | # you may add your own clauses, such as: 10 | # 11 | # def render("500.json", _assigns) do 12 | # %{errors: %{detail: "Internal Server Error"}} 13 | # end 14 | 15 | # By default, Phoenix returns the status message from 16 | # the template name. For example, "404.json" becomes 17 | # "Not Found". 18 | def render(template, _assigns) do 19 | %{errors: %{detail: Phoenix.Controller.status_message_from_template(template)}} 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/vulkan/vulkan_driver.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_VULKAN_VULKAN_DRIVER_H_ 8 | #define IREE_HAL_DRIVERS_VULKAN_VULKAN_DRIVER_H_ 9 | 10 | #include "iree/hal/api.h" 11 | #include "iree/hal/drivers/vulkan/api.h" 12 | 13 | // NOTE: the driver API calls are defined in api.h. 14 | // TODO(benvanik): clean that up? api.h is nice because then we only need to 15 | // deploy a single header file for the backend, but it is a bit tricky. 16 | 17 | #endif // IREE_HAL_DRIVERS_VULKAN_VULKAN_DRIVER_H_ 18 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/testing/gtest.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_TESTING_GTEST_H_ 8 | #define IREE_TESTING_GTEST_H_ 9 | 10 | #include "gmock/gmock-matchers.h" // IWYU pragma: export 11 | #include "gmock/gmock.h" // IWYU pragma: export 12 | #include "gtest/gtest-message.h" // IWYU pragma: export 13 | #include "gtest/gtest-spi.h" // IWYU pragma: export 14 | #include "gtest/gtest-test-part.h" // IWYU pragma: export 15 | #include "gtest/gtest.h" // IWYU pragma: export 16 | 17 | #endif // IREE_TESTING_GTEST_H_ 18 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/base/internal/time.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BASE_INTERNAL_TIME_H_ 8 | #define IREE_BASE_INTERNAL_TIME_H_ 9 | 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif // __cplusplus 15 | 16 | // Implementation for the public iree_time_now() function. 17 | // Also available to other libraries under base/ to avoid circular dependencies. 18 | int64_t iree_platform_time_now(void); 19 | 20 | #ifdef __cplusplus 21 | } // extern "C" 22 | #endif // __cplusplus 23 | 24 | #endif // IREE_BASE_INTERNAL_TIME_H_ 25 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/runtime/api.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_RUNTIME_API_H_ 8 | #define IREE_RUNTIME_API_H_ 9 | 10 | // Lower-level APIs: 11 | #include "iree/base/api.h" // IWYU pragma: export 12 | #include "iree/hal/api.h" // IWYU pragma: export 13 | #include "iree/vm/api.h" // IWYU pragma: export 14 | 15 | // Runtime API: 16 | #include "iree/runtime/call.h" // IWYU pragma: export 17 | #include "iree/runtime/instance.h" // IWYU pragma: export 18 | #include "iree/runtime/session.h" // IWYU pragma: export 19 | 20 | #endif // IREE_RUNTIME_API_H_ 21 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/arch/x86_64/unpack_x86_64_internal.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_ARCH_X86_64_UNPACK_X86_64_INTERNAL_H_ 8 | #define IREE_BUILTINS_UKERNEL_ARCH_X86_64_UNPACK_X86_64_INTERNAL_H_ 9 | 10 | #include "iree/builtins/ukernel/unpack_internal.h" 11 | 12 | IREE_UK_UNPACK_TILE_FUNC_DECL( 13 | iree_uk_unpack_tile_8x8_x32_x86_64_avx2_fma_direct) 14 | IREE_UK_UNPACK_TILE_FUNC_DECL( 15 | iree_uk_unpack_tile_16x16_x32_x86_64_avx512_base_direct) 16 | 17 | #endif // IREE_BUILTINS_UKERNEL_ARCH_X86_64_UNPACK_X86_64_INTERNAL_H_ 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # The directory Mix will write compiled artifacts to. 2 | /_build/ 3 | 4 | # If you run "mix test --cover", coverage assets end up here. 5 | /cover/ 6 | 7 | # The directory Mix downloads your dependencies sources to. 8 | /deps/ 9 | 10 | # Where third-party dependencies like ExDoc output generated docs. 11 | /doc/ 12 | 13 | # Ignore .fetch files in case you like to edit your project deps locally. 14 | /.fetch 15 | 16 | # If the VM crashes, it generates a dump, let's ignore it too. 17 | erl_crash.dump 18 | 19 | # Also ignore archive artifacts (built via "mix archive.build"). 20 | *.ez 21 | 22 | # Ignore package tarball (built via "mix hex.build"). 23 | nx_iree-*.tar 24 | 25 | # Temporary files, for example, from tests. 26 | /tmp/ 27 | 28 | /iree-runtime/ 29 | /cache/ 30 | 31 | /priv/iree-compile 32 | /priv/iree-runtime 33 | /priv/libnx_iree.so 34 | -------------------------------------------------------------------------------- /compiler.exs: -------------------------------------------------------------------------------- 1 | NxIREE.list_drivers() |> IO.inspect(label: "drivers") 2 | 3 | {:ok, [dev | _]} = NxIREE.list_devices("metal") |> IO.inspect() 4 | 5 | fun = fn a, b -> 6 | key = Nx.Random.key(42) 7 | {val, _key} = Nx.Random.uniform(key, 0.0, 1.0) 8 | 9 | x = Nx.cos(a) |> Nx.add(Nx.sin(b)) 10 | {x, val, Nx.add(x, val)} 11 | end 12 | 13 | args = [Nx.template({4}, :f32), Nx.template({4}, :s64)] 14 | # args = [] 15 | flags = ["--iree-hal-target-backends=metal-spirv", "--iree-input-type=stablehlo_xla", "--iree-execution-model=async-internal"] 16 | 17 | Nx.Defn.default_options(compiler: NxIREE.Compiler, iree_compiler_flags: flags, iree_runtime_options: [device: dev]) 18 | 19 | f = Nx.Defn.compile(fun, args) 20 | 21 | Nx.default_backend(NxIREE.Backend) 22 | arg0 = Nx.tensor([1.0, 2.0, 3.0, 4.0]) 23 | arg1 = Nx.tensor([1, -1, 1, -1]) 24 | f.(arg0, arg1) |> dbg() 25 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/config/prod.exs: -------------------------------------------------------------------------------- 1 | import Config 2 | 3 | # Note we also include the path to a cache manifest 4 | # containing the digested version of static files. This 5 | # manifest is generated by the `mix assets.deploy` task, 6 | # which you should run after static files are built and 7 | # before starting your production server. 8 | config :live_nx_iree, LiveNxIREEWeb.Endpoint, 9 | cache_static_manifest: "priv/static/cache_manifest.json" 10 | 11 | # Configures Swoosh API Client 12 | config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: LiveNxIREE.Finch 13 | 14 | # Disable Swoosh Local Memory Storage 15 | config :swoosh, local: false 16 | 17 | # Do not print debug messages in production 18 | config :logger, level: :info 19 | 20 | # Runtime production configuration, including reading 21 | # of environment variables, is done on config/runtime.exs. 22 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/gettext.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.Gettext do 2 | @moduledoc """ 3 | A module providing Internationalization with a gettext-based API. 4 | 5 | By using [Gettext](https://hexdocs.pm/gettext), 6 | your module gains a set of macros for translations, for example: 7 | 8 | import LiveNxIREEWeb.Gettext 9 | 10 | # Simple translation 11 | gettext("Here is the string to translate") 12 | 13 | # Plural translation 14 | ngettext("Here is the string to translate", 15 | "Here are the strings to translate", 16 | 3) 17 | 18 | # Domain-based translation 19 | dgettext("errors", "Here is the error message to translate") 20 | 21 | See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage. 22 | """ 23 | use Gettext, otp_app: :live_nx_iree 24 | end 25 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/metal/registration/driver_module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_METAL_REGISTRATION_DRIVER_MODULE_H_ 8 | #define IREE_HAL_DRIVERS_METAL_REGISTRATION_DRIVER_MODULE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | IREE_API_EXPORT iree_status_t 18 | iree_hal_metal_driver_module_register(iree_hal_driver_registry_t* registry); 19 | 20 | #ifdef __cplusplus 21 | } // extern "C" 22 | #endif // __cplusplus 23 | 24 | #endif // IREE_HAL_DRIVERS_METAL_REGISTRATION_DRIVER_MODULE_H_ 25 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/controllers/error_html.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.ErrorHTML do 2 | @moduledoc """ 3 | This module is invoked by your endpoint in case of errors on HTML requests. 4 | 5 | See config/config.exs. 6 | """ 7 | use LiveNxIREEWeb, :html 8 | 9 | # If you want to customize your error pages, 10 | # uncomment the embed_templates/1 call below 11 | # and add pages to the error directory: 12 | # 13 | # * lib/live_nx_iree_web/controllers/error_html/404.html.heex 14 | # * lib/live_nx_iree_web/controllers/error_html/500.html.heex 15 | # 16 | # embed_templates "error_html/*" 17 | 18 | # The default is to render a plain text page based on 19 | # the template name. For example, "404.html" becomes 20 | # "Not Found". 21 | def render(template, _assigns) do 22 | Phoenix.Controller.status_message_from_template(template) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/local_sync/registration/driver_module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVER_LOCAL_SYNC_REGISTRATION_DRIVER_MODULE_H_ 8 | #define IREE_HAL_DRIVER_LOCAL_SYNC_REGISTRATION_DRIVER_MODULE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | IREE_API_EXPORT iree_status_t iree_hal_local_sync_driver_module_register( 18 | iree_hal_driver_registry_t* registry); 19 | 20 | #ifdef __cplusplus 21 | } // extern "C" 22 | #endif // __cplusplus 23 | 24 | #endif // IREE_HAL_DRIVER_LOCAL_SYNC_REGISTRATION_DRIVER_MODULE_H_ 25 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/local_task/registration/driver_module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_LOCAL_TASK_REGISTRATION_DRIVER_MODULE_H_ 8 | #define IREE_HAL_DRIVERS_LOCAL_TASK_REGISTRATION_DRIVER_MODULE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | IREE_API_EXPORT iree_status_t iree_hal_local_task_driver_module_register( 18 | iree_hal_driver_registry_t* registry); 19 | 20 | #ifdef __cplusplus 21 | } // extern "C" 22 | #endif // __cplusplus 23 | 24 | #endif // IREE_HAL_DRIVERS_LOCAL_TASK_REGISTRATION_DRIVER_MODULE_H_ 25 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/local_sync/sync_event.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_LOCAL_SYNC_SYNC_EVENT_H_ 8 | #define IREE_HAL_DRIVERS_LOCAL_SYNC_SYNC_EVENT_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | iree_status_t iree_hal_sync_event_create( 18 | iree_hal_queue_affinity_t queue_affinity, iree_hal_event_flags_t flags, 19 | iree_allocator_t host_allocator, iree_hal_event_t** out_event); 20 | 21 | #ifdef __cplusplus 22 | } // extern "C" 23 | #endif // __cplusplus 24 | 25 | #endif // IREE_HAL_DRIVERS_LOCAL_SYNC_SYNC_EVENT_H_ 26 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/local_task/task_event.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_LOCAL_TASK_TASK_EVENT_H_ 8 | #define IREE_HAL_DRIVERS_LOCAL_TASK_TASK_EVENT_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | iree_status_t iree_hal_task_event_create( 18 | iree_hal_queue_affinity_t queue_affinity, iree_hal_event_flags_t flags, 19 | iree_allocator_t host_allocator, iree_hal_event_t** out_event); 20 | 21 | #ifdef __cplusplus 22 | } // extern "C" 23 | #endif // __cplusplus 24 | 25 | #endif // IREE_HAL_DRIVERS_LOCAL_TASK_TASK_EVENT_H_ 26 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/hip/registration/driver_module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_HIP_REGISTRATION_DRIVER_MODULE_H_ 8 | #define IREE_HAL_DRIVERS_HIP_REGISTRATION_DRIVER_MODULE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | // Registers the HIP HAL driver to the given |registry|. 18 | IREE_API_EXPORT iree_status_t 19 | iree_hal_hip_driver_module_register(iree_hal_driver_registry_t* registry); 20 | 21 | #ifdef __cplusplus 22 | } // extern "C" 23 | #endif // __cplusplus 24 | 25 | #endif // IREE_HAL_DRIVERS_HIP_REGISTRATION_DRIVER_MODULE_H_ 26 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/cuda/registration/driver_module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_CUDA_REGISTRATION_DRIVER_MODULE_H_ 8 | #define IREE_HAL_DRIVERS_CUDA_REGISTRATION_DRIVER_MODULE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | // Registers the CUDA HAL driver to the given |registry|. 18 | IREE_API_EXPORT iree_status_t 19 | iree_hal_cuda_driver_module_register(iree_hal_driver_registry_t* registry); 20 | 21 | #ifdef __cplusplus 22 | } // extern "C" 23 | #endif // __cplusplus 24 | 25 | #endif // IREE_HAL_DRIVERS_CUDA_REGISTRATION_DRIVER_MODULE_H_ 26 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/DisconnectedView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DisconnectedView.swift 3 | // DisconnectedView 4 | // 5 | 6 | import SwiftUI 7 | 8 | struct DisconnectedView: View { 9 | var body: some View { 10 | if #available(iOS 17, macOS 14, tvOS 17, watchOS 10, *) { 11 | ContentUnavailableView { 12 | Label("No Connection", systemImage: "network.slash") 13 | } description: { 14 | Text("The app will reconnect when network connection is regained.") 15 | } 16 | } else { 17 | VStack { 18 | Label("No Connection", systemImage: "network.slash") 19 | .font(.headline) 20 | Text("The app will reconnect when network connection is regained.") 21 | .foregroundStyle(.secondary) 22 | } 23 | } 24 | } 25 | } 26 | 27 | #Preview { 28 | DisconnectedView() 29 | } 30 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/modules/check/module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_MODULES_CHECK_MODULE_H_ 8 | #define IREE_MODULES_CHECK_MODULE_H_ 9 | 10 | #include 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/vm/api.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif // __cplusplus 18 | 19 | // Creates a native custom module. 20 | iree_status_t iree_check_module_create(iree_vm_instance_t* instance, 21 | iree_allocator_t allocator, 22 | iree_vm_module_t** out_module); 23 | 24 | #ifdef __cplusplus 25 | } // extern "C" 26 | #endif // __cplusplus 27 | 28 | #endif // IREE_MODULES_CHECK_MODULE_H_ 29 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/io/formats/irpa/irpa_parser.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_IO_FORMATS_IRPA_irpa_parser_H_ 8 | #define IREE_IO_FORMATS_IRPA_irpa_parser_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/io/file_handle.h" 12 | #include "iree/io/parameter_index.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | // Parses an IREE archive file and merges its contained resources into |index|. 19 | IREE_API_EXPORT iree_status_t iree_io_parse_irpa_index( 20 | iree_io_file_handle_t* file_handle, iree_io_parameter_index_t* index); 21 | 22 | #ifdef __cplusplus 23 | } // extern "C" 24 | #endif // __cplusplus 25 | 26 | #endif // IREE_IO_FORMATS_IRPA_irpa_parser_H_ 27 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/arch/arm_64/mmt4d_arm_64_internal.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_ARCH_ARM_64_MMT4D_ARM_64_INTERNAL_H_ 8 | #define IREE_BUILTINS_UKERNEL_ARCH_ARM_64_MMT4D_ARM_64_INTERNAL_H_ 9 | 10 | #include "iree/builtins/ukernel/mmt4d_internal.h" 11 | 12 | #define IREE_UK_MMT4D_TILE(ARCH, LHS, RHS, OUT, M0, N0, K0, SUFFIX) \ 13 | IREE_UK_MMT4D_TILE_FUNC_DECL( \ 14 | iree_uk_mmt4d_tile_##LHS##RHS##OUT##_##M0##x##N0##x##K0##_##ARCH##SUFFIX) 15 | 16 | #include "iree/builtins/ukernel/arch/arm_64/mmt4d_arm_64_tiles.inl" 17 | 18 | #undef IREE_UK_MMT4D_TILE 19 | 20 | #endif // IREE_BUILTINS_UKERNEL_ARCH_ARM_64_MMT4D_ARM_64_INTERNAL_H_ 21 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/arch/x86_64/mmt4d_x86_64_internal.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_ARCH_X86_64_MMT4D_X86_64_INTERNAL_H_ 8 | #define IREE_BUILTINS_UKERNEL_ARCH_X86_64_MMT4D_X86_64_INTERNAL_H_ 9 | 10 | #include "iree/builtins/ukernel/mmt4d_internal.h" 11 | 12 | #define IREE_UK_MMT4D_TILE(ARCH, LHS, RHS, OUT, M0, N0, K0, SUFFIX) \ 13 | IREE_UK_MMT4D_TILE_FUNC_DECL( \ 14 | iree_uk_mmt4d_tile_##LHS##RHS##OUT##_##M0##x##N0##x##K0##_##ARCH##SUFFIX) 15 | 16 | #include "iree/builtins/ukernel/arch/x86_64/mmt4d_x86_64_tiles.inl" 17 | 18 | #undef IREE_UK_MMT4D_TILE 19 | 20 | #endif // IREE_BUILTINS_UKERNEL_ARCH_X86_64_MMT4D_X86_64_INTERNAL_H_ 21 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // LiveNxIREE 4 | // 5 | 6 | import SwiftUI 7 | import LiveViewNative 8 | import LiveViewNativeLiveForm 9 | 10 | struct ContentView: View { 11 | var body: some View { 12 | #LiveView( 13 | .automatic( 14 | development: URL(string: "http://192.168.38.57:4000/")!, //.localhost(path: "/"), 15 | production: URL(string: "https://example.com")! 16 | ), 17 | addons: [ 18 | .liveForm, 19 | .nxAddon 20 | ] 21 | ) { 22 | ConnectingView() 23 | } disconnected: { 24 | DisconnectedView() 25 | } reconnecting: { content, isReconnecting in 26 | ReconnectingView(isReconnecting: isReconnecting) { 27 | content 28 | } 29 | } error: { error in 30 | ErrorView(error: error) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/.gitignore: -------------------------------------------------------------------------------- 1 | # The directory Mix will write compiled artifacts to. 2 | /_build/ 3 | 4 | # If you run "mix test --cover", coverage assets end up here. 5 | /cover/ 6 | 7 | # The directory Mix downloads your dependencies sources to. 8 | /deps/ 9 | 10 | # Where 3rd-party dependencies like ExDoc output generated docs. 11 | /doc/ 12 | 13 | # Ignore .fetch files in case you like to edit your project deps locally. 14 | /.fetch 15 | 16 | # If the VM crashes, it generates a dump, let's ignore it too. 17 | erl_crash.dump 18 | 19 | # Also ignore archive artifacts (built via "mix archive.build"). 20 | *.ez 21 | 22 | # Temporary files, for example, from tests. 23 | /tmp/ 24 | 25 | # Ignore package tarball (built via "mix hex.build"). 26 | live_nx_iree-*.tar 27 | 28 | # Ignore assets that are produced by build tools. 29 | /priv/static/assets/ 30 | 31 | # Ignore digested assets cache. 32 | /priv/static/cache_manifest.json 33 | 34 | # In case you use Node.js/npm, you want to ignore these. 35 | npm-debug.log 36 | /assets/node_modules/ 37 | 38 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/vulkan/registration/driver_module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_VULKAN_REGISTRATION_DRIVER_MODULE_H_ 8 | #define IREE_HAL_DRIVERS_VULKAN_REGISTRATION_DRIVER_MODULE_H_ 9 | 10 | // clang-format off: must be included before all other headers. 11 | #include "iree/hal/drivers/vulkan/vulkan_headers.h" 12 | // clang-format on 13 | 14 | #include "iree/base/api.h" 15 | #include "iree/hal/api.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif // __cplusplus 20 | 21 | IREE_API_EXPORT iree_status_t 22 | iree_hal_vulkan_driver_module_register(iree_hal_driver_registry_t* registry); 23 | 24 | #ifdef __cplusplus 25 | } // extern "C" 26 | #endif // __cplusplus 27 | 28 | #endif // IREE_HAL_DRIVERS_VULKAN_REGISTRATION_DRIVER_MODULE_H_ 29 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/io/formats/gguf/gguf_parser.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_IO_FORMATS_GGUF_GGUF_PARSER_H_ 8 | #define IREE_IO_FORMATS_GGUF_GGUF_PARSER_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/io/file_handle.h" 12 | #include "iree/io/parameter_index.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | // Parses a .gguf file and merges its contained resources into |index|. 19 | // 20 | // Specification: 21 | // https://github.com/ggerganov/ggml/blob/master/docs/gguf.md 22 | IREE_API_EXPORT iree_status_t iree_io_parse_gguf_index( 23 | iree_io_file_handle_t* file_handle, iree_io_parameter_index_t* index); 24 | 25 | #ifdef __cplusplus 26 | } // extern "C" 27 | #endif // __cplusplus 28 | 29 | #endif // IREE_IO_FORMATS_GGUF_GGUF_PARSER_H_ 30 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/modules/vmvx/module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_MODULES_VMVX_MODULE_H_ 8 | #define IREE_MODULES_VMVX_MODULE_H_ 9 | 10 | #include 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/vm/api.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif // __cplusplus 18 | 19 | // Creates the VMVX module with a default configuration. 20 | IREE_API_EXPORT iree_status_t iree_vmvx_module_create( 21 | iree_vm_instance_t* instance, iree_allocator_t host_allocator, 22 | iree_vm_module_t** out_module); 23 | 24 | // Updates the context-local state of the module. 25 | IREE_API_EXPORT void iree_vmvx_module_state_update_workgroup_state( 26 | iree_vm_module_state_t* module_state, uint32_t processor_id); 27 | 28 | #ifdef __cplusplus 29 | } // extern "C" 30 | #endif // __cplusplus 31 | 32 | #endif // IREE_MODULES_VMVX_MODULE_H_ 33 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/utils/libmpi_dynamic_symbols.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | MPI_PFN_DECL(MPI_Init, int*, char***) 8 | MPI_PFN_DECL(MPI_Initialized, int*) 9 | MPI_PFN_DECL(MPI_Finalize) 10 | MPI_PFN_DECL(MPI_Bcast, void* buffer, int count, IREE_MPI_Datatype datatype, 11 | int root, IREE_MPI_Comm comm) 12 | MPI_PFN_DECL(MPI_Comm_rank, IREE_MPI_Comm comm, int* rank) 13 | MPI_PFN_DECL(MPI_Comm_size, IREE_MPI_Comm comm, int* size) 14 | MPI_PFN_DECL(MPI_Comm_split, IREE_MPI_Comm comm, int color, int key, 15 | IREE_MPI_Comm* newcomm) 16 | 17 | #if IREE_MPI_TYPES_ARE_POINTERS 18 | MPI_PFN_DECL(ompi_mpi_byte) 19 | MPI_PFN_DECL(ompi_mpi_comm_world) 20 | #endif // IREE_MPI_TYPES_ARE_POINTERS 21 | 22 | // MPI error handling 23 | MPI_PFN_DECL(MPI_Error_class, int err_code, int* err_class) 24 | MPI_PFN_DECL(MPI_Error_string, int err_code, char* string, int* resultlen) 25 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/styles/app.swiftui.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.Styles.App.SwiftUI do 2 | use LiveViewNative.Stylesheet, :swiftui 3 | # Read more about UtilityStyles if you want to use them 4 | @import LiveViewNative.SwiftUI.UtilityStyles 5 | 6 | # Add your styles here 7 | # Refer to your client's documentation on what the proper syntax 8 | # is for defining rules within classes 9 | ~SHEET""" 10 | """ 11 | 12 | # If you need to have greater control over how your style rules are created 13 | # you can use the function defintion style which is more verbose but allows 14 | # for more fine-grained controled 15 | # 16 | # This example shows what is not possible within the more concise ~SHEET 17 | # use `` allows for a setting 18 | # of both the `width` and `height` values. 19 | 20 | # def class("frame:" <> dims) do 21 | # [width] = Regex.run(~r/w(\d+)/, dims, capture: :all_but_first) 22 | # [height] = Regex.run(~r/h(\d+)/, dims, capture: :all_but_first) 23 | 24 | # ~RULES""" 25 | # frame(width: {width}, height: {height}) 26 | # """ 27 | # end 28 | end 29 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/tooling/instrument_util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_TOOLING_INSTRUMENT_UTIL_H_ 8 | #define IREE_TOOLING_INSTRUMENT_UTIL_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/vm/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | //===----------------------------------------------------------------------===// 18 | // Instrument data management 19 | //===----------------------------------------------------------------------===// 20 | 21 | // Processes instrument data in |context| based on command line flags. 22 | // No-op if there's no instrument data available. 23 | iree_status_t iree_tooling_process_instrument_data( 24 | iree_vm_context_t* context, iree_allocator_t host_allocator); 25 | 26 | #ifdef __cplusplus 27 | } // extern "C" 28 | #endif // __cplusplus 29 | 30 | #endif // IREE_TOOLING_INSTRUMENT_UTIL_H_ 31 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/vulkan/native_event.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_VULKAN_NATIVE_EVENT_H_ 8 | #define IREE_HAL_DRIVERS_VULKAN_NATIVE_EVENT_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/drivers/vulkan/handle_util.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | // Creates a native Vulkan VkEvent object. 19 | iree_status_t iree_hal_vulkan_native_event_create( 20 | iree::hal::vulkan::VkDeviceHandle* logical_device, 21 | iree_hal_queue_affinity_t queue_affinity, iree_hal_event_flags_t flags, 22 | iree_hal_event_t** out_event); 23 | 24 | // Returns Vulkan event handle. 25 | VkEvent iree_hal_vulkan_native_event_handle(const iree_hal_event_t* event); 26 | 27 | #ifdef __cplusplus 28 | } // extern "C" 29 | #endif // __cplusplus 30 | 31 | #endif // IREE_HAL_DRIVERS_VULKAN_NATIVE_EVENT_H_ 32 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/vulkan/nop_executable_cache.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_VULKAN_NOP_EXECUTABLE_CACHE_H_ 8 | #define IREE_HAL_DRIVERS_VULKAN_NOP_EXECUTABLE_CACHE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/drivers/vulkan/handle_util.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | // Creates a no-op executable cache that does not cache at all. 19 | // This is useful to isolate pipeline caching behavior and verify compilation 20 | // behavior. 21 | iree_status_t iree_hal_vulkan_nop_executable_cache_create( 22 | iree::hal::vulkan::VkDeviceHandle* logical_device, 23 | iree_string_view_t identifier, 24 | iree_hal_executable_cache_t** out_executable_cache); 25 | 26 | #ifdef __cplusplus 27 | } // extern "C" 28 | #endif // __cplusplus 29 | 30 | #endif // IREE_HAL_DRIVERS_VULKAN_NOP_EXECUTABLE_CACHE_H_ 31 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/vm/bytecode/module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_VM_BYTECODE_MODULE_H_ 8 | #define IREE_VM_BYTECODE_MODULE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/vm/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | // Creates a VM module from an in-memory ModuleDef FlatBuffer archive. 18 | // If a |archive_allocator| is provided then it will be used to free the 19 | // |archive_contents| when the module is destroyed and otherwise the ownership 20 | // of the memory remains with the caller. 21 | IREE_API_EXPORT iree_status_t iree_vm_bytecode_module_create( 22 | iree_vm_instance_t* instance, iree_const_byte_span_t archive_contents, 23 | iree_allocator_t archive_allocator, iree_allocator_t allocator, 24 | iree_vm_module_t** out_module); 25 | 26 | #ifdef __cplusplus 27 | } // extern "C" 28 | #endif // __cplusplus 29 | 30 | #endif // IREE_VM_BYTECODE_MODULE_H_ 31 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/modules/io/parameters/module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_MODULES_IO_PARAMETERS_MODULE_H_ 8 | #define IREE_MODULES_IO_PARAMETERS_MODULE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/io/parameter_provider.h" 13 | #include "iree/vm/api.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif // __cplusplus 18 | 19 | // Creates a module for accessing parameters via a set of |providers|. 20 | // The providers are retained for the lifetime of the module. 21 | IREE_API_EXPORT iree_status_t iree_io_parameters_module_create( 22 | iree_vm_instance_t* instance, iree_host_size_t provider_count, 23 | iree_io_parameter_provider_t* const* providers, 24 | iree_allocator_t host_allocator, 25 | iree_vm_module_t** IREE_RESTRICT out_module); 26 | 27 | #ifdef __cplusplus 28 | } // extern "C" 29 | #endif // __cplusplus 30 | 31 | #endif // IREE_MODULES_IO_PARAMETERS_MODULE_H_ 32 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/io/formats/parser_registry.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_IO_FORMATS_PARSER_REGISTRY_H_ 8 | #define IREE_IO_FORMATS_PARSER_REGISTRY_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/io/file_handle.h" 12 | #include "iree/io/parameter_index.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | // Parses a parameter file index in the opened |file_handle|. 19 | // |path| is used for logging and file format identification. It may either be 20 | // the original file path of |file_handle| or an extension (such as `irpa`). 21 | // Upon return any parameters in the file are appended to the |index|. 22 | IREE_API_EXPORT iree_status_t iree_io_parse_file_index( 23 | iree_string_view_t path, iree_io_file_handle_t* file_handle, 24 | iree_io_parameter_index_t* index); 25 | 26 | #ifdef __cplusplus 27 | } // extern "C" 28 | #endif // __cplusplus 29 | 30 | #endif // IREE_IO_FORMATS_PARSER_REGISTRY_H_ 31 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/init.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_INIT_H_ 8 | #define IREE_HAL_DRIVERS_INIT_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | // Registers all drivers that were linked into the current binary based on the 18 | // build configuration. Note that there may be no drivers available. 19 | // 20 | // This only registers IREE core drivers (those under iree/hal/). User-provided 21 | // drivers must be directly registered or directly created, though a user could 22 | // create their own user_register_all_available_drivers() that calls this as 23 | // well as registering their drivers. 24 | IREE_API_EXPORT iree_status_t 25 | iree_hal_register_all_available_drivers(iree_hal_driver_registry_t* registry); 26 | 27 | #ifdef __cplusplus 28 | } // extern "C" 29 | #endif // __cplusplus 30 | 31 | #endif // IREE_HAL_DRIVERS_INIT_H_ 32 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/vulkan/native_allocator.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_VULKAN_NATIVE_ALLOCATOR_H_ 8 | #define IREE_HAL_DRIVERS_VULKAN_NATIVE_ALLOCATOR_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/drivers/vulkan/handle_util.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | // Creates a native Vulkan API-based allocator that directly allocates memory 19 | // from the underlying implementation with no pooling or suballocation. 20 | iree_status_t iree_hal_vulkan_native_allocator_create( 21 | const iree_hal_vulkan_device_options_t* options, VkInstance instance, 22 | VkPhysicalDevice physical_device, 23 | iree::hal::vulkan::VkDeviceHandle* logical_device, 24 | iree_hal_allocator_t** out_allocator); 25 | 26 | #ifdef __cplusplus 27 | } // extern "C" 28 | #endif // __cplusplus 29 | 30 | #endif // IREE_HAL_DRIVERS_VULKAN_NATIVE_ALLOCATOR_H_ 31 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/vm/api.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_VM_API_H_ 8 | #define IREE_VM_API_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/vm/buffer.h" // IWYU pragma: export 12 | #include "iree/vm/context.h" // IWYU pragma: export 13 | #include "iree/vm/instance.h" // IWYU pragma: export 14 | #include "iree/vm/invocation.h" // IWYU pragma: export 15 | #include "iree/vm/list.h" // IWYU pragma: export 16 | #include "iree/vm/module.h" // IWYU pragma: export 17 | #include "iree/vm/native_module.h" // IWYU pragma: export 18 | #include "iree/vm/ref.h" // IWYU pragma: export 19 | #include "iree/vm/shims.h" // IWYU pragma: export 20 | #include "iree/vm/stack.h" // IWYU pragma: export 21 | #include "iree/vm/type_def.h" // IWYU pragma: export 22 | #include "iree/vm/value.h" // IWYU pragma: export 23 | #include "iree/vm/variant.h" // IWYU pragma: export 24 | 25 | #endif // IREE_VM_API_H_ 26 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/NxAddon/ImageView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Base64ImageView.swift 3 | // NxLVN 4 | // 5 | // Created by Paulo.Valente on 1/28/24. 6 | // 7 | 8 | import SwiftUI 9 | import LiveViewNative 10 | 11 | class ImageView: ObservableObject { 12 | @Published var image: UIImage? = nil 13 | @Published var width: Int? = nil 14 | @Published var height: Int? = nil 15 | 16 | func update(_ newImage: UIImage?, _ width: Int?, _ height: Int?) { 17 | self.image = newImage 18 | self.width = width 19 | self.height = height 20 | } 21 | } 22 | 23 | public struct ImageViewContainer: View { 24 | /// The interactions allowed on the map. 25 | @_documentation(visibility: public) 26 | @ObservedObject var imageView: ImageView 27 | 28 | public var body: some View { 29 | if let image = imageView.image { 30 | Image(uiImage: image) 31 | .resizable() 32 | .aspectRatio(contentMode: .fit) 33 | .frame(width: CGFloat(imageView.width!), height: CGFloat(imageView.height!)) 34 | .clipped() 35 | } else { 36 | Text("No image available") 37 | .padding() 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/tooling/parameter_util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_TOOLING_PARAMETER_UTIL_H_ 8 | #define IREE_TOOLING_PARAMETER_UTIL_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/vm/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | typedef struct iree_io_parameter_index_t iree_io_parameter_index_t; 18 | typedef struct iree_io_scope_map_t iree_io_scope_map_t; 19 | 20 | // Populates |scope_map| with parameter indices as specified by flags. 21 | iree_status_t iree_tooling_build_parameter_indices_from_flags( 22 | iree_io_scope_map_t* scope_map); 23 | 24 | // Builds an I/O parameters module based on the runtime flags provided. 25 | iree_status_t iree_tooling_create_parameters_module_from_flags( 26 | iree_vm_instance_t* instance, iree_allocator_t host_allocator, 27 | iree_vm_module_t** out_module); 28 | 29 | #ifdef __cplusplus 30 | } // extern "C" 31 | #endif // __cplusplus 32 | 33 | #endif // IREE_TOOLING_PARAMETER_UTIL_H_ 34 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/vm/ops_emitc.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_VM_OPS_EMITC_H_ 8 | #define IREE_VM_OPS_EMITC_H_ 9 | 10 | // This file contains utility macros used for things that EmitC can't handle 11 | // directly. 12 | 13 | // Assign a value through a pointer variable 14 | #define EMITC_DEREF_ASSIGN_VALUE(ptr, value) *(ptr) = (value) 15 | 16 | // Assign a value pointed to by `ptr` through a pointer variable 17 | #define EMITC_DEREF_ASSIGN_PTR(ptr, value) *(ptr) = *(value) 18 | 19 | // Call a function pointer with the given arguments 20 | #define EMITC_CALL_INDIRECT(func, ...) (func)(__VA_ARGS__) 21 | 22 | // Get an array element 23 | #define EMITC_ARRAY_ELEMENT(array, index) (array)[index] 24 | 25 | // Get the address of an array element 26 | #define EMITC_ARRAY_ELEMENT_ADDRESS(array, index) &(array)[index] 27 | 28 | // Assign a value to an array at a given index 29 | #define EMITC_ARRAY_ELEMENT_ASSIGN(array, index, value) (array)[index] = (value) 30 | 31 | #endif // IREE_VM_OPS_EMITC_H_ 32 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/hip/nop_executable_cache.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_HIP_NOP_EXECUTABLE_CACHE_H_ 8 | #define IREE_HAL_DRIVERS_HIP_NOP_EXECUTABLE_CACHE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/drivers/hip/dynamic_symbols.h" 13 | #include "iree/hal/drivers/hip/hip_headers.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif // __cplusplus 18 | 19 | // Creates a no-op executable cache that does not cache at all. 20 | // This is useful to isolate pipeline caching behavior and verify compilation 21 | // behavior. 22 | iree_status_t iree_hal_hip_nop_executable_cache_create( 23 | iree_string_view_t identifier, 24 | const iree_hal_hip_dynamic_symbols_t* symbols, hipDevice_t device, 25 | iree_allocator_t host_allocator, 26 | iree_hal_executable_cache_t** out_executable_cache); 27 | 28 | #ifdef __cplusplus 29 | } // extern "C" 30 | #endif // __cplusplus 31 | 32 | #endif // IREE_HAL_DRIVERS_HIP_NOP_EXECUTABLE_CACHE_H_ 33 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/c_src/nx_iree.h: -------------------------------------------------------------------------------- 1 | // 2 | // nx_iree.h 3 | // LiveNxIREE 4 | // 5 | // Created by Paulo.Valente on 8/21/24. 6 | // 7 | 8 | #ifndef nx_iree_h 9 | #define nx_iree_h 10 | 11 | #include 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | iree_vm_instance_t* nx_iree_create_instance(); 19 | iree_hal_device_t* nx_iree_create_device(char* device_uri); 20 | void nx_iree_release_device(iree_hal_device_t*); 21 | 22 | char** nx_iree_call(iree_vm_instance_t* vm_instance, iree_hal_device_t* device, uint64_t bytecode_size, unsigned char* bytecode, uint64_t num_inputs, char** serialized_inputs, uint64_t num_outputs, char* error_message, uint64_t* output_byte_sizes); 23 | 24 | // this function expects to receive a single image ordered as channels x height x width and return an image with the same dimensions 25 | unsigned char* nx_iree_image_call(iree_vm_instance_t* vm_instance, iree_hal_device_t* device, uint64_t bytecode_size, unsigned char* bytecode, uint64_t* input_dims, unsigned char* input_data, char* error_message, uint32_t seed, float noise_amount); 26 | 27 | char** nx_iree_list_all_devices(uint64_t* count); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | 34 | #endif /* nx_iree_h */ 35 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/arch/arm_64/pack_arm_64_internal.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_ARCH_ARM_64_PACK_ARM_64_INTERNAL_H_ 8 | #define IREE_BUILTINS_UKERNEL_ARCH_ARM_64_PACK_ARM_64_INTERNAL_H_ 9 | 10 | #include "iree/builtins/ukernel/pack_internal.h" 11 | 12 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_8x1_x8_arm_64_direct) 13 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_8x4_x8_arm_64_direct) 14 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_8x1_x32_arm_64_direct) 15 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_8x8_x8_arm_64_direct) 16 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_8x1_x32_arm_64_transpose) 17 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_8x1_x8_arm_64_transpose) 18 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_8x4_x8_arm_64_transpose) 19 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_8x8_x8_arm_64_transpose) 20 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_8x8_x32_arm_64_direct) 21 | 22 | #endif // foIREE_BUILTINS_UKERNEL_ARCH_ARM_64_PACK_ARM_64_INTERNAL_H_ 23 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/vm/shims_emitc.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_VM_SHIMS_EMITC_H_ 8 | #define IREE_VM_SHIMS_EMITC_H_ 9 | 10 | #include "iree/base/attributes.h" 11 | #include "iree/vm/module.h" 12 | #include "iree/vm/stack.h" 13 | 14 | typedef iree_status_t (*iree_vm_native_function_target_emitc_t)( 15 | iree_vm_stack_t* IREE_RESTRICT stack, iree_vm_native_function_flags_t flags, 16 | iree_byte_span_t args_storage, iree_byte_span_t rets_storage, 17 | void* IREE_RESTRICT module, void* IREE_RESTRICT module_state); 18 | 19 | static inline iree_status_t iree_emitc_shim( 20 | iree_vm_stack_t* IREE_RESTRICT stack, iree_vm_native_function_flags_t flags, 21 | iree_byte_span_t args_storage, iree_byte_span_t rets_storage, 22 | iree_vm_native_function_target_emitc_t target_fn, 23 | void* IREE_RESTRICT module, void* IREE_RESTRICT module_state) { 24 | return target_fn(stack, flags, args_storage, rets_storage, module, 25 | module_state); 26 | } 27 | 28 | #endif // IREE_VM_SHIMS_EMITC_H_ 29 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/components/layouts/app.html.heex: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | v<%= Application.spec(:phoenix, :vsn) %> 9 | 10 | 11 | 12 | 13 | @elixirphoenix 14 | 15 | 16 | GitHub 17 | 18 | 22 | Get Started → 23 | 24 | 25 | 26 | 27 | 28 | 29 | <.flash_group flash={@flash} /> 30 | <%= @inner_content %> 31 | 32 | 33 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/cuda/nop_executable_cache.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_CUDA_NOP_EXECUTABLE_CACHE_H_ 8 | #define IREE_HAL_DRIVERS_CUDA_NOP_EXECUTABLE_CACHE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/drivers/cuda/cuda_dynamic_symbols.h" 13 | #include "iree/hal/drivers/cuda/cuda_headers.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif // __cplusplus 18 | 19 | // Creates a no-op executable cache that does not cache at all. 20 | // This is useful to isolate pipeline caching behavior and verify compilation 21 | // behavior. 22 | iree_status_t iree_hal_cuda_nop_executable_cache_create( 23 | iree_string_view_t identifier, 24 | const iree_hal_cuda_dynamic_symbols_t* symbols, CUdevice device, 25 | iree_allocator_t host_allocator, 26 | iree_hal_executable_cache_t** out_executable_cache); 27 | 28 | #ifdef __cplusplus 29 | } // extern "C" 30 | #endif // __cplusplus 31 | 32 | #endif // IREE_HAL_DRIVERS_CUDA_NOP_EXECUTABLE_CACHE_H_ 33 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/metal/nop_executable_cache.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_METAL_METAL_NOP_EXECUTABLE_CACHE_H_ 8 | #define IREE_HAL_DRIVERS_METAL_METAL_NOP_EXECUTABLE_CACHE_H_ 9 | 10 | #import 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/hal/api.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif // __cplusplus 18 | 19 | // Creates a no-op executable cache that does not cache at all. 20 | // This is useful to isolate pipeline caching behavior and verify compilation 21 | // behavior. 22 | // 23 | // |out_executable_cache| must be released by the caller (see 24 | // iree_hal_executable_cache_release). 25 | iree_status_t iree_hal_metal_nop_executable_cache_create( 26 | id device, iree_string_view_t identifier, 27 | iree_allocator_t host_allocator, 28 | iree_hal_executable_cache_t** out_executable_cache); 29 | 30 | #ifdef __cplusplus 31 | } // extern "C" 32 | #endif // __cplusplus 33 | 34 | #endif // IREE_HAL_DRIVERS_METAL_METAL_NOP_EXECUTABLE_CACHE_H_ 35 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/test/support/conn_case.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.ConnCase do 2 | @moduledoc """ 3 | This module defines the test case to be used by 4 | tests that require setting up a connection. 5 | 6 | Such tests rely on `Phoenix.ConnTest` and also 7 | import other functionality to make it easier 8 | to build common data structures and query the data layer. 9 | 10 | Finally, if the test case interacts with the database, 11 | we enable the SQL sandbox, so changes done to the database 12 | are reverted at the end of every test. If you are using 13 | PostgreSQL, you can even run database tests asynchronously 14 | by setting `use LiveNxIREEWeb.ConnCase, async: true`, although 15 | this option is not recommended for other databases. 16 | """ 17 | 18 | use ExUnit.CaseTemplate 19 | 20 | using do 21 | quote do 22 | # The default endpoint for testing 23 | @endpoint LiveNxIREEWeb.Endpoint 24 | 25 | use LiveNxIREEWeb, :verified_routes 26 | 27 | # Import conveniences for testing with connections 28 | import Plug.Conn 29 | import Phoenix.ConnTest 30 | import LiveNxIREEWeb.ConnCase 31 | end 32 | end 33 | 34 | setup tags do 35 | LiveNxIREE.DataCase.setup_sandbox(tags) 36 | {:ok, conn: Phoenix.ConnTest.build_conn()} 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/hip/hip_allocator.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_HIP_ALLOCATOR_H_ 8 | #define IREE_HAL_DRIVERS_HIP_ALLOCATOR_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/drivers/hip/memory_pools.h" 13 | #include "iree/hal/drivers/hip/status_util.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif // __cplusplus 18 | 19 | // Creates a HIP memory allocator. 20 | // |device| and |stream| will be used for management operations. 21 | // |pools| provides memory pools that may be shared across multiple allocators 22 | // and the pointer must remain valid for the lifetime of the allocator. 23 | iree_status_t iree_hal_hip_allocator_create( 24 | const iree_hal_hip_dynamic_symbols_t* hip_symbols, hipDevice_t device, 25 | hipStream_t stream, iree_hal_hip_memory_pools_t* pools, 26 | iree_allocator_t host_allocator, iree_hal_allocator_t** out_allocator); 27 | 28 | #ifdef __cplusplus 29 | } // extern "C" 30 | #endif // __cplusplus 31 | 32 | #endif // IREE_HAL_DRIVERS_HIP_ALLOCATOR_H_ 33 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/io/memory_stream.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_IO_MEMORY_STREAM_H_ 8 | #define IREE_IO_MEMORY_STREAM_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/io/stream.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | //===----------------------------------------------------------------------===// 18 | // iree_io_memory_stream_t 19 | //===----------------------------------------------------------------------===// 20 | 21 | // Wraps a fixed-size host memory allocation |contents| in a stream. 22 | // |release_callback| can be used to receive a callback when the stream is 23 | // destroyed and the reference to the contents is no longer required. 24 | IREE_API_EXPORT iree_status_t iree_io_memory_stream_wrap( 25 | iree_io_stream_mode_t mode, iree_byte_span_t contents, 26 | iree_io_stream_release_callback_t release_callback, 27 | iree_allocator_t host_allocator, iree_io_stream_t** out_stream); 28 | 29 | #ifdef __cplusplus 30 | } // extern "C" 31 | #endif // __cplusplus 32 | 33 | #endif // IREE_IO_MEMORY_STREAM_H_ 34 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/vm/bytecode/archive.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_VM_BYTECODE_ARCHIVE_H_ 8 | #define IREE_VM_BYTECODE_ARCHIVE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/vm/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | // Alignment applied to each segment of the archive. 18 | // All embedded file contents (FlatBuffers, rodata, etc) are aligned to this 19 | // boundary. 20 | #define IREE_VM_ARCHIVE_SEGMENT_ALIGNMENT 64 21 | 22 | // Parses the module archive header in |archive_contents|. 23 | // The subrange containing the FlatBuffer data is returned as well as the 24 | // offset where external rodata begins. Note that archives may have 25 | // non-contiguous layouts! 26 | IREE_API_EXPORT iree_status_t iree_vm_bytecode_archive_parse_header( 27 | iree_const_byte_span_t archive_contents, 28 | iree_const_byte_span_t* out_flatbuffer_contents, 29 | iree_host_size_t* out_rodata_offset); 30 | 31 | #ifdef __cplusplus 32 | } // extern "C" 33 | #endif // __cplusplus 34 | 35 | #endif // IREE_VM_BYTECODE_ARCHIVE_H_ 36 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree/application.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREE.Application do 2 | # See https://hexdocs.pm/elixir/Application.html 3 | # for more information on OTP Applications 4 | @moduledoc false 5 | 6 | use Application 7 | 8 | @impl true 9 | def start(_type, _args) do 10 | children = [ 11 | LiveNxIREEWeb.Telemetry, 12 | # LiveNxIREE.Repo, 13 | {DNSCluster, query: Application.get_env(:live_nx_iree, :dns_cluster_query) || :ignore}, 14 | {Phoenix.PubSub, name: LiveNxIREE.PubSub}, 15 | # Start the Finch HTTP client for sending emails 16 | {Finch, name: LiveNxIREE.Finch}, 17 | # Start a worker by calling: LiveNxIREE.Worker.start_link(arg) 18 | # {LiveNxIREE.Worker, arg}, 19 | # Start to serve requests, typically the last entry 20 | LiveNxIREEWeb.Endpoint 21 | ] 22 | 23 | # See https://hexdocs.pm/elixir/Supervisor.html 24 | # for other strategies and supported options 25 | opts = [strategy: :one_for_one, name: LiveNxIREE.Supervisor] 26 | Supervisor.start_link(children, opts) 27 | end 28 | 29 | # Tell Phoenix to update the endpoint configuration 30 | # whenever the application is updated. 31 | @impl true 32 | def config_change(changed, _new, removed) do 33 | LiveNxIREEWeb.Endpoint.config_change(changed, removed) 34 | :ok 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/hip/hip_headers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_HIP_HIP_HEADERS_H_ 8 | #define IREE_HAL_DRIVERS_HIP_HIP_HEADERS_H_ 9 | 10 | #if defined(IREE_PTR_SIZE_32) 11 | #error "32-bit not supported on HIP backend" 12 | #endif // defined(IREE_PTR_SIZE_32) 13 | 14 | #define __HIP_PLATFORM_AMD__ 15 | // Order matters here--hip_deprecated.h depends on hip_runtime_api.h. So turn 16 | // off clang-format. 17 | // 18 | // We need to pull in this hip_deprecated.h for the old hipDeviceProp_t struct 19 | // definition, hipDeviceProp_tR0000. HIP 6.0 release changes the struct in the 20 | // middle. The hipDeviceProp_t struct would need to use the matching 21 | // hipGetDevicePropertiesR0600() API to query it. We want to also support HIP 22 | // 5.x versions so use the old hipGetDeviceProperties() API with its matching 23 | // struct. 24 | 25 | // clang-format off 26 | #include "hip/hip_runtime_api.h" // IWYU pragma: export 27 | #include "hip/hip_deprecated.h" // IWYU pragma: export 28 | // clang-format on 29 | 30 | #endif // IREE_HAL_DRIVERS_HIP_HIP_HEADERS_H_ 31 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/unpack.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_UNPACK_H_ 8 | #define IREE_BUILTINS_UKERNEL_UNPACK_H_ 9 | 10 | #include "iree/builtins/ukernel/common.h" 11 | 12 | // `unpack` microkernel. Currently only used in the VMVX backend, not used in 13 | // the LLVMCPU backend, because codegen is thought to be good enough and because 14 | // pack ops tend to get fused with many other ops, with substantial performance 15 | // benefit outweighing the microkernel advantage. 16 | 17 | IREE_UK_EXPORT void iree_uk_unpack( 18 | const void* in_buffer, iree_uk_index_t in_offset, 19 | iree_uk_index_t in_stride0, iree_uk_index_t in_stride1, void* out_buffer, 20 | iree_uk_index_t out_offset, iree_uk_index_t out_stride0, 21 | iree_uk_index_t out_stride1, iree_uk_index_t in_size0, 22 | iree_uk_index_t in_size1, iree_uk_index_t in_size2, 23 | iree_uk_index_t in_size3, iree_uk_index_t out_size0, 24 | iree_uk_index_t out_size1, iree_uk_uint32_t flags, 25 | const iree_uk_uint64_t* cpu_data); 26 | 27 | #endif // IREE_BUILTINS_UKERNEL_UNPACK_H_ 28 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/modules/hal/loader/module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_MODULES_HAL_LOADER_MODULE_H_ 8 | #define IREE_MODULES_HAL_LOADER_MODULE_H_ 9 | 10 | #include 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/hal/api.h" 14 | #include "iree/hal/local/executable_loader.h" 15 | #include "iree/modules/hal/types.h" 16 | #include "iree/vm/api.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif // __cplusplus 21 | 22 | enum iree_hal_loader_module_flag_bits_t { 23 | IREE_HAL_LOADER_MODULE_FLAG_NONE = 0u, 24 | }; 25 | typedef uint32_t iree_hal_loader_module_flags_t; 26 | 27 | // Creates the dynamic HAL executable loader module for local execution. 28 | IREE_API_EXPORT iree_status_t iree_hal_loader_module_create( 29 | iree_vm_instance_t* instance, iree_hal_loader_module_flags_t flags, 30 | iree_host_size_t loader_count, iree_hal_executable_loader_t** loaders, 31 | iree_allocator_t host_allocator, iree_vm_module_t** out_module); 32 | 33 | #ifdef __cplusplus 34 | } // extern "C" 35 | #endif // __cplusplus 36 | 37 | #endif // IREE_MODULES_HAL_LOADER_MODULE_H_ 38 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/query_tile_sizes_internal.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_QUERY_TILE_SIZES_INTERNAL_H_ 8 | #define IREE_BUILTINS_UKERNEL_QUERY_TILE_SIZES_INTERNAL_H_ 9 | 10 | #include "iree/builtins/ukernel/query_tile_sizes.h" 11 | 12 | static inline iree_uk_uint32_t iree_uk_query_tile_sizes_operand_role( 13 | iree_uk_uint32_t flags) { 14 | return flags & IREE_UK_FLAG_QUERY_TILE_SIZES_OPERAND_ROLE_MASK; 15 | } 16 | 17 | static inline iree_uk_uint32_t iree_uk_query_tile_sizes_operation( 18 | iree_uk_uint32_t flags) { 19 | return flags & IREE_UK_FLAG_QUERY_TILE_SIZES_OPERATION_MASK; 20 | } 21 | 22 | // Holds matmul tile params as returned from architecture-specific backend code. 23 | typedef struct iree_uk_matmul_tile_sizes_t { 24 | int M, K, N; 25 | } iree_uk_matmul_tile_sizes_t; 26 | 27 | // Architecture-specific implementation. 28 | bool iree_uk_query_matmul_tile_sizes_arch( 29 | const iree_uk_query_tile_sizes_2d_params_t* params, 30 | iree_uk_matmul_tile_sizes_t* out_matmul_tile_sizes); 31 | 32 | #endif // IREE_BUILTINS_UKERNEL_QUERY_TILE_SIZES_INTERNAL_H_ 33 | -------------------------------------------------------------------------------- /cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12 FATAL_ERROR) 2 | 3 | set(_NAME nx_iree_runtime) 4 | 5 | project(${_NAME} VERSION 1.0 LANGUAGES CXX C) 6 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 7 | include(CheckCCompilerFlag) 8 | 9 | set(CMAKE_CXX_STANDARD 17) 10 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 11 | set(CMAKE_CXX_EXTENSIONS OFF) 12 | 13 | set(IREE_INPUT_STABLEHLO ON) 14 | set(IREE_BUILD_TESTS OFF) 15 | set(IREE_BUILD_SAMPLES OFF) 16 | 17 | if(CMAKE_BUILD_TYPE MATCHES MinSizeRel) 18 | set(IREE_SIZE_OPTIMIZED ON) 19 | endif() 20 | 21 | file(GLOB iree_runtime_sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h") 22 | 23 | if("$ENV{IREE_BUILD_TARGET}" STREQUAL "webassembly") 24 | add_subdirectory(modules/emscripten) 25 | else() 26 | add_subdirectory(modules/default) 27 | endif() 28 | 29 | set_target_properties(${_NAME} PROPERTIES 30 | INSTALL_RPATH_USE_LINK_PATH TRUE 31 | BUILD_WITH_INSTALL_RPATH TRUE 32 | ) 33 | 34 | set(__BUILD_DIR "${IREE_RUNTIME_BUILD_DIR}") 35 | 36 | add_subdirectory("${NX_IREE_SOURCE_DIR}" ${__BUILD_DIR} EXCLUDE_FROM_ALL) 37 | 38 | # Ensure visibility of all symbols 39 | set(CMAKE_CXX_VISIBILITY_PRESET default) 40 | set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF) 41 | 42 | target_compile_options(${_NAME} PUBLIC ${IREE_DEFAULT_COPTS}) 43 | 44 | add_definitions(-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1) -------------------------------------------------------------------------------- /test/nx_iree/native_test.exs: -------------------------------------------------------------------------------- 1 | defmodule NxIREE.NativeTest do 2 | use ExUnit.Case, async: true 3 | 4 | test "serializes and deserializes a tensor" do 5 | tensor = Nx.tensor([[[1, 2], [3, 4], [5, 6]]], type: :s32, backend: NxIREE.Backend) 6 | 7 | {:ok, serialized} = NxIREE.Native.serialize_tensor(tensor.data.ref) 8 | 9 | assert << 10 | type::unsigned-integer-native-size(32), 11 | num_bytes::unsigned-integer-native-size(64), 12 | data::binary-size(num_bytes), 13 | num_dims::unsigned-integer-native-size(64), 14 | dims_bin::bitstring 15 | >> = serialized 16 | 17 | dims = 18 | for <> do 19 | x 20 | end 21 | 22 | # the type assertion is really an internal type to iree, 23 | # but we assert on it as a sanity check. 24 | # This can be skipped if needed in the future. 25 | assert Bitwise.band(type, 0xFF) == 32 26 | assert Bitwise.band(Bitwise.bsr(type, 24), 0xFF) == 0x10 27 | 28 | assert num_bytes == Nx.byte_size(tensor) 29 | assert data == Nx.to_binary(tensor) 30 | assert num_dims == 3 31 | assert dims == [1, 3, 2] 32 | 33 | {:ok, deserialized_ref} = NxIREE.Native.deserialize_tensor(serialized) 34 | 35 | assert Nx.to_binary(tensor) == Nx.to_binary(put_in(tensor.data.ref, deserialized_ref)) 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/utils/debug_allocator.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_UTILS_DEBUG_ALLOCATOR_H_ 8 | #define IREE_HAL_UTILS_DEBUG_ALLOCATOR_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | // A HAL buffer allocator scribbles debug patterns into all allocated 18 | // buffers. This can be used to identify incorrect use of memory. Note that this 19 | // has severe performance implications and should only be used when diagnosing 20 | // memory correctness issues. 21 | typedef struct iree_hal_debug_allocator_t iree_hal_debug_allocator_t; 22 | 23 | // Creates a debug allocator intercepting all |device_allocator| allocations. 24 | // If needed |device| will be used for scheduling work. 25 | iree_status_t iree_hal_debug_allocator_create( 26 | iree_hal_device_t* device, iree_hal_allocator_t* device_allocator, 27 | iree_allocator_t host_allocator, iree_hal_allocator_t** out_allocator); 28 | 29 | #ifdef __cplusplus 30 | } // extern "C" 31 | #endif // __cplusplus 32 | 33 | #endif // IREE_HAL_UTILS_DEBUG_ALLOCATOR_H_ 34 | -------------------------------------------------------------------------------- /lib/nx_iree/native.ex: -------------------------------------------------------------------------------- 1 | defmodule NxIREE.Native do 2 | @moduledoc false 3 | @on_load :__on_load__ 4 | 5 | def __on_load__ do 6 | # libnx_iree.so wraps libnx_iree_runtime.so/dylib and provides a NIF interface 7 | path = :filename.join(:code.priv_dir(:nx_iree), "libnx_iree") 8 | :erlang.load_nif(path, 0) 9 | end 10 | 11 | def create_instance, do: :erlang.nif_error(:undef) 12 | def get_driver_registry, do: :erlang.nif_error(:undef) 13 | 14 | def list_devices(_registry), do: :erlang.nif_error(:undef) 15 | def list_devices(_registry, _driver), do: :erlang.nif_error(:undef) 16 | def list_drivers(_registry), do: :erlang.nif_error(:undef) 17 | 18 | def create_device(_registry, _device_uri), do: :erlang.nif_error(:undef) 19 | 20 | def deallocate_buffer(_reference), do: :erlang.nif_error(:undef) 21 | def allocate_buffer(_data, _device_ref, _dims, _element_type), do: :erlang.nif_error(:undef) 22 | def read_buffer(_device_ref, _input_ref, _num_bytes), do: :erlang.nif_error(:undef) 23 | 24 | def call_io(_instance_ref, _device_ref, _driver_name, _bytecode, _inputs), 25 | do: :erlang.nif_error(:undef) 26 | 27 | def call_cpu(_instance_ref, _device_ref, _driver_name, _bytecode, _inputs), 28 | do: :erlang.nif_error(:undef) 29 | 30 | def serialize_tensor(_reference), do: :erlang.nif_error(:undef) 31 | def deserialize_tensor(_binary), do: :erlang.nif_error(:undef) 32 | end 33 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/local/executable_environment.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_LOCAL_EXECUTABLE_ENVIRONMENT_H_ 8 | #define IREE_HAL_LOCAL_EXECUTABLE_ENVIRONMENT_H_ 9 | 10 | #include 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/hal/api.h" 14 | #include "iree/hal/local/executable_library.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif // __cplusplus 19 | 20 | //===----------------------------------------------------------------------===// 21 | // iree_hal_executable_environment_*_t 22 | //===----------------------------------------------------------------------===// 23 | 24 | // Initializes |out_environment| to the default empty environment. 25 | // No imports will be available unless overridden during loading. 26 | // |temp_allocator| may be used for temporary allocations during initialization. 27 | void iree_hal_executable_environment_initialize( 28 | iree_allocator_t temp_allocator, 29 | iree_hal_executable_environment_v0_t* out_environment); 30 | 31 | #ifdef __cplusplus 32 | } // extern "C" 33 | #endif // __cplusplus 34 | 35 | #endif // IREE_HAL_LOCAL_EXECUTABLE_ENVIRONMENT_H_ 36 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/local/loaders/embedded_elf_loader.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_LOCAL_LOADERS_EMBEDDED_ELF_LOADER_H_ 8 | #define IREE_HAL_LOCAL_LOADERS_EMBEDDED_ELF_LOADER_H_ 9 | 10 | #include 11 | #include 12 | 13 | #include "iree/base/api.h" 14 | #include "iree/hal/local/executable_loader.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif // __cplusplus 19 | 20 | typedef struct iree_hal_executable_plugin_manager_t 21 | iree_hal_executable_plugin_manager_t; 22 | 23 | // Creates an executable loader that can load minimally-featured ELF dynamic 24 | // libraries on any platform. This allows us to use a single file format across 25 | // all operating systems at the cost of some missing debugging/profiling 26 | // features. 27 | iree_status_t iree_hal_embedded_elf_loader_create( 28 | iree_hal_executable_plugin_manager_t* plugin_manager, 29 | iree_allocator_t host_allocator, 30 | iree_hal_executable_loader_t** out_executable_loader); 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif // __cplusplus 35 | 36 | #endif // IREE_HAL_LOCAL_LOADERS_EMBEDDED_ELF_LOADER_H_ 37 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/metal/metal_device.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_METAL_METAL_DEVICE_H_ 8 | #define IREE_HAL_DRIVERS_METAL_METAL_DEVICE_H_ 9 | 10 | #import 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/hal/api.h" 14 | #include "iree/hal/drivers/metal/api.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif // __cplusplus 19 | 20 | // Creates a Metal device by wrapping |device| from the given |driver| with the 21 | // specific |params|. 22 | // 23 | // |out_device| must be released by the caller (see iree_hal_device_release). 24 | iree_status_t iree_hal_metal_device_create( 25 | iree_string_view_t identifier, const iree_hal_metal_device_params_t* params, 26 | id device, iree_allocator_t host_allocator, 27 | iree_hal_device_t** out_device); 28 | 29 | // Returns the parameters used for creating the device. 30 | const iree_hal_metal_device_params_t* iree_hal_metal_device_params( 31 | const iree_hal_device_t* device); 32 | 33 | #ifdef __cplusplus 34 | } // extern "C" 35 | #endif // __cplusplus 36 | 37 | #endif // IREE_HAL_DRIVERS_METAL_METAL_DEVICE_H_ 38 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/local_sync/sync_driver.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_LOCAL_SYNC_SYNC_DRIVER_H_ 8 | #define IREE_HAL_DRIVERS_LOCAL_SYNC_SYNC_DRIVER_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/drivers/local_sync/sync_device.h" 13 | #include "iree/hal/local/executable_loader.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif // __cplusplus 18 | 19 | // Creates a new synchronous local CPU driver that creates devices that perform 20 | // execution inline on threads issuing submissions. |loaders| is the set of 21 | // executable loaders that are available for loading in each device context. 22 | iree_status_t iree_hal_sync_driver_create( 23 | iree_string_view_t identifier, 24 | const iree_hal_sync_device_params_t* default_params, 25 | iree_host_size_t loader_count, iree_hal_executable_loader_t** loaders, 26 | iree_hal_allocator_t* device_allocator, iree_allocator_t host_allocator, 27 | iree_hal_driver_t** out_driver); 28 | 29 | #ifdef __cplusplus 30 | } // extern "C" 31 | #endif // __cplusplus 32 | 33 | #endif // IREE_HAL_DRIVERS_LOCAL_SYNC_SYNC_DRIVER_H_ 34 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/query_tile_sizes.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_QUERY_TILE_SIZES_H_ 8 | #define IREE_BUILTINS_UKERNEL_QUERY_TILE_SIZES_H_ 9 | 10 | #include "iree/builtins/ukernel/common.h" 11 | 12 | // `query_tile_sizes` microkernel. Only used in the VMVX backend, because that 13 | // is the only place where target information is not known at compile time, 14 | // forcing deferral of tile-size selection to runtime. 15 | 16 | // Parameters for a query_tile_sizes operation. 17 | typedef struct iree_uk_query_tile_sizes_2d_params_t { 18 | iree_uk_uint32_t flags; 19 | iree_uk_index_t size0; 20 | iree_uk_index_t size1; 21 | const iree_uk_uint64_t* cpu_data; 22 | } iree_uk_query_tile_sizes_2d_params_t; 23 | 24 | typedef struct iree_uk_query_tile_sizes_2d_out_params_t { 25 | iree_uk_index_t tile_size0; 26 | iree_uk_index_t tile_size1; 27 | } iree_uk_query_tile_sizes_2d_out_params_t; 28 | 29 | IREE_UK_EXPORT void iree_uk_query_tile_sizes_2d( 30 | const iree_uk_query_tile_sizes_2d_params_t* params, 31 | iree_uk_query_tile_sizes_2d_out_params_t* out_params); 32 | 33 | #endif // IREE_BUILTINS_UKERNEL_QUERY_TILE_SIZES_H_ 34 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/cuda/cuda_allocator.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_CUDA_CUDA_ALLOCATOR_H_ 8 | #define IREE_HAL_DRIVERS_CUDA_CUDA_ALLOCATOR_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/drivers/cuda/cuda_dynamic_symbols.h" 13 | #include "iree/hal/drivers/cuda/memory_pools.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif // __cplusplus 18 | 19 | // Creates a CUDA memory allocator. 20 | // |device| and |stream| will be used for management operations. 21 | // |pools| provides memory pools that may be shared across multiple allocators 22 | // and the pointer must remain valid for the lifetime of the allocator. Pools 23 | // may not be supported on all devices and can be NULL. 24 | iree_status_t iree_hal_cuda_allocator_create( 25 | const iree_hal_cuda_dynamic_symbols_t* cuda_symbols, CUdevice device, 26 | CUstream stream, iree_hal_cuda_memory_pools_t* pools, 27 | iree_allocator_t host_allocator, iree_hal_allocator_t** out_allocator); 28 | 29 | #ifdef __cplusplus 30 | } // extern "C" 31 | #endif // __cplusplus 32 | 33 | #endif // IREE_HAL_DRIVERS_CUDA_CUDA_ALLOCATOR_H_ 34 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/config/test.exs: -------------------------------------------------------------------------------- 1 | import Config 2 | 3 | # Configure your database 4 | # 5 | # The MIX_TEST_PARTITION environment variable can be used 6 | # to provide built-in test partitioning in CI environment. 7 | # Run `mix help test` for more information. 8 | config :live_nx_iree, LiveNxIREE.Repo, 9 | username: "postgres", 10 | password: "postgres", 11 | hostname: "localhost", 12 | database: "live_nx_iree_test#{System.get_env("MIX_TEST_PARTITION")}", 13 | pool: Ecto.Adapters.SQL.Sandbox, 14 | pool_size: System.schedulers_online() * 2 15 | 16 | # We don't run a server during test. If one is required, 17 | # you can enable the server option below. 18 | config :live_nx_iree, LiveNxIREEWeb.Endpoint, 19 | http: [ip: {127, 0, 0, 1}, port: 4002], 20 | secret_key_base: "7v8vwAFxEaV+KHGWD/AR2PEuzsLB4DNnZE3Z7k5uS9BE9QkU/gcHgUKQssSurNI7", 21 | server: false 22 | 23 | # In test we don't send emails 24 | config :live_nx_iree, LiveNxIREE.Mailer, adapter: Swoosh.Adapters.Test 25 | 26 | # Disable swoosh api client as it is only required for production adapters 27 | config :swoosh, :api_client, false 28 | 29 | # Print only warnings and errors during test 30 | config :logger, level: :warning 31 | 32 | # Initialize plugs at runtime for faster test compilation 33 | config :phoenix, :plug_init_mode, :runtime 34 | 35 | # Enable helpful, but potentially expensive runtime checks 36 | config :phoenix_live_view, 37 | enable_expensive_runtime_checks: true 38 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/modules/hal/inline/module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_MODULES_HAL_INLINE_MODULE_H_ 8 | #define IREE_MODULES_HAL_INLINE_MODULE_H_ 9 | 10 | #include 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/hal/api.h" 14 | #include "iree/modules/hal/types.h" 15 | #include "iree/vm/api.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif // __cplusplus 20 | 21 | enum iree_hal_inline_module_flag_bits_t { 22 | IREE_HAL_INLINE_MODULE_FLAG_NONE = 0u, 23 | }; 24 | typedef uint32_t iree_hal_inline_module_flags_t; 25 | 26 | // Creates the inline HAL module for local execution. 27 | // This provides ABI compatibility with the full HAL implementation in a much 28 | // smaller footprint. The given |device_allocator| will be used for buffer 29 | // allocations. 30 | IREE_API_EXPORT iree_status_t iree_hal_inline_module_create( 31 | iree_vm_instance_t* instance, iree_hal_inline_module_flags_t flags, 32 | iree_hal_allocator_t* device_allocator, iree_allocator_t host_allocator, 33 | iree_vm_module_t** out_module); 34 | 35 | #ifdef __cplusplus 36 | } // extern "C" 37 | #endif // __cplusplus 38 | 39 | #endif // IREE_MODULES_HAL_INLINE_MODULE_H_ 40 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/mmt4d.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_MMT4D_H_ 8 | #define IREE_BUILTINS_UKERNEL_MMT4D_H_ 9 | 10 | #include "iree/builtins/ukernel/common.h" 11 | 12 | // `mmt4d` microkernel. Used on LLVMCPU (as well as VMVX), due to difficulty of 13 | // code generation of matrix multiplications kernels. 14 | IREE_UK_EXPORT void iree_uk_mmt4d( 15 | const void* lhs_buffer, iree_uk_index_t lhs_offset, 16 | iree_uk_index_t lhs_stride0, const void* rhs_buffer, 17 | iree_uk_index_t rhs_offset, iree_uk_index_t rhs_stride0, void* out_buffer, 18 | iree_uk_index_t out_offset, iree_uk_index_t out_stride0, iree_uk_index_t M, 19 | iree_uk_index_t N, iree_uk_index_t K, iree_uk_int32_t M0, 20 | iree_uk_int32_t N0, iree_uk_int32_t K0, iree_uk_uint32_t flags, 21 | const iree_uk_uint64_t* cpu_data); 22 | 23 | // Returns a bit-field of information about how a mmt4d with the given 24 | // parameters would run. 25 | IREE_UK_EXPORT iree_uk_uint32_t 26 | iree_uk_mmt4d_info(iree_uk_int32_t M0, iree_uk_int32_t N0, iree_uk_int32_t K0, 27 | iree_uk_uint32_t flags, const iree_uk_uint64_t* cpu_data); 28 | 29 | #endif // IREE_BUILTINS_UKERNEL_MMT4D_H_ 30 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/base/internal/flatcc/building.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BASE_INTERNAL_FLATCC_BUILDING_H_ 8 | #define IREE_BASE_INTERNAL_FLATCC_BUILDING_H_ 9 | 10 | //===----------------------------------------------------------------------===// 11 | // flatcc include order fixes 12 | //===----------------------------------------------------------------------===// 13 | // 14 | // This header merely wraps the flatcc headers that are generally useful to 15 | // include in various places that may not know the specific messages they are 16 | // working with. 17 | // 18 | // If using flatcc prefer to include this file over any hard-to-handle flatcc 19 | // file such as flatbuffers_common_reader.h or flatbuffers_common_builder.h. 20 | // 21 | // NOTE: order matters for these includes so stop clang from messing with it: 22 | // clang-format off 23 | 24 | #include "iree/base/internal/flatcc/parsing.h" 25 | 26 | #include "flatcc/flatcc_builder.h" // IWYU pragma: export 27 | #include "flatcc/reflection/flatbuffers_common_builder.h" // IWYU pragma: export 28 | #include "iree/base/internal/flatcc/dummy_builder.h" // IWYU pragma: export 29 | 30 | // clang-format on 31 | 32 | #endif // IREE_BASE_INTERNAL_FLATCC_BUILDING_H_ 33 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/base/internal/flatcc/parsing.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BASE_INTERNAL_FLATCC_PARSING_H_ 8 | #define IREE_BASE_INTERNAL_FLATCC_PARSING_H_ 9 | 10 | //===----------------------------------------------------------------------===// 11 | // flatcc include order fixes 12 | //===----------------------------------------------------------------------===// 13 | // 14 | // This header merely wraps the flatcc headers that are generally useful to 15 | // include in various places that may not know the specific messages they are 16 | // working with. 17 | // 18 | // If using flatcc prefer to include this file over any hard-to-handle flatcc 19 | // file such as flatbuffers_common_reader.h or flatbuffers_common_builder.h. 20 | // 21 | // NOTE: order matters for these includes so stop clang from messing with it: 22 | // clang-format off 23 | 24 | #include "flatcc/reflection/flatbuffers_common_reader.h" // IWYU pragma: export 25 | #include "iree/base/internal/flatcc/dummy_reader.h" // IWYU pragma: export 26 | 27 | #include "flatcc/flatcc_verifier.h" // IWYU pragma: export 28 | #include "iree/base/internal/flatcc/dummy_verifier.h" // IWYU pragma: export 29 | 30 | // clang-format on 31 | 32 | #endif // IREE_BASE_INTERNAL_FLATCC_PARSING_H_ 33 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/vm/bytecode/utils/features.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_VM_BYTECODE_UTILS_FEATURES_H_ 8 | #define IREE_VM_BYTECODE_UTILS_FEATURES_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/vm/api.h" 12 | #include "iree/vm/bytecode/utils/isa.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | // Formats a buffer usage bitfield as a string. 19 | // See iree_bitfield_format for usage. 20 | iree_string_view_t iree_vm_bytecode_features_format( 21 | iree_vm_FeatureBits_enum_t value, iree_bitfield_string_temp_t* out_temp); 22 | 23 | // Returns the features available in this build of the runtime. 24 | iree_vm_FeatureBits_enum_t iree_vm_bytecode_available_features(void); 25 | 26 | // Returns a pretty status reported at |file|/|line| when one or more features 27 | // from |required_features| is missing from |available_features|. 28 | // Returns OK if all required features are available. 29 | iree_status_t iree_vm_check_feature_mismatch( 30 | const char* file, int line, iree_vm_FeatureBits_enum_t required_features, 31 | iree_vm_FeatureBits_enum_t available_features); 32 | 33 | #ifdef __cplusplus 34 | } // extern "C" 35 | #endif // __cplusplus 36 | 37 | #endif // IREE_VM_BYTECODE_UTILS_FEATURES_H_ 38 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/local_task/task_queue_state.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_LOCAL_TASK_TASK_QUEUE_STATE_H_ 8 | #define IREE_HAL_DRIVERS_LOCAL_TASK_TASK_QUEUE_STATE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/base/internal/atomics.h" 12 | #include "iree/hal/api.h" 13 | #include "iree/task/scope.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif // __cplusplus 18 | 19 | // State tracking for an individual queue. 20 | // 21 | // Thread-compatible: only intended to be used by a queue with the submission 22 | // lock held. 23 | typedef struct iree_hal_task_queue_state_t { 24 | // TODO(#4518): track event state. 25 | int reserved; 26 | } iree_hal_task_queue_state_t; 27 | 28 | // Initializes queue state with the given |identifier| used to annotate tasks 29 | // submitted to the queue. 30 | void iree_hal_task_queue_state_initialize( 31 | iree_hal_task_queue_state_t* out_queue_state); 32 | 33 | // Deinitializes queue state and cleans up any tracking intermediates. 34 | void iree_hal_task_queue_state_deinitialize( 35 | iree_hal_task_queue_state_t* queue_state); 36 | 37 | #ifdef __cplusplus 38 | } // extern "C" 39 | #endif // __cplusplus 40 | 41 | #endif // IREE_HAL_DRIVERS_LOCAL_TASK_TASK_QUEUE_STATE_H_ 42 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/local/loaders/system_library_loader.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_LOCAL_LOADERS_SYSTEM_LIBRARY_LOADER_H_ 8 | #define IREE_HAL_LOCAL_LOADERS_SYSTEM_LIBRARY_LOADER_H_ 9 | 10 | #include 11 | #include 12 | 13 | #include "iree/base/api.h" 14 | #include "iree/hal/local/executable_loader.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif // __cplusplus 19 | 20 | typedef struct iree_hal_executable_plugin_manager_t 21 | iree_hal_executable_plugin_manager_t; 22 | 23 | // Creates an executable loader that can load files from platform-supported 24 | // dynamic libraries (such as .dylib on darwin, .so on linux, .dll on windows). 25 | // 26 | // This uses the legacy "dylib"-style format that will be deleted soon and is 27 | // only a placeholder until the compiler can be switched to output 28 | // iree_hal_executable_library_t-compatible files. 29 | iree_status_t iree_hal_system_library_loader_create( 30 | iree_hal_executable_plugin_manager_t* plugin_manager, 31 | iree_allocator_t host_allocator, 32 | iree_hal_executable_loader_t** out_executable_loader); 33 | 34 | #ifdef __cplusplus 35 | } // extern "C" 36 | #endif // __cplusplus 37 | 38 | #endif // IREE_HAL_LOCAL_LOADERS_SYSTEM_LIBRARY_LOADER_H_ 39 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/tooling/modules/resolver.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_TOOLING_MODULES_REGISTRY_H_ 8 | #define IREE_TOOLING_MODULES_REGISTRY_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/vm/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | // Registers all types used by available modules. 18 | // NOTE: this is only required as a separate step in the tooling as we perform 19 | // dynamic module resolution and in order to load modules to find their 20 | // dependencies their dependent types must be registered first. This could be 21 | // fixed in the future to only resolve types when a module is instantiated in 22 | // a context instead of when loaded but is TBD. 23 | iree_status_t iree_tooling_register_all_module_types( 24 | iree_vm_instance_t* instance); 25 | 26 | // Resolves a module dependency to an initialized module. 27 | // Returns OK if the dependency is optional and not found. 28 | iree_status_t iree_tooling_resolve_module_dependency( 29 | iree_vm_instance_t* instance, const iree_vm_module_dependency_t* dependency, 30 | iree_allocator_t host_allocator, iree_vm_module_t** out_module); 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif // __cplusplus 35 | 36 | #endif // IREE_TOOLING_MODULES_REGISTRY_H_ 37 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/base/internal/flatcc/debugging.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BASE_INTERNAL_FLATCC_DEBUGGING_H_ 8 | #define IREE_BASE_INTERNAL_FLATCC_DEBUGGING_H_ 9 | 10 | //===----------------------------------------------------------------------===// 11 | // flatcc include order fixes 12 | //===----------------------------------------------------------------------===// 13 | // 14 | // This header merely wraps the flatcc headers that are generally useful to 15 | // include in various places that may not know the specific messages they are 16 | // working with. 17 | // 18 | // If using flatcc prefer to include this file over any hard-to-handle flatcc 19 | // file such as flatbuffers_common_reader.h or flatbuffers_common_builder.h. 20 | // 21 | // NOTE: order matters for these includes so stop clang from messing with it: 22 | // clang-format off 23 | 24 | #include "iree/base/internal/flatcc/parsing.h" 25 | 26 | #include "flatcc/flatcc_json_parser.h" // IWYU pragma: export 27 | #include "iree/base/internal/flatcc/dummy_json_parser.h" // IWYU pragma: export 28 | 29 | #include "flatcc/flatcc_json_printer.h" // IWYU pragma: export 30 | #include "iree/base/internal/flatcc/dummy_json_printer.h" // IWYU pragma: export 31 | 32 | // clang-format on 33 | 34 | #endif // IREE_BASE_INTERNAL_FLATCC_DEBUGGING_H_ 35 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/local/local_executable_cache.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_LOCAL_LOCAL_EXECUTABLE_CACHE_H_ 8 | #define IREE_HAL_LOCAL_LOCAL_EXECUTABLE_CACHE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/local/executable_loader.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | // TODO(benvanik): when we refactor executable caches this can become something 19 | // more specialized; like nop_executable_cache (does nothing but pass through) 20 | // or inproc_lru_executable_cache (simple in-memory LRU of recent executables). 21 | // 22 | // We can also set this up so they share storage. Ideally a JIT'ed executable in 23 | // one device is the same JIT'ed executable in another, and in multi-tenant 24 | // situations we're likely to want that isolation _and_ sharing. 25 | 26 | iree_status_t iree_hal_local_executable_cache_create( 27 | iree_string_view_t identifier, iree_host_size_t worker_capacity, 28 | iree_host_size_t loader_count, iree_hal_executable_loader_t** loaders, 29 | iree_allocator_t host_allocator, 30 | iree_hal_executable_cache_t** out_executable_cache); 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif // __cplusplus 35 | 36 | #endif // IREE_HAL_LOCAL_LOCAL_EXECUTABLE_CACHE_H_ 37 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/vm/dynamic/module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_VM_DYNAMIC_MODULE_H_ 8 | #define IREE_VM_DYNAMIC_MODULE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/vm/api.h" 12 | #include "iree/vm/dynamic/api.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | // Creates a VM module from a dynamically loaded shared library at |path|. 19 | // The exported symbol with |export_name| matching the signature of 20 | // iree_vm_dynamic_module_create_fn_t will be used to create the module. 21 | // 22 | // Optionally key-value parameters may be provided to the module on 23 | // initialization. They strings referenced need only exist during creation and 24 | // modules will clone any they need to retain. 25 | // 26 | // |allocator| will be passed to the module to serve its allocations and must 27 | // remain valid for the module lifetime. 28 | IREE_API_EXPORT iree_status_t iree_vm_dynamic_module_load_from_file( 29 | iree_vm_instance_t* instance, iree_string_view_t path, 30 | iree_string_view_t export_name, iree_host_size_t param_count, 31 | const iree_string_pair_t* params, iree_allocator_t allocator, 32 | iree_vm_module_t** out_module); 33 | 34 | #ifdef __cplusplus 35 | } // extern "C" 36 | #endif // __cplusplus 37 | 38 | #endif // IREE_VM_DYNAMIC_MODULE_H_ 39 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/router.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.Router do 2 | use LiveNxIREEWeb, :router 3 | 4 | pipeline :browser do 5 | plug :accepts, ["html", "swiftui"] 6 | plug :fetch_session 7 | plug :fetch_live_flash 8 | 9 | plug :put_root_layout, 10 | html: {LiveNxIREEWeb.Layouts, :root}, 11 | swiftui: {LiveNxIREEWeb.Layouts.SwiftUI, :root} 12 | 13 | plug :protect_from_forgery 14 | plug :put_secure_browser_headers 15 | end 16 | 17 | pipeline :api do 18 | plug :accepts, ["json"] 19 | end 20 | 21 | scope "/", LiveNxIREEWeb do 22 | pipe_through :browser 23 | 24 | # live "/", HomeLive, :index 25 | live "/", CameraLive, :index 26 | end 27 | 28 | # Other scopes may use custom stacks. 29 | # scope "/api", LiveNxIREEWeb do 30 | # pipe_through :api 31 | # end 32 | 33 | # Enable LiveDashboard and Swoosh mailbox preview in development 34 | if Application.compile_env(:live_nx_iree, :dev_routes) do 35 | # If you want to use the LiveDashboard in production, you should put 36 | # it behind authentication and allow only admins to access it. 37 | # If your application does not have an admins-only section yet, 38 | # you can use Plug.BasicAuth to set up some basic authentication 39 | # as long as you are also using SSL (which you should anyway). 40 | import Phoenix.LiveDashboard.Router 41 | 42 | scope "/dev" do 43 | pipe_through :browser 44 | 45 | live_dashboard "/dashboard", metrics: LiveNxIREEWeb.Telemetry 46 | forward "/mailbox", Plug.Swoosh.MailboxPreview 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/io/scope_map.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_IO_SCOPE_MAP_H_ 8 | #define IREE_IO_SCOPE_MAP_H_ 9 | 10 | #include 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/io/parameter_index.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif // __cplusplus 18 | 19 | typedef struct iree_io_scope_map_entry_t { 20 | iree_string_view_t scope; 21 | iree_io_parameter_index_t* index; 22 | } iree_io_scope_map_entry_t; 23 | 24 | typedef struct iree_io_scope_map_t { 25 | iree_allocator_t host_allocator; 26 | iree_host_size_t count; 27 | iree_host_size_t capacity; 28 | iree_io_scope_map_entry_t** entries; 29 | } iree_io_scope_map_t; 30 | 31 | IREE_API_EXPORT void iree_io_scope_map_initialize( 32 | iree_allocator_t host_allocator, iree_io_scope_map_t* out_scope_map); 33 | 34 | IREE_API_EXPORT void iree_io_scope_map_deinitialize( 35 | iree_io_scope_map_t* scope_map); 36 | 37 | IREE_API_EXPORT iree_status_t iree_io_scope_map_lookup( 38 | iree_io_scope_map_t* scope_map, iree_string_view_t scope, 39 | iree_io_parameter_index_t** out_index); 40 | 41 | IREE_API_EXPORT iree_status_t iree_io_scope_map_dump( 42 | iree_io_scope_map_t* scope_map, iree_string_builder_t* builder); 43 | 44 | #ifdef __cplusplus 45 | } // extern "C" 46 | #endif // __cplusplus 47 | 48 | #endif // IREE_IO_SCOPE_MAP_H_ 49 | -------------------------------------------------------------------------------- /lib/nx_iree/mix_helpers.exs: -------------------------------------------------------------------------------- 1 | defmodule NxIREE.MixHelpers do 2 | @moduledoc false 3 | def github_release_path(file, version \\ nil) do 4 | version = version || File.read!(Path.join(:code.priv_dir(:nx_iree), "VERSION")) 5 | 6 | Path.join( 7 | "https://github.com/elixir-nx/nx_iree/releases/download/v#{version}/", 8 | file 9 | ) 10 | end 11 | 12 | def download!(name, url, dest) do 13 | case download(name, url, dest) do 14 | :ok -> 15 | :ok 16 | 17 | {:error, :not_found} -> 18 | {:error, :not_found} 19 | 20 | {:error, reason} -> 21 | raise "unable to download #{name} from #{url}: #{inspect(reason)}" 22 | end 23 | end 24 | 25 | defp download(name, url, dest) do 26 | {:ok, _} = Application.ensure_all_started(:req) 27 | 28 | Req.new(url: url, into: File.stream!(dest, [:write, :binary])) 29 | |> Req.Request.prepend_response_steps( 30 | pre_redirect: &Req.Steps.redirect/1, 31 | handle_non_200_responses: fn 32 | {request, %{status: 200} = response} -> 33 | {request, response} 34 | 35 | {request, response} -> 36 | {%{request | into: nil}, response} 37 | end 38 | ) 39 | |> Req.get() 40 | |> case do 41 | {:ok, %{status: 200}} -> 42 | :ok 43 | 44 | {:ok, %{status: 404}} -> 45 | {:error, :not_found} 46 | 47 | {:ok, %{status: status}} -> 48 | raise "unable to download #{name} from #{url}: status #{status}" 49 | 50 | {:error, reason} -> 51 | raise "unable to download #{name} from #{url}: #{inspect(reason)}" 52 | end 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/metal/metal_buffer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_METAL_METAL_BUFFER_H_ 8 | #define IREE_HAL_DRIVERS_METAL_METAL_BUFFER_H_ 9 | 10 | #import 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/hal/api.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif // __cplusplus 18 | 19 | // Wraps a Metal allocation in an iree_hal_buffer_t by retaining |metal_buffer|. 20 | // 21 | // |out_buffer| must be released by the caller (see iree_hal_buffer_release). 22 | iree_status_t iree_hal_metal_buffer_wrap( 23 | #if defined(IREE_PLATFORM_MACOS) 24 | id queue, 25 | #endif // IREE_PLATFORM_MACOS 26 | id metal_buffer, iree_hal_allocator_t* allocator, 27 | iree_hal_memory_type_t memory_type, iree_hal_memory_access_t allowed_access, 28 | iree_hal_buffer_usage_t allowed_usage, iree_device_size_t allocation_size, 29 | iree_device_size_t byte_offset, iree_device_size_t byte_length, 30 | iree_hal_buffer_release_callback_t release_callback, 31 | iree_hal_buffer_t** out_buffer); 32 | 33 | // Returns the underlying Metal buffer handle for the given |buffer|. 34 | id iree_hal_metal_buffer_handle(const iree_hal_buffer_t* buffer); 35 | 36 | #ifdef __cplusplus 37 | } // extern "C" 38 | #endif // __cplusplus 39 | 40 | #endif // IREE_HAL_DRIVERS_METAL_METAL_BUFFER_H_ 41 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/local/plugins/static_plugin.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_LOCAL_PLUGINS_STATIC_PLUGIN_H_ 8 | #define IREE_HAL_LOCAL_PLUGINS_STATIC_PLUGIN_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/local/executable_plugin_manager.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | // Creates a statically-declared executable import plugin available from the 19 | // given |query_fn|. The plugin will be loaded and verified for compatibility. 20 | // 21 | // Optionally key-value parameters may be provided to the plugin on 22 | // initialization. They strings referenced need only exist during creation and 23 | // plugins will clone any they need to retain. 24 | // 25 | // |host_allocator| will be used to create the plugin wrapper and be passed to 26 | // the plugin to service all additional allocation requests it may have. It must 27 | // remain valid for the lifetime of the plugin. 28 | iree_status_t iree_hal_static_executable_plugin_create( 29 | iree_hal_executable_plugin_query_fn_t query_fn, 30 | iree_host_size_t param_count, const iree_string_pair_t* params, 31 | iree_allocator_t host_allocator, iree_hal_executable_plugin_t** out_plugin); 32 | 33 | #ifdef __cplusplus 34 | } // extern "C" 35 | #endif // __cplusplus 36 | 37 | #endif // IREE_HAL_LOCAL_PLUGINS_STATIC_PLUGIN_H_ 38 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/tooling/comparison.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_TOOLING_COMPARISON_H_ 8 | #define IREE_TOOLING_COMPARISON_H_ 9 | 10 | #include 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/vm/api.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif // __cplusplus 18 | 19 | // Compares expected vs actual results and appends to |builder|. 20 | // Returns true if all values match and false otherwise. 21 | // Errors when performing comparison will abort the process. 22 | // When all list elements match no output is written and otherwise 23 | // newline-separated strings detailing the differing elements is appended. 24 | bool iree_tooling_compare_variant_lists_and_append( 25 | iree_vm_list_t* expected_list, iree_vm_list_t* actual_list, 26 | iree_allocator_t host_allocator, iree_string_builder_t* builder); 27 | 28 | // Compares expected vs actual results and appends to |file|. 29 | // Refer to iree_tooling_compare_variant_lists_and_append for details. 30 | bool iree_tooling_compare_variant_lists(iree_vm_list_t* expected_list, 31 | iree_vm_list_t* actual_list, 32 | iree_allocator_t host_allocator, 33 | FILE* file); 34 | 35 | #ifdef __cplusplus 36 | } // extern "C" 37 | #endif // __cplusplus 38 | 39 | #endif // IREE_TOOLING_COMPARISON_H_ 40 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/vulkan/vulkan_device.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_VULKAN_VULKAN_DEVICE_H_ 8 | #define IREE_HAL_DRIVERS_VULKAN_VULKAN_DEVICE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/drivers/vulkan/api.h" 13 | #include "iree/hal/drivers/vulkan/dynamic_symbols.h" 14 | #include "iree/hal/drivers/vulkan/extensibility_util.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif // __cplusplus 19 | 20 | // Creates a device that owns and manages its own VkDevice. 21 | // 22 | // The |driver| will be retained for as long as the device is live such that if 23 | // the driver owns the |instance| provided it is ensured to be valid. |driver| 24 | // may be NULL if there is no parent driver to retain (such as when wrapping 25 | // existing VkInstances provided by the application). 26 | iree_status_t iree_hal_vulkan_device_create( 27 | iree_hal_driver_t* driver, iree_string_view_t identifier, 28 | iree_hal_vulkan_features_t requested_features, 29 | const iree_hal_vulkan_device_options_t* options, 30 | iree_hal_vulkan_syms_t* instance_syms, VkInstance instance, 31 | VkPhysicalDevice physical_device, iree_allocator_t host_allocator, 32 | iree_hal_device_t** out_device); 33 | 34 | #ifdef __cplusplus 35 | } // extern "C" 36 | #endif // __cplusplus 37 | 38 | #endif // IREE_HAL_DRIVERS_VULKAN_VULKAN_DEVICE_H_ 39 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/ReconnectingView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ReconnectingView.swift 3 | // ReconnectingView 4 | // 5 | 6 | import SwiftUI 7 | 8 | struct ReconnectingView: View { 9 | let isReconnecting: Bool 10 | @ViewBuilder let content: Content 11 | 12 | var body: some View { 13 | content 14 | .frame(maxWidth: .infinity, maxHeight: .infinity) 15 | .overlay(alignment: .top) { 16 | if isReconnecting { 17 | VStack { 18 | Label("No Connection", systemImage: "wifi.slash") 19 | .bold() 20 | Text("Reconnecting") 21 | .foregroundStyle(.secondary) 22 | } 23 | .font(.caption) 24 | .padding(8) 25 | .frame(maxWidth: .infinity) 26 | #if os(watchOS) 27 | .background(.background) 28 | #else 29 | .background(.regularMaterial) 30 | #endif 31 | .transition(.move(edge: .top).combined(with: .opacity)) 32 | } 33 | } 34 | .animation(.default, value: isReconnecting) 35 | } 36 | } 37 | 38 | #Preview { 39 | struct PreviewView: View { 40 | @State private var isReconnecting = true 41 | 42 | var body: some View { 43 | ReconnectingView(isReconnecting: isReconnecting) { 44 | Toggle("Reconnecting", isOn: $isReconnecting) 45 | } 46 | } 47 | } 48 | return PreviewView() 49 | } 50 | -------------------------------------------------------------------------------- /test/nx_iree/nx_test.exs: -------------------------------------------------------------------------------- 1 | defmodule NxIREE.NxTest do 2 | use ExUnit.Case 3 | 4 | @illegal_ops [ 5 | fft: 2, 6 | fft2: 2, 7 | ifft: 2, 8 | ifft2: 2, 9 | select_and_scatter: 3, 10 | window_scatter_min: 5, 11 | window_scatter_max: 5 12 | ] 13 | 14 | @rounding_error [ 15 | erf: 1, 16 | erfc: 1, 17 | asinh: 1, 18 | cbrt: 1, 19 | atan2: 2, 20 | cosh: 1, 21 | expm1: 1, 22 | sigmoid: 1, 23 | standard_deviation: 2, 24 | atanh: 1, 25 | tanh: 1, 26 | tan: 1, 27 | real: 1, 28 | asin: 1, 29 | asinh: 1, 30 | atan: 1, 31 | acos: 1, 32 | acosh: 1, 33 | cos: 1, 34 | sin: 1, 35 | phase: 1, 36 | covariance: 3, 37 | weighted_mean: 3, 38 | variance: 2, 39 | # as_type tests on f64 which is not supported on metal 40 | as_type: 2, 41 | rsqrt: 1 42 | ] 43 | 44 | @partial_support [ 45 | # stable: true is not supported 46 | argsort: 2, 47 | # tensor/2 tests on f8 which is not supported yet 48 | tensor: 2, 49 | # bit_size/1 tests on u2 which is not supported yet 50 | bit_size: 1, 51 | # iota/2 tests on f64 which is not supported on metal 52 | iota: 2, 53 | # does not support complex tensors 54 | conv: 3 55 | ] 56 | 57 | @errors_to_be_fixed [ 58 | # bug on filter_by_indices_list in the Nx compiler 59 | top_k: 2, 60 | # window_* crashes on iree-compile 61 | window_product: 3, 62 | window_mean: 3, 63 | window_sum: 3, 64 | window_min: 3, 65 | window_max: 3 66 | ] 67 | 68 | doctest Nx, 69 | except: 70 | @illegal_ops ++ 71 | @rounding_error ++ @partial_support ++ @errors_to_be_fixed 72 | end 73 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/arch/x86_64/pack_x86_64_internal.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_ARCH_X86_64_PACK_X86_64_INTERNAL_H_ 8 | #define IREE_BUILTINS_UKERNEL_ARCH_X86_64_PACK_X86_64_INTERNAL_H_ 9 | 10 | #include "iree/builtins/ukernel/pack_internal.h" 11 | 12 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_8x8_x32_x86_64_avx2_fma_direct) 13 | IREE_UK_PACK_TILE_FUNC_DECL( 14 | iree_uk_pack_tile_16x16_x32_x86_64_avx512_base_direct) 15 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_8x1_x32_x86_64_avx2_fma_direct) 16 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_8x1_x32_x86_64_avx2_fma_transpose) 17 | IREE_UK_PACK_TILE_FUNC_DECL( 18 | iree_uk_pack_tile_16x1_x32_x86_64_avx512_base_direct) 19 | IREE_UK_PACK_TILE_FUNC_DECL( 20 | iree_uk_pack_tile_16x1_x32_x86_64_avx512_base_transpose) 21 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_8x2_x8_x86_64_avx2_fma_direct) 22 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_8x2_x8_x86_64_avx2_fma_transpose) 23 | IREE_UK_PACK_TILE_FUNC_DECL(iree_uk_pack_tile_16x2_x8_x86_64_avx512_base_direct) 24 | IREE_UK_PACK_TILE_FUNC_DECL( 25 | iree_uk_pack_tile_16x2_x8_x86_64_avx512_base_transpose) 26 | IREE_UK_PACK_TILE_FUNC_DECL( 27 | iree_uk_pack_tile_16x2_x16_x86_64_avx512_base_direct) 28 | IREE_UK_PACK_TILE_FUNC_DECL( 29 | iree_uk_pack_tile_16x2_x16_x86_64_avx512_base_transpose) 30 | 31 | #endif // foIREE_BUILTINS_UKERNEL_ARCH_X86_64_PACK_X86_64_INTERNAL_H_ 32 | -------------------------------------------------------------------------------- /axon.exs: -------------------------------------------------------------------------------- 1 | Mix.install([ 2 | {:axon, github: "elixir-nx/axon", branch: "main"}, 3 | {:nx_iree, path: "."}, 4 | {:nx, github: "elixir-nx/nx", sparse: "nx", override: true}, 5 | {:exla, github: "elixir-nx/nx", sparse: "exla", override: true} 6 | ], system_env: %{"NX_IREE_PREFER_PRECOMPILED" => false}) 7 | 8 | {:ok, drivers} = NxIREE.list_drivers() |> IO.inspect(label: "drivers") 9 | 10 | {:ok, [dev | _]} = NxIREE.list_devices("cuda") 11 | 12 | flags = ["--iree-hal-target-backends=cuda", "--iree-input-type=stablehlo_xla", "--iree-execution-model=async-internal"] 13 | Nx.Defn.default_options(compiler: NxIREE.Compiler, iree_compiler_flags: flags, iree_runtime_options: [device: dev]) 14 | 15 | model = 16 | Axon.input("x", shape: {nil, 3}) 17 | |> Axon.dense(8, activation: :relu) 18 | |> Axon.dense(1, activation: :relu) 19 | 20 | Nx.Defn.default_options(compiler: NxIREE.Compiler, iree_compiler_flags: flags, iree_runtime_options: [device: dev]) 21 | # Nx.Defn.default_options(compiler: EXLA, iree_compiler_flags: flags, iree_runtime_options: [device: dev]) 22 | 23 | template = %{"x" => Nx.template({10, 3}, :f32)} 24 | 25 | {init_fn, predict_fn} = Axon.build(model, []) 26 | init_params = Nx.Defn.jit_apply(init_fn, [template, Axon.ModelState.new(Axon.ModelState.empty())]) 27 | 28 | IO.puts("\n\n\n======= BEGIN predict_compiled_fn =======\n\n\n") 29 | predict_compiled_fn = Nx.Defn.compile(predict_fn, [init_params, template]) 30 | IO.puts("\n\n\n======= END predict_compiled_fn =======\n\n\n") 31 | 32 | IO.puts("\n\n\n======= BEGIN predict_compiled_fn CALL =======\n\n\n") 33 | predict_compiled_fn.(init_params, Nx.iota({10, 3}, type: :f32)) |> dbg() 34 | IO.puts("\n\n\n======= END predict_compiled_fn CALL =======\n\n\n") 35 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/vulkan/direct_command_queue.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_VULKAN_DIRECT_COMMAND_QUEUE_H_ 8 | #define IREE_HAL_DRIVERS_VULKAN_DIRECT_COMMAND_QUEUE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/drivers/vulkan/command_queue.h" 13 | #include "iree/hal/drivers/vulkan/handle_util.h" 14 | #include "iree/hal/drivers/vulkan/util/arena.h" 15 | 16 | namespace iree { 17 | namespace hal { 18 | namespace vulkan { 19 | 20 | // Command queue implementation directly maps to VkQueue. 21 | class DirectCommandQueue final : public CommandQueue { 22 | public: 23 | DirectCommandQueue(VkDeviceHandle* logical_device, 24 | iree_hal_command_category_t supported_categories, 25 | VkQueue queue); 26 | ~DirectCommandQueue() override; 27 | 28 | iree_status_t Submit( 29 | iree_host_size_t batch_count, 30 | const iree_hal_vulkan_submission_batch_t* batches) override; 31 | 32 | iree_status_t WaitIdle(iree_timeout_t timeout) override; 33 | 34 | private: 35 | iree_status_t TranslateBatchInfo( 36 | const iree_hal_vulkan_submission_batch_t* batch, 37 | VkSubmitInfo* submit_info, 38 | VkTimelineSemaphoreSubmitInfo* timeline_submit_info, Arena* arena); 39 | }; 40 | 41 | } // namespace vulkan 42 | } // namespace hal 43 | } // namespace iree 44 | 45 | #endif // IREE_HAL_DRIVERS_VULKAN_DIRECT_COMMAND_QUEUE_H_ 46 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE.xcodeproj/xcuserdata/paulo.valente.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | LiveNxIREE Watch App.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | LiveNxIREE.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | Parsing (Playground) 1.xcscheme 18 | 19 | isShown 20 | 21 | orderHint 22 | 3 23 | 24 | Parsing (Playground) 2.xcscheme 25 | 26 | isShown 27 | 28 | orderHint 29 | 4 30 | 31 | Parsing (Playground) 3.xcscheme 32 | 33 | isShown 34 | 35 | orderHint 36 | 5 37 | 38 | Parsing (Playground) 4.xcscheme 39 | 40 | isShown 41 | 42 | orderHint 43 | 6 44 | 45 | Parsing (Playground) 5.xcscheme 46 | 47 | isShown 48 | 49 | orderHint 50 | 7 51 | 52 | Parsing (Playground).xcscheme 53 | 54 | isShown 55 | 56 | orderHint 57 | 2 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/queue.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_QUEUE_H_ 8 | #define IREE_HAL_QUEUE_H_ 9 | 10 | #include 11 | 12 | #include "iree/base/api.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | //===----------------------------------------------------------------------===// 19 | // Types and Enums 20 | //===----------------------------------------------------------------------===// 21 | 22 | // A bitmap indicating logical device queue affinity. 23 | // Used to direct submissions to specific device queues or locate memory nearby 24 | // where it will be used. The meaning of the bits in the bitmap is 25 | // implementation-specific: a bit may represent a logical queue in an underlying 26 | // API such as a VkQueue or a physical queue such as a discrete virtual device. 27 | // 28 | // Bitwise operations can be performed on affinities; for example AND'ing two 29 | // affinities will produce the intersection and OR'ing will produce the union. 30 | // This enables just-in-time selection as a command buffer could be made 31 | // available to some set of queues when recorded and then AND'ed with an actual 32 | // set of queues to execute on during submission. 33 | typedef uint64_t iree_hal_queue_affinity_t; 34 | 35 | // Specifies that any queue may be selected. 36 | #define IREE_HAL_QUEUE_AFFINITY_ANY ((iree_hal_queue_affinity_t)(-1)) 37 | 38 | #ifdef __cplusplus 39 | } // extern "C" 40 | #endif // __cplusplus 41 | 42 | #endif // IREE_HAL_QUEUE_H_ 43 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/vulkan/debug_reporter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_VULKAN_DEBUG_REPORTER_H_ 8 | #define IREE_HAL_DRIVERS_VULKAN_DEBUG_REPORTER_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/drivers/vulkan/dynamic_symbols.h" 13 | 14 | // A debug reporter that works with the VK_EXT_debug_utils extension. 15 | // One reporter should be created per VkInstance to receive callbacks from the 16 | // API and route them to our logging systems. 17 | // 18 | // Since creating a reporter requires a VkInstance it's not possible to report 19 | // on messages during instance creation. To work around this it's possible to 20 | // pass a *CreateInfo struct to vkCreateInstance as part of the 21 | // VkInstanceCreateInfo::pNext chain. The callback will only be used this way 22 | // during the creation call after which users can create the real 23 | // instance-specific reporter. 24 | typedef struct iree_hal_vulkan_debug_reporter_t 25 | iree_hal_vulkan_debug_reporter_t; 26 | 27 | iree_status_t iree_hal_vulkan_debug_reporter_allocate( 28 | VkInstance instance, iree::hal::vulkan::DynamicSymbols* syms, 29 | int32_t min_verbosity, const VkAllocationCallbacks* allocation_callbacks, 30 | iree_allocator_t host_allocator, 31 | iree_hal_vulkan_debug_reporter_t** out_reporter); 32 | 33 | void iree_hal_vulkan_debug_reporter_free( 34 | iree_hal_vulkan_debug_reporter_t* reporter); 35 | 36 | #endif // IREE_HAL_DRIVERS_VULKAN_DEBUG_REPORTER_H_ 37 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/assets/js/app.js: -------------------------------------------------------------------------------- 1 | // If you want to use Phoenix channels, run `mix help phx.gen.channel` 2 | // to get started and then uncomment the line below. 3 | // import "./user_socket.js" 4 | 5 | // You can include dependencies in two ways. 6 | // 7 | // The simplest option is to put them in assets/vendor and 8 | // import them using relative paths: 9 | // 10 | // import "../vendor/some-package.js" 11 | // 12 | // Alternatively, you can `npm install some-package --prefix assets` and import 13 | // them using a path starting with the package name: 14 | // 15 | // import "some-package" 16 | // 17 | 18 | // Include phoenix_html to handle method=PUT/DELETE in forms and buttons. 19 | import "phoenix_html" 20 | // Establish Phoenix Socket and LiveView configuration. 21 | import {Socket} from "phoenix" 22 | import {LiveSocket} from "phoenix_live_view" 23 | import topbar from "../vendor/topbar" 24 | 25 | let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content") 26 | let liveSocket = new LiveSocket("/live", Socket, { 27 | longPollFallbackMs: 2500, 28 | params: {_csrf_token: csrfToken} 29 | }) 30 | 31 | // Show progress bar on live navigation and form submits 32 | topbar.config({barColors: {0: "#29d"}, shadowColor: "rgba(0, 0, 0, .3)"}) 33 | window.addEventListener("phx:page-loading-start", _info => topbar.show(300)) 34 | window.addEventListener("phx:page-loading-stop", _info => topbar.hide()) 35 | 36 | // connect if there are any LiveViews on the page 37 | liveSocket.connect() 38 | 39 | // expose liveSocket on window for web console debug logs and latency simulation: 40 | // >> liveSocket.enableDebug() 41 | // >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session 42 | // >> liveSocket.disableLatencySim() 43 | window.liveSocket = liveSocket 44 | 45 | -------------------------------------------------------------------------------- /cmake/modules/default/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(IREE_HAL_DRIVER_DEFAULTS ON) 2 | set(IREE_HAL_DRIVER_LOCAL_SYNC ON) 3 | set(IREE_HAL_EXECUTABLE_LOADER_DEFAULTS OFF) 4 | set(IREE_HAL_EXECUTABLE_LOADER_EMBEDDED_ELF ON) 5 | 6 | list(REMOVE_ITEM iree_runtime_sources 7 | "${CMAKE_SOURCE_DIR}/src/emscripten_api.cc" 8 | "${CMAKE_SOURCE_DIR}/src/emscripten_api.h" 9 | ) 10 | 11 | add_library(${_NAME} SHARED ${iree_runtime_sources}) 12 | 13 | set_target_properties(${_NAME} PROPERTIES 14 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" 15 | ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" 16 | SUFFIX ".so" 17 | ) 18 | 19 | install( 20 | TARGETS ${_NAME} 21 | DESTINATION "." 22 | ) 23 | 24 | target_link_libraries(${_NAME} iree_runtime_runtime) 25 | target_link_libraries(${_NAME} iree_tooling_context_util) 26 | 27 | # Install the header files - this will make it easier to copy them over 28 | # to the final bundle. 29 | install(DIRECTORY "${IREE_RUNTIME_INCLUDE_PATH}" 30 | DESTINATION "include" 31 | FILES_MATCHING PATTERN "*.h") 32 | 33 | file(GLOB HEADER_FILES "${CMAKE_SOURCE_DIR}/src/*.h") 34 | 35 | install(FILES ${HEADER_FILES} 36 | DESTINATION "include/nx_iree") 37 | 38 | if(APPLE) 39 | # Although the compiler complains about not using these, 40 | # things only work with them set 41 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -undefined dynamic_lookup -fvisibility=default") 42 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-export_dynamic") 43 | check_c_compiler_flag("-arch arm64" ARM64_SUPPORTED) 44 | if(ARM64_SUPPORTED) 45 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMAC_ARM64") 46 | endif() 47 | else() 48 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -shared -fvisibility=default") 49 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-dynamic") 50 | endif() -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/io/parameter_index_provider.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_IO_PARAMETER_INDEX_PROVIDER_H_ 8 | #define IREE_IO_PARAMETER_INDEX_PROVIDER_H_ 9 | 10 | #include 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/hal/api.h" 14 | #include "iree/io/parameter_index.h" 15 | #include "iree/io/parameter_provider.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif // __cplusplus 20 | 21 | // Reasonable default for the `max_concurrent_operations` parameter. 22 | #define IREE_IO_PARAMETER_INDEX_PROVIDER_DEFAULT_MAX_CONCURRENT_OPERATIONS 16 23 | 24 | // Creates a parameter provider serving from the provided |index|. 25 | // As parameters are operated on their files will be registered with the devices 26 | // they are used on and cached for future requests. 27 | // 28 | // |max_concurrent_operations| can be used to limit how many file operations as 29 | // part of a gather or scatter are allowed to be in-flight at a time. A lower 30 | // number can reduce system resource requirements during the operation (less 31 | // transient memory required, etc) while increasing latency (lower I/O 32 | // utilization). 33 | IREE_API_EXPORT iree_status_t iree_io_parameter_index_provider_create( 34 | iree_string_view_t scope, iree_io_parameter_index_t* index, 35 | iree_host_size_t max_concurrent_operations, iree_allocator_t host_allocator, 36 | iree_io_parameter_provider_t** out_provider); 37 | 38 | #ifdef __cplusplus 39 | } // extern "C" 40 | #endif // __cplusplus 41 | 42 | #endif // IREE_IO_PARAMETER_INDEX_PROVIDER_H_ 43 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/pack.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_PACK_H_ 8 | #define IREE_BUILTINS_UKERNEL_PACK_H_ 9 | 10 | #include "iree/builtins/ukernel/common.h" 11 | 12 | // `pack` microkernel. Currently only used in the VMVX backend, not used in the 13 | // LLVMCPU backend, because codegen is thought to be good enough and because 14 | // fusions really matter here. 15 | 16 | // The least significant bits of `padding_value`, up to element size, are used 17 | // for padding. As this is based solely on bit-significance and not on byte 18 | // addresses, this is independent of endianness. 19 | // 20 | // If the element size is less than 64 bits then the most significant bits 21 | // (above element size) are unused. 22 | // 23 | // If the element size is more than 64 bits then only repeating 64-bit 24 | // patterns are supported for padding. This covers most cases as floating 25 | // point types encode zero as zero bits. 26 | IREE_UK_EXPORT void iree_uk_pack( 27 | const void* in_buffer, iree_uk_index_t in_offset, 28 | iree_uk_index_t in_stride0, iree_uk_index_t in_stride1, void* out_buffer, 29 | iree_uk_index_t out_offset, iree_uk_index_t out_stride0, 30 | iree_uk_index_t out_stride1, iree_uk_index_t in_size0, 31 | iree_uk_index_t in_size1, iree_uk_index_t out_size0, 32 | iree_uk_index_t out_size1, iree_uk_index_t out_size2, 33 | iree_uk_index_t out_size3, iree_uk_uint64_t padding_value, 34 | iree_uk_uint32_t flags, const iree_uk_uint64_t* cpu_data); 35 | 36 | #endif // IREE_BUILTINS_UKERNEL_PACK_H_ 37 | -------------------------------------------------------------------------------- /scripts/clone_iree.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | IREE_GIT_REV=$1 6 | NX_IREE_SOURCE_DIR=$2 7 | 8 | echo "Args:" 9 | echo " IREE_GIT_REV: ${IREE_GIT_REV}" 10 | echo " NX_IREE_SOURCE_DIR: ${NX_IREE_SOURCE_DIR}" 11 | 12 | IREE_REPO=https://github.com/iree-org/iree 13 | 14 | remove_stale_locks() { 15 | find . -name "index.lock" -type f -exec rm -f {} \; 16 | } 17 | 18 | if [ -d ${NX_IREE_SOURCE_DIR} ]; then 19 | echo "IREE directory already exists. Checking if it's up to date..." 20 | cd ${NX_IREE_SOURCE_DIR} 21 | 22 | # Fetch the latest changes 23 | git fetch origin 24 | 25 | # Check if the current commit matches the requested revision 26 | CURRENT_REV=$(git rev-parse HEAD) 27 | if git rev-parse --verify --quiet "refs/tags/${IREE_GIT_REV}"; then 28 | TARGET_REV=$(git rev-parse "refs/tags/${IREE_GIT_REV}") 29 | else 30 | TARGET_REV=$(git rev-parse origin/${IREE_GIT_REV}) 31 | fi 32 | 33 | if [ "${CURRENT_REV}" != "${TARGET_REV}" ]; then 34 | echo "Directory is out of date. Resetting to the target revision ${IREE_GIT_REV}." 35 | git reset --hard origin/${IREE_GIT_REV} 36 | else 37 | echo "Directory is up to date." 38 | fi 39 | 40 | # Ensure submodules are also up to date 41 | remove_stale_locks 42 | 43 | git submodule update --init --recursive --depth 1 44 | 45 | exit 0; 46 | fi 47 | 48 | git clone --branch ${IREE_GIT_REV} --depth 1 ${IREE_REPO} ${NX_IREE_SOURCE_DIR} 49 | 50 | cd ${NX_IREE_SOURCE_DIR} 51 | 52 | git config --global submodule.recurse true 53 | for submodule in $(git config --file .gitmodules --name-only --get-regexp path | sed 's/\.path$//'); do 54 | git config submodule.${submodule}.shallow true 55 | git config submodule.${submodule}.fetchRecurseSubmodules true 56 | done 57 | 58 | remove_stale_locks 59 | 60 | git submodule update --init --recursive --depth 1 -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/metal/direct_allocator.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_METAL_DIRECT_ALLOCATOR_H_ 8 | #define IREE_HAL_DRIVERS_METAL_DIRECT_ALLOCATOR_H_ 9 | 10 | #import 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/hal/api.h" 14 | #include "iree/hal/drivers/metal/api.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif // __cplusplus 19 | 20 | // Creates a straightforward Metal allocator from the given |device| that 21 | // performs allocations separately without caching or suballocation. 22 | // 23 | // On macOS, we additionally need the command queue to encode commands to make 24 | // buffer contents visible to the CPU for managed storage type. 25 | // 26 | // |out_allocator| must be released by the caller (see 27 | // iree_hal_allocator_release). 28 | iree_status_t iree_hal_metal_allocator_create( 29 | id device, 30 | #if defined(IREE_PLATFORM_MACOS) 31 | id queue, 32 | #endif // IREE_PLATFORM_MACOS 33 | iree_hal_metal_resource_hazard_tracking_mode_t resource_tracking_mode, 34 | iree_allocator_t host_allocator, iree_hal_allocator_t** out_allocator); 35 | 36 | #if defined(IREE_PLATFORM_MACOS) 37 | // Returns the underyling MetalCommandQueue associated with the given 38 | // |allocator|. 39 | id iree_hal_metal_allocator_command_queue( 40 | const iree_hal_allocator_t* allocator); 41 | #endif // IREE_PLATFORM_MACOS 42 | 43 | #ifdef __cplusplus 44 | } // extern "C" 45 | #endif // __cplusplus 46 | 47 | #endif // IREE_HAL_DRIVERS_METAL_DIRECT_ALLOCATOR_H_ 48 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/tooling/function_util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_TOOLING_FUNCTION_UTIL_H_ 8 | #define IREE_TOOLING_FUNCTION_UTIL_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/vm/api.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | // Appends fences to |list| if the invocation model of |function| requires them 19 | // (has the `iree.abi.model` as `coarse-fences`). 20 | // If no |wait_fence| is provided then the invocation will begin immediately. 21 | // Upon return if |out_signal_fence| is not NULL the caller must wait on the 22 | // returned |out_signal_fence| before accessing the contents of any buffers 23 | // returned from the invocation. 24 | iree_status_t iree_tooling_append_async_fences( 25 | iree_vm_list_t* list, iree_vm_function_t function, 26 | iree_hal_device_t* device, iree_hal_fence_t* wait_fence, 27 | iree_hal_fence_t** out_signal_fence); 28 | 29 | // Transfers all buffers in |list| to ones using |target_params|. 30 | // If no |wait_fence| is provided then the transfer will begin immediately. 31 | // If no |signal_fence| is provided then the call will block until the transfer 32 | // completes. 33 | iree_status_t iree_tooling_transfer_variants( 34 | iree_vm_list_t* list, iree_hal_device_t* target_device, 35 | iree_hal_allocator_t* target_allocator, 36 | iree_hal_buffer_params_t target_params, iree_hal_fence_t* wait_fence, 37 | iree_hal_fence_t* signal_fence); 38 | 39 | #ifdef __cplusplus 40 | } // extern "C" 41 | #endif 42 | 43 | #endif // IREE_TOOLING_FUNCTION_UTIL_H_ 44 | -------------------------------------------------------------------------------- /run.exs: -------------------------------------------------------------------------------- 1 | NxIREE.list_drivers() |> IO.inspect(label: "drivers") 2 | 3 | {:ok, [dev | _]} = NxIREE.list_devices("local-sync") |> IO.inspect() 4 | 5 | # Obtained by using EXLA.to_mlir_module(fn a, b -> Nx.add(Nx.cos(a), Nx.sin(b)) end, [Nx.template({4}, :f32), Nx.template({4}, :s64)]) 6 | mlir_module = """ 7 | module { 8 | func.func public @main(%arg0: tensor<4xf32>, %arg1: tensor<4xi32>) -> tensor<4xf32> { 9 | %0 = stablehlo.cosine %arg0 : tensor<4xf32> 10 | %1 = stablehlo.convert %arg1 : (tensor<4xi32>) -> tensor<4xf32> 11 | %2 = stablehlo.sine %1 : tensor<4xf32> 12 | %3 = stablehlo.add %0, %2 : tensor<4xf32> 13 | return %3 : tensor<4xf32> 14 | } 15 | } 16 | """ 17 | 18 | mlir_module = """ 19 | module { 20 | func.func public @main(%arg0: tensor<4xf32>, %arg1: tensor<4xi32>) -> tensor<4xf32> { 21 | %0 = stablehlo.convert %arg1 : (tensor<4xi32>) -> tensor<4xf32> 22 | %1 = stablehlo.add %0, %arg0 : tensor<4xf32> 23 | return %1 : tensor<4xf32> 24 | } 25 | } 26 | """ 27 | 28 | flags = [ 29 | "--iree-hal-target-backends=llvm-cpu", 30 | "--iree-input-type=stablehlo", 31 | "--iree-llvmcpu-target-triple=wasm32-unknown-emscripten", 32 | "--iree-llvmcpu-target-cpu-features=+atomics,+bulk-memory,+simd128" 33 | ] 34 | # flags = ["--iree-hal-target-backends=metal-spirv", "--iree-input-type=stablehlo_xla", "--iree-execution-model=async-internal"] 35 | 36 | %NxIREE.Module{bytecode: bytecode} = module = NxIREE.compile(mlir_module, flags, output_container: Nx.template({4}, :f32)) 37 | 38 | File.write!("/tmp/add_sin_cos.vmfb", bytecode) 39 | 40 | arg0 = Nx.tensor([1.0, 2.0, 3.0, 4.0]) 41 | arg1 = Nx.tensor([1, -1, 1, -1]) 42 | 43 | IO.gets("Press enter to continue - #{System.pid()}") 44 | {:ok, result} = NxIREE.call(module, [arg0, arg1], device: dev) |> IO.inspect() 45 | 46 | IO.inspect(result, limit: 4) 47 | 48 | 49 | IO.gets("Press enter to finish") 50 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/local/executable_library_demo.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_LOCAL_EXECUTABLE_LIBRARY_DEMO_H_ 8 | #define IREE_HAL_LOCAL_EXECUTABLE_LIBRARY_DEMO_H_ 9 | 10 | #include 11 | 12 | #include "iree/hal/local/executable_library.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | // Ideally we would have the IREE compiler generate a header like this so that 19 | // it's possible to manually call into executables. For now this is just an 20 | // example for the demo: the real HAL does not require this header as it 21 | // dlsym's the function pointer and packs the push constants itself. 22 | 23 | // Push constants used in the 'dispatch_tile_a' entry point. 24 | typedef union { 25 | uint32_t values[1]; 26 | struct { 27 | float f0; 28 | }; 29 | } dispatch_tile_a_push_constants_t; 30 | 31 | // Returns a simple demo library with the following structure: 32 | // 33 | // Name: 'demo_library' 34 | // 35 | // [0] 'dispatch_tile_a': matmul+div 36 | // push constants: 1 (dispatch_tile_a_push_constants_t) 37 | // bindings: 2 38 | // [0] = R 39 | // [1] = W 40 | // 41 | // [1] 'dispatch_tile_b': conv2d[512x512] 42 | // push constants: 0 43 | // bindings: 0 44 | // 45 | const iree_hal_executable_library_header_t** demo_executable_library_query( 46 | iree_hal_executable_library_version_t max_version, 47 | const iree_hal_executable_environment_v0_t* environment); 48 | 49 | #ifdef __cplusplus 50 | } // extern "C" 51 | #endif // __cplusplus 52 | 53 | #endif // IREE_HAL_LOCAL_EXECUTABLE_LIBRARY_DEMO_H_ 54 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/api.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | // See iree/base/api.h for documentation on the API conventions used. 8 | 9 | #ifndef IREE_HAL_API_H_ 10 | #define IREE_HAL_API_H_ 11 | 12 | #include "iree/hal/allocator.h" // IWYU pragma: export 13 | #include "iree/hal/buffer.h" // IWYU pragma: export 14 | #include "iree/hal/buffer_transfer.h" // IWYU pragma: export 15 | #include "iree/hal/buffer_view.h" // IWYU pragma: export 16 | #include "iree/hal/buffer_view_util.h" // IWYU pragma: export 17 | #include "iree/hal/channel.h" // IWYU pragma: export 18 | #include "iree/hal/channel_provider.h" // IWYU pragma: export 19 | #include "iree/hal/command_buffer.h" // IWYU pragma: export 20 | #include "iree/hal/device.h" // IWYU pragma: export 21 | #include "iree/hal/driver.h" // IWYU pragma: export 22 | #include "iree/hal/driver_registry.h" // IWYU pragma: export 23 | #include "iree/hal/event.h" // IWYU pragma: export 24 | #include "iree/hal/executable.h" // IWYU pragma: export 25 | #include "iree/hal/executable_cache.h" // IWYU pragma: export 26 | #include "iree/hal/fence.h" // IWYU pragma: export 27 | #include "iree/hal/file.h" // IWYU pragma: export 28 | #include "iree/hal/pipeline_layout.h" // IWYU pragma: export 29 | #include "iree/hal/queue.h" // IWYU pragma: export 30 | #include "iree/hal/resource.h" // IWYU pragma: export 31 | #include "iree/hal/semaphore.h" // IWYU pragma: export 32 | #include "iree/hal/string_util.h" // IWYU pragma: export 33 | 34 | #endif // IREE_HAL_API_H_ 35 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/vulkan/sparse_buffer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_VULKAN_SPARSE_BUFFER_H_ 8 | #define IREE_HAL_DRIVERS_VULKAN_SPARSE_BUFFER_H_ 9 | 10 | // clang-format off: must be included before all other headers. 11 | #include "iree/hal/drivers/vulkan/vulkan_headers.h" // IWYU pragma: export 12 | // clang-format on 13 | 14 | #include "iree/base/api.h" 15 | #include "iree/hal/api.h" 16 | #include "iree/hal/drivers/vulkan/handle_util.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif // __cplusplus 21 | 22 | // EXPERIMENTAL: allocate a buffer with fully bound memory with undefined 23 | // contents. Allocation and binding will happen synchronously on the calling 24 | // thread. 25 | // 26 | // This will eventually be replaced with HAL device APIs for controlling the 27 | // reserve/commit/decommit/release behavior of the virtual/physical storage. 28 | iree_status_t iree_hal_vulkan_sparse_buffer_create_bound_sync( 29 | iree_hal_allocator_t* allocator, iree_hal_memory_type_t memory_type, 30 | iree_hal_memory_access_t allowed_access, 31 | iree_hal_buffer_usage_t allowed_usage, iree_device_size_t allocation_size, 32 | iree_device_size_t byte_offset, iree_device_size_t byte_length, 33 | iree::hal::vulkan::VkDeviceHandle* logical_device, VkQueue queue, 34 | VkBuffer handle, VkMemoryRequirements requirements, 35 | uint32_t memory_type_index, VkDeviceSize max_allocation_size, 36 | iree_hal_buffer_t** out_buffer); 37 | 38 | #ifdef __cplusplus 39 | } // extern "C" 40 | #endif // __cplusplus 41 | 42 | #endif // IREE_HAL_DRIVERS_VULKAN_SPARSE_BUFFER_H_ 43 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/io/vec_stream.h: -------------------------------------------------------------------------------- 1 | // Copyright 2024 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_IO_VEC_STREAM_H_ 8 | #define IREE_IO_VEC_STREAM_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/io/stream.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | //===----------------------------------------------------------------------===// 18 | // iree_io_vec_stream_t 19 | //===----------------------------------------------------------------------===// 20 | 21 | // Creates an in-memory stream that grows as data is written. 22 | // Blocks of |block_size| (16-byte aligned) are allocated each time growth is 23 | // required and writes will be split to fit into blocks. To retrieve the data 24 | // from the stream use iree_io_vec_stream_enumerate_blocks or seek and read it 25 | // back. 26 | IREE_API_EXPORT iree_status_t iree_io_vec_stream_create( 27 | iree_io_stream_mode_t mode, iree_host_size_t block_size, 28 | iree_allocator_t host_allocator, iree_io_stream_t** out_stream); 29 | 30 | // Called for each block in stream order. Blocks may be sized under the 31 | // requested block size if they contain partial data. 32 | typedef iree_status_t(IREE_API_PTR* iree_io_vec_stream_callback_fn_t)( 33 | void* user_data, iree_const_byte_span_t block); 34 | 35 | // Issues |callback| for each block of data in the stream. 36 | IREE_API_EXPORT iree_status_t iree_io_vec_stream_enumerate_blocks( 37 | iree_io_stream_t* stream, iree_io_vec_stream_callback_fn_t callback, 38 | void* user_data); 39 | 40 | #ifdef __cplusplus 41 | } // extern "C" 42 | #endif // __cplusplus 43 | 44 | #endif // IREE_IO_VEC_STREAM_H_ 45 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/modules/hal/utils/buffer_diagnostics.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_MODULES_HAL_UTILS_BUFFER_DIAGNOSTICS_H_ 8 | #define IREE_MODULES_HAL_UTILS_BUFFER_DIAGNOSTICS_H_ 9 | 10 | #include 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/hal/api.h" 14 | #include "iree/modules/hal/types.h" 15 | #include "iree/vm/api.h" 16 | 17 | //===----------------------------------------------------------------------===// 18 | // iree_hal_buffer_t 19 | //===----------------------------------------------------------------------===// 20 | 21 | iree_status_t iree_hal_modules_buffer_assert( 22 | iree_vm_ref_t buffer_ref, iree_vm_ref_t message_ref, 23 | iree_device_size_t minimum_length, 24 | iree_hal_memory_type_t required_memory_types, 25 | iree_hal_buffer_usage_t required_buffer_usage); 26 | 27 | //===----------------------------------------------------------------------===// 28 | // iree_hal_buffer_view_t 29 | //===----------------------------------------------------------------------===// 30 | 31 | iree_status_t iree_hal_modules_buffer_view_assert( 32 | iree_vm_ref_t buffer_view_ref, iree_vm_ref_t message_ref, 33 | iree_hal_element_type_t expected_element_type, 34 | iree_hal_encoding_type_t expected_encoding_type, 35 | iree_host_size_t expected_shape_rank, 36 | const iree_hal_dim_t* expected_shape_dims); 37 | 38 | iree_status_t iree_hal_modules_buffer_view_trace( 39 | iree_vm_ref_t key_ref, iree_vm_size_t buffer_view_count, 40 | iree_vm_abi_r_t* buffer_view_refs, iree_allocator_t host_allocator); 41 | 42 | #endif // IREE_MODULES_HAL_UTILS_BUFFER_DIAGNOSTICS_H_ 43 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/tools/benchmark.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_TOOLS_BENCHMARK_H_ 8 | #define IREE_BUILTINS_UKERNEL_TOOLS_BENCHMARK_H_ 9 | 10 | #include "iree/builtins/ukernel/tools/util.h" 11 | #include "iree/testing/benchmark.h" 12 | 13 | // Struct for passing around benchmark user data 14 | typedef struct iree_uk_benchmark_user_data_t iree_uk_benchmark_user_data_t; 15 | 16 | // High level init/register/run/cleanup entry points. Used in main(). 17 | void iree_uk_benchmark_initialize(int* argc, char** argv); 18 | void iree_uk_benchmark_register( 19 | const char* name, 20 | iree_status_t (*benchmark_func)(const iree_benchmark_def_t*, 21 | iree_benchmark_state_t*), 22 | const void* params, size_t params_size, const char* cpu_features); 23 | void iree_uk_benchmark_run_and_cleanup(void); 24 | 25 | // Like malloc, but any buffers allocated through this are freed by 26 | // iree_uk_benchmark_run_and_cleanup. Used during benchmark registration to 27 | // allocate buffers that will be accessed when the benchmark is run. 28 | void* iree_uk_benchmark_static_alloc(size_t size); 29 | 30 | // Accessors for iree_uk_benchmark_user_data_t. Used by benchmark payload funcs. 31 | const void* iree_uk_benchmark_params( 32 | const iree_uk_benchmark_user_data_t* user_data); 33 | const iree_uk_uint64_t* iree_uk_benchmark_cpu_data( 34 | const iree_uk_benchmark_user_data_t* user_data); 35 | iree_uk_random_engine_t* iree_uk_benchmark_random_engine( 36 | const iree_uk_benchmark_user_data_t* user_data); 37 | 38 | #endif // IREE_BUILTINS_UKERNEL_TOOLS_BENCHMARK_H_ 39 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/utils/allocators.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_UTILS_ALLOCATORS_H_ 8 | #define IREE_HAL_UTILS_ALLOCATORS_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | // WARNING: including this file will pull in all allocator implementations. 18 | // Only use this if you need the dynamic allocator configuration and otherwise 19 | // prefer to directly instantiate the allocators you want with their structured 20 | // options instead of strings. 21 | 22 | // Parses a single allocator specification value and wraps |base_allocator|. 23 | // The available allocators is based on the build configuration. 24 | // 25 | // Examples: 26 | // some_allocator 27 | // some_allocator:key=value 28 | // some_allocator:key=value,key=value 29 | iree_status_t iree_hal_configure_allocator_from_spec( 30 | iree_string_view_t spec, iree_hal_device_t* device, 31 | iree_hal_allocator_t* base_allocator, 32 | iree_hal_allocator_t** out_wrapped_allocator); 33 | 34 | // Configures a |device| allocator based on the allocator |specs|. 35 | // This will wrap the underlying device allocator in zero or more configurable 36 | // allocator shims. 37 | // 38 | // WARNING: not thread-safe and must only be called immediately after device 39 | // creation. 40 | iree_status_t iree_hal_configure_allocator_from_specs( 41 | iree_host_size_t spec_count, const iree_string_view_t* specs, 42 | iree_hal_device_t* device); 43 | 44 | #ifdef __cplusplus 45 | } // extern "C" 46 | #endif // __cplusplus 47 | 48 | #endif // IREE_HAL_UTILS_ALLOCATORS_H_ 49 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/lib/live_nx_iree_web/endpoint.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREEWeb.Endpoint do 2 | use Phoenix.Endpoint, otp_app: :live_nx_iree 3 | 4 | # The session will be stored in the cookie and signed, 5 | # this means its contents can be read but not tampered with. 6 | # Set :encryption_salt if you would also like to encrypt it. 7 | @session_options [ 8 | store: :cookie, 9 | key: "_live_nx_iree_key", 10 | signing_salt: "2EHs6gfk", 11 | same_site: "Lax" 12 | ] 13 | 14 | socket "/live", Phoenix.LiveView.Socket, 15 | websocket: [connect_info: [session: @session_options]], 16 | longpoll: [connect_info: [session: @session_options]] 17 | 18 | # Serve at "/" the static files from "priv/static" directory. 19 | # 20 | # You should set gzip to true if you are running phx.digest 21 | # when deploying your static files in production. 22 | plug Plug.Static, 23 | at: "/", 24 | from: :live_nx_iree, 25 | gzip: false, 26 | only: LiveNxIREEWeb.static_paths() 27 | 28 | # Code reloading can be explicitly enabled under the 29 | # :code_reloader configuration of your endpoint. 30 | if code_reloading? do 31 | socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket 32 | plug Phoenix.LiveReloader 33 | plug LiveViewNative.LiveReloader 34 | plug Phoenix.CodeReloader 35 | plug Phoenix.Ecto.CheckRepoStatus, otp_app: :live_nx_iree 36 | end 37 | 38 | plug Phoenix.LiveDashboard.RequestLogger, 39 | param_key: "request_logger", 40 | cookie_key: "request_logger" 41 | 42 | plug Plug.RequestId 43 | plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint] 44 | 45 | plug Plug.Parsers, 46 | parsers: [:urlencoded, :multipart, :json], 47 | pass: ["*/*"], 48 | json_decoder: Phoenix.json_library() 49 | 50 | plug Plug.MethodOverride 51 | plug Plug.Head 52 | plug Plug.Session, @session_options 53 | plug LiveNxIREEWeb.Router 54 | end 55 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/buffer_heap_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_BUFFER_HEAP_IMPL_H_ 8 | #define IREE_HAL_BUFFER_HEAP_IMPL_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/base/internal/synchronization.h" 12 | #include "iree/hal/buffer.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | //===----------------------------------------------------------------------===// 19 | // Private utilities for working with heap buffers 20 | //===----------------------------------------------------------------------===// 21 | 22 | // Shared heap allocator statistics; owned by a heap allocator. 23 | // Access to the base statistics must be guarded by |mutex|. 24 | typedef struct iree_hal_heap_allocator_statistics_t { 25 | iree_slim_mutex_t mutex; 26 | iree_hal_allocator_statistics_t base; 27 | } iree_hal_heap_allocator_statistics_t; 28 | 29 | // Allocates a new heap buffer from the specified |data_allocator|. 30 | // |host_allocator| is used for the iree_hal_buffer_t metadata. If both 31 | // |data_allocator| and |host_allocator| are the same the buffer will be created 32 | // as a flat slab. |out_buffer| must be released by the caller. 33 | iree_status_t iree_hal_heap_buffer_create( 34 | iree_hal_allocator_t* allocator, 35 | iree_hal_heap_allocator_statistics_t* statistics, 36 | const iree_hal_buffer_params_t* params, iree_device_size_t allocation_size, 37 | iree_allocator_t data_allocator, iree_allocator_t host_allocator, 38 | iree_hal_buffer_t** out_buffer); 39 | 40 | #ifdef __cplusplus 41 | } // extern "C" 42 | #endif // __cplusplus 43 | 44 | #endif // IREE_HAL_BUFFER_HEAP_IMPL_H_ 45 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/metal/shared_event.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_METAL_METAL_SHARED_EVENT_H_ 8 | #define IREE_HAL_DRIVERS_METAL_METAL_SHARED_EVENT_H_ 9 | 10 | #import 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/hal/api.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif // __cplusplus 18 | 19 | // Creates a Metal shared event with the given |initial_value| to implement an 20 | // IREE semaphore. 21 | // 22 | // |listener| is used for dispatching notifications for async execution. 23 | // 24 | // |out_semaphore| must be released by the caller (see 25 | // iree_hal_semaphore_release). 26 | iree_status_t iree_hal_metal_shared_event_create( 27 | id device, uint64_t initial_value, 28 | MTLSharedEventListener* listener, iree_allocator_t host_allocator, 29 | iree_hal_semaphore_t** out_semaphore); 30 | 31 | // Returns true if |semaphore| is a Metal shared event. 32 | bool iree_hal_metal_shared_event_isa(iree_hal_semaphore_t* semaphore); 33 | 34 | // Returns the underlying Metal shared event handle for the given |semaphore|. 35 | id iree_hal_metal_shared_event_handle( 36 | const iree_hal_semaphore_t* semaphore); 37 | 38 | // Waits on the shared events in the given |semaphore_list| according to the 39 | // |wait_mode| before |timeout|. 40 | iree_status_t iree_hal_metal_shared_event_multi_wait( 41 | iree_hal_wait_mode_t wait_mode, 42 | const iree_hal_semaphore_list_t* semaphore_list, iree_timeout_t timeout); 43 | 44 | #ifdef __cplusplus 45 | } // extern "C" 46 | #endif // __cplusplus 47 | 48 | #endif // IREE_HAL_DRIVERS_METAL_METAL_SHARED_EVENT_H_ 49 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/vm/bytecode/verifier.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_VM_BYTECODE_VERIFIER_H_ 8 | #define IREE_VM_BYTECODE_VERIFIER_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/vm/api.h" 12 | #include "iree/vm/bytecode/module_impl.h" 13 | 14 | // Verifies the structure of the FlatBuffer so that we can avoid doing so during 15 | // runtime. There are still some conditions we must be aware of (such as omitted 16 | // names on functions with internal linkage), however we shouldn't need to 17 | // bounds check anything within the FlatBuffer after this succeeds. 18 | iree_status_t iree_vm_bytecode_module_flatbuffer_verify( 19 | iree_const_byte_span_t archive_contents, 20 | iree_const_byte_span_t flatbuffer_contents, 21 | iree_host_size_t archive_rodata_offset); 22 | 23 | // Verifies the bytecode contained within the given |function_ordinal|. 24 | // Assumes that all information on |module| has been verified and only function 25 | // information requires verification. 26 | // 27 | // NOTE: verification only checks that the function is well-formed and not that 28 | // it is correct or will execute successfully. The only thing this tries to 29 | // guarantee is that executing the bytecode won't cause a crash. 30 | // 31 | // If verification requires transient allocations for tracking they will be made 32 | // from |scratch_allocator|. No allocation will live outside of the function and 33 | // callers may provide stack-based arenas. 34 | iree_status_t iree_vm_bytecode_function_verify( 35 | iree_vm_bytecode_module_t* module, uint16_t function_ordinal, 36 | iree_allocator_t scratch_allocator); 37 | 38 | #endif // IREE_VM_BYTECODE_VERIFIER_H_ 39 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/base/loop_emscripten.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BASE_LOOP_EMSCRIPTEN_H_ 8 | #define IREE_BASE_LOOP_EMSCRIPTEN_H_ 9 | 10 | #include "iree/base/api.h" 11 | 12 | #if defined(IREE_PLATFORM_EMSCRIPTEN) 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | //===----------------------------------------------------------------------===// 19 | // iree_loop_emscripten_t 20 | //===----------------------------------------------------------------------===// 21 | 22 | // A loop backed by the web browser event loop, built using Emscripten. 23 | // TODO(scotttodd): comment on thread safety (when established) 24 | typedef struct iree_loop_emscripten_t iree_loop_emscripten_t; 25 | 26 | // Allocates a loop using |allocator| stored into |out_loop|. 27 | IREE_API_EXPORT iree_status_t iree_loop_emscripten_allocate( 28 | iree_allocator_t allocator, iree_loop_emscripten_t** out_loop); 29 | 30 | // Frees |loop_emscripten|, aborting all pending operations. 31 | IREE_API_EXPORT void iree_loop_emscripten_free(iree_loop_emscripten_t* loop); 32 | 33 | IREE_API_EXPORT iree_status_t 34 | iree_loop_emscripten_ctl(void* self, iree_loop_command_t command, 35 | const void* params, void** inout_ptr); 36 | 37 | // Returns a loop that uses |data|. 38 | static inline iree_loop_t iree_loop_emscripten(iree_loop_emscripten_t* data) { 39 | iree_loop_t loop = { 40 | data, 41 | iree_loop_emscripten_ctl, 42 | }; 43 | return loop; 44 | } 45 | 46 | #ifdef __cplusplus 47 | } // extern "C" 48 | #endif // __cplusplus 49 | 50 | #endif // IREE_PLATFORM_EMSCRIPTEN 51 | 52 | #endif // IREE_BASE_LOOP_EMSCRIPTEN_H_ 53 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/local_task/task_driver.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_LOCAL_TASK_TASK_DRIVER_H_ 8 | #define IREE_HAL_DRIVERS_LOCAL_TASK_TASK_DRIVER_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/drivers/local_task/task_device.h" 13 | #include "iree/hal/local/executable_loader.h" 14 | #include "iree/task/executor.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif // __cplusplus 19 | 20 | // Creates a new iree/task/-based local CPU driver that creates devices sharing 21 | // the provided executors for scheduling tasks. 22 | // 23 | // |queue_count| specifies the number of logical device queues exposed to 24 | // programs with one entry in |queue_executors| providing the scheduling scope. 25 | // Multiple queues may share the same executor. When multiple executors are used 26 | // queries for device capabilities will always report from the first. 27 | // 28 | // |loaders| is the set of executable loaders that are available for loading in 29 | // the device context. The loaders are retained for the lifetime of the device. 30 | iree_status_t iree_hal_task_driver_create( 31 | iree_string_view_t identifier, 32 | const iree_hal_task_device_params_t* default_params, 33 | iree_host_size_t queue_count, iree_task_executor_t* const* queue_executors, 34 | iree_host_size_t loader_count, iree_hal_executable_loader_t** loaders, 35 | iree_hal_allocator_t* device_allocator, iree_allocator_t host_allocator, 36 | iree_hal_driver_t** out_driver); 37 | 38 | #ifdef __cplusplus 39 | } // extern "C" 40 | #endif // __cplusplus 41 | 42 | #endif // IREE_HAL_DRIVERS_LOCAL_TASK_TASK_DRIVER_H_ 43 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "AppIcon.jpg", 5 | "idiom" : "universal", 6 | "platform" : "ios", 7 | "size" : "1024x1024" 8 | }, 9 | { 10 | "filename" : "16-mac.png", 11 | "idiom" : "mac", 12 | "scale" : "1x", 13 | "size" : "16x16" 14 | }, 15 | { 16 | "filename" : "32-mac.png", 17 | "idiom" : "mac", 18 | "scale" : "2x", 19 | "size" : "16x16" 20 | }, 21 | { 22 | "filename" : "32-mac 1.png", 23 | "idiom" : "mac", 24 | "scale" : "1x", 25 | "size" : "32x32" 26 | }, 27 | { 28 | "filename" : "64-mac.png", 29 | "idiom" : "mac", 30 | "scale" : "2x", 31 | "size" : "32x32" 32 | }, 33 | { 34 | "filename" : "128-mac.png", 35 | "idiom" : "mac", 36 | "scale" : "1x", 37 | "size" : "128x128" 38 | }, 39 | { 40 | "filename" : "256-mac.png", 41 | "idiom" : "mac", 42 | "scale" : "2x", 43 | "size" : "128x128" 44 | }, 45 | { 46 | "filename" : "256-mac 1.png", 47 | "idiom" : "mac", 48 | "scale" : "1x", 49 | "size" : "256x256" 50 | }, 51 | { 52 | "filename" : "512-mac.png", 53 | "idiom" : "mac", 54 | "scale" : "2x", 55 | "size" : "256x256" 56 | }, 57 | { 58 | "filename" : "512-mac 1.png", 59 | "idiom" : "mac", 60 | "scale" : "1x", 61 | "size" : "512x512" 62 | }, 63 | { 64 | "filename" : "1024-mac.png", 65 | "idiom" : "mac", 66 | "scale" : "2x", 67 | "size" : "512x512" 68 | }, 69 | { 70 | "filename" : "AppIcon 1.jpg", 71 | "idiom" : "universal", 72 | "platform" : "watchos", 73 | "size" : "1024x1024" 74 | } 75 | ], 76 | "info" : { 77 | "author" : "xcode", 78 | "version" : 1 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/vulkan/native_semaphore.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_VULKAN_NATIVE_SEMAPHORE_H_ 8 | #define IREE_HAL_DRIVERS_VULKAN_NATIVE_SEMAPHORE_H_ 9 | 10 | #include 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/hal/api.h" 14 | #include "iree/hal/drivers/vulkan/handle_util.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif // __cplusplus 19 | 20 | // Creates a timeline semaphore implemented using the native VkSemaphore type. 21 | iree_status_t iree_hal_vulkan_native_semaphore_create( 22 | iree::hal::vulkan::VkDeviceHandle* logical_device, uint64_t initial_value, 23 | iree_hal_semaphore_t** out_semaphore); 24 | 25 | // Returns true if |semaphore| is a Vulkan native semaphore. 26 | bool iree_hal_vulkan_native_semaphore_isa(iree_hal_semaphore_t* semaphore); 27 | 28 | // Returns the Vulkan timeline semaphore handle. 29 | VkSemaphore iree_hal_vulkan_native_semaphore_handle( 30 | iree_hal_semaphore_t* semaphore); 31 | 32 | // Performs a multi-wait on one or more semaphores. 33 | // By default this is an all-wait but |wait_flags| may contain 34 | // VK_SEMAPHORE_WAIT_ANY_BIT to change to an any-wait. 35 | // 36 | // Returns IREE_STATUS_DEADLINE_EXCEEDED if the wait does not complete before 37 | // |deadline_ns| elapses. 38 | iree_status_t iree_hal_vulkan_native_semaphore_multi_wait( 39 | iree::hal::vulkan::VkDeviceHandle* logical_device, 40 | const iree_hal_semaphore_list_t* semaphore_list, iree_timeout_t timeout, 41 | VkSemaphoreWaitFlags wait_flags); 42 | 43 | #ifdef __cplusplus 44 | } // extern "C" 45 | #endif // __cplusplus 46 | 47 | #endif // IREE_HAL_DRIVERS_VULKAN_NATIVE_SEMAPHORE_H_ 48 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/test/support/data_case.ex: -------------------------------------------------------------------------------- 1 | defmodule LiveNxIREE.DataCase do 2 | @moduledoc """ 3 | This module defines the setup for tests requiring 4 | access to the application's data layer. 5 | 6 | You may define functions here to be used as helpers in 7 | your tests. 8 | 9 | Finally, if the test case interacts with the database, 10 | we enable the SQL sandbox, so changes done to the database 11 | are reverted at the end of every test. If you are using 12 | PostgreSQL, you can even run database tests asynchronously 13 | by setting `use LiveNxIREE.DataCase, async: true`, although 14 | this option is not recommended for other databases. 15 | """ 16 | 17 | use ExUnit.CaseTemplate 18 | 19 | using do 20 | quote do 21 | alias LiveNxIREE.Repo 22 | 23 | import Ecto 24 | import Ecto.Changeset 25 | import Ecto.Query 26 | import LiveNxIREE.DataCase 27 | end 28 | end 29 | 30 | setup tags do 31 | LiveNxIREE.DataCase.setup_sandbox(tags) 32 | :ok 33 | end 34 | 35 | @doc """ 36 | Sets up the sandbox based on the test tags. 37 | """ 38 | def setup_sandbox(tags) do 39 | pid = Ecto.Adapters.SQL.Sandbox.start_owner!(LiveNxIREE.Repo, shared: not tags[:async]) 40 | on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end) 41 | end 42 | 43 | @doc """ 44 | A helper that transforms changeset errors into a map of messages. 45 | 46 | assert {:error, changeset} = Accounts.create_user(%{password: "short"}) 47 | assert "password is too short" in errors_on(changeset).password 48 | assert %{password: ["password is too short"]} = errors_on(changeset) 49 | 50 | """ 51 | def errors_on(changeset) do 52 | Ecto.Changeset.traverse_errors(changeset, fn {message, opts} -> 53 | Regex.replace(~r"%{(\w+)}", message, fn _, key -> 54 | opts |> Keyword.get(String.to_existing_atom(key), key) |> to_string() 55 | end) 56 | end) 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/drivers/local_sync/sync_device.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_DRIVERS_LOCAL_SYNC_SYNC_DEVICE_H_ 8 | #define IREE_HAL_DRIVERS_LOCAL_SYNC_SYNC_DEVICE_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | #include "iree/hal/local/executable_loader.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | // Parameters configuring an iree_hal_sync_device_t. 19 | // Must be initialized with iree_hal_sync_device_params_initialize prior to use. 20 | typedef struct iree_hal_sync_device_params_t { 21 | // Total size of each block in the device shared block pool. 22 | // Larger sizes will lower overhead and ensure the heap isn't hit for 23 | // transient allocations while also increasing memory consumption. 24 | iree_host_size_t arena_block_size; 25 | } iree_hal_sync_device_params_t; 26 | 27 | // Initializes |out_params| to default values. 28 | void iree_hal_sync_device_params_initialize( 29 | iree_hal_sync_device_params_t* out_params); 30 | 31 | // Creates a new synchronous local CPU device that performs execution inline 32 | // on threads issuing submissions. |loaders| is the set of executable 33 | // loaders that are available for loading in the device context. 34 | iree_status_t iree_hal_sync_device_create( 35 | iree_string_view_t identifier, const iree_hal_sync_device_params_t* params, 36 | iree_host_size_t loader_count, iree_hal_executable_loader_t** loaders, 37 | iree_hal_allocator_t* device_allocator, iree_allocator_t host_allocator, 38 | iree_hal_device_t** out_device); 39 | 40 | #ifdef __cplusplus 41 | } // extern "C" 42 | #endif // __cplusplus 43 | 44 | #endif // IREE_HAL_DRIVERS_LOCAL_SYNC_SYNC_DEVICE_H_ 45 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/modules/hal/module.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_MODULES_HAL_MODULE_H_ 8 | #define IREE_MODULES_HAL_MODULE_H_ 9 | 10 | #include 11 | 12 | #include "iree/base/api.h" 13 | #include "iree/hal/api.h" 14 | #include "iree/modules/hal/types.h" 15 | #include "iree/vm/api.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif // __cplusplus 20 | 21 | enum iree_hal_module_flag_bits_t { 22 | IREE_HAL_MODULE_FLAG_NONE = 0u, 23 | 24 | // Forces HAL methods to block instead of yielding as a coroutine. 25 | IREE_HAL_MODULE_FLAG_SYNCHRONOUS = 1u << 0, 26 | }; 27 | typedef uint32_t iree_hal_module_flags_t; 28 | 29 | // Creates the HAL module initialized to use one or more |devices|. 30 | // Each context using this module will share the devices and have compatible 31 | // allocations. 32 | IREE_API_EXPORT iree_status_t iree_hal_module_create( 33 | iree_vm_instance_t* instance, iree_host_size_t device_count, 34 | iree_hal_device_t** devices, iree_hal_module_flags_t flags, 35 | iree_allocator_t host_allocator, iree_vm_module_t** out_module); 36 | 37 | // Returns the total number of available devices registered with the HAL module. 38 | IREE_API_EXPORT iree_host_size_t 39 | iree_hal_module_state_device_count(iree_vm_module_state_t* module_state); 40 | 41 | // Returns the device at |index| currently in use by the HAL module. 42 | // Returns NULL if no device has been initialized yet or the index is out of 43 | // bounds. 44 | IREE_API_EXPORT iree_hal_device_t* iree_hal_module_state_device_get( 45 | iree_vm_module_state_t* module_state, iree_host_size_t index); 46 | 47 | #ifdef __cplusplus 48 | } // extern "C" 49 | #endif // __cplusplus 50 | 51 | #endif // IREE_MODULES_HAL_MODULE_H_ 52 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/io/formats/safetensors/safetensors_parser.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_IO_FORMATS_SAFETENSORS_SAFETENSORS_PARSER_H_ 8 | #define IREE_IO_FORMATS_SAFETENSORS_SAFETENSORS_PARSER_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/io/file_handle.h" 12 | #include "iree/io/parameter_index.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif // __cplusplus 17 | 18 | // Parses a .safetensors file and merges its contained resources into |index|. 19 | // 20 | // Documentation: https://github.com/huggingface/safetensors 21 | // This is a very basic archive file with some issues (no alignment, etc) but 22 | // at least doesn't require Python pickle decoding (just JSON). The major reason 23 | // to use this is if sourcing from a Hugging Face model that has its weights 24 | // already in the safetensors format. 25 | // 26 | // WARNING: this implementation has not been thoroughly tested or verified as 27 | // safe or correct. Use with caution only on trusted inputs. Tip: don't embed 28 | // other file formats within your file format and call it "safe" as it's only 29 | // going to be as safe as the implementations of the other file formats you 30 | // embed. In this case a full JSON parser is required and must be safe and we 31 | // don't take that dependency for a testing tool. Users wanting to productionize 32 | // this should implement their own safetensors parser or use the rust one with 33 | // all the fun that entails. 34 | IREE_API_EXPORT iree_status_t iree_io_parse_safetensors_index( 35 | iree_io_file_handle_t* file_handle, iree_io_parameter_index_t* index); 36 | 37 | #ifdef __cplusplus 38 | } // extern "C" 39 | #endif // __cplusplus 40 | 41 | #endif // IREE_IO_FORMATS_SAFETENSORS_SAFETENSORS_PARSER_H_ 42 | -------------------------------------------------------------------------------- /lib/mix/tasks/nx_iree/native_download.ex: -------------------------------------------------------------------------------- 1 | defmodule Mix.Tasks.NxIree.NativeDownload do 2 | @moduledoc """ 3 | Downloads the native IREE library for the requested platform. 4 | 5 | Currently only supported in macOS arm64 hosts. 6 | """ 7 | 8 | @valid_platforms ~w(host ios ios_simulator visionos visionos_simulator tvos tvos_simulator) 9 | @platform "--platform <" <> Enum.join(@valid_platforms, "|") <> ">" 10 | @output_dir "--output-dir " 11 | @shortdoc "#{@platform} #{@output_dir}" 12 | 13 | use Mix.Task 14 | 15 | @impl Mix.Task 16 | def run(args) do 17 | {parsed, _rest, _errors} = 18 | OptionParser.parse(args, 19 | switches: [platform: :string, output_dir: :string], 20 | aliases: [p: :platform, d: :output_dir] 21 | ) 22 | 23 | platform = parsed[:platform] 24 | output_dir = parsed[:output_dir] 25 | 26 | unless platform do 27 | raise """ 28 | Missing required argument: #{@platform} 29 | """ 30 | end 31 | 32 | unless output_dir do 33 | raise """ 34 | Missing required argument: #{@output_dir} 35 | """ 36 | end 37 | 38 | platform = platform |> String.trim() |> String.downcase() 39 | output_dir = String.trim(output_dir) 40 | 41 | os = :os.type() 42 | arch = List.to_string(:erlang.system_info(:system_architecture)) 43 | 44 | case {os, arch} do 45 | {{:unix, :darwin}, "aarch64" <> _} -> :ok 46 | {os, arch} -> raise "unsupported host: #{inspect(os)} (#{arch})" 47 | end 48 | 49 | file = "nx_iree-embedded-macos-#{platform}.tar.gz" 50 | 51 | File.mkdir_p!(output_dir) 52 | 53 | downloaded_file = Path.join(output_dir, file) 54 | 55 | url = NxIREE.MixHelpers.github_release_path(file) 56 | :ok = NxIREE.MixHelpers.download!("Native NxIREE library (#{platform})", url, downloaded_file) 57 | 58 | :ok = 59 | downloaded_file 60 | |> String.to_charlist() 61 | |> :erl_tar.extract([:compressed, cwd: String.to_charlist(output_dir)]) 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/utils/mpi_channel_provider.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_UTILS_MPI_CHANNEL_PROVIDER_H_ 8 | #define IREE_HAL_UTILS_MPI_CHANNEL_PROVIDER_H_ 9 | 10 | #include "iree/base/api.h" 11 | #include "iree/hal/api.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif // __cplusplus 16 | 17 | typedef struct iree_hal_mpi_dynamic_symbols_t iree_hal_mpi_dynamic_symbols_t; 18 | 19 | // Returns true if MPI support has been configured by the user and should be 20 | // used. This checks for required MPI environment variables that are set 21 | // when running under mpirun. 22 | IREE_API_EXPORT bool iree_hal_mpi_is_configured(void); 23 | 24 | // Creates an MPI-based collective channel provider. 25 | // On creation the provider will initialize MPI with MPI_Init and on destruction 26 | // will finalize MPI with MPI_Finalize after which time MPI can never be used in 27 | // the process again. Users should create one provider and share it across all 28 | // devices used within the process. 29 | IREE_API_EXPORT iree_status_t iree_hal_mpi_channel_provider_create( 30 | iree_allocator_t host_allocator, 31 | iree_hal_channel_provider_t** out_channel_provider); 32 | 33 | // Returns true if |channel_provider| is an MPI channel provider. 34 | IREE_API_EXPORT bool iree_hal_mpi_channel_provider_isa( 35 | iree_hal_channel_provider_t* channel_provider); 36 | 37 | // Returns the dynamically loaded MPI symbols or NULL if |channel_provider| is 38 | // not an MPI channel provider. 39 | IREE_API_EXPORT iree_hal_mpi_dynamic_symbols_t* 40 | iree_hal_mpi_channel_provider_symbols( 41 | iree_hal_channel_provider_t* channel_provider); 42 | 43 | #ifdef __cplusplus 44 | } // extern "C" 45 | #endif // __cplusplus 46 | 47 | #endif // IREE_HAL_UTILS_MPI_CHANNEL_PROVIDER_H_ 48 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/hal/local/loaders/static_library_loader.h: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_HAL_LOCAL_LOADERS_STATIC_LIBRARY_LOADER_H_ 8 | #define IREE_HAL_LOCAL_LOADERS_STATIC_LIBRARY_LOADER_H_ 9 | 10 | #include 11 | #include 12 | 13 | #include "iree/base/api.h" 14 | #include "iree/hal/local/executable_library.h" 15 | #include "iree/hal/local/executable_loader.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif // __cplusplus 20 | 21 | // Creates a library loader that exposes the provided libraries to the HAL for 22 | // use as executables. 23 | // 24 | // This loader will handle executable formats of 'static'. Version checks will 25 | // ensure that the IREE compiler-produced static library version is one that the 26 | // runtime can support. 27 | // 28 | // The name defined on each library will be used to lookup the executables and 29 | // must match with the names used during compilation exactly. The 30 | // iree_hal_executable_params_t used to reference the executables will contain 31 | // the library name and be used to lookup the library in the list. 32 | // 33 | // Multiple static library loaders can be registered in cases when several 34 | // independent sets of libraries are linked in however duplicate names both 35 | // within and across loaders will result in undefined behavior. 36 | iree_status_t iree_hal_static_library_loader_create( 37 | iree_host_size_t library_count, 38 | const iree_hal_executable_library_query_fn_t* library_query_fns, 39 | iree_hal_executable_import_provider_t import_provider, 40 | iree_allocator_t host_allocator, 41 | iree_hal_executable_loader_t** out_executable_loader); 42 | 43 | #ifdef __cplusplus 44 | } // extern "C" 45 | #endif // __cplusplus 46 | 47 | #endif // IREE_HAL_LOCAL_LOADERS_STATIC_LIBRARY_LOADER_H_ 48 | -------------------------------------------------------------------------------- /embedded_devices/live_nx_iree/native/swiftui/LiveNxIREE/nx_iree/include/iree/builtins/ukernel/tools/test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The IREE Authors 2 | // 3 | // Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | // See https://llvm.org/LICENSE.txt for license information. 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | 7 | #ifndef IREE_BUILTINS_UKERNEL_TOOLS_TEST_H_ 8 | #define IREE_BUILTINS_UKERNEL_TOOLS_TEST_H_ 9 | 10 | #include "iree/builtins/ukernel/tools/util.h" 11 | 12 | // Opaque struct holding some test case information and some resources such as 13 | // a pseudorandom engine and CPU data. 14 | typedef struct iree_uk_test_t iree_uk_test_t; 15 | 16 | // Synchronously run a test --- no registration. 17 | // 18 | // `params` is the "user data" parameters that will be passed as the second 19 | // argument to `test_func`. 20 | // 21 | // If `cpu_features` is non-NULL then `test_func` will be called a second time 22 | // with the corresponding CPU features enabled in the iree_uk_test_t* passed as 23 | // first argument to `test_func`. This is done as a second separate call to 24 | // `test_func` so that we maintain test coverage for the fallback logic and 25 | // baseline kernels used when CPU features are unavailable. 26 | void iree_uk_test(const char* name, 27 | void (*test_func)(iree_uk_test_t*, const void*), 28 | const void* params, const char* cpu_features); 29 | 30 | // Fail the current test. 31 | #define IREE_UK_TEST_FAIL(test) iree_uk_test_fail(test, __FILE__, __LINE__) 32 | 33 | // Implementation of IREE_UK_TEST_FAIL. 34 | void iree_uk_test_fail(iree_uk_test_t* test, const char* file, int line); 35 | 36 | // Used by test functions to get a random engine. 37 | iree_uk_random_engine_t* iree_uk_test_random_engine(const iree_uk_test_t* test); 38 | 39 | // Used by test functions to get CPU data. 40 | const iree_uk_uint64_t* iree_uk_test_cpu_data(const iree_uk_test_t* test); 41 | 42 | // Must be called by the test `main` function to provide its return value. 43 | int iree_uk_test_exit_status(void); 44 | 45 | #endif // IREE_BUILTINS_UKERNEL_TOOLS_TEST_H_ 46 | --------------------------------------------------------------------------------
8 | v<%= Application.spec(:phoenix, :vsn) %> 9 |