1 //===- DecodeAttributesInterfaces.h - DecodeAttributes Interfaces -*- C++ -*-=//
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 #ifndef MLIR_INTERFACES_DECODEATTRIBUTESINTERFACES_H_
9 #define MLIR_INTERFACES_DECODEATTRIBUTESINTERFACES_H_
10 
11 #include "mlir/IR/BuiltinAttributes.h"
12 #include "mlir/IR/DialectInterface.h"
13 #include "mlir/Support/LogicalResult.h"
14 
15 namespace mlir {
16 
17 /// Define an interface to decode opaque constant tensor.
18 class DialectDecodeAttributesInterface
19     : public DialectInterface::Base<DialectDecodeAttributesInterface> {
20 public:
DialectDecodeAttributesInterface(Dialect * dialect)21   DialectDecodeAttributesInterface(Dialect *dialect) : Base(dialect) {}
22 
23   /// Registered hook to decode opaque constants associated with this
24   /// dialect. The hook function attempts to decode an opaque constant tensor
25   /// into a tensor with non-opaque content. If decoding is successful, this
26   /// method returns success() and sets 'output' attribute. If not, it returns
27   /// failure() and leaves 'output' unspecified. The default hook fails to
28   /// decode.
decode(OpaqueElementsAttr input,ElementsAttr & output)29   virtual LogicalResult decode(OpaqueElementsAttr input,
30                                ElementsAttr &output) const {
31     return failure();
32   }
33 };
34 
35 } // end namespace mlir
36 
37 #endif // MLIR_INTERFACES_DECODEATTRIBUTESINTERFACES_H_
38