forked from iree-org/iree
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix device list of loaded executable in PJRT plugin for multiple GPUs (…
…iree-org#19369) It closes iree-org#19366, and blocks iree-org#19279. After this PR, `ClientOptions::Compile` will first check the device assignment in the compile options, and then return the corresponding device list with the loaded executable. To achieve this, we introduce protobuf via `FetchContent` in this PR, which is scoped to the PJRT plugin. Compile options will be passed by the PJRT client encoded in protobuf, and in this plugin we decode it first and then retrieve some interesting fields. ci-exactly: build_packages, test_pjrt --------- Signed-off-by: PragmaTwice <[email protected]> Co-authored-by: Scott Todd <[email protected]>
- Loading branch information
1 parent
094ea05
commit d88d0a7
Showing
9 changed files
with
1,462 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Copyright 2024 The IREE Authors | ||
# | ||
# 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 | ||
|
||
include(CMakeParseArguments) | ||
include(FetchContent) | ||
|
||
# disable some targets we don't use | ||
set(protobuf_INSTALL OFF) | ||
set(protobuf_BUILD_TESTS OFF) | ||
|
||
# to prevent protobuf itself from using `find_package` | ||
set(protobuf_FORCE_FETCH_DEPENDENCIES ON) | ||
|
||
# pin the version of protobuf | ||
set(protobuf_VERSION 29.1) | ||
|
||
FetchContent_Declare( | ||
protobuf | ||
GIT_REPOSITORY https://github.com/protocolbuffers/protobuf | ||
GIT_TAG v${protobuf_VERSION} | ||
GIT_SHALLOW ON | ||
) | ||
|
||
FetchContent_MakeAvailable(protobuf) | ||
|
||
# make protobuf_generate() function available | ||
include(${protobuf_SOURCE_DIR}/cmake/protobuf-generate.cmake) | ||
|
||
# iree_pjrt_protobuf_cc_library() | ||
# | ||
# CMake function to invoke the protoc compiler. | ||
# | ||
# Parameters: | ||
# NAME: name of target | ||
# SRCS: List of source files for the library | ||
# PROTOC_ARGS: List of protoc arguments. | ||
# PUBLIC: Add this so that this library will be exported under iree:: | ||
# Also in IDE, target will appear in IREE folder while non PUBLIC will be in IREE/internal. | ||
# TESTONLY: When added, this target will only be built if user passes -DIREE_BUILD_TESTS=ON to CMake. | ||
# | ||
# iree_pjrt_protobuf_cc_library( | ||
# NAME | ||
# some_def | ||
# SRC | ||
# some_def.proto | ||
# PUBLIC | ||
# ) | ||
function(iree_pjrt_protobuf_cc_library) | ||
cmake_parse_arguments(_RULE | ||
"PUBLIC;TESTONLY" | ||
"NAME" | ||
"SRCS;PROTOC_ARGS" | ||
${ARGN} | ||
) | ||
|
||
if(_RULE_TESTONLY AND NOT IREE_BUILD_TESTS) | ||
return() | ||
endif() | ||
|
||
# Prefix the library with the package name, so we get: iree_package_name | ||
iree_package_name(_PACKAGE_NAME) | ||
set(_NAME "${_PACKAGE_NAME}_${_RULE_NAME}") | ||
|
||
add_library(${_NAME} ${_RULE_SRCS}) | ||
protobuf_generate( | ||
TARGET ${_NAME} | ||
LANGUAGE cpp | ||
PROTOC_OPTIONS ${_RULE_PROTOC_ARGS} | ||
) | ||
target_include_directories(${_NAME} | ||
PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> | ||
) | ||
target_link_libraries(${_NAME} | ||
PUBLIC | ||
protobuf::libprotobuf | ||
${IREE_DEFAULT_LINKOPTS} | ||
) | ||
iree_install_targets( | ||
TARGETS ${_NAME} | ||
) | ||
|
||
# Alias the iree_package_name library to iree::package::name. | ||
# This lets us more clearly map to Bazel and makes it possible to | ||
# disambiguate the underscores in paths vs. the separators. | ||
iree_package_ns(_PACKAGE_NS) | ||
iree_add_alias_library(${_PACKAGE_NS}::${_RULE_NAME} ${_NAME}) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.