-
Notifications
You must be signed in to change notification settings - Fork 653
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[python][tuner] Set up bindings for iree_codegen (#19108)
Starting with the `DispatchLoweringPassPipeline` attribute.
- Loading branch information
Showing
17 changed files
with
247 additions
and
6 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
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,37 @@ | ||
// Copyright 2024 The IREE Authors | ||
// | ||
// 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 IREE_COMPILER_DIALECTS_IREE_CODEGEN_H | ||
#define IREE_COMPILER_DIALECTS_IREE_CODEGEN_H | ||
|
||
#include "mlir-c/IR.h" | ||
#include "mlir-c/Support.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
// The following C API is **NOT STABLE** and likely to change in the future. | ||
// It mirrors the IREE Codegen Dialect which is not stable itself. | ||
|
||
MLIR_CAPI_EXPORTED bool | ||
ireeAttributeIsACodegenDispatchLoweringPassPipelineAttr(MlirAttribute attr); | ||
|
||
MLIR_CAPI_EXPORTED MlirTypeID | ||
ireeCodegenDispatchLoweringPassPipelineAttrGetTypeID(void); | ||
|
||
MLIR_CAPI_EXPORTED MlirAttribute ireeCodegenDispatchLoweringPassPipelineAttrGet( | ||
MlirContext mlirCtx, uint32_t value); | ||
|
||
MLIR_CAPI_EXPORTED | ||
uint32_t | ||
ireeCodegenDispatchLoweringPassPipelineAttrGetValue(MlirAttribute attr); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // IREE_COMPILER_DIALECTS_IREE_CODEGEN_H |
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
12 changes: 12 additions & 0 deletions
12
compiler/bindings/python/iree/compiler/dialects/IREECodegenBinding.td
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,12 @@ | ||
// Copyright 2024 The IREE Authors | ||
// | ||
// 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 PYTHON_BINDINGS_IREECODEGEN_OPS | ||
#define PYTHON_BINDINGS_IREECODEGEN_OPS | ||
|
||
include "iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenAttrs.td" | ||
|
||
#endif // PYTHON_BINDINGS_IREECODEGEN_OPS |
9 changes: 9 additions & 0 deletions
9
compiler/bindings/python/iree/compiler/dialects/iree_codegen.py
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,9 @@ | ||
# Copyright 2024 The IREE Authors | ||
# | ||
# 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 | ||
|
||
from ._iree_codegen_ops_gen import * | ||
from ._iree_codegen_enum_gen import * | ||
from .._mlir_libs._ireeCompilerDialects.iree_codegen import * |
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
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
44 changes: 44 additions & 0 deletions
44
compiler/src/iree/compiler/API/Internal/IREECodegenDialectCAPI.cpp
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,44 @@ | ||
// Copyright 2024 The IREE Authors | ||
// | ||
// 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 <cstdint> | ||
#include <type_traits> | ||
#include "iree/compiler/Codegen/Dialect/Codegen/IR/IREECodegenAttrs.h" | ||
#include "iree/compiler/dialects/iree_codegen.h" | ||
#include "mlir-c/IR.h" | ||
#include "mlir/CAPI/IR.h" | ||
#include "mlir/CAPI/Support.h" | ||
|
||
using mlir::iree_compiler::IREE::Codegen::DispatchLoweringPassPipeline; | ||
using mlir::iree_compiler::IREE::Codegen::DispatchLoweringPassPipelineAttr; | ||
|
||
bool ireeAttributeIsACodegenDispatchLoweringPassPipelineAttr( | ||
MlirAttribute attr) { | ||
return llvm::isa<DispatchLoweringPassPipelineAttr>(unwrap(attr)); | ||
} | ||
|
||
MlirTypeID ireeCodegenDispatchLoweringPassPipelineAttrGetTypeID() { | ||
return wrap(DispatchLoweringPassPipelineAttr::getTypeID()); | ||
} | ||
|
||
static_assert( | ||
std::is_same_v<uint32_t, | ||
std::underlying_type_t<DispatchLoweringPassPipeline>>, | ||
"Enum type changed"); | ||
|
||
MlirAttribute | ||
ireeCodegenDispatchLoweringPassPipelineAttrGet(MlirContext mlirCtx, | ||
uint32_t value) { | ||
mlir::MLIRContext *ctx = unwrap(mlirCtx); | ||
return wrap(DispatchLoweringPassPipelineAttr::get( | ||
ctx, static_cast<DispatchLoweringPassPipeline>(value))); | ||
} | ||
|
||
uint32_t | ||
ireeCodegenDispatchLoweringPassPipelineAttrGetValue(MlirAttribute attr) { | ||
return static_cast<uint32_t>( | ||
llvm::cast<DispatchLoweringPassPipelineAttr>(unwrap(attr)).getValue()); | ||
} |
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
Oops, something went wrong.