Files
llvm-tms34010/mlir/lib/Bindings/Python/MainModule.cpp
T
Stella Laurenzo 722475a375 Initial boiler-plate for python bindings.
Summary:
* Native '_mlir' extension module.
* Python mlir/__init__.py trampoline module.
* Lit test that checks a message.
* Uses some cmake configurations that have worked for me in the past but likely needs further elaboration.

Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, Kayjukh, jurahul, msifontes

Tags: #mlir

Differential Revision: https://reviews.llvm.org/D83279
2020-07-09 12:03:58 -07:00

28 lines
836 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 "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());
});
}