2020-06-12 08:47:14 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "npcomp/InitAll.h"
|
|
|
|
|
2020-08-13 10:28:04 +08:00
|
|
|
#include "npcomp/Dialect/ATen/ATenDialect.h"
|
|
|
|
#include "npcomp/Dialect/ATen/ATenPasses.h"
|
2020-06-12 08:47:14 +08:00
|
|
|
#include "npcomp/Dialect/Basicpy/IR/BasicpyDialect.h"
|
|
|
|
#include "npcomp/Dialect/Basicpy/Transforms/Passes.h"
|
2020-10-08 08:12:52 +08:00
|
|
|
#include "npcomp/Dialect/Refbackrt/IR/RefbackrtDialect.h"
|
2020-06-12 08:47:14 +08:00
|
|
|
#include "npcomp/Dialect/Numpy/IR/NumpyDialect.h"
|
2020-07-09 13:51:54 +08:00
|
|
|
#include "npcomp/Dialect/Numpy/Transforms/Passes.h"
|
[RefBackend] Split out RefBackend (refback) dialect from TCP.
This is the first in a patch series that is refactoring the
constellation of things variously called or associated with "E2E",
"RefE2E", "npcomprt", and "TCP" into a more cleanly layered result.
Concretely, this first patch fixes the fact that TCP was basically
acting like a dumping ground needed by the reference backend. This
splits it out, which is fairly mechanical, but touches a lot of lines of
code (basically replacing `tcp` with `refback` and `TCP` with
`RefBackend).
Now, the RefBackend dialect is that dumping ground, which
is slighly better, as it starts allowing TCP to become a nice clean
middle layer that is not related per se to the reference backend.
The previous name RefE2E or "reference e2e flow" was super confusing.
Now that we are seeing more clearly where the "backend" distinction
lies, the [RefBackend] commit tag is born :)
2020-10-07 06:44:18 +08:00
|
|
|
#include "npcomp/Dialect/RefBackend/IR/RefBackendDialect.h"
|
2020-06-12 08:47:14 +08:00
|
|
|
#include "npcomp/Dialect/TCF/IR/TCFDialect.h"
|
2020-07-11 12:51:03 +08:00
|
|
|
#include "npcomp/Dialect/TCF/Transforms/Passes.h"
|
2020-06-12 08:47:14 +08:00
|
|
|
#include "npcomp/Dialect/TCP/IR/TCPDialect.h"
|
2020-09-29 03:02:35 +08:00
|
|
|
#include "npcomp/Dialect/Torch/IR/TorchDialect.h"
|
2020-07-05 07:56:09 +08:00
|
|
|
#include "npcomp/Typing/Transforms/Passes.h"
|
2020-06-12 08:47:14 +08:00
|
|
|
|
2020-08-28 06:09:10 +08:00
|
|
|
#include "npcomp/Conversion/Passes.h"
|
2020-10-07 07:14:37 +08:00
|
|
|
#include "npcomp/RefBackend/RefBackend.h"
|
2020-06-12 08:47:14 +08:00
|
|
|
|
|
|
|
#ifdef NPCOMP_ENABLE_IREE
|
|
|
|
#include "iree/tools/init_compiler_modules.h"
|
|
|
|
#include "iree/tools/init_iree_dialects.h"
|
|
|
|
#include "iree/tools/init_iree_passes.h"
|
|
|
|
#include "iree/tools/init_mlir_dialects.h"
|
|
|
|
#include "iree/tools/init_mlir_passes.h"
|
|
|
|
#include "iree/tools/init_targets.h"
|
|
|
|
#include "iree/tools/init_xla_dialects.h"
|
2020-06-12 08:57:10 +08:00
|
|
|
// TODO: For some reason these aren't bundled with the rest.
|
|
|
|
#include "iree/compiler/Conversion/HLOToLinalg/Passes.h"
|
|
|
|
#include "iree/compiler/Conversion/init_conversions.h"
|
|
|
|
#include "iree/compiler/Dialect/HAL/Conversion/Passes.h"
|
2020-06-12 08:47:14 +08:00
|
|
|
#endif // NPCOMP_ENABLE_IREE
|
|
|
|
|
2020-08-28 06:09:10 +08:00
|
|
|
static void registerDependencyDialects(mlir::DialectRegistry ®istry) {
|
2020-06-12 08:47:14 +08:00
|
|
|
#ifdef NPCOMP_ENABLE_IREE
|
|
|
|
// TODO: We should probably be registering the MLIR dialects regardless
|
|
|
|
// of building with IREE, but we have to do it with IREE, and the
|
|
|
|
// dependencies are coming from there and wouldn't be great to duplicate.
|
|
|
|
// See iree/tools:init_mlir_passes_and_dialects
|
2020-08-28 06:09:10 +08:00
|
|
|
mlir::registerMlirDialects(registry);
|
|
|
|
mlir::registerXLADialects(registry);
|
|
|
|
mlir::iree_compiler::registerIreeDialects(registry);
|
|
|
|
mlir::iree_compiler::registerIreeCompilerModuleDialects(registry);
|
2020-06-12 08:47:14 +08:00
|
|
|
#endif // NPCOMP_ENABLE_IREE
|
|
|
|
}
|
|
|
|
|
|
|
|
static void registerDependencyPasses() {
|
2020-06-12 08:57:10 +08:00
|
|
|
#ifdef NPCOMP_ENABLE_IREE
|
|
|
|
// TODO: We should probably be registering the MLIR passes regardless
|
|
|
|
// of building with IREE, but we have to do it with IREE, and the
|
|
|
|
// dependencies are coming from there and wouldn't be great to duplicate.
|
|
|
|
// See iree/tools:init_mlir_passes_and_dialects
|
|
|
|
mlir::registerMlirPasses();
|
|
|
|
mlir::iree_compiler::registerAllIreePasses();
|
|
|
|
mlir::iree_compiler::registerHALConversionPasses();
|
|
|
|
mlir::iree_compiler::registerHALTargetBackends();
|
|
|
|
mlir::iree_compiler::registerLinalgToSPIRVPasses();
|
|
|
|
mlir::iree_compiler::registerHLOToLinalgPasses();
|
|
|
|
mlir::iree_compiler::registerLinalgToLLVMPasses();
|
|
|
|
#endif // NPCOMP_ENABLE_IREE
|
2020-06-12 08:47:14 +08:00
|
|
|
}
|
|
|
|
|
2020-08-28 06:09:10 +08:00
|
|
|
void mlir::NPCOMP::registerAllDialects(mlir::DialectRegistry ®istry) {
|
|
|
|
// clang-format off
|
|
|
|
registry.insert<mlir::NPCOMP::aten::ATenDialect,
|
|
|
|
Basicpy::BasicpyDialect,
|
|
|
|
Numpy::NumpyDialect,
|
2020-10-08 08:12:52 +08:00
|
|
|
refbackrt::RefbackrtDialect,
|
[RefBackend] Split out RefBackend (refback) dialect from TCP.
This is the first in a patch series that is refactoring the
constellation of things variously called or associated with "E2E",
"RefE2E", "npcomprt", and "TCP" into a more cleanly layered result.
Concretely, this first patch fixes the fact that TCP was basically
acting like a dumping ground needed by the reference backend. This
splits it out, which is fairly mechanical, but touches a lot of lines of
code (basically replacing `tcp` with `refback` and `TCP` with
`RefBackend).
Now, the RefBackend dialect is that dumping ground, which
is slighly better, as it starts allowing TCP to become a nice clean
middle layer that is not related per se to the reference backend.
The previous name RefE2E or "reference e2e flow" was super confusing.
Now that we are seeing more clearly where the "backend" distinction
lies, the [RefBackend] commit tag is born :)
2020-10-07 06:44:18 +08:00
|
|
|
refback::RefBackendDialect,
|
2020-08-28 06:09:10 +08:00
|
|
|
tcf::TCFDialect,
|
2020-09-29 03:02:35 +08:00
|
|
|
tcp::TCPDialect,
|
|
|
|
mlir::NPCOMP::Torch::TorchDialect>();
|
2020-08-28 06:09:10 +08:00
|
|
|
// clang-format on
|
|
|
|
registerDependencyDialects(registry);
|
2020-06-12 08:47:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void mlir::NPCOMP::registerAllPasses() {
|
2020-08-13 10:28:04 +08:00
|
|
|
mlir::NPCOMP::aten::registerATenPasses();
|
2020-10-07 07:14:37 +08:00
|
|
|
mlir::NPCOMP::registerRefBackendPasses();
|
2020-08-28 06:09:10 +08:00
|
|
|
mlir::NPCOMP::registerConversionPasses();
|
|
|
|
mlir::NPCOMP::registerBasicpyPasses();
|
|
|
|
mlir::NPCOMP::registerNumpyPasses();
|
|
|
|
mlir::NPCOMP::registerTCFPasses();
|
|
|
|
mlir::NPCOMP::registerTypingPasses();
|
2020-06-12 08:47:14 +08:00
|
|
|
registerDependencyPasses();
|
|
|
|
}
|