Skip to content

Commit e95c198

Browse files
committed
[circle-mlir] Add pass for Sign operation
This introduces the sign operation pass. ONE-DCO-1.0-Signed-off-by: Seungho Henry Park <shs.park@samsung.com>
1 parent b339cd1 commit e95c198

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

circle-mlir/circle-mlir/lib/pass/src/ConvertONNXToCirclePass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#include "ops/ResizeOp.h"
7777
#include "ops/ShapeOp.h"
7878
#include "ops/SigmoidOp.h"
79+
#include "ops/SignOp.h"
7980
#include "ops/SinOp.h"
8081
#include "ops/SliceOp.h"
8182
#include "ops/SoftmaxOp.h"
@@ -265,6 +266,7 @@ void ConvertONNXToCirclePass::runOnOperation()
265266
patterns.insert<ConvResizeV13>(typeConverter, context);
266267
patterns.insert<ConvShape>(typeConverter, context);
267268
patterns.insert<ConvSigmoid>(typeConverter, context);
269+
patterns.insert<ConvSign>(typeConverter, context);
268270
patterns.insert<ConvSin>(typeConverter, context);
269271
patterns.insert<ConvSlice>(typeConverter, context);
270272
patterns.insert<ConvSoftmax>(typeConverter, context);
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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

Comments
 (0)