zhanghb97 fcd2969da9 Initial MLIR python bindings based on the C API.
* Basic support for context creation, module parsing and dumping.

Differential Revision: https://reviews.llvm.org/D85481
2020-08-16 19:34:25 -07:00

33 lines
993 B
C++

//===- MainModule.cpp - Main pybind module --------------------------------===//
//
// 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 <tuple>
#include <pybind11/pybind11.h>
#include "IRModules.h"
#include "mlir/IR/MLIRContext.h"
using namespace mlir;
PYBIND11_MODULE(_mlir, m) {
m.doc() = "MLIR Python Native Extension";
m.def("get_test_value", []() {
// This is just calling a method on the MLIRContext as a smoketest
// for linkage.
MLIRContext context;
return std::make_tuple(std::string("From the native module"),
context.isMultithreadingEnabled());
});
// Define and populate IR submodule.
auto irModule = m.def_submodule("ir", "MLIR IR Bindings");
populateIRSubmodule(irModule);
}