File tree Expand file tree Collapse file tree 7 files changed +95
-0
lines changed Expand file tree Collapse file tree 7 files changed +95
-0
lines changed Original file line number Diff line number Diff line change
1
+ //===-- mlir-c/Dialect/SPIRV.h - C API for SPIRV dialect ----------*- C -*-===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM
4
+ // Exceptions.
5
+ // See https://llvm.org/LICENSE.txt for license information.
6
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7
+ //
8
+ //===----------------------------------------------------------------------===//
9
+
10
+ #ifndef MLIR_C_DIALECT_SPIRV_H
11
+ #define MLIR_C_DIALECT_SPIRV_H
12
+
13
+ #include "mlir-c/IR.h"
14
+ #include "mlir-c/Support.h"
15
+
16
+ #ifdef __cplusplus
17
+ extern "C" {
18
+ #endif
19
+
20
+ MLIR_DECLARE_CAPI_DIALECT_REGISTRATION (SPIRV , spirv );
21
+
22
+ #ifdef __cplusplus
23
+ }
24
+ #endif
25
+
26
+ #endif // MLIR_C_DIALECT_SPIRV_H
Original file line number Diff line number Diff line change @@ -171,6 +171,15 @@ add_mlir_upstream_c_api_library(MLIRCAPIFunc
171
171
MLIRFuncDialect
172
172
)
173
173
174
+ add_mlir_upstream_c_api_library (MLIRCAPISPIRV
175
+ SPIRV.cpp
176
+
177
+ PARTIAL_SOURCES_INTENDED
178
+ LINK_LIBS PUBLIC
179
+ MLIRCAPIIR
180
+ MLIRSPIRVDialect
181
+ )
182
+
174
183
add_mlir_upstream_c_api_library (MLIRCAPITensor
175
184
Tensor.cpp
176
185
Original file line number Diff line number Diff line change
1
+ // ===- SPIRV.cpp - C Interface for SPIRV dialect --------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ // ===----------------------------------------------------------------------===//
8
+
9
+ #include " mlir-c/Dialect/SPIRV.h"
10
+ #include " mlir/CAPI/Registration.h"
11
+ #include " mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
12
+
13
+ MLIR_DEFINE_CAPI_DIALECT_REGISTRATION (SPIRV, spirv, mlir::spirv::SPIRVDialect)
Original file line number Diff line number Diff line change @@ -378,6 +378,13 @@ declare_mlir_dialect_python_bindings(
378
378
"../../include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td"
379
379
)
380
380
381
+ declare_mlir_dialect_python_bindings (
382
+ ADD_TO_PARENT MLIRPythonSources.Dialects
383
+ ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR} /mlir"
384
+ TD_FILE dialects/SPIRVOps.td
385
+ SOURCES dialects/spirv.py
386
+ DIALECT_NAME spirv )
387
+
381
388
declare_mlir_dialect_python_bindings (
382
389
ADD_TO_PARENT MLIRPythonSources.Dialects
383
390
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR} /mlir"
Original file line number Diff line number Diff line change
1
+ //===-- SPIRVOps.td - Entry point for SPIRVOps bind --------*- tablegen -*-===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #ifndef PYTHON_BINDINGS_SPIRV_OPS
10
+ #define PYTHON_BINDINGS_SPIRV_OPS
11
+
12
+ include "mlir/Dialect/SPIRV/IR/SPIRVOps.td"
13
+
14
+ #endif
Original file line number Diff line number Diff line change
1
+ # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2
+ # See https://llvm.org/LICENSE.txt for license information.
3
+ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
+
5
+ from ._spirv_ops_gen import *
Original file line number Diff line number Diff line change
1
+ # RUN: %PYTHON %s | FileCheck %s
2
+
3
+ from mlir .ir import *
4
+ import mlir .dialects .spirv as spirv
5
+
6
+
7
+ def run (f ):
8
+ print ("\n TEST:" , f .__name__ )
9
+ f ()
10
+
11
+
12
+ # CHECK-LABEL: TEST: testConstantOp
13
+ @run
14
+ def testConstantOps ():
15
+ with Context () as ctx , Location .unknown ():
16
+ module = Module .create ()
17
+ with InsertionPoint (module .body ):
18
+ i32 = IntegerType .get_signless (32 )
19
+ spirv .ConstantOp (value = IntegerAttr .get (i32 , 42 ), constant = i32 )
20
+ # CHECK: spirv.Constant 42 : i32
21
+ print (module )
You can’t perform that action at this time.
0 commit comments