Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a new target for high-level op generation: mlir-miopen-driver.
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
set(LIBS | ||
MLIRAnalysis | ||
MLIRMIOpenOps | ||
MLIRParser | ||
MLIRPass | ||
MLIRStandardOps | ||
MLIRTransforms | ||
MLIRSupport | ||
) | ||
|
||
add_llvm_tool(mlir-miopen-driver | ||
mlir-miopen-driver.cpp | ||
) | ||
llvm_update_compile_flags(mlir-miopen-driver) | ||
whole_archive_link(mlir-miopen-driver ${LIBS}) | ||
target_link_libraries(mlir-miopen-driver PRIVATE MLIRIR ${LIBS} LLVMSupport) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//===- mlir-miopen-driver.cpp - MLIR MIOpen Dialect Driver ----------------===// | ||
// | ||
// Part of the MLIR 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Main entry function for mlir-miopen-driver. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "mlir/Analysis/Passes.h" | ||
#include "mlir/Pass/Pass.h" | ||
#include "mlir/Pass/PassManager.h" | ||
#include "mlir/Support/FileUtilities.h" | ||
#include "llvm/Support/CommandLine.h" | ||
#include "llvm/Support/InitLLVM.h" | ||
#include "llvm/Support/SourceMgr.h" | ||
#include "llvm/Support/ToolOutputFile.h" | ||
|
||
using namespace llvm; | ||
using namespace mlir; | ||
|
||
static cl::opt<std::string> | ||
inputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-")); | ||
|
||
static cl::opt<std::string> outputFilename("o", cl::desc("Output filename"), | ||
cl::value_desc("filename"), | ||
cl::init("-")); | ||
|
||
static cl::opt<std::string> filterLayout("f", cl::desc("Filter layout"), | ||
cl::value_desc("layout string"), | ||
cl::init("kcyx")); | ||
|
||
static cl::opt<std::string> inputLayout("i", cl::desc("Input layout"), | ||
cl::value_desc("layout string"), | ||
cl::init("nchw")); | ||
|
||
static cl::opt<std::string> outputLayout("d", cl::desc("Output layout"), | ||
cl::value_desc("layout string"), | ||
cl::init("nkhw")); | ||
|
||
int main(int argc, char **argv) { | ||
InitLLVM y(argc, argv); | ||
|
||
// Parse pass names in main to ensure static initialization completed. | ||
cl::ParseCommandLineOptions(argc, argv, "MLIR MIOpen Dialect driver\n"); | ||
|
||
// Set up the input file. | ||
std::string errorMessage; | ||
auto file = openInputFile(inputFilename, &errorMessage); | ||
if (!file) { | ||
llvm::errs() << errorMessage << "\n"; | ||
return 1; | ||
} | ||
|
||
auto output = openOutputFile(outputFilename, &errorMessage); | ||
if (!output) { | ||
llvm::errs() << errorMessage << "\n"; | ||
exit(1); | ||
} | ||
|
||
return 0; | ||
} |