diff --git a/cmake/modules/TTMLIRVersion.cmake b/cmake/modules/TTMLIRVersion.cmake index 03d165ea3c..48e90b1d75 100644 --- a/cmake/modules/TTMLIRVersion.cmake +++ b/cmake/modules/TTMLIRVersion.cmake @@ -1,10 +1,37 @@ +# get git commit hash execute_process( COMMAND git rev-parse HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} OUTPUT_VARIABLE TTMLIR_GIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE ) + +# get the latest tag from Git +execute_process( + COMMAND git describe --tags --abbrev=0 + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + OUTPUT_VARIABLE GIT_TAG + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +# get the number of commits since the latest tag +execute_process( + COMMAND git rev-list ${GIT_TAG}..HEAD --count + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + OUTPUT_VARIABLE GIT_COMMITS + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +# Extract the major and minor version from the tag (assumes tags are in "major.minor" format) +string(REGEX MATCH "^v([0-9]+)\\.([0-9]+)$" GIT_TAG_MATCH ${GIT_TAG}) +set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1}) +set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_2}) +set(PROJECT_VERSION_PATCH ${GIT_COMMITS}) + +message(STATUS "Project commit hash: ${TTMLIR_GIT_HASH}") +message(STATUS "Project version: ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") + add_definitions("-DTTMLIR_GIT_HASH=${TTMLIR_GIT_HASH}") -add_definitions("-DTTMLIR_VERSION_MAJOR=0") -add_definitions("-DTTMLIR_VERSION_MINOR=0") -add_definitions("-DTTMLIR_VERSION_RELEASE=0") +add_definitions("-DTTMLIR_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}") +add_definitions("-DTTMLIR_VERSION_MINOR=${PROJECT_VERSION_MINOR}") +add_definitions("-DTTMLIR_VERSION_PATCH=${PROJECT_VERSION_PATCH}") diff --git a/include/ttmlir/Target/Common/version.fbs b/include/ttmlir/Target/Common/version.fbs index 4161b5d0b7..ccb9b2e2ae 100644 --- a/include/ttmlir/Target/Common/version.fbs +++ b/include/ttmlir/Target/Common/version.fbs @@ -3,5 +3,5 @@ namespace tt.target; struct Version { major: uint16; minor: uint16; - release: uint32; + patch: uint32; } diff --git a/include/ttmlir/Version.h b/include/ttmlir/Version.h index 2441e7e727..ed66f1d2fc 100644 --- a/include/ttmlir/Version.h +++ b/include/ttmlir/Version.h @@ -16,17 +16,17 @@ namespace ttmlir { #ifndef TTMLIR_VERSION_MINOR #error "TTMLIR_VERSION_MINOR must be defined" #endif -#ifndef TTMLIR_VERSION_RELEASE -#error "TTMLIR_VERSION_RELEASE must be defined" +#ifndef TTMLIR_VERSION_PATCH +#error "TTMLIR_VERSION_PATCH must be defined" #endif struct Version { unsigned major; unsigned minor; - unsigned release; + unsigned patch; - constexpr Version(unsigned major, unsigned minor, unsigned release) - : major(major), minor(minor), release(release) {} + constexpr Version(unsigned major, unsigned minor, unsigned patch) + : major(major), minor(minor), patch(patch) {} constexpr bool operator<=(const Version &other) const { return major < other.major || @@ -41,7 +41,7 @@ struct Version { inline constexpr Version getVersion() { return Version(TTMLIR_VERSION_MAJOR, TTMLIR_VERSION_MINOR, - TTMLIR_VERSION_RELEASE); + TTMLIR_VERSION_PATCH); } #define XSTR(s) STR(s) diff --git a/lib/Dialect/TTMetal/Transforms/SerializeToBinary.cpp b/lib/Dialect/TTMetal/Transforms/SerializeToBinary.cpp index 341c4c96d6..282a5e5e03 100644 --- a/lib/Dialect/TTMetal/Transforms/SerializeToBinary.cpp +++ b/lib/Dialect/TTMetal/Transforms/SerializeToBinary.cpp @@ -215,7 +215,7 @@ class TTMetalSerializeToBinary ::ttmlir::Version ttmlirVersion = ::ttmlir::getVersion(); ::tt::target::Version binaryVersion( - ttmlirVersion.major, ttmlirVersion.minor, ttmlirVersion.release); + ttmlirVersion.major, ttmlirVersion.minor, ttmlirVersion.patch); std::vector<::flatbuffers::Offset<::tt::target::metal::CommandQueue>> commandQueues = { diff --git a/lib/Dialect/TTNN/Transforms/SerializeToBinary.cpp b/lib/Dialect/TTNN/Transforms/SerializeToBinary.cpp index beb7c6909b..73904feed9 100644 --- a/lib/Dialect/TTNN/Transforms/SerializeToBinary.cpp +++ b/lib/Dialect/TTNN/Transforms/SerializeToBinary.cpp @@ -203,7 +203,7 @@ class TTNNSerializeToBinary ::ttmlir::Version ttmlirVersion = ::ttmlir::getVersion(); ::tt::target::Version binaryVersion( - ttmlirVersion.major, ttmlirVersion.minor, ttmlirVersion.release); + ttmlirVersion.major, ttmlirVersion.minor, ttmlirVersion.patch); ModuleOp module = getOperation(); auto systemDesc = toFlatbuffer( diff --git a/runtime/include/tt/runtime/detail/ttnn.h b/runtime/include/tt/runtime/detail/ttnn.h index dd2da63001..c31df0a3c1 100644 --- a/runtime/include/tt/runtime/detail/ttnn.h +++ b/runtime/include/tt/runtime/detail/ttnn.h @@ -30,6 +30,7 @@ #pragma clang diagnostic ignored "-Wunneeded-internal-declaration" #pragma clang diagnostic ignored "-Wunused-local-typedef" #pragma clang diagnostic ignored "-Wunused-function" +#pragma clang diagnostic ignored "-Wpessimizing-move" #define FMT_HEADER_ONLY #include "ttnn//operations/reduction/generic/generic_reductions.hpp" #include "ttnn/device.hpp" diff --git a/runtime/lib/binary.cpp b/runtime/lib/binary.cpp index 5689e9d3b4..43a1d66e53 100644 --- a/runtime/lib/binary.cpp +++ b/runtime/lib/binary.cpp @@ -51,7 +51,7 @@ std::string getVersion(Flatbuffer binary) { auto const *version = getBinary(binary)->version(); return std::to_string(version->major()) + "." + std::to_string(version->minor()) + "." + - std::to_string(version->release()); + std::to_string(version->patch()); } std::string_view getTTMLIRGitHash(Flatbuffer binary) { @@ -116,7 +116,7 @@ std::string getVersion(Flatbuffer binary) { auto const *version = getBinary(binary)->version(); return std::to_string(version->major()) + "." + std::to_string(version->minor()) + "." + - std::to_string(version->release()); + std::to_string(version->patch()); } std::string_view getTTMLIRGitHash(Flatbuffer binary) { diff --git a/runtime/lib/ttnn/runtime.cpp b/runtime/lib/ttnn/runtime.cpp index d5d6d21330..ee5ad46afe 100644 --- a/runtime/lib/ttnn/runtime.cpp +++ b/runtime/lib/ttnn/runtime.cpp @@ -37,7 +37,7 @@ std::pair getCurrentSystemDesc() { ::flatbuffers::FlatBufferBuilder fbb; ::ttmlir::Version ttmlirVersion = ::ttmlir::getVersion(); ::tt::target::Version version(ttmlirVersion.major, ttmlirVersion.minor, - ttmlirVersion.release); + ttmlirVersion.patch); ::tt::target::Dim2d deviceGrid = toFlatbuffer(device.logical_grid_size()); std::vector<::flatbuffers::Offset> chipDescs = { ::tt::target::CreateChipDesc(fbb, toFlatbuffer(device.arch()),