Skip to content

Commit

Permalink
Extracted minimum changes from migration branch (#722)
Browse files Browse the repository at this point in the history
Migrate PA Repo w/ Minimum Client changes.

Add typing

Remove unused functions
  • Loading branch information
fpetrini15 authored and dyastremsky committed Jul 29, 2024
1 parent c0b4745 commit dffe0cd
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ option(TRITON_ENABLE_TESTS "Include tests in build" OFF)
option(TRITON_ENABLE_GPU "Enable GPU support in libraries" OFF)
option(TRITON_ENABLE_ZLIB "Include ZLIB library in build" ON)

# Package Perf Analyzer with the Python Client -- Intended to be used by PA repo
option(TRITON_PACKAGE_PERF_ANALYZER "Include Perf Analyzer in pip wheel" OFF)

set(TRITON_REPO_ORGANIZATION "https://github.com/triton-inference-server" CACHE STRING "Git repository to pull from")
set(TRITON_COMMON_REPO_TAG "main" CACHE STRING "Tag for triton-inference-server/common repo")
set(TRITON_THIRD_PARTY_REPO_TAG "main" CACHE STRING "Tag for triton-inference-server/third_party repo")
Expand Down Expand Up @@ -223,6 +226,7 @@ if(TRITON_ENABLE_PYTHON_HTTP OR TRITON_ENABLE_PYTHON_GRPC)
-DTRITON_ENABLE_PERF_ANALYZER_OPENAI:BOOL=${TRITON_ENABLE_PERF_ANALYZER_OPENAI}
-DTRITON_ENABLE_EXAMPLES:BOOL=${TRITON_ENABLE_EXAMPLES}
-DTRITON_ENABLE_TESTS:BOOL=${TRITON_ENABLE_TESTS}
-DTRITON_PACKAGE_PERF_ANALYZER:BOOL=${TRITON_PACKAGE_PERF_ANALYZER}
-DTRITON_ENABLE_GPU:BOOL=${TRITON_ENABLE_GPU}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX:PATH=${TRITON_INSTALL_PREFIX}
Expand Down
106 changes: 104 additions & 2 deletions src/c++/library/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright (c) 2020-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -60,7 +60,58 @@ if(TRITON_ENABLE_CC_HTTP OR TRITON_ENABLE_PERF_ANALYZER OR TRITON_ENABLE_EXAMPLE
PRIVATE
client-common-library
)
endif()

add_library(
json_utils_static STATIC
$<TARGET_OBJECTS:json-utils-library>
)

add_library(
TritonClient::json_utils_static ALIAS json_utils_static
)

foreach(_json_target json-utils-library json_utils_static)
target_compile_features(${_json_target} PRIVATE cxx_std_${TRITON_MIN_CXX_STANDARD})
target_compile_options(
${_json_target} PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wextra -Wno-unused-parameter -Werror>
$<$<CXX_COMPILER_ID:MSVC>:/W0 /D_WIN32_WINNT=0x0A00 /EHsc>
)

set_target_properties(
${_json_target}
PROPERTIES
POSITION_INDEPENDENT_CODE ON
)

target_include_directories(
${_json_target}
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)

install(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/json_utils.h
DESTINATION include
)
endforeach()

install(
TARGETS
json_utils_static
EXPORT
triton-client-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

endif() # TRITON_ENABLE_CC_HTTP OR TRITON_ENABLE_PERF_ANALYZER OR TRITON_ENABLE_EXAMPLES

#
# shm_utils
Expand All @@ -75,6 +126,56 @@ target_link_libraries(
client-common-library
)

add_library(
shm_utils_static STATIC
$<TARGET_OBJECTS:shm-utils-library>
)

add_library(
TritonClient::shm_utils_static ALIAS shm_utils_static
)

foreach(_shm_target shm-utils-library shm_utils_static)
target_compile_features(${_shm_target} PRIVATE cxx_std_${TRITON_MIN_CXX_STANDARD})
target_compile_options(
${_shm_target} PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wextra -Wno-unused-parameter -Werror>
$<$<CXX_COMPILER_ID:MSVC>:/W0 /D_WIN32_WINNT=0x0A00 /EHsc>
)

set_target_properties(
${_shm_target}
PROPERTIES
POSITION_INDEPENDENT_CODE ON
)

target_include_directories(
${_shm_target}
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)

install(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/shm_utils.h
DESTINATION include
)
endforeach()

install(
TARGETS
shm_utils_static
EXPORT
triton-client-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

if(TRITON_ENABLE_CC_GRPC OR TRITON_ENABLE_PERF_ANALYZER)
#
# libgrpcclient.so and libgrpcclient_static.a
Expand Down Expand Up @@ -400,6 +501,7 @@ if(TRITON_ENABLE_CC_HTTP OR TRITON_ENABLE_CC_GRPC OR TRITON_ENABLE_PERF_ANALYZER
FILES
${CMAKE_CURRENT_SOURCE_DIR}/common.h
${CMAKE_CURRENT_SOURCE_DIR}/ipc.h
${CMAKE_CURRENT_SOURCE_DIR}/cencode.h
DESTINATION include
)

Expand Down
6 changes: 2 additions & 4 deletions src/c++/perf_analyzer/genai-perf/tests/test_csv_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import os
from io import StringIO
from pathlib import Path
from typing import Any, List
from typing import Any, List, Tuple

import pytest
from genai_perf import parser
Expand All @@ -38,15 +38,13 @@

class TestCsvExporter:
@pytest.fixture
def mock_read_write(self, monkeypatch: pytest.MonkeyPatch) -> List[tuple[str, str]]:
def mock_read_write(self, monkeypatch: pytest.MonkeyPatch) -> List[Tuple[str, str]]:
"""
This function will mock the open function for specific files.
"""

written_data = []

original_open = open

def custom_open(filename, *args, **kwargs):
def write(self: Any, content: str) -> int:
print(f"Writing to {filename}") # To help with debugging failures
Expand Down
6 changes: 2 additions & 4 deletions src/c++/perf_analyzer/genai-perf/tests/test_json_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import json
import os
from io import StringIO
from typing import Any, List
from typing import Any, List, Tuple

import genai_perf.parser as parser
import pytest
Expand All @@ -37,15 +37,13 @@

class TestJsonExporter:
@pytest.fixture
def mock_read_write(self, monkeypatch: pytest.MonkeyPatch) -> List[tuple[str, str]]:
def mock_read_write(self, monkeypatch: pytest.MonkeyPatch) -> List[Tuple[str, str]]:
"""
This function will mock the open function for specific files.
"""

written_data = []

original_open = open

def custom_open(filename, *args, **kwargs):
def write(self: Any, content: str) -> int:
print(f"Writing to {filename}")
Expand Down
4 changes: 3 additions & 1 deletion src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2021-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -38,6 +38,8 @@ option(TRITON_ENABLE_PERF_ANALYZER "Enable Performance Analyzer" OFF)
option(TRITON_ENABLE_EXAMPLES "Include examples in build" OFF)
option(TRITON_ENABLE_TESTS "Include tests in build" OFF)
option(TRITON_ENABLE_GPU "Enable GPU support in libraries" OFF)
# Package Perf Analyzer with the Python Client -- Intended to be used by PA repo
option(TRITON_PACKAGE_PERF_ANALYZER "Include Perf Analyzer in pip wheel" OFF)

set(TRITON_COMMON_REPO_TAG "main" CACHE STRING "Tag for triton-inference-server/common repo")

Expand Down
4 changes: 2 additions & 2 deletions src/python/library/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2020-2024, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -100,7 +100,7 @@ if (NOT WIN32)
${WHEEL_DEPENDS}
)

if (${TRITON_ENABLE_PERF_ANALYZER})
if (${TRITON_PACKAGE_PERF_ANALYZER})
set(perf_analyzer_arg --perf-analyzer ${CMAKE_INSTALL_PREFIX}/bin/perf_analyzer)
endif()
set(linux_wheel_stamp_file "linux_stamp.whl")
Expand Down
4 changes: 2 additions & 2 deletions src/python/library/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# Copyright 2020-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2020-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -82,7 +82,7 @@ def req_file(filename, folder="requirements"):
data_files = [
("", ["LICENSE.txt"]),
]
if (PLATFORM_FLAG != "any") and ("@TRITON_ENABLE_PERF_ANALYZER@" == "ON"):
if (PLATFORM_FLAG != "any") and ("@TRITON_PACKAGE_PERF_ANALYZER@" == "ON"):
data_files += [("bin", ["perf_analyzer", "perf_client"])]

setup(
Expand Down

0 comments on commit dffe0cd

Please sign in to comment.