Skip to content

Commit

Permalink
Merge pull request #59 from Xilinx/jose.xtennn-to-be
Browse files Browse the repository at this point in the history
Add toggle to disable compiling code that depends on torch-mlir
  • Loading branch information
mgehre-amd authored Aug 9, 2024
2 parents 1f540af + 56aebf9 commit 647acb2
Show file tree
Hide file tree
Showing 48 changed files with 174 additions and 3,565 deletions.
22 changes: 14 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ endif()

project(mlir-xten LANGUAGES CXX C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_VERBOSE_MAKEFILE ON)

function(TORCH_MLIR_detect_pybind11_install)
if(NOT DEFINED MLIR_XTEN_ENABLE_TORCH)
option(MLIR_XTEN_ENABLE_TORCH "Enable torch-mlir" ON)
endif()

function(detect_pybind11_install)
if(pybind11_DIR)
message(STATUS "Using explicit pybind11 cmake directory: ${pybind11_DIR} (-Dpybind11_DIR to change)")
else()
Expand All @@ -50,7 +54,7 @@ function(TORCH_MLIR_detect_pybind11_install)
set(pybind11_DIR "${PACKAGE_DIR}" PARENT_SCOPE)
endif()
endfunction()
TORCH_MLIR_detect_pybind11_install()
detect_pybind11_install()
find_package(pybind11 REQUIRED)
set(pybind11_INCLUDE_DIR ${pybind11_INCLUDE_DIR})
find_package(Python3 COMPONENTS Interpreter Development)
Expand Down Expand Up @@ -110,8 +114,10 @@ include_directories(${MLIR_INCLUDE_DIRS})
include_directories(${XTEN_SOURCE_DIR}/include)
include_directories(${XTEN_BINARY_DIR}/include)

# TORCH_MLIR
include_directories(${TORCH_MLIR_INCLUDE_DIRS})
if(MLIR_XTEN_ENABLE_TORCH)
# TORCH_MLIR
include_directories(${TORCH_MLIR_INCLUDE_DIRS})
endif()

add_definitions(${LLVM_DEFINITIONS})

Expand All @@ -120,9 +126,9 @@ add_definitions(${LLVM_DEFINITIONS})
umbrella_lit_testsuite_begin(check-xten-all)

# Make sure we build the docs
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_custom_target(docs ALL)
add_dependencies(docs mlir-doc)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_custom_target(docs ALL)
add_dependencies(docs mlir-doc)
endif()

add_subdirectory(include)
Expand Down
7 changes: 6 additions & 1 deletion include/xten/Conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@

set(LLVM_TARGET_DEFINITIONS Passes.td)
mlir_tablegen(Passes.h.inc -gen-pass-decls -name XTenConversion)
add_public_tablegen_target(XTenConversionIncGen)

if(MLIR_XTEN_ENABLE_TORCH)
set(LLVM_TARGET_DEFINITIONS PassesTorch.td)
mlir_tablegen(PassesTorch.h.inc -gen-pass-decls -name XTenConversion)
endif()

add_mlir_doc(Passes XTenConversionPasses ./ -gen-pass-doc)
add_public_tablegen_target(XTenConversionIncGen)
9 changes: 9 additions & 0 deletions include/xten/Conversion/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,17 @@ namespace xten {

#define GEN_PASS_DECL
#define GEN_PASS_REGISTRATION

#include "xten/Conversion/Passes.h.inc"

#ifdef MLIR_XTEN_ENABLE_TORCH
namespace torch {
#define GEN_PASS_DECL
#define GEN_PASS_REGISTRATION
#include "xten/Conversion/PassesTorch.h.inc"
}
#endif

void registerConversionPasses();

} // namespace xten
Expand Down
12 changes: 0 additions & 12 deletions include/xten/Conversion/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,4 @@ def ConvertXTenNNToLinalg : Pass<"convert-xtennn-to-linalg", "mlir::func::FuncOp
];
}

def ConvertXTenNNToTorch : Pass<"convert-xtennn-to-torch", "mlir::func::FuncOp"> {
let summary = "Convert XTenNN operations to Torch.";
let description = [{
Partial conversion of XTenNN operations to Torch.
}];
let constructor = "amd::xten_nn::createXTenNNToTorchPass()";
let dependentDialects = [
"mlir::torch::Torch::TorchDialect",
"mlir::torch::TorchConversion::TorchConversionDialect",
];
}

#endif
31 changes: 31 additions & 0 deletions include/xten/Conversion/PassesTorch.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//===- PassesTorch.td --------------------------------------*- tablegen -*-===//
//
// This file is licensed 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
//

// (c) Copyright 2021 Xilinx, Inc. All Rights reserved.
// (c) Copyright 2022 - 2024 Advanced Micro Devices, Inc. All Rights reserved.

//
//===----------------------------------------------------------------------===//

#ifndef XTEN_CONVERSION_PASSES_TORCH
#define XTEN_CONVERSION_PASSES_TORCH

include "mlir/Pass/PassBase.td"

def ConvertXTenNNToTorch : Pass<"convert-xtennn-to-torch", "mlir::func::FuncOp"> {
let summary = "Convert XTenNN operations to Torch.";
let description = [{
Partial conversion of XTenNN operations to Torch.
}];
let constructor = "amd::xten_nn::createXTenNNToTorchPass()";
let dependentDialects = [
"mlir::torch::Torch::TorchDialect",
"mlir::torch::TorchConversion::TorchConversionDialect",
];
}

#endif // XTEN_CONVERSION_PASSES_TORCH
28 changes: 0 additions & 28 deletions include/xten/Transform/ATenLoweringPass.h

This file was deleted.

31 changes: 0 additions & 31 deletions include/xten/Transform/ATenOpReport.h

This file was deleted.

28 changes: 0 additions & 28 deletions include/xten/Transform/LowerToLibATenPass.h

This file was deleted.

3 changes: 0 additions & 3 deletions include/xten/Transform/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#ifndef XTEN_TRANSFORM_PASSES_H
#define XTEN_TRANSFORM_PASSES_H

#include "xten/Transform/ATenLoweringPass.h"
#include "xten/Transform/ATenOpReport.h"
#include "xten/Transform/LowerToLibATenPass.h"
#include "xten/Transform/XTenMinimizeLiveTensors.h"

namespace xilinx::xten {
Expand Down
15 changes: 0 additions & 15 deletions include/xten/Transform/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,6 @@

include "mlir/Pass/PassBase.td"

// def ATenLowering : Pass<"aten-lowering", "ModuleOp"> {
// let summary = "ATen dialect lowering to function calls";
// let constructor = "xilinx::xten::createATenLoweringPass()";
// }

def ATenOpReport : Pass<"aten-op-report", "ModuleOp"> {
let summary = "Generate ATen dialect operation statistics";
let constructor = "xilinx::xten::createATenOpReportPass()";
}

def LowerToLibATen : Pass<"lower-to-libaten", "ModuleOp"> {
let summary = "Lower ATen Ops to library calls";
let constructor = "xilinx::xten::createLowerToLibATenPass()";
}

def XTenMinimizeLiveTensors : Pass<"xten-minimize-live", "func::FuncOp"> {
let summary = "Reorder xten operations to minimize the total size of the live tensors";
let constructor = "xilinx::xten::createXTenMinimizeLiveTensorsPass()";
Expand Down
82 changes: 0 additions & 82 deletions include/xten/Util/Arch.h

This file was deleted.

38 changes: 0 additions & 38 deletions include/xten/Util/Util.h

This file was deleted.

1 change: 0 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@

add_subdirectory(Conversion)
add_subdirectory(Dialect)
add_subdirectory(Util)
add_subdirectory(Transform)
Loading

0 comments on commit 647acb2

Please sign in to comment.