xref: /llvm-project/mlir/include/mlir/IR/TensorEncoding.td (revision db791b278a414fb6df1acc1799adcf11d8fb9169)
1//===- TensorEncoding.td - Tensor encoding interfaces ------*- 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// Defines the interfaces associated with tensor encoding attributes.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef MLIR_IR_TENSORINTERFACES
14#define MLIR_IR_TENSORINTERFACES
15
16include "mlir/IR/OpBase.td"
17
18//===----------------------------------------------------------------------===//
19// Attribute interface to verify a tensor encoding.
20//===----------------------------------------------------------------------===//
21
22def VerifiableTensorEncoding : AttrInterface<"VerifiableTensorEncoding"> {
23  let cppNamespace = "::mlir";
24  let description = [{
25    Verifies an encoding attribute for a tensor.
26  }];
27  let methods = [
28    InterfaceMethod<
29      /*desc=*/[{
30        Verifies the encoding is valid for a tensor type with the
31        given shape and element type. Generates a diagnostic using
32        the supplied callback on failure.
33      }],
34      /*retTy=*/"::llvm::LogicalResult",
35      /*methodName=*/"verifyEncoding",
36      /*args=*/(ins
37        "::mlir::ArrayRef<int64_t>":$shape,
38        "::mlir::Type":$elementType,
39        "::llvm::function_ref<::mlir::InFlightDiagnostic()>":$emitError)
40    >,
41  ];
42}
43
44#endif // MLIR_IR_TENSORINTERFACES
45