-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR][CAPI] add C API typedef to fix downstream C API usage #135380
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
Conversation
Signed-off-by: Bangtian Liu <[email protected]>
@llvm/pr-subscribers-mlir Author: Bangtian Liu (bangtianliu) ChangesThis PR is after #135253 and #134935 to fix the error reported by #135253 (comment). This PR Adds typedef declarations for I confirm that this fix resolves the reported error based on my testing. Full diff: https://github.com/llvm/llvm-project/pull/135380.diff 1 Files Affected:
diff --git a/mlir/include/mlir-c/Dialect/Linalg.h b/mlir/include/mlir-c/Dialect/Linalg.h
index 838c280903e2e..4f2ee0d434222 100644
--- a/mlir/include/mlir-c/Dialect/Linalg.h
+++ b/mlir/include/mlir-c/Dialect/Linalg.h
@@ -24,19 +24,19 @@ mlirLinalgFillBuiltinNamedOpRegion(MlirOperation mlirOp);
MLIR_CAPI_EXPORTED bool mlirLinalgIsAContractionOp(MlirOperation op);
-struct MlirLinalgContractionDimensions {
+typedef struct MlirLinalgContractionDimensions {
MlirAttribute batch;
MlirAttribute m;
MlirAttribute n;
MlirAttribute k;
-};
+} MlirLinalgContractionDimensions;
MLIR_CAPI_EXPORTED MlirLinalgContractionDimensions
mlirLinalgInferContractionDimensions(MlirOperation op);
MLIR_CAPI_EXPORTED bool mlirLinalgIsAConvolutionOp(MlirOperation op);
-struct MlirLinalgConvolutionDimensions {
+typedef struct MlirLinalgConvolutionDimensions {
MlirAttribute batch;
MlirAttribute outputImage;
MlirAttribute outputChannel;
@@ -45,7 +45,7 @@ struct MlirLinalgConvolutionDimensions {
MlirAttribute depth;
MlirAttribute strides;
MlirAttribute dilations;
-};
+} MlirLinalgConvolutionDimensions;
MLIR_CAPI_EXPORTED MlirLinalgConvolutionDimensions
mlirLinalgInferConvolutionDimensions(MlirOperation op);
|
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.
personally I prefer to just write struct
and eschew typedef
but I realize I've gotta be the only person in the world that feels that way :)
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.
LGTM. This seems consistent with how other C sturcts are defined, e.g.:
llvm-project/mlir/include/mlir-c/IR.h
Lines 46 to 49 in 88e15b7
struct name { \ | |
storage *ptr; \ | |
}; \ | |
typedef struct name name |
…5380) This PR is after llvm#135253 and llvm#134935 to fix the error reported by llvm#135253 (comment). This PR Adds typedef declarations for `MlirLinalgContractionDimensions` and `MlirLinalgConvolutionDimensions` in the C API to ensure compatibility with pure C code. I confirm that this fix resolves the reported error based on my testing. Signed-off-by: Bangtian Liu <[email protected]>
This PR is after #135253 and #134935 to fix the error reported by #135253 (comment). This PR Adds typedef declarations for
MlirLinalgContractionDimensions
andMlirLinalgConvolutionDimensions
in the C API to ensure compatibility with pure C code.I confirm that this fix resolves the reported error based on my testing.