Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
46 changes: 31 additions & 15 deletions plugins/hipdnn-plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,42 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)

# Local Includes
list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_LIST_DIR}/build_tools/cmake/
)
include(FusilliPluginDependencyUtils)

# Global constants
set(FUSILLI_PLUGIN_NAME fusilli_plugin)
set(FUSILLI_PLUGIN_ENGINE_ID 1001)
set(FUSILLI_PLUGIN_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib/${HIPDNN_PLUGIN_ENGINE_SUBDIR}")

# Options
option(FUSILLI_PLUGIN_USE_LOCAL_FUSILLI "Use local Fusilli build from ../fusilli" ON)
# 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
)

# Dependencies
set(HIP_PLATFORM "amd")
find_package(hip REQUIRED)
fusilli_plugin_dependency(GTest GTEST_VERSION 1.16.0)
fusilli_plugin_dependency(IREERuntime)
fusilli_plugin_dependency(hipdnn_frontend HIP_DNN_HASH 4e0a0452cfcb8fdb86e9c40a6e43debab4d4ecbc)
fusilli_plugin_dependency(Fusilli USE_LOCAL ${FUSILLI_PLUGIN_USE_LOCAL_FUSILLI})
find_package(hip CONFIG REQUIRED)
find_package(IREERuntime CONFIG REQUIRED)
find_package(hipdnn_sdk CONFIG REQUIRED)
find_package(hipdnn_frontend CONFIG REQUIRED)
find_package(Fusilli CONFIG REQUIRED)
find_package(GTest CONFIG REQUIRED)

# Includes
include_directories(include)
Expand All @@ -45,15 +61,15 @@ include_directories(include)
add_library(${FUSILLI_PLUGIN_NAME} SHARED
src/fusilli_plugin.cpp
)
target_compile_options(${FUSILLI_PLUGIN_NAME} PRIVATE ${HIPDNN_WARNING_COMPILE_OPTIONS})
target_compile_options(${FUSILLI_PLUGIN_NAME} PRIVATE ${FUSILLI_PLUGIN_WARNING_COMPILE_OPTIONS})
target_link_libraries(${FUSILLI_PLUGIN_NAME} PRIVATE hipdnn_sdk hip::host fusilli::fusilli)
target_compile_definitions(${FUSILLI_PLUGIN_NAME} PRIVATE
FUSILLI_PLUGIN_NAME="${FUSILLI_PLUGIN_NAME}"
FUSILLI_PLUGIN_ENGINE_ID=${FUSILLI_PLUGIN_ENGINE_ID}
)
set_target_properties(${FUSILLI_PLUGIN_NAME} PROPERTIES
CXX_VISIBILITY_PRESET hidden
LIBRARY_OUTPUT_DIRECTORY "${HIPDNN_BUILD_PLUGIN_ENGINE_DIR}"
LIBRARY_OUTPUT_DIRECTORY "${FUSILLI_PLUGIN_DIR}"
)

# Tests
Expand Down

This file was deleted.

12 changes: 6 additions & 6 deletions plugins/hipdnn-plugin/include/graph_import.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ class GraphImport {

// Import graph level properties.
fusilliGraph.setName(hipDnnGraph.name()->str())
.setIODataType(
FUSILLI_TRY(hipDnnDataTypeToFusilliDataType(hipDnnGraph.io_type())))
.setIntermediateDataType(FUSILLI_TRY(
hipDnnDataTypeToFusilliDataType(hipDnnGraph.intermediate_type())))
.setIODataType(FUSILLI_TRY(
hipDnnDataTypeToFusilliDataType(hipDnnGraph.io_data_type())))
.setIntermediateDataType(FUSILLI_TRY(hipDnnDataTypeToFusilliDataType(
hipDnnGraph.intermediate_data_type())))
.setComputeDataType(FUSILLI_TRY(
hipDnnDataTypeToFusilliDataType(hipDnnGraph.compute_type())));
hipDnnDataTypeToFusilliDataType(hipDnnGraph.compute_data_type())));

return importNodes();
}
Expand All @@ -109,7 +109,7 @@ class GraphImport {
if (opGraphWrapper.nodeCount() > 1)
return fusilli::error(fusilli::ErrorCode::NotImplemented,
"Multi-node graphs not supported currently.");
for (size_t i = 0; i < opGraphWrapper.nodeCount(); ++i) {
for (uint32_t i = 0; i < opGraphWrapper.nodeCount(); ++i) {
const hipdnn_sdk::data_objects::Node &node = opGraphWrapper.getNode(i);
FUSILLI_CHECK_ERROR(importNode(node));
}
Expand Down
36 changes: 32 additions & 4 deletions plugins/hipdnn-plugin/src/fusilli_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,28 @@ hipdnnPluginStatus_t hipdnnEnginePluginDestroyExecutionContext(
return HIPDNN_PLUGIN_STATUS_SUCCESS;
}

hipdnnPluginStatus_t hipdnnEnginePluginGetWorkspaceSizeFromExecutionContext(
hipdnnEnginePluginHandle_t handle,
hipdnnEnginePluginExecutionContext_t executionContext,
size_t *workspaceSize) {
LOG_API_ENTRY("handle={:p}, executionContext={:p}, workspaceSize={:p}",
static_cast<void *>(handle),
static_cast<void *>(executionContext),
static_cast<void *>(workspaceSize));
FUSILLI_PLUGIN_CHECK_NULL(handle);
FUSILLI_PLUGIN_CHECK_NULL(executionContext);
FUSILLI_PLUGIN_CHECK_NULL(workspaceSize);

// TODO(#2309): for now we're focusing on kernels that don't require scratch
// buffer space. Eventually we will need to teach IREE to report what scratch
// buffer space required, and how to use a passed in pre-allocated scratch
// space rather than a runtime allocated scratch space.
*workspaceSize = 0;

LOG_API_SUCCESS_AUTO("workspaceSize={}", *workspaceSize);
return HIPDNN_PLUGIN_STATUS_SUCCESS;
}

hipdnnPluginStatus_t hipdnnEnginePluginExecuteOpGraph(
hipdnnEnginePluginHandle_t handle,
hipdnnEnginePluginExecutionContext_t executionContext, void *workspace,
Expand All @@ -466,6 +488,10 @@ hipdnnPluginStatus_t hipdnnEnginePluginExecuteOpGraph(
.usage = IREE_HAL_BUFFER_USAGE_DEFAULT,
.access = IREE_HAL_MEMORY_ACCESS_READ | IREE_HAL_MEMORY_ACCESS_WRITE,
.type = IREE_HAL_MEMORY_TYPE_DEVICE_LOCAL,
.queue_affinity = IREE_HAL_QUEUE_AFFINITY_ANY,
// As we are importing a buffer rather than allocating, this param should
// be ignored.
.min_alignment = 0,
};

// Fill variant pack for graph execution. Fusilli expects a variant pack to
Expand Down Expand Up @@ -495,13 +521,14 @@ hipdnnPluginStatus_t hipdnnEnginePluginExecuteOpGraph(
iree_hal_external_buffer_t externalBuffer = {
.type = IREE_HAL_EXTERNAL_BUFFER_TYPE_DEVICE_ALLOCATION,
.flags = 0,
.size = static_cast<iree_device_size_t>(sizeof(float) *
tensorAttr->getVolume()),
.size = static_cast<iree_device_size_t>(
sizeof(float) * static_cast<size_t>(tensorAttr->getVolume())),
.handle =
{
.device_allocation =
{
.ptr = (uint64_t)hipMallocedBuffer.ptr,
.ptr =
reinterpret_cast<uint64_t>(hipMallocedBuffer.ptr),
},
},
};
Expand All @@ -514,7 +541,8 @@ hipdnnPluginStatus_t hipdnnEnginePluginExecuteOpGraph(
iree_hal_buffer_view_t *outBufferView = nullptr;
FUSILLI_PLUGIN_CHECK_ERROR(iree_hal_buffer_view_create(
/*buffer=*/importedBuffer, /*shape_rank=*/tensorAttr->getDim().size(),
/*shape=*/(const iree_hal_dim_t *)tensorAttr->getDim().data(),
/*shape=*/
reinterpret_cast<const iree_hal_dim_t *>(tensorAttr->getDim().data()),
/*element_type=*/
FUSILLI_PLUGIN_TRY(
fusilliDataTypeToIreeHalDataType(tensorAttr->getDataType())),
Expand Down
Loading
Loading