Skip to content

Commit 61bfc5d

Browse files
feat: Individual phase (#19)
- added cmake library integration - added cpp tensor interface - added cpp tensor operations --------- Co-authored-by: Fabian Hofer <[email protected]>
1 parent 5fbb8f9 commit 61bfc5d

File tree

24 files changed

+2407
-69
lines changed

24 files changed

+2407
-69
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: CI
33

44
on:
55
push:
6-
branches: [ "main" ]
76
pull_request:
87
branches: [ "main" ]
98

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,13 @@ set(BENCH_KERNLES_FILES
274274
)
275275

276276
set(SRC_INTERFACE_FILES
277-
TensorUtils.h
277+
Contraction.cpp
278+
Einsum.cpp
279+
Einsum.h
280+
Gemm.cpp
278281
Tensor.cpp
282+
TensorUtils.h
283+
Unary.cpp
279284
)
280285

281286
set(TEST_INTERFACE_FILES
@@ -326,6 +331,8 @@ endforeach()
326331
# ==== Public headers of the installed library ====
327332
set(public_headers
328333
include/${PROJECT_NAME}/Tensor.h
334+
include/${PROJECT_NAME}/Error.h
335+
include/${PROJECT_NAME}/UnaryType.h
329336
)
330337

331338
list(APPEND TEST_FILEPATHS "${INTERFACE_FILEPATHS}" "${public_headers}")
@@ -436,7 +443,7 @@ target_include_directories(${PROJECT_NAME}
436443
PUBLIC
437444
# using the project name as additional directory to include <project_name>/header.h instead of header.h if it is included as internal library
438445
# where top-level project will look for the library's public headers
439-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}>
446+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
440447
# where external projects will look for the library's public headers
441448
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
442449
)
@@ -471,6 +478,7 @@ install(EXPORT "${PROJECT_NAME}Targets"
471478
NAMESPACE ${namespace}::
472479
DESTINATION cmake
473480
)
481+
add_library(mlc::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
474482

475483
include(CMakePackageConfigHelpers)
476484

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Machine Learning Compilers
2+
3+
This repository was created as part of the **Machine Learning Compilers** lecture and lab at Friedrich Schiller University Jena during the summer term 2025. While the lecture focused on theoretical concepts, the lab had a practical orientation, with the goal of implementing a domain-specific compiler for tensor expressions.
4+
5+
The main objective of the lab was to build a Just-In-Time (JIT) compiler from scratch that supports a variety of tensor operations. Tensor compilers automate the transformation of tensor expressions into executable code, aiming for high throughput, low latency, short compile times, flexibility and portability.
6+
7+
The lab involved weekly tasks that guided the development of this compiler. The corresponding code and implementations are part of this repository.
8+
9+
## Overview
10+
11+
This repository includes:
12+
13+
- Implementations of all lab tasks
14+
- Source code of a functional JIT compiler for tensor operations
15+
- Modular code structured for reuse and extensibility
16+
17+
The weekly tasks from the lab can be found here: [scalable-analyses](https://github.com/scalable-analyses/pbtc/tree/main/lab)
18+
19+
## Technical Documentation
20+
21+
A detailed technical documentation of our implementation including the design decisions and solutions to the lab tasks, and explanations of the source code is available on our [project website](https://integer-ctrl.github.io/machine-learning-compilers/).
22+
23+
## CMake Library
24+
25+
To make the compiler easy to integrate into other projects, we structured it as a CMake library. This allows users to include and build upon our functionality directly in their own CMake-based projects. More details about the library and how to use it can be found in the [user-guide.md](https://github.com/Integer-Ctrl/machine-learning-compilers/cmake-library/user-guide.md).
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
cmake_minimum_required(VERSION 3.28.0)
2+
project(ExampleProject VERSION 0.1.0 LANGUAGES C CXX ASM)
3+
4+
# The MachineLearningCompiler library is only supported on Linux on arm.
5+
if(NOT (UNIX AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm)"))
6+
message(FATAL_ERROR "Only arm on Linux is supported.")
7+
endif()
8+
9+
10+
# Set default build type to Release if not specified
11+
if(NOT CMAKE_BUILD_TYPE)
12+
set(CMAKE_BUILD_TYPE "Release")
13+
endif()
14+
15+
get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
16+
if(IS_MULTI_CONFIG)
17+
message(NOTICE "Using multi-config generator. Compile with: cmake --build . --config [Debug|Release] --target <target>")
18+
else()
19+
message(NOTICE "Using single-config generator. Generate with: cmake .. -DCMAKE_BUILD_TYPE=[Debug|Release]")
20+
if(NOT CMAKE_BUILD_TYPE)
21+
set(CMAKE_BUILD_TYPE "Release")
22+
message(WARNING "No Build type is set. Using Release!")
23+
endif()
24+
endif()
25+
26+
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
27+
28+
29+
# ===========================================
30+
# Include the MachineLearningCompiler Library
31+
# ===========================================
32+
33+
# Option 1: Including the MachineLearningCompiler Library
34+
35+
# Optional: Toggles if included libraries is build as shared or static libraries. Default is ON.
36+
set(BUILD_SHARED_LIBS ON)
37+
38+
# Optional: Toggles if OpenMP should be used by the library. Default is ON.
39+
set(MLC_USE_OPENMP ON)
40+
41+
Include(FetchContent)
42+
FetchContent_Declare(
43+
MachineLearningCompiler
44+
GIT_REPOSITORY https://github.com/Integer-Ctrl/machine-learning-compilers
45+
GIT_TAG individual-phase #TODO change
46+
EXCLUDE_FROM_ALL
47+
)
48+
FetchContent_MakeAvailable(MachineLearningCompiler)
49+
50+
# Option 2: Include it from the the current machine if installed.
51+
# find_library(mlc::MachineLearningCompiler)
52+
53+
# ===========================================
54+
55+
add_executable(example
56+
Example.cpp
57+
)
58+
target_link_libraries(example mlc::MachineLearningCompiler)

0 commit comments

Comments
 (0)