Skip to content

Commit

Permalink
Redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov committed Jan 8, 2025
1 parent 330a42a commit 65efcee
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 24 deletions.
5 changes: 0 additions & 5 deletions cmake/templates/__version__.py.in

This file was deleted.

19 changes: 19 additions & 0 deletions cmake/templates/version.cpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (C) 2023-2025 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#include "openvino/genai/version.hpp"

namespace ov {
namespace genai {

const Version get_version() {
const static Version version = {
.buildNumber = "@OpenVINOGenAI_FULL_VERSION@",
.description = "OpenVINO GenAI version",
};

return version;
}

} // namespace genai
} // namespace ov
11 changes: 11 additions & 0 deletions cmake/templates/version.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@

#pragma once

#include "openvino/core/version.hpp"
#include "openvino/genai/visibility.hpp"

#define OPENVINO_GENAI_VERSION_MAJOR @OpenVINOGenAI_VERSION_MAJOR@
#define OPENVINO_GENAI_VERSION_MINOR @OpenVINOGenAI_VERSION_MINOR@
#define OPENVINO_GENAI_VERSION_PATCH @OpenVINOGenAI_VERSION_PATCH@

namespace ov {
namespace genai {

OPENVINO_EXTERN_C OPENVINO_GENAI_EXPORTS const ov::Version OPENVINO_CDECL get_version();

} // namespace genai
} // namespace ov
17 changes: 12 additions & 5 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,18 @@ FetchContent_MakeAvailable(safetensors.h)

ov_genai_build_jinja2cpp()

# generate version files

configure_file("${OpenVINOGenAI_SOURCE_DIR}/cmake/templates/version.hpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/openvino/genai/version.hpp" @ONLY)

configure_file("${OpenVINOGenAI_SOURCE_DIR}/cmake/templates/version.cpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/version.cpp" @ONLY)

# Library

file(GLOB_RECURSE SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c")
list(APPEND SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/version.cpp")

set(TARGET_NAME openvino_genai)

Expand All @@ -67,12 +76,10 @@ if(TARGET openvino_tokenizers)
add_dependencies(${TARGET_NAME} openvino_tokenizers)
endif()

configure_file("${OpenVINOGenAI_SOURCE_DIR}/cmake/templates/version.hpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/version.hpp" @ONLY)

target_include_directories(${TARGET_NAME}
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" "$<INSTALL_INTERFACE:runtime/include>"
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:runtime/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")

target_include_directories(${TARGET_NAME} SYSTEM PRIVATE "${safetensors.h_SOURCE_DIR}")
Expand Down
9 changes: 0 additions & 9 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/__init__.py"
"${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/py_openvino_genai.pyi"
DESTINATION "${CMAKE_BINARY_DIR}/openvino_genai/")

configure_file("${OpenVINOGenAI_SOURCE_DIR}/cmake/templates/__version__.py.in"
"${CMAKE_BINARY_DIR}/openvino_genai/__version__.py" @ONLY)

if(OpenVINODeveloperPackage_FOUND)
# TODO: commit changes separately
# ov_add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})
Expand Down Expand Up @@ -69,18 +66,12 @@ endif()
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/__init__.py"
"${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/__init__.pyi"
"${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/py_openvino_genai.pyi"
"${CMAKE_BINARY_DIR}/openvino_genai/__version__.py"
DESTINATION python/openvino_genai
COMPONENT pygenai_${Python3_VERSION_MAJOR}_${Python3_VERSION_MINOR})
install(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION python/openvino_genai
COMPONENT pygenai_${Python3_VERSION_MAJOR}_${Python3_VERSION_MINOR})

install(FILES "${CMAKE_BINARY_DIR}/openvino_genai/__version__.py"
DESTINATION openvino_genai
COMPONENT wheel_genai
EXCLUDE_FROM_ALL)

install(FILES "${OpenVINOGenAI_SOURCE_DIR}/LICENSE"
"${OpenVINOGenAI_SOURCE_DIR}/third-party-programs.txt"
"${OpenVINOGenAI_SOURCE_DIR}/SECURITY.md"
Expand Down
5 changes: 3 additions & 2 deletions src/python/openvino_genai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

import openvino # add_dll_directory for openvino lib
import os
from .__version__ import __version__


if hasattr(os, "add_dll_directory"):
os.add_dll_directory(os.path.dirname(__file__))
Expand All @@ -17,8 +15,11 @@
RawPerfMetrics,
PerfMetrics,
StreamerBase,
get_version,
)

__version__ = get_version().build_number

# VLM pipeline

from .py_openvino_genai import (
Expand Down
5 changes: 3 additions & 2 deletions src/python/openvino_genai/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ from openvino_genai.py_openvino_genai import WhisperPerfMetrics
from openvino_genai.py_openvino_genai import WhisperPipeline
from openvino_genai.py_openvino_genai import WhisperRawPerfMetrics
from openvino_genai.py_openvino_genai import draft_model
from openvino_genai.py_openvino_genai import get_version
import os as os
from . import py_openvino_genai
__all__ = ['Adapter', 'AdapterConfig', 'AggregationMode', 'AutoencoderKL', 'CLIPTextModel', 'CLIPTextModelWithProjection', 'CacheEvictionConfig', 'ChunkStreamerBase', 'ContinuousBatchingPipeline', 'CppStdGenerator', 'DecodedResults', 'EncodedResults', 'FluxTransformer2DModel', 'GenerationConfig', 'GenerationResult', 'Generator', 'Image2ImagePipeline', 'ImageGenerationConfig', 'InpaintingPipeline', 'LLMPipeline', 'PerfMetrics', 'RawPerfMetrics', 'SD3Transformer2DModel', 'Scheduler', 'SchedulerConfig', 'StopCriteria', 'StreamerBase', 'T5EncoderModel', 'Text2ImagePipeline', 'TokenizedInputs', 'Tokenizer', 'TorchGenerator', 'UNet2DConditionModel', 'VLMPipeline', 'WhisperGenerationConfig', 'WhisperPerfMetrics', 'WhisperPipeline', 'WhisperRawPerfMetrics', 'draft_model', 'openvino', 'os', 'py_openvino_genai']
__version__: str = '2025.0.0.0-1615-cdf8118377b'
__all__ = ['Adapter', 'AdapterConfig', 'AggregationMode', 'AutoencoderKL', 'CLIPTextModel', 'CLIPTextModelWithProjection', 'CacheEvictionConfig', 'ChunkStreamerBase', 'ContinuousBatchingPipeline', 'CppStdGenerator', 'DecodedResults', 'EncodedResults', 'FluxTransformer2DModel', 'GenerationConfig', 'GenerationResult', 'Generator', 'Image2ImagePipeline', 'ImageGenerationConfig', 'InpaintingPipeline', 'LLMPipeline', 'PerfMetrics', 'RawPerfMetrics', 'SD3Transformer2DModel', 'Scheduler', 'SchedulerConfig', 'StopCriteria', 'StreamerBase', 'T5EncoderModel', 'Text2ImagePipeline', 'TokenizedInputs', 'Tokenizer', 'TorchGenerator', 'UNet2DConditionModel', 'VLMPipeline', 'WhisperGenerationConfig', 'WhisperPerfMetrics', 'WhisperPipeline', 'WhisperRawPerfMetrics', 'draft_model', 'get_version', 'openvino', 'os', 'py_openvino_genai']
__version__: str = '2025.0.0.0-1616-330a42a5285-version'
4 changes: 3 additions & 1 deletion src/python/openvino_genai/py_openvino_genai.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from __future__ import annotations
import openvino._pyopenvino
import os
import typing
__all__ = ['Adapter', 'AdapterConfig', 'AggregationMode', 'AutoencoderKL', 'CLIPTextModel', 'CLIPTextModelWithProjection', 'CacheEvictionConfig', 'ChunkStreamerBase', 'ContinuousBatchingPipeline', 'CppStdGenerator', 'DecodedResults', 'EncodedGenerationResult', 'EncodedResults', 'FluxTransformer2DModel', 'GenerationConfig', 'GenerationFinishReason', 'GenerationHandle', 'GenerationOutput', 'GenerationResult', 'GenerationStatus', 'Generator', 'Image2ImagePipeline', 'ImageGenerationConfig', 'InpaintingPipeline', 'LLMPipeline', 'MeanStdPair', 'PerfMetrics', 'PipelineMetrics', 'RawPerfMetrics', 'SD3Transformer2DModel', 'Scheduler', 'SchedulerConfig', 'StopCriteria', 'StreamerBase', 'T5EncoderModel', 'Text2ImagePipeline', 'TokenizedInputs', 'Tokenizer', 'TorchGenerator', 'UNet2DConditionModel', 'VLMDecodedResults', 'VLMPerfMetrics', 'VLMPipeline', 'VLMRawPerfMetrics', 'WhisperDecodedResultChunk', 'WhisperDecodedResults', 'WhisperGenerationConfig', 'WhisperPerfMetrics', 'WhisperPipeline', 'WhisperRawPerfMetrics', 'draft_model']
__all__ = ['Adapter', 'AdapterConfig', 'AggregationMode', 'AutoencoderKL', 'CLIPTextModel', 'CLIPTextModelWithProjection', 'CacheEvictionConfig', 'ChunkStreamerBase', 'ContinuousBatchingPipeline', 'CppStdGenerator', 'DecodedResults', 'EncodedGenerationResult', 'EncodedResults', 'FluxTransformer2DModel', 'GenerationConfig', 'GenerationFinishReason', 'GenerationHandle', 'GenerationOutput', 'GenerationResult', 'GenerationStatus', 'Generator', 'Image2ImagePipeline', 'ImageGenerationConfig', 'InpaintingPipeline', 'LLMPipeline', 'MeanStdPair', 'PerfMetrics', 'PipelineMetrics', 'RawPerfMetrics', 'SD3Transformer2DModel', 'Scheduler', 'SchedulerConfig', 'StopCriteria', 'StreamerBase', 'T5EncoderModel', 'Text2ImagePipeline', 'TokenizedInputs', 'Tokenizer', 'TorchGenerator', 'UNet2DConditionModel', 'VLMDecodedResults', 'VLMPerfMetrics', 'VLMPipeline', 'VLMRawPerfMetrics', 'WhisperDecodedResultChunk', 'WhisperDecodedResults', 'WhisperGenerationConfig', 'WhisperPerfMetrics', 'WhisperPipeline', 'WhisperRawPerfMetrics', 'draft_model', 'get_version']
class Adapter:
"""
Immutable LoRA Adapter that carries the adaptation matrices and serves as unique adapter identifier.
Expand Down Expand Up @@ -2204,3 +2204,5 @@ def draft_model(models_path: os.PathLike, device: str = '', **kwargs) -> openvin
"""
device on which inference will be performed
"""
def get_version() -> openvino._pyopenvino.Version:
...
3 changes: 3 additions & 0 deletions src/python/py_openvino_genai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <pybind11/typing.h>

#include "openvino/genai/llm_pipeline.hpp"
#include "openvino/genai/version.hpp"

#include "py_utils.hpp"

Expand Down Expand Up @@ -82,6 +83,8 @@ class ConstructableStreamer: public StreamerBase {
PYBIND11_MODULE(py_openvino_genai, m) {
m.doc() = "Pybind11 binding for OpenVINO GenAI library";

m.def("get_version", ov::genai::get_version);

init_perf_metrics(m);
py::class_<DecodedResults>(m, "DecodedResults", decoded_results_docstring)
.def(py::init<>())
Expand Down

0 comments on commit 65efcee

Please sign in to comment.