Files
clang-p2996/mlir/include/mlir/IR/TensorEncoding.td
Aart Bik 23c9e8bc25 [mlir][tensors] Introduce attribute interface/attribute for tensor encoding
The new "encoding" field in tensor types so far had no meaning. This revision introduces:

1. an encoding attribute interface in IR: for verification between tensors and encodings in general
2. an attribute in Tensor dialect; #tensor.sparse<dict> + concrete sparse tensors API

Active discussion:
https://llvm.discourse.group/t/rfc-introduce-a-sparse-tensor-type-to-core-mlir/2944/

Reviewed By: silvas, penpornk, bixia

Differential Revision: https://reviews.llvm.org/D101008
2021-04-26 18:31:54 -07:00

45 lines
1.5 KiB
TableGen

//===- TensorEncoding.td - Tensor encoding interfaces ------*- tablegen -*-===//
//
// Part of the LLVM Project, 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
//
//===----------------------------------------------------------------------===//
//
// Defines the interfaces associated with tensor encoding attributes.
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_IR_TENSORINTERFACES
#define MLIR_IR_TENSORINTERFACES
include "mlir/IR/OpBase.td"
//===----------------------------------------------------------------------===//
// Attribute interface to verify a tensor encoding.
//===----------------------------------------------------------------------===//
def VerifiableTensorEncoding : AttrInterface<"VerifiableTensorEncoding"> {
let cppNamespace = "::mlir";
let description = [{
Verifies an encoding attribute for a tensor.
}];
let methods = [
InterfaceMethod<
/*desc=*/[{
Verifies the encoding is valid for a tensor type with the
given shape and element type. Generates a diagnostic using
the supplied callback on failure.
}],
/*retTy=*/"::mlir::LogicalResult",
/*methodName=*/"verifyEncoding",
/*args=*/(ins
"ArrayRef<int64_t>":$shape,
"Type":$elementType,
"::llvm::function_ref<::mlir::InFlightDiagnostic()>":$emitError)
>,
];
}
#endif // MLIR_IR_TENSORINTERFACES