#include "mlir/Conversion/TosaToTensor/TosaToTensor.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Tensor/Utils/Utils.h"
#include "mlir/Dialect/Tosa/IR/TosaOps.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Transforms/DialectConversion.h"
#include <numeric>
usingnamespacemlir;
usingnamespacetosa;
namespace {
TensorType inferReshapeInputType(TypedValue<TensorType> input,
ArrayRef<int64_t> newShape) { … }
TensorType inferReshapeExpandedType(TensorType inputType,
ArrayRef<int64_t> newShape) { … }
TensorType inferReshapeCollapsedType(TensorType lhsType, TensorType rhsType) { … }
SmallVector<ReassociationExprs>
createReassociationMapForCollapse(OpBuilder &builder, Type srcType, Type dstType) { … }
Value createCollapse(OpBuilder &builder, Location loc, TensorType resultType,
Value input) { … }
Value createExpand(OpBuilder &builder, Location loc, TensorType resultType,
Value input) { … }
class ReshapeConverter : public OpConversionPattern<tosa::ReshapeOp> { … };
class SliceConverter : public OpConversionPattern<tosa::SliceOp> { … };
class PadConverter : public OpConversionPattern<tosa::PadOp> { … };
struct ConcatConverter : public OpConversionPattern<tosa::ConcatOp> { … };
}
void mlir::tosa::populateTosaToTensorConversionPatterns(
TypeConverter &converter, RewritePatternSet *patterns) { … }