-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TargetModel in python bindings #1500
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d4417ad
TargetModel in python
fifield 4f76d57
refactor
fifield a5228b9
add is_npu, format
fifield 90e1a52
missing commit
fifield 616c019
black format
fifield d922337
clang-format
fifield 4ef51b6
add more of the api boilerplate
fifield File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
//===- TargetModel.h --------------------------------------------*- 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 | ||
// | ||
// (c) Copyright 2024 Advanced Micro Devices, Inc. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef AIE_C_TARGETMODEL_H | ||
#define AIE_C_TARGETMODEL_H | ||
|
||
#include "mlir-c/IR.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Opaque type declarations. | ||
// | ||
// Types are exposed to C bindings as structs containing opaque pointers. They | ||
// are not supposed to be inspected from C. This allows the underlying | ||
// representation to change without affecting the API users. The use of structs | ||
// instead of typedefs enables some type safety as structs are not implicitly | ||
// convertible to each other. | ||
// | ||
// Instances of these types may or may not own the underlying object. The | ||
// ownership semantics is defined by how an instance of the type was obtained. | ||
//===----------------------------------------------------------------------===// | ||
|
||
#define DEFINE_C_API_STRUCT(name, storage) \ | ||
struct name { \ | ||
storage d; \ | ||
}; \ | ||
typedef struct name name | ||
|
||
DEFINE_C_API_STRUCT(AieTargetModel, uint32_t); | ||
|
||
#undef DEFINE_C_API_STRUCT | ||
|
||
MLIR_CAPI_EXPORTED AieTargetModel aieGetTargetModel(uint32_t device); | ||
|
||
/// Returns the number of columns in the target model. | ||
MLIR_CAPI_EXPORTED int aieTargetModelColumns(AieTargetModel targetModel); | ||
|
||
/// Returns the number of rows in the target model. | ||
MLIR_CAPI_EXPORTED int aieTargetModelRows(AieTargetModel targetModel); | ||
|
||
/// Returns true if this is an NPU target model. | ||
MLIR_CAPI_EXPORTED bool aieTargetModelIsNPU(AieTargetModel targetModel); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsCoreTile(AieTargetModel targetModel, | ||
int col, int row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemTile(AieTargetModel targetModel, | ||
int col, int row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsShimNOCTile(AieTargetModel targetModel, | ||
int col, int row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsShimPLTile(AieTargetModel targetModel, | ||
int col, int row); | ||
|
||
MLIR_CAPI_EXPORTED bool | ||
aieTargetModelIsShimNOCorPLTile(AieTargetModel targetModel, int col, int row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsInternal(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsWest(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsEast(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsNorth(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsSouth(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemWest(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemEast(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemNorth(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemSouth(AieTargetModel targetModel, | ||
int src_col, int src_row, | ||
int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED bool | ||
aieTargetModelIsLegalMemAffinity(AieTargetModel targetModel, int src_col, | ||
int src_row, int dst_col, int dst_row); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetMemSouthBaseAddress(AieTargetModel targetModel); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetMemNorthBaseAddress(AieTargetModel targetModel); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetMemEastBaseAddress(AieTargetModel targetModel); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetMemWestBaseAddress(AieTargetModel targetModel); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetLocalMemorySize(AieTargetModel targetModel); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetNumLocks(AieTargetModel targetModel, int col, int row); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetNumBDs(AieTargetModel targetModel, | ||
int col, int row); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetNumMemTileRows(AieTargetModel targetModel); | ||
|
||
MLIR_CAPI_EXPORTED uint32_t | ||
aieTargetModelGetMemTileSize(AieTargetModel targetModel); | ||
|
||
/// Returns true if this is an NPU target model. | ||
MLIR_CAPI_EXPORTED bool aieTargetModelIsNPU(AieTargetModel targetModel); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // AIE_C_TARGETMODEL_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
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not a good idea... My intention with the TargetModel is that it's a singleton pattern, which is independent of the MLIR. an AIEDevice is the device of a particular design. And a Device is not actually necessary, only a container object that implements the right interface. It's unclear to me why you need to walk from the TargetModel back to a device anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was convenient for wrapping/unwrapping to keep only the enum around, and this helped with that. https://github.com/Xilinx/mlir-aie/pull/1500/files#diff-3f51e6951752378031f1f22e2616b9d3c77de3a54fcbb31cdc6ab6bd34d109dbR18-R24. But I can probably refactor to avoid the change to
TargetModel