Skip to content

Commit

Permalink
Merge pull request #62 from Xilinx/matthias.capi
Browse files Browse the repository at this point in the history
Add CAPI and python module
  • Loading branch information
mgehre-amd authored Aug 13, 2024
2 parents 4e832e3 + 5ca5a6b commit 02ef1a0
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 1 deletion.
16 changes: 16 additions & 0 deletions include/xten-c/Dialects.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef XTEN_C_DIALECTS_H
#define XTEN_C_DIALECTS_H

#include "mlir-c/IR.h"

#ifdef __cplusplus
extern "C" {
#endif

MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(XTenNN, xten_nn);

#ifdef __cplusplus
}
#endif

#endif // XTEN_C_DIALECTS_H
10 changes: 10 additions & 0 deletions lib/CAPI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
add_mlir_public_c_api_library(
XTenCAPI
Dialects.cpp
ADDITIONAL_HEADER_DIRS
${XTEN_SOURCE_DIR}/include/xten-c/
ENABLE_AGGREGATION
LINK_LIBS
PUBLIC
XTenNNDialect
)
16 changes: 16 additions & 0 deletions lib/CAPI/Dialects.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//===- Dialects.cpp - C Interface for Dialects ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// Also available under a BSD-style license. See LICENSE.
//
//===----------------------------------------------------------------------===//

#include "xten-c/Dialects.h"

#include "xten/Dialect/XTenNN/IR/XTenNNBase.h"

#include "mlir/CAPI/Registration.h"

MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(XTenNN, xten_nn, amd::xten_nn::XTenNNDialect)
1 change: 1 addition & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# (c) Copyright 2021 Xilinx, Inc. All Rights reserved.
# (c) Copyright 2022 - 2024 Advanced Micro Devices, Inc. All Rights reserved.

add_subdirectory(CAPI)
add_subdirectory(Conversion)
add_subdirectory(Dialect)
add_subdirectory(Transform)
12 changes: 11 additions & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,14 @@ RUNTIME DESTINATION bin COMPONENT python)
install(DIRECTORY xten
DESTINATION python COMPONENT python)

#add_subdirectory(test)
declare_mlir_python_sources(XTenPythonSources)
declare_mlir_python_sources(XTenPythonSources.Dialects
ADD_TO_PARENT XTenPythonSources)

declare_mlir_dialect_python_bindings(
ADD_TO_PARENT XTenPythonSources.Dialects
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
TD_FILE dialects/XTenNNOps.td
SOURCES
dialects/xten_nn.py
DIALECT_NAME xten_nn)

0 comments on commit 02ef1a0

Please sign in to comment.