1 //===- Utils.h - Utilities to support the Tensor dialect -------*- 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 9 #ifndef MLIR_DIALECT_TENSOR_UTILS_UTILS_H_ 10 #define MLIR_DIALECT_TENSOR_UTILS_UTILS_H_ 11 12 #include "mlir/Dialect/Tensor/IR/Tensor.h" 13 14 namespace mlir { 15 namespace tensor { 16 17 // Return a PadOp that pads `source` to `type` size where the static 18 // sizes are assumed to be greater than the dynamic sizes. If `type` has dynamic 19 // dimensions the padding width is set to zero. The op performs "high" padding 20 // (i.e. it adds trailing padding values until the desired size is met). 21 PadOp createPadHighOp(RankedTensorType type, Value source, Value pad, 22 bool nofold, Location loc, OpBuilder &builder); 23 24 // Return a PadOp that pads `source to `type` size with `pad` value. 25 // I.e., a block will be created and the `pad` value will be yielded 26 // directly. If the type passed is nullptr, it is inferred. 27 PadOp createPadScalarOp(Type type, Value source, Value pad, 28 ArrayRef<OpFoldResult> low, ArrayRef<OpFoldResult> high, 29 bool nofold, Location loc, OpBuilder &builder); 30 31 // Creates dim ops for each dynamic dimension of the raked tensor argument and 32 // returns these as values. 33 SmallVector<Value> createDynamicDimValues(OpBuilder &b, Location loc, 34 Value rankedTensor); 35 36 } // namespace tensor 37 } // namespace mlir 38 39 #endif // MLIR_DIALECT_TENSOR_UTILS_UTILS_H_ 40