[TOSA] Add aten.le.tensor support (#2033)

revert-1980-tanyo/update-llvm-tag
Chi_Liu 2023-04-14 08:43:14 -07:00 committed by GitHub
parent 318fe13468
commit ad36e61040
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -741,6 +741,10 @@ TOSA_PASS_SET = {
"HardsigmoidRandomModule_basic",
"HardswishModule_basic",
"HardswishRandomModule_basic",
"BucketizeTensorStaticFloatModule_basic",
"BucketizeTensorStaticModule_basic",
"ElementwiseLeFloatTensorModule_basic",
"ElementwiseLeIntTensorModule_basic",
"FullLikeModuleInt2DStatic_basic",
"FullModuleInt3D_basic",
"FullModuleFloat2D_basic",

View File

@ -3581,6 +3581,32 @@ LogicalResult ConvertAtenOp<AtenWhereSelfOp>::matchAndRewrite(
return success();
}
template <>
LogicalResult ConvertAtenOp<AtenLeTensorOp>::matchAndRewrite(
AtenLeTensorOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const {
// Not a tensor type.
auto selfType = adaptor.getSelf().getType().dyn_cast<TensorType>();
if (!selfType)
return rewriter.notifyMatchFailure(
op, "Only tensor types input are currently supported");
auto otherType = adaptor.getOther().getType().dyn_cast<TensorType>();
if (!otherType)
return rewriter.notifyMatchFailure(
op, "Only tensor types condition are currently supported");
auto outType = getTypeConverter()->convertType(op.getType());
auto greaterOp = rewriter.create<tosa::GreaterOp>(
op.getLoc(), outType, adaptor.getSelf(), adaptor.getOther());
rewriter.replaceOpWithNewOp<tosa::LogicalNotOp>(op, outType,
greaterOp.getOutput());
return success();
}
template <>
LogicalResult ConvertAtenOp<AtenClampOp>::matchAndRewrite(
AtenClampOp op, OpAdaptor adaptor,
@ -4663,6 +4689,7 @@ public:
INSERT_ATENOP_PATTERN(AtenGatherOp);
INSERT_ATENOP_PATTERN(AtenIndexTensorOp);
INSERT_ATENOP_PATTERN(AtenWhereSelfOp);
INSERT_ATENOP_PATTERN(AtenLeTensorOp);
INSERT_ATENOP_PATTERN(AtenClampOp);
INSERT_ATENOP_PATTERN(AtenArangeStartStepOp);
INSERT_ATENOP_PATTERN(PrimNumToTensorScalarOp);