|
| 1 | +/* |
| 2 | + * Copyright (c) 2026 Samsung Electronics Co., Ltd. All Rights Reserved |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +#ifndef __CIRCLE_MLIR_PASS_OPS_SIGN_OP_H__ |
| 18 | +#define __CIRCLE_MLIR_PASS_OPS_SIGN_OP_H__ |
| 19 | + |
| 20 | +#include <circle-mlir/dialect/CircleDialect.h> |
| 21 | + |
| 22 | +#include "ConvertHelper.h" |
| 23 | + |
| 24 | +#include <mlir/Transforms/DialectConversion.h> |
| 25 | + |
| 26 | +#include <src/Dialect/ONNX/ONNXOps.hpp> |
| 27 | + |
| 28 | +namespace mlir |
| 29 | +{ |
| 30 | +namespace Circle |
| 31 | +{ |
| 32 | + |
| 33 | +class ConvSign : public mlir::OpConversionPattern<mlir::ONNXSignOp> |
| 34 | +{ |
| 35 | +public: |
| 36 | + using mlir::OpConversionPattern<mlir::ONNXSignOp>::OpConversionPattern; |
| 37 | + using OpAdaptor = typename mlir::ONNXSignOp::Adaptor; |
| 38 | + |
| 39 | + mlir::LogicalResult matchAndRewrite(mlir::ONNXSignOp op, OpAdaptor adaptor, |
| 40 | + mlir::ConversionPatternRewriter &rewriter) const override |
| 41 | + { |
| 42 | + mlir::Value input = adaptor.getInput(); |
| 43 | + |
| 44 | + rewriter.replaceOpWithNewOp<SignOp>(op, op.getType(), input); |
| 45 | + |
| 46 | + return mlir::success(); |
| 47 | + } |
| 48 | +}; |
| 49 | + |
| 50 | +} // namespace Circle |
| 51 | +} // namespace mlir |
| 52 | + |
| 53 | +#endif // __CIRCLE_MLIR_PASS_OPS_SIGN_OP_H__ |
0 commit comments