2022-07-21 07:18:16 +08:00
|
|
|
//===------------------------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
// Also available under a BSD-style license. See LICENSE.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef TORCHMLIR_LIB_CONVERSION_TORCHTOMHLO_POPULATEPATTERNS_H
|
|
|
|
#define TORCHMLIR_LIB_CONVERSION_TORCHTOMHLO_POPULATEPATTERNS_H
|
|
|
|
|
|
|
|
#include "mlir/Transforms/DialectConversion.h"
|
|
|
|
|
|
|
|
namespace mlir {
|
|
|
|
namespace torch {
|
|
|
|
namespace torch_to_mhlo {
|
|
|
|
|
2022-09-01 10:36:02 +08:00
|
|
|
struct TorchToMhloOptions {
|
|
|
|
bool enableStaticShape = false;
|
|
|
|
size_t dimSizeIndexBits = 64;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename AtenOpT>
|
|
|
|
class ConvertAtenOp : public OpConversionPattern<AtenOpT> {
|
|
|
|
public:
|
|
|
|
using OpAdaptor = typename AtenOpT::Adaptor;
|
|
|
|
ConvertAtenOp(TypeConverter &typeConverter, MLIRContext *context,
|
|
|
|
const TorchToMhloOptions &options)
|
|
|
|
: OpConversionPattern<AtenOpT>(typeConverter, context) {
|
|
|
|
this->options = options;
|
|
|
|
}
|
|
|
|
LogicalResult
|
|
|
|
matchAndRewrite(AtenOpT op, OpAdaptor adaptor,
|
|
|
|
ConversionPatternRewriter &rewriter) const override {
|
|
|
|
return rewriter.notifyMatchFailure(op, "haven't been implemented");
|
|
|
|
}
|
|
|
|
const TorchToMhloOptions &getOptions() const { return options; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
TorchToMhloOptions options;
|
|
|
|
};
|
|
|
|
|
2022-07-21 07:18:16 +08:00
|
|
|
void populateBasicOpPatternsAndLegality(TypeConverter &typeConverter,
|
|
|
|
RewritePatternSet &patterns,
|
2022-09-01 10:36:02 +08:00
|
|
|
ConversionTarget &target,
|
|
|
|
const TorchToMhloOptions &options);
|
2022-07-22 15:18:18 +08:00
|
|
|
void populateViewLikeOpPatternsAndLegality(TypeConverter &typeConverter,
|
|
|
|
RewritePatternSet &patterns,
|
2022-09-01 10:36:02 +08:00
|
|
|
ConversionTarget &target,
|
|
|
|
const TorchToMhloOptions &options);
|
2022-07-25 23:47:46 +08:00
|
|
|
void populateGatherOpPatternsAndLegality(TypeConverter &typeConverter,
|
|
|
|
RewritePatternSet &patterns,
|
2022-09-01 10:36:02 +08:00
|
|
|
ConversionTarget &target,
|
|
|
|
const TorchToMhloOptions &options);
|
2022-08-03 10:47:52 +08:00
|
|
|
void populateReductionOpPatternsAndLegality(TypeConverter &typeConverter,
|
2022-09-01 10:36:02 +08:00
|
|
|
RewritePatternSet &patterns,
|
|
|
|
ConversionTarget &target,
|
|
|
|
const TorchToMhloOptions &options);
|
2022-08-04 10:10:54 +08:00
|
|
|
void populateLinearOpPatternsAndLegality(TypeConverter &typeConverter,
|
|
|
|
RewritePatternSet &patterns,
|
2022-09-01 10:36:02 +08:00
|
|
|
ConversionTarget &target,
|
|
|
|
const TorchToMhloOptions &options);
|
2022-08-04 10:10:54 +08:00
|
|
|
|
2022-08-04 12:34:22 +08:00
|
|
|
void populatePoolingOpPatternsAndLegality(TypeConverter &typeConverter,
|
|
|
|
RewritePatternSet &patterns,
|
2022-09-01 10:36:02 +08:00
|
|
|
ConversionTarget &target,
|
|
|
|
const TorchToMhloOptions &options);
|
2022-08-04 12:34:22 +08:00
|
|
|
|
2022-07-21 07:18:16 +08:00
|
|
|
} // namespace torch_to_mhlo
|
|
|
|
} // namespace torch
|
|
|
|
} // namespace mlir
|
|
|
|
|
|
|
|
#endif // TORCHMLIR_LIB_CONVERSION_TORCHTOMHLO_POPULATEPATTERNS_H
|