//===- TypeUtilities.cpp - Helper function for type queries ---------------===// // // 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 // //===----------------------------------------------------------------------===// // // This file defines generic type utilities. // //===----------------------------------------------------------------------===// #include "mlir/IR/TypeUtilities.h" #include "mlir/IR/Attributes.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Types.h" #include "mlir/IR/Value.h" #include "llvm/ADT/SmallVectorExtras.h" #include <numeric> usingnamespacemlir; Type mlir::getElementTypeOrSelf(Type type) { … } Type mlir::getElementTypeOrSelf(Value val) { … } Type mlir::getElementTypeOrSelf(Attribute attr) { … } SmallVector<Type, 10> mlir::getFlattenedTypes(TupleType t) { … } /// Return true if the specified type is an opaque type with the specified /// dialect and typeData. bool mlir::isOpaqueTypeWithName(Type type, StringRef dialect, StringRef typeData) { … } /// Returns success if the given two shapes are compatible. That is, they have /// the same size and each pair of the elements are equal or one of them is /// dynamic. LogicalResult mlir::verifyCompatibleShape(ArrayRef<int64_t> shape1, ArrayRef<int64_t> shape2) { … } /// Returns success if the given two types have compatible shape. That is, /// they are both scalars (not shaped), or they are both shaped types and at /// least one is unranked or they have compatible dimensions. Dimensions are /// compatible if at least one is dynamic or both are equal. The element type /// does not matter. LogicalResult mlir::verifyCompatibleShape(Type type1, Type type2) { … } /// Returns success if the given two arrays have the same number of elements and /// each pair wise entries have compatible shape. LogicalResult mlir::verifyCompatibleShapes(TypeRange types1, TypeRange types2) { … } LogicalResult mlir::verifyCompatibleDims(ArrayRef<int64_t> dims) { … } /// Returns success if all given types have compatible shapes. That is, they are /// all scalars (not shaped), or they are all shaped types and any ranked shapes /// have compatible dimensions. Dimensions are compatible if all non-dynamic /// dims are equal. The element type does not matter. LogicalResult mlir::verifyCompatibleShapes(TypeRange types) { … } Type OperandElementTypeIterator::mapElement(Value value) const { … } Type ResultElementTypeIterator::mapElement(Value value) const { … } TypeRange mlir::insertTypesInto(TypeRange oldTypes, ArrayRef<unsigned> indices, TypeRange newTypes, SmallVectorImpl<Type> &storage) { … } TypeRange mlir::filterTypesOut(TypeRange types, const BitVector &indices, SmallVectorImpl<Type> &storage) { … }