2021-09-11 02:44:38 +08:00
|
|
|
//===-- TorchBind.td - Torch dialect bind ------------------*- tablegen -*-===//
|
|
|
|
//
|
|
|
|
// 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
|
2021-09-30 00:03:40 +08:00
|
|
|
// Also available under a BSD-style license. See LICENSE.
|
2021-09-11 02:44:38 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "mlir-c/Bindings/Python/Interop.h"
|
|
|
|
#include "mlir/Bindings/Python/PybindAdaptors.h"
|
2021-09-23 00:55:09 +08:00
|
|
|
#include "torch-mlir-c/Dialects.h"
|
|
|
|
#include "torch-mlir-c/Registration.h"
|
2021-09-11 02:44:38 +08:00
|
|
|
|
|
|
|
namespace py = pybind11;
|
|
|
|
|
|
|
|
PYBIND11_MODULE(_torchMlir, m) {
|
2021-09-23 00:55:09 +08:00
|
|
|
torchMlirRegisterAllPasses();
|
|
|
|
|
2021-09-11 02:44:38 +08:00
|
|
|
m.doc() = "torch-mlir main python extension";
|
|
|
|
|
2022-07-22 00:35:42 +08:00
|
|
|
m.def(
|
|
|
|
"register_dialect",
|
|
|
|
[](MlirContext context, bool load) {
|
|
|
|
MlirDialectHandle handle = mlirGetDialectHandle__torch__();
|
|
|
|
mlirDialectHandleRegisterDialect(handle, context);
|
|
|
|
if (load) {
|
|
|
|
mlirDialectHandleLoadDialect(handle, context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
py::arg("context"), py::arg("load") = true);
|
2021-09-11 02:44:38 +08:00
|
|
|
}
|