Skip to content

Commit

Permalink
DRAFT initial circle-mlir project
Browse files Browse the repository at this point in the history
on-going draft to introduce initial circle-mlir project.

Signed-off-by: SaeHie Park <[email protected]>
  • Loading branch information
seanshpark committed Feb 11, 2025
1 parent 1125136 commit 841ddca
Show file tree
Hide file tree
Showing 48 changed files with 4,382 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/run-circle-mlir-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Run Circle-MLIR Ubuntu Build

on:
pull_request:
branches:
- master
- release/*
paths:
- '.github/workflows/run-circle-mlir-build.yml'
- 'circle-mlir/**'

defaults:
run:
shell: bash

# Cancel previous running jobs when pull request is updated
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
circle-mlir-test:
if: github.repository_owner == 'Samsung'
strategy:
matrix:
type: [ Debug, Release ]
ubuntu_code: [ jammy ]
include:
- ubuntu_code: jammy
ubuntu_vstr: u2204

runs-on: ubuntu-24.04

container:
image: nnfw/circle-mlir-build-${{ matrix.ubuntu_vstr }}:latest
options: --user root

name: circle-mlir ${{ matrix.ubuntu_vstr }} ${{ matrix.type }} test

steps:
- name: Checkout
uses: actions/checkout@v4

# TODO download circle-interpreter

# NOTE Docker image has pre-installed submodules in /workdir
# NOTE Docker image has pre-installed python packages
- name: Configure
run: |
Python3_ROOT_DIR=/usr/bin cmake -B build/${{ matrix.type }} -S ./circle-mlir \
-DCMAKE_INSTALL_PREFIX=build/${{ matrix.type }}.install \
-DCMAKE_BUILD_TYPE=${{ matrix.type }} \
-DCIRCLE_MLIR_WORKDIR=/workdir
- name: Build, test & install
run: |
cmake --build build/${{ matrix.type }} -j4
CTEST_OUTPUT_ON_FAILURE=1 cmake --build build/${{ matrix.type }} --verbose -- test
cmake --build build/${{ matrix.type }} -j4 -- install
1 change: 1 addition & 0 deletions circle-mlir/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Makefile
47 changes: 47 additions & 0 deletions circle-mlir/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Match the minimum required version of LLVM and MLIR
cmake_minimum_required(VERSION 3.13.4)

project(circle-mlir)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Type of build" FORCE)
endif()

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_compile_options("-fexceptions")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/infra/cmake")

# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()

# configuration flags
include(CfgOptionFlags)

# enable test coverage
include(TestCoverage)

# enable ctest
include(CTest)

# enable googletest
include(GTestHelper)
include(GoogleTest)

# to override submodules install
if(DEFINED ENV{CIRCLE_MLIR_LOCALINST})
set(CIRCLE_MLIR_LOCALINST $ENV{CIRCLE_MLIR_LOCALINST})
endif()

if(CIRCLE_MLIR_LOCALINST)
message(STATUS "CIRCLE_MLIR_LOCALINST=${CIRCLE_MLIR_LOCALINST}")
endif()

set(RES_CIRCLE_SCHEMA "${CMAKE_SOURCE_DIR}/../res/CircleSchema")

add_subdirectory(circle-mlir)
6 changes: 6 additions & 0 deletions circle-mlir/circle-mlir/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include(UseMLIR)
include(UseAbseil)

add_subdirectory(lib)
add_subdirectory(tools)
add_subdirectory(tools-test)
9 changes: 9 additions & 0 deletions circle-mlir/circle-mlir/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
add_subdirectory(tools)

add_subdirectory(arser)
add_subdirectory(schema)
add_subdirectory(dialect)
#add_subdirectory(utils)
#add_subdirectory(pass)
#add_subdirectory(import)
#add_subdirectory(export)
19 changes: 19 additions & 0 deletions circle-mlir/circle-mlir/lib/arser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
add_library(arser INTERFACE)

# It specifies INTERFACE so that future targets linked with arser library will inherit its include directory.
# It means that a developer who want to link arser just need to add one line.
# target_link_library(another-users-target arser)
target_include_directories(arser INTERFACE include/)

# NOTE test for arser are removed.
# instead, add arser_validate to validate header compilation.
add_library(arser_validate STATIC src/arser.cpp)
target_link_libraries(arser_validate PUBLIC arser)

if(NOT ENABLE_TEST)
return()
endif()

GTest_AddTest(arser_test test/arser.test.cpp)
target_link_libraries(arser_test arser)
target_link_libraries(arser_test cirmlir_coverage)
3 changes: 3 additions & 0 deletions circle-mlir/circle-mlir/lib/arser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# arser

From https://github.com/Samsung/ONE/tree/d808a9973093bf8062a253d5c8f66072d7100551/compiler/arser
Loading

0 comments on commit 841ddca

Please sign in to comment.