Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dnn-providers/fusilli-provider/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BasedOnStyle: LLVM
8 changes: 8 additions & 0 deletions dnn-providers/fusilli-provider/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CMake build
build/

# clangd intellisense cache
.cache/

# CMake presets
CMakeUserPresets.json
129 changes: 129 additions & 0 deletions dnn-providers/fusilli-provider/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Copyright 2025 Advanced Micro Devices, Inc.
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

cmake_minimum_required(VERSION 3.24)

project(fusilli-plugin
VERSION 0.1.0
DESCRIPTION "Fusilli-Plugin: A Fusilli/IREE powered hipDNN plugin for graph JIT compilation."
LANGUAGES C CXX)

# Set C++ standard
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)

# CMake includes
include(GNUInstallDirs)
include(FetchContent)

# IREE Runtime Dependency - build from source, same pattern as fusilli/CMakeLists.txt
if(NOT IREE_SOURCE_DIR)
message(FATAL_ERROR "IREE_SOURCE_DIR must be provided. Set -DIREE_SOURCE_DIR=<path> to the IREE source directory.")
endif()
message(STATUS "Using existing IREE sources: ${IREE_SOURCE_DIR}")
# Set IREE build flags
set(IREE_VISIBILITY_HIDDEN OFF)
set(IREE_BUILD_COMPILER OFF)
set(IREE_BUILD_TESTS OFF)
set(IREE_BUILD_SAMPLES OFF)
set(IREE_ERROR_ON_MISSING_SUBMODULES OFF)
set(IREE_HAL_DRIVER_DEFAULTS OFF)
set(IREE_HAL_DRIVER_HIP ON)
set(IREE_HIP_TEST_TARGET_CHIP "" CACHE STRING "")
# Build IREERuntime as part of plugin
FetchContent_Declare(
IREERuntime
SOURCE_DIR ${IREE_SOURCE_DIR}
# Fusilli's config file requires IREE runtime via
# find_dependency(IREERuntime), which triggers find_package(IREERuntime). The
# dependency can only be fulfilled via source build: FetchContent_Declare or
# add_subdirectory. Of those options, only FetchContent_Declare provides a way
# of intercepting the find_package call and redirecting to the source build.
OVERRIDE_FIND_PACKAGE
SYSTEM
)
FetchContent_MakeAvailable(IREERuntime)

# Other dependencies
find_package(hip CONFIG REQUIRED)
find_package(hipdnn_data_sdk CONFIG REQUIRED)
find_package(hipdnn_plugin_sdk CONFIG REQUIRED)
find_package(hipdnn_frontend CONFIG REQUIRED)
find_package(hipdnn_test_sdk CONFIG REQUIRED)
find_package(Fusilli CONFIG REQUIRED)
# Fetch GTest if system install isn't available
find_package(GTest CONFIG QUIET)
if(NOT GTest_FOUND)
message(STATUS "GTest not found on system: Fetching from GitHub")
FetchContent_Declare(
googletest
QUIET
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.16.0
)
FetchContent_MakeAvailable(googletest)
endif()


# Global constants
set(FUSILLI_PLUGIN_TARGET fusilli_plugin)
# Relative path from build/install prefix to plugin location.
# HIPDNN_PLUGIN_ENGINE_SUBDIR is provided by hipdnn_sdk.
set(FUSILLI_PLUGIN_RELATIVE_PATH "${CMAKE_INSTALL_LIBDIR}/${HIPDNN_PLUGIN_ENGINE_SUBDIR}")

# Useful compile warnings
list(PREPEND FUSILLI_PLUGIN_WARNING_COMPILE_OPTIONS
-Werror # Treat all warnings as errors
-Wall # Enable most common warnings
-Wextra # Enable additional warnings not covered by -Wall
-Wpedantic # Enforce strict ISO C++ compliance
-Wshadow # Warn about variable shadowing
-Wnon-virtual-dtor # Warn if a class with virtual functions has a non-virtual destructor
-Wold-style-cast # Warn about C-style casts
-Wcast-align # Warn about potential performance issues with misaligned casts
-Woverloaded-virtual # Warn if a base class function is hidden by a derived class function with the same name
-Wconversion # Warn about implicit type conversions that may alter a value
-Wsign-conversion # Warn about implicit conversions between signed and unsigned types
-Wnull-dereference # Warn about dereferencing null pointers
-Wdouble-promotion # Warn when a float is implicitly promoted to a double
-Wformat=2 # Enable stricter format string checks
-Winit-self # Warn about variables initialized with itself
-Wunreachable-code # Warn about unreachable code
-Wno-error=unused-command-line-argument # Disable error for unused command line arguments
-Wno-gnu-statement-expression # Disable gnu error for statement expression, this will need to change on Windows.
-Wswitch-default # Warn if a switch statement does not have a default case
)

# Includes
include_directories(include)

# Plugin definition
add_library(${FUSILLI_PLUGIN_TARGET} SHARED
src/fusilli_plugin.cpp
)
target_compile_options(${FUSILLI_PLUGIN_TARGET} PRIVATE ${FUSILLI_PLUGIN_WARNING_COMPILE_OPTIONS})
target_link_libraries(${FUSILLI_PLUGIN_TARGET} PRIVATE hipdnn_plugin_sdk hipdnn_data_sdk hip::host fusilli::fusilli)
set_target_properties(${FUSILLI_PLUGIN_TARGET} PROPERTIES
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${FUSILLI_PLUGIN_RELATIVE_PATH}"
)
# Version script hides all symbol definitions not staring with "hipdnn"
target_link_options(
${FUSILLI_PLUGIN_TARGET} PRIVATE "LINKER:--version-script=${CMAKE_SOURCE_DIR}/exports.map"
)

# Installation
install(TARGETS ${FUSILLI_PLUGIN_TARGET}
LIBRARY DESTINATION "${FUSILLI_PLUGIN_RELATIVE_PATH}"
)

# Tests
enable_testing()
add_subdirectory(test)
7 changes: 7 additions & 0 deletions dnn-providers/fusilli-provider/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Fusilli Plugin

Fusilli-Plugin: A Fusilli/IREE powered hipDNN plugin for graph JIT compilation.
Comment thread
AaronStGeorge marked this conversation as resolved.
Outdated

:construction: **This project is under active development, many things don't work yet** :construction:

The plugin builds as a shared library (`fusilli_plugin.so`) providing a `hipDNN` [kernel engine plugin](https://github.com/ROCm/hipDNN/blob/develop/docs/PluginDevelopment.md#creating-a-kernel-engine-plugin) [API](https://github.com/ROCm/hipDNN/blob/839cf6c4bc6fe403d0ef72cb5d7df004e2004743/sdk/include/hipdnn_sdk/plugin/EnginePluginApi.h).
Comment thread
AaronStGeorge marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Copyright 2025 Advanced Micro Devices, Inc.
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#===------------------------------------------------------------------------===#
#
# This file contains test utilities for Fusilli's hipDNN plugin.
#
# TheRock CI generates test, lib, dbg, etc. artifacts from the build - CI tests
# are run on separate runners using a downloaded version of a project's test
# artifacts. This approach allows the build to use a cheaper CPU-only machine,
# and the tests for each project to run in parallel on more expensive GPU
# machines (after the build has completed).
#
# In TheRock the pattern is to install tests as well as a generated CTest script
# in the test artifact. When the artifact is downloaded to an isolated runner,
# CTest can simply be pointed at the generated script + pre-built tests.
#
# This file provides `add_fusilli_plugin_test()` to wrap up boilerplate for test
# setup + test installation + test script generation.
#
#===------------------------------------------------------------------------===#

include(GoogleTest)

# Set up the installed CTestTestfile.cmake. We add a ".install" postfix to
# differentiate from CTestTestfile.cmake generated by GTest during the build.
# Note: we can't simply use the GTest version as the paths are absolute, the
# test script will need to be installed (and therefore relocated) so must use
# relative paths.
set(_FUSILLI_PLUGIN_INSTALLED_CTEST_FILE "${CMAKE_CURRENT_BINARY_DIR}/CTestTestfile.cmake.install")

file(WRITE "${_FUSILLI_PLUGIN_INSTALLED_CTEST_FILE}"
"# Autogenerated CTestTestfile for installed fusilli-plugin tests\n"
"# Generated by fusilli-plugin build system\n\n"
)

install(
FILES "${_FUSILLI_PLUGIN_INSTALLED_CTEST_FILE}"
DESTINATION "${CMAKE_INSTALL_BINDIR}/fusilli_plugin_test_infra"
RENAME CTestTestfile.cmake
)

# Creates a fusilli plugin test.
#
# To support build configurations (such as TheRock) that require tests to run on
# a different machine from where they were built, add_fusilli_plugin_test builds
# and _installs_ tests + CTest runner scripts
#
# add_fusilli_plugin_test(
# NAME <test-name>
# SRCS <file> [<file> ...]
# DEPS <dep> [<dep> ...]
# [COMPILE_DEFS <def> [<def> ...]]
# )
#
# NAME
# The name of the test executable (required).
#
# SRCS
# Source files to compile into the executable (required).
#
# DEPS
# Library dependencies to be linked to this target.
#
# COMPILE_DEFS
# Compile definitions to add to the target.
function(add_fusilli_plugin_test)
cmake_parse_arguments(
ARG # prefix
"" # options
"NAME" # one value keywords
"SRCS;DEPS;COMPILE_DEFS" # multi-value keywords
${ARGN} # extra arguments
)

if(NOT DEFINED ARG_NAME)
message(FATAL_ERROR "add_fusilli_plugin_test: NAME is required")
endif()

if(NOT DEFINED ARG_SRCS)
message(FATAL_ERROR "add_fusilli_plugin_test: SRCS is required")
endif()

# Create executable
add_executable(${ARG_NAME} ${ARG_SRCS})

# When installed all tests are at the same level in the file hierarchy, ensure
# tests are at the same level in the build directory as well
set_target_properties(${ARG_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/test"
)

# Set compile options
target_compile_options(${ARG_NAME} PRIVATE ${FUSILLI_PLUGIN_WARNING_COMPILE_OPTIONS})

# Link dependencies
target_link_libraries(${ARG_NAME} PRIVATE ${ARG_DEPS})

# Add compile definitions if provided
if(DEFINED ARG_COMPILE_DEFS)
target_compile_definitions(${ARG_NAME} PRIVATE ${ARG_COMPILE_DEFS})
endif()

# Register with CTest
gtest_discover_tests(${ARG_NAME}
PROPERTIES
ENVIRONMENT "HIPDNN_LOG_LEVEL=info"
ENVIRONMENT "FUSILLI_LOG_INFO=1"
ENVIRONMENT "FUSILLI_LOG_FILE=stdout"
)

# Install test executable
install(TARGETS ${ARG_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Append to installed CTestTestfile.cmake. Paths are relative as tests get
# relocated on install.
file(APPEND "${_FUSILLI_PLUGIN_INSTALLED_CTEST_FILE}"
"add_test(${ARG_NAME} \"../${ARG_NAME}\")\n"
)
file(APPEND "${_FUSILLI_PLUGIN_INSTALLED_CTEST_FILE}"
"\n# Set environment variables\n"
"set_tests_properties(${ARG_NAME}\n"
" PROPERTIES\n"
" ENVIRONMENT \"HIPDNN_LOG_LEVEL=info\"\n"
" ENVIRONMENT \"FUSILLI_LOG_INFO=1\"\n"
" ENVIRONMENT \"FUSILLI_LOG_FILE=stdout\"\n"
")\n"
)
endfunction()
8 changes: 8 additions & 0 deletions dnn-providers/fusilli-provider/exports.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Version script for fusilli_plugin
* Export only the hipDNN plugin interface symbols
*/
{
global: hipdnn*;
local: *;
};
Loading
Loading