mirror of https://github.com/llvm/torch-mlir
VerifyBackendContract -> VerifyLinalgOnTensorsBackendContract
This moves it into TorchConversion since it is only needed there. This removes the Backend/ directory.pull/323/head
parent
06559efe94
commit
2213584c4f
|
@ -1 +0,0 @@
|
||||||
add_subdirectory(Common)
|
|
|
@ -1,5 +0,0 @@
|
||||||
set(LLVM_TARGET_DEFINITIONS Passes.td)
|
|
||||||
mlir_tablegen(Passes.h.inc -gen-pass-decls)
|
|
||||||
add_public_tablegen_target(NPCOMPCommonBackendPassIncGen)
|
|
||||||
|
|
||||||
add_mlir_doc(Passes CommonBackendPasses ./ -gen-pass-doc)
|
|
|
@ -1,27 +0,0 @@
|
||||||
//===------------------------------------------------------------*- C++ -*-===//
|
|
||||||
//
|
|
||||||
// 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
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#ifndef NPCOMP_BACKEND_COMMON_PASSES_H
|
|
||||||
#define NPCOMP_BACKEND_COMMON_PASSES_H
|
|
||||||
|
|
||||||
#include "mlir/Pass/Pass.h"
|
|
||||||
#include "mlir/Pass/PassManager.h"
|
|
||||||
|
|
||||||
namespace mlir {
|
|
||||||
namespace NPCOMP {
|
|
||||||
namespace CommonBackend {
|
|
||||||
/// Registers all CommonBackend passes.
|
|
||||||
void registerCommonBackendPasses();
|
|
||||||
|
|
||||||
std::unique_ptr<OperationPass<ModuleOp>> createVerifyBackendContractPass();
|
|
||||||
|
|
||||||
} // namespace CommonBackend
|
|
||||||
} // namespace NPCOMP
|
|
||||||
} // namespace mlir
|
|
||||||
|
|
||||||
#endif // NPCOMP_BACKEND_COMMON_PASSES_H
|
|
|
@ -1,19 +0,0 @@
|
||||||
//===-- Passes.td - Pass definition file -------------------*- tablegen -*-===//
|
|
||||||
//
|
|
||||||
// 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
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#ifndef NPCOMP_BACKEND_COMMON_PASSES
|
|
||||||
#define NPCOMP_BACKEND_COMMON_PASSES
|
|
||||||
|
|
||||||
include "mlir/Pass/PassBase.td"
|
|
||||||
|
|
||||||
def VerifyBackendContract : Pass<"npcomp-verify-backend-contract", "ModuleOp"> {
|
|
||||||
let summary = "Verifies conformity to the backend contract that npcomp targets";
|
|
||||||
let constructor = "mlir::NPCOMP::CommonBackend::createVerifyBackendContractPass()";
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // NPCOMP_BACKEND_COMMON_PASSES
|
|
|
@ -1,5 +0,0 @@
|
||||||
# Common backend utilities
|
|
||||||
|
|
||||||
This directory contains passes/transformations/analyses/etc. that are relevant
|
|
||||||
to the backend contract that npcomp targets, but otherwise independent of any
|
|
||||||
particular backend.
|
|
|
@ -1,3 +1,2 @@
|
||||||
add_subdirectory(Backend)
|
|
||||||
add_subdirectory(Conversion)
|
add_subdirectory(Conversion)
|
||||||
add_subdirectory(Dialect)
|
add_subdirectory(Dialect)
|
||||||
|
|
|
@ -32,6 +32,8 @@ std::unique_ptr<OperationPass<ModuleOp>> createFuncBackendTypeConversionPass();
|
||||||
std::unique_ptr<OperationPass<FuncOp>>
|
std::unique_ptr<OperationPass<FuncOp>>
|
||||||
createFinalizingBackendTypeConversionPass();
|
createFinalizingBackendTypeConversionPass();
|
||||||
|
|
||||||
|
std::unique_ptr<OperationPass<ModuleOp>> createVerifyLinalgOnTensorsBackendContractPass();
|
||||||
|
|
||||||
} // namespace TorchConversion
|
} // namespace TorchConversion
|
||||||
|
|
||||||
/// Registers all Torch transformation passes.
|
/// Registers all Torch transformation passes.
|
||||||
|
|
|
@ -52,4 +52,9 @@ def FinalizingBackendTypeConversion
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def VerifyLinalgOnTensorsBackendContract : Pass<"npcomp-verify-linalg-on-tensors-backend-contract", "ModuleOp"> {
|
||||||
|
let summary = "Verifies conformity to the linalg-on-tensors backend contract";
|
||||||
|
let constructor = "mlir::NPCOMP::TorchConversion::createVerifyLinalgOnTensorsBackendContractPass()";
|
||||||
|
}
|
||||||
|
|
||||||
#endif // NPCOMP_TORCHCONVERSION_PASSES
|
#endif // NPCOMP_TORCHCONVERSION_PASSES
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
add_subdirectory(Common)
|
|
|
@ -1,22 +0,0 @@
|
||||||
add_npcomp_library(NPCOMPCommonBackend
|
|
||||||
VerifyBackendContract.cpp
|
|
||||||
Passes.cpp
|
|
||||||
|
|
||||||
ADDITIONAL_HEADER_DIRS
|
|
||||||
${PROJECT_SRC_DIR}/include/npcomp/Backend/Common
|
|
||||||
|
|
||||||
DEPENDS
|
|
||||||
NPCOMPCommonBackendPassIncGen
|
|
||||||
|
|
||||||
LINK_COMPONENTS
|
|
||||||
Core
|
|
||||||
|
|
||||||
LINK_LIBS PUBLIC
|
|
||||||
MLIRIR
|
|
||||||
MLIRLinalg
|
|
||||||
MLIRTensor
|
|
||||||
MLIRStandard
|
|
||||||
MLIRMath
|
|
||||||
)
|
|
||||||
|
|
||||||
mlir_check_all_link_libraries(NPCOMPCommonBackend)
|
|
|
@ -1,25 +0,0 @@
|
||||||
//===- PassDetail.h - Pass class details ------------------------*- C++ -*-===//
|
|
||||||
//
|
|
||||||
// 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
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#ifndef BACKEND_COMMON_PASSDETAIL_H
|
|
||||||
#define BACKEND_COMMON_PASSDETAIL_H
|
|
||||||
|
|
||||||
#include "mlir/Pass/Pass.h"
|
|
||||||
|
|
||||||
namespace mlir {
|
|
||||||
namespace NPCOMP {
|
|
||||||
namespace CommonBackend {
|
|
||||||
|
|
||||||
#define GEN_PASS_CLASSES
|
|
||||||
#include "npcomp/Backend/Common/Passes.h.inc"
|
|
||||||
|
|
||||||
} // namespace CommonBackend
|
|
||||||
} // namespace NPCOMP
|
|
||||||
} // end namespace mlir
|
|
||||||
|
|
||||||
#endif // BACKEND_COMMON_PASSDETAIL_H
|
|
|
@ -1,25 +0,0 @@
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// 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
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#include "PassDetail.h"
|
|
||||||
#include "npcomp/Backend/Common/Passes.h"
|
|
||||||
|
|
||||||
#include "mlir/IR/BuiltinOps.h"
|
|
||||||
|
|
||||||
using namespace mlir;
|
|
||||||
using namespace mlir::NPCOMP;
|
|
||||||
using namespace mlir::NPCOMP::CommonBackend;
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
#define GEN_PASS_REGISTRATION
|
|
||||||
#include "npcomp/Backend/Common/Passes.h.inc"
|
|
||||||
} // end namespace
|
|
||||||
|
|
||||||
void mlir::NPCOMP::CommonBackend::registerCommonBackendPasses() {
|
|
||||||
::registerPasses();
|
|
||||||
}
|
|
|
@ -1,4 +1,3 @@
|
||||||
add_subdirectory(Backend)
|
|
||||||
add_subdirectory(CAPI)
|
add_subdirectory(CAPI)
|
||||||
add_subdirectory(Conversion)
|
add_subdirectory(Conversion)
|
||||||
add_subdirectory(Dialect)
|
add_subdirectory(Dialect)
|
||||||
|
@ -25,7 +24,6 @@ add_npcomp_library(NPCOMPInitAll
|
||||||
|
|
||||||
PUBLIC
|
PUBLIC
|
||||||
# Local depends
|
# Local depends
|
||||||
NPCOMPCommonBackend
|
|
||||||
TorchMLIRTorchDialect
|
TorchMLIRTorchDialect
|
||||||
NPCOMPTorchConversionDialect
|
NPCOMPTorchConversionDialect
|
||||||
NPCOMPConversionPasses
|
NPCOMPConversionPasses
|
||||||
|
|
|
@ -2,6 +2,7 @@ add_npcomp_conversion_library(NPCOMPTorchConversionPasses
|
||||||
BackendTypeConversion.cpp
|
BackendTypeConversion.cpp
|
||||||
Passes.cpp
|
Passes.cpp
|
||||||
VerifyInvariantsBeforeBackendLowering.cpp
|
VerifyInvariantsBeforeBackendLowering.cpp
|
||||||
|
VerifyLinalgOnTensorsBackendContract.cpp
|
||||||
|
|
||||||
ADDITIONAL_HEADER_DIRS
|
ADDITIONAL_HEADER_DIRS
|
||||||
${PROJECT_SOURCE_DIR}/include/npcomp/Dialect/TorchConversion/Transforms
|
${PROJECT_SOURCE_DIR}/include/npcomp/Dialect/TorchConversion/Transforms
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "mlir/Dialect/StandardOps/Transforms/Passes.h"
|
#include "mlir/Dialect/StandardOps/Transforms/Passes.h"
|
||||||
#include "mlir/Pass/PassManager.h"
|
#include "mlir/Pass/PassManager.h"
|
||||||
#include "mlir/Transforms/Passes.h"
|
#include "mlir/Transforms/Passes.h"
|
||||||
#include "npcomp/Backend/Common/Passes.h"
|
|
||||||
#include "npcomp/Conversion/TorchToLinalg/TorchToLinalg.h"
|
#include "npcomp/Conversion/TorchToLinalg/TorchToLinalg.h"
|
||||||
#include "npcomp/Conversion/TorchToSCF/TorchToSCF.h"
|
#include "npcomp/Conversion/TorchToSCF/TorchToSCF.h"
|
||||||
#include "npcomp/Conversion/TorchToStd/TorchToStd.h"
|
#include "npcomp/Conversion/TorchToStd/TorchToStd.h"
|
||||||
|
@ -75,8 +74,8 @@ void mlir::NPCOMP::TorchConversion::createTorchScriptToNpcompBackendPipeline(
|
||||||
pm.addNestedPass<FuncOp>(
|
pm.addNestedPass<FuncOp>(
|
||||||
TorchConversion::createFinalizingBackendTypeConversionPass());
|
TorchConversion::createFinalizingBackendTypeConversionPass());
|
||||||
|
|
||||||
// Verify that we have lowered to the form that npcomp backends expect.
|
// Verify that we have lowered to the form that linalg on tensors backends
|
||||||
// This fails compilation (signalPassFailure) if the IR is not in the
|
// expect. This fails compilation (signalPassFailure) if the IR is not in the
|
||||||
// correct form.
|
// correct form.
|
||||||
pm.addPass(CommonBackend::createVerifyBackendContractPass());
|
pm.addPass(TorchConversion::createVerifyLinalgOnTensorsBackendContractPass());
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,22 +7,24 @@
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "PassDetail.h"
|
#include "PassDetail.h"
|
||||||
|
|
||||||
#include "mlir/Dialect/Linalg/IR/LinalgOps.h"
|
#include "mlir/Dialect/Linalg/IR/LinalgOps.h"
|
||||||
#include "mlir/Dialect/Math/IR/Math.h"
|
#include "mlir/Dialect/Math/IR/Math.h"
|
||||||
#include "mlir/Dialect/Tensor/IR/Tensor.h"
|
#include "mlir/Dialect/Tensor/IR/Tensor.h"
|
||||||
#include "mlir/IR/OpDefinition.h"
|
#include "mlir/IR/OpDefinition.h"
|
||||||
#include "mlir/Transforms/DialectConversion.h"
|
#include "mlir/Transforms/DialectConversion.h"
|
||||||
#include "npcomp/Backend/Common/Passes.h"
|
#include "npcomp/Dialect/TorchConversion/Transforms/Passes.h"
|
||||||
|
|
||||||
#include "mlir/IR/BuiltinOps.h"
|
#include "mlir/IR/BuiltinOps.h"
|
||||||
|
|
||||||
using namespace mlir;
|
using namespace mlir;
|
||||||
using namespace mlir::NPCOMP;
|
using namespace mlir::NPCOMP;
|
||||||
using namespace mlir::NPCOMP::CommonBackend;
|
using namespace mlir::NPCOMP::TorchConversion;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class VerifyBackendContractPass
|
class VerifyLinalgOnTensorsBackendContractPass
|
||||||
: public VerifyBackendContractBase<VerifyBackendContractPass> {
|
: public VerifyLinalgOnTensorsBackendContractBase<
|
||||||
|
VerifyLinalgOnTensorsBackendContractPass> {
|
||||||
void runOnOperation() override {
|
void runOnOperation() override {
|
||||||
MLIRContext *context = &getContext();
|
MLIRContext *context = &getContext();
|
||||||
auto module = getOperation();
|
auto module = getOperation();
|
||||||
|
@ -79,6 +81,6 @@ class VerifyBackendContractPass
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::unique_ptr<OperationPass<ModuleOp>>
|
std::unique_ptr<OperationPass<ModuleOp>>
|
||||||
mlir::NPCOMP::CommonBackend::createVerifyBackendContractPass() {
|
mlir::NPCOMP::TorchConversion::createVerifyLinalgOnTensorsBackendContractPass() {
|
||||||
return std::make_unique<VerifyBackendContractPass>();
|
return std::make_unique<VerifyLinalgOnTensorsBackendContractPass>();
|
||||||
}
|
}
|
|
@ -9,7 +9,6 @@
|
||||||
#include "npcomp/InitAll.h"
|
#include "npcomp/InitAll.h"
|
||||||
|
|
||||||
#include "mlir/IR/Dialect.h"
|
#include "mlir/IR/Dialect.h"
|
||||||
#include "npcomp/Backend/Common/Passes.h"
|
|
||||||
#include "npcomp/Conversion/Passes.h"
|
#include "npcomp/Conversion/Passes.h"
|
||||||
#include "npcomp/Dialect/TorchConversion/IR/TorchConversionDialect.h"
|
#include "npcomp/Dialect/TorchConversion/IR/TorchConversionDialect.h"
|
||||||
#include "npcomp/Dialect/TorchConversion/Transforms/Passes.h"
|
#include "npcomp/Dialect/TorchConversion/Transforms/Passes.h"
|
||||||
|
@ -21,5 +20,4 @@ void mlir::NPCOMP::registerAllDialects(mlir::DialectRegistry ®istry) {
|
||||||
void mlir::NPCOMP::registerAllPasses() {
|
void mlir::NPCOMP::registerAllPasses() {
|
||||||
mlir::NPCOMP::registerConversionPasses();
|
mlir::NPCOMP::registerConversionPasses();
|
||||||
mlir::NPCOMP::registerTorchConversionPasses();
|
mlir::NPCOMP::registerTorchConversionPasses();
|
||||||
mlir::NPCOMP::CommonBackend::registerCommonBackendPasses();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class NpcompBackend(abc.ABC):
|
||||||
"""Compile the provided MLIR module into a compiled artifact.
|
"""Compile the provided MLIR module into a compiled artifact.
|
||||||
|
|
||||||
The module adheres to the npcomp backend contract
|
The module adheres to the npcomp backend contract
|
||||||
(see the VerifyBackendContract pass).
|
(see the VerifyLinalgOnTensorsBackendContract pass).
|
||||||
|
|
||||||
The compiled artifact can be any type, but must be correctly
|
The compiled artifact can be any type, but must be correctly
|
||||||
interpreted by the `load` method.
|
interpreted by the `load` method.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// RUN: npcomp-opt -npcomp-verify-backend-contract -split-input-file -verify-diagnostics -allow-unregistered-dialect %s | FileCheck %s
|
// RUN: npcomp-opt -npcomp-verify-linalg-on-tensors-backend-contract -split-input-file -verify-diagnostics -allow-unregistered-dialect %s | FileCheck %s
|
||||||
|
|
||||||
// CHECK: func @mm
|
// CHECK: func @mm
|
||||||
func @mm(%arg0: tensor<?x?xf32>, %arg1: tensor<?x?xf32>) -> tensor<?x?xf32> {
|
func @mm(%arg0: tensor<?x?xf32>, %arg1: tensor<?x?xf32>) -> tensor<?x?xf32> {
|
Loading…
Reference in New Issue