mirror of https://github.com/llvm/torch-mlir
Add stub numpy dialect.
parent
ac302ea916
commit
d3b6e1767a
|
@ -0,0 +1 @@
|
|||
BasedOnStyle: LLVM
|
|
@ -1,3 +1,5 @@
|
|||
.vscode
|
||||
|
||||
build
|
||||
build-mlir
|
||||
install-mlir
|
||||
|
|
|
@ -35,8 +35,8 @@ link_directories(${LLVM_BUILD_LIBRARY_DIR})
|
|||
add_definitions(${LLVM_DEFINITIONS})
|
||||
|
||||
# MLIR npcomp project.
|
||||
set(MLIR_NPCOMP_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # --src-root
|
||||
set(MLIR_NPCOMP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) # --includedir
|
||||
#set(MLIR_NPCOMP_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # --src-root
|
||||
#set(MLIR_NPCOMP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) # --includedir
|
||||
|
||||
set(MLIR_NPCOMP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(MLIR_NPCOMP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
@ -51,9 +51,9 @@ message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")
|
|||
|
||||
# TODO(laurenzo): What is the right way to get include directories for
|
||||
# cross project dependencies?
|
||||
include_directories(${MLIR_NPCOMP_INCLUDE_DIR})
|
||||
include_directories(${CMAKE_SOURCE_DIR}/../mlir/include)
|
||||
include_directories(${CMAKE_BINARY_DIR}/tools/mlir/include)
|
||||
#include_directories(${MLIR_NPCOMP_INCLUDE_DIR})
|
||||
#include_directories(${CMAKE_SOURCE_DIR}/../mlir/include)
|
||||
#include_directories(${CMAKE_BINARY_DIR}/tools/mlir/include)
|
||||
|
||||
add_subdirectory(include/npcomp)
|
||||
add_subdirectory(lib)
|
||||
|
|
|
@ -1 +1 @@
|
|||
# Empty file
|
||||
add_subdirectory(Dialect)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
add_subdirectory(Numpy)
|
|
@ -0,0 +1,3 @@
|
|||
add_mlir_dialect(NumpyOps numpy)
|
||||
add_mlir_doc(NumpyDialect -gen-dialect-doc NumpyDialect Numpy/)
|
||||
add_mlir_doc(NumpyOps -gen-op-doc NumpyOps Numpy/)
|
|
@ -0,0 +1,24 @@
|
|||
//===- NumpyDialect.h - Core numpy dialect ----------------------*- 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_DIALECT_NUMPY_NUMPY_DIALECT_H
|
||||
#define NPCOMP_DIALECT_NUMPY_NUMPY_DIALECT_H
|
||||
|
||||
#include "mlir/IR/Dialect.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace npcomp {
|
||||
namespace NUMPY {
|
||||
|
||||
#include "npcomp/Dialect/Numpy/NumpyOpsDialect.h.inc"
|
||||
|
||||
} // namespace NUMPY
|
||||
} // namespace npcomp
|
||||
} // namespace mlir
|
||||
|
||||
#endif // NPCOMP_DIALECT_NUMPY_NUMPY_DIALECT_H
|
|
@ -0,0 +1,26 @@
|
|||
//===- NumpyDialect.td - Core numpy dialect ----------------*- 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_DIALECT_NUMPY_NUMPY_DIALECT
|
||||
#define NPCOMP_DIALECT_NUMPY_NUMPY_DIALECT
|
||||
|
||||
include "mlir/IR/OpBase.td"
|
||||
|
||||
def Numpy_Dialect : Dialect {
|
||||
let name = "numpy";
|
||||
let summary = "Core numpy dialect";
|
||||
let description = [{
|
||||
Dialect of types and core numpy ops and abstractions.
|
||||
}];
|
||||
let cppNamespace = "NUMPY";
|
||||
}
|
||||
|
||||
class Numpy_Op<string mnemonic, list<OpTrait> traits = []> :
|
||||
Op<Numpy_Dialect, mnemonic, traits>;
|
||||
|
||||
#endif // NPCOMP_DIALECT_NUMPY_NUMPY_DIALECT
|
|
@ -0,0 +1,27 @@
|
|||
//===- NumpyOps.h - Core numpy dialect ops ----------------------*- 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_DIALECT_NUMPY_NUMPY_OPS_H
|
||||
#define NPCOMP_DIALECT_NUMPY_NUMPY_OPS_H
|
||||
|
||||
#include "mlir/IR/Dialect.h"
|
||||
#include "mlir/IR/OpDefinition.h"
|
||||
#include "mlir/Interfaces/SideEffects.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace npcomp {
|
||||
namespace NUMPY {
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "npcomp/Dialect/Numpy/NumpyOps.h.inc"
|
||||
|
||||
} // namespace NUMPY
|
||||
} // namespace npcomp
|
||||
} // namespace mlir
|
||||
|
||||
#endif // NPCOMP_DIALECT_NUMPY_NUMPY_OPS_H
|
|
@ -0,0 +1,30 @@
|
|||
//===- NumpyOps.td - Core numpy dialect ops ----------------*- 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef NPCOMP_DIALECT_NUMPY_NUMPY_OPS
|
||||
#define NPCOMP_DIALECT_NUMPY_NUMPY_OPS
|
||||
|
||||
include "NumpyDialect.td"
|
||||
include "mlir/Interfaces/SideEffects.td"
|
||||
|
||||
def Numpy_FooOp : Numpy_Op<"foo", [NoSideEffect,
|
||||
SameOperandsAndResultType]> {
|
||||
let summary = "Temp op";
|
||||
let description = [{
|
||||
Temp op
|
||||
}];
|
||||
|
||||
let arguments = (ins I32:$input);
|
||||
let results = (outs I32:$res);
|
||||
|
||||
let assemblyFormat = [{
|
||||
$input attr-dict `:` type($input)
|
||||
}];
|
||||
}
|
||||
|
||||
#endif // NPCOMP_DIALECT_NUMPY_NUMPY_OPS
|
|
@ -1 +0,0 @@
|
|||
// Empty file
|
|
@ -1,7 +1 @@
|
|||
add_llvm_tool(npcomp-dummy-runner
|
||||
dummy-runner.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(npcomp-dummy-runner PRIVATE
|
||||
LLVMSupport
|
||||
)
|
||||
add_subdirectory(Dialect)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
add_subdirectory(Numpy)
|
|
@ -0,0 +1,12 @@
|
|||
add_mlir_dialect_library(NPCOMPNumpyDialect
|
||||
NumpyDialect.cpp
|
||||
NumpyOps.cpp
|
||||
|
||||
ADDITIONAL_HEADER_DIRS
|
||||
${PROJECT_SOURCE_DIR}/include/npcomp/Dialect/Numpy
|
||||
|
||||
DEPENDS
|
||||
MLIRNumpyOpsIncGen
|
||||
)
|
||||
|
||||
target_link_libraries(NPCOMPNumpyDialect PUBLIC MLIRIR)
|
|
@ -0,0 +1,21 @@
|
|||
//===- NumpyDialect.cpp - Core numpy dialect --------------------*- 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "npcomp/Dialect/Numpy/NumpyDialect.h"
|
||||
#include "npcomp/Dialect/Numpy/NumpyOps.h"
|
||||
|
||||
using namespace mlir;
|
||||
using namespace mlir::npcomp::NUMPY;
|
||||
|
||||
NumpyDialect::NumpyDialect(MLIRContext *context)
|
||||
: Dialect(getDialectNamespace(), context) {
|
||||
addOperations<
|
||||
#define GET_OP_LIST
|
||||
#include "npcomp/Dialect/Numpy/NumpyOps.cpp.inc"
|
||||
>();
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
//===- NumpyOps.cpp - Core numpy dialect ops --------------------*- 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "npcomp/Dialect/Numpy/NumpyOps.h"
|
||||
#include "mlir/IR/OpImplementation.h"
|
||||
#include "npcomp/Dialect/Numpy/NumpyDialect.h"
|
||||
|
||||
namespace mlir {
|
||||
namespace npcomp {
|
||||
namespace numpy {
|
||||
|
||||
#include "npcomp/Dialect/Numpy/NumpyOps.cpp.inc"
|
||||
|
||||
} // namespace numpy
|
||||
} // namespace npcomp
|
||||
} // namespace mlir
|
|
@ -1,12 +0,0 @@
|
|||
#include "llvm/Support/InitLLVM.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "npcomp/Dummy.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
InitLLVM y(argc, argv);
|
||||
cl::ParseCommandLineOptions(argc, argv, "Dummy program\n");
|
||||
llvm::outs() << "Hello world!\n";
|
||||
return 0;
|
||||
}
|
|
@ -65,8 +65,12 @@ target_link_libraries(${extension_target}
|
|||
PRIVATE
|
||||
${dialect_libs}
|
||||
${conversion_libs}
|
||||
|
||||
pybind11::module
|
||||
|
||||
# Local depends
|
||||
NPCOMPNumpyDialect
|
||||
|
||||
# Upstream depends
|
||||
LLVMSupport
|
||||
MLIRAffineToStandard
|
||||
MLIRAffineTransforms
|
||||
|
|
Loading…
Reference in New Issue