Skip to content

Commit d7aaf99

Browse files
eigen-kfacebook-github-bot
authored andcommitted
Use cadence replace ops passes in turing partitioner.
Summary: Jarvis&Helios passes unification. Context: https://docs.google.com/document/d/1v3B-0ngdeEx0VoI8pAKovqeLkkByMM6hFBqtOzBboOw/edit?usp=sharing Differential Revision: D78701343
1 parent 8f062d3 commit d7aaf99

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

backends/cadence/aot/replace_ops.py

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,47 +2407,52 @@ def call_operator(self, op, args, kwargs, meta):
24072407
)
24082408

24092409

2410-
# This class encapsulates all the functions that replace/switch one op in the
2411-
# graph with another.
2412-
class CadenceReplaceOpsInGraph:
2410+
# Encapsulates the generic graph improvement passes.
2411+
class GenericReplaceOpsInGraph:
24132412
passes = [
2414-
ReplaceEmptyTensorsWithFullPass,
2415-
ReplaceFunctionallyEquivalentOpTargets,
2413+
ReplaceSqueezeAndUnsqueezeWithViewPass,
2414+
ReplaceSplitWithSlicePass,
2415+
ReplaceSelectWithViewOpPass,
2416+
ReplaceMMWithAddMMPass,
2417+
ReplaceRepeatWithCatPass,
2418+
ReplaceFullLikeWithFullPass,
2419+
ReplaceFunctionallyEquivalentOpTargets,
2420+
ReplaceConvolutionOptionalArgsWithConcreteArgsPass,
2421+
ReplaceAddMMWithLinearPass,
2422+
ReplacePadWithCatPass,
2423+
ReplaceConstantPadNdWithSlicePass,
2424+
ReplaceTrivialConvWithLinear,
2425+
ReplaceScalarTensorWithFullPass,
2426+
ReplaceInfArgInFullWithValuePass,
2427+
ReplaceLogicalNotBooleanWhereWithWherePass,
2428+
ReplaceAdaptiveAvgPoolWithAtenAvgPoolPass,
2429+
ReplaceAtenApproxGeluWithApproxGeluPass,
2430+
ReplaceAtenConvolutionWithJarvisConvolutionPass,
2431+
ReplacePT2QuantWithCadenceQuantPass,
2432+
ReplacePT2DequantWithCadenceDequantPass,
2433+
ReplacePowWithMulPass,
2434+
ReplaceEmptyTensorsWithFullPass,
2435+
ReplaceScalarWithTensorArgPass,
2436+
RemoveNopSelectOpPass,
2437+
ReplaceNopTransposeOrPermuteWithViewPass,
2438+
]
2439+
2440+
# Encapsulates all the passes which replace ops in graph including Sadence specific ones.
2441+
class CadenceReplaceOpsInGraph:
2442+
cadence_specific_passes = [
24162443
ReplacePermuteWithTransposePass,
2417-
ReplaceScalarWithTensorArgPass,
2418-
ReplaceConvolutionOptionalArgsWithConcreteArgsPass,
2419-
ReplaceMMWithAddMMPass,
2420-
ReplaceSqueezeAndUnsqueezeWithViewPass,
2421-
ReplaceAddMMWithLinearPass,
2422-
RemoveNopSelectOpPass,
2423-
ReplaceSelectWithViewOpPass,
2424-
ReplaceRepeatWithCatPass,
24252444
ReplacePadWithCatPass,
2426-
ReplaceConstantPadNdWithSlicePass,
24272445
ReplaceConvWithChannelLastConvPass,
2428-
ReplaceAtenConvolutionWithJarvisConvolutionPass,
24292446
ForceChannelLastForConvPass,
2430-
ReplaceTrivialConvWithLinear,
24312447
ReplaceConvWithIm2RowAndLinear,
24322448
ReplaceTransposedConvWithLinearPass,
24332449
# This pass should be after passes that replace conv -> im2row + linear.
24342450
ReplaceIm2RowWithViewPass,
24352451
MakeSliceAndCatDimOutermostPass,
24362452
ReplaceMatmulWithTransposedMatmulPass,
2437-
ReplaceNopTransposeOrPermuteWithViewPass,
24382453
ReplaceLinearWithFullyConnectedOpPass,
2439-
ReplaceScalarTensorWithFullPass,
2440-
ReplaceFullLikeWithFullPass,
2441-
ReplaceInfArgInFullWithValuePass,
2442-
ReplaceLogicalNotBooleanWhereWithWherePass,
2443-
ReplacePT2QuantWithCadenceQuantPass,
2444-
ReplacePT2DequantWithCadenceDequantPass,
24452454
ReplaceSingleElementTensorArgumentsFromFullOpWithScalarPass,
2446-
ReplaceAdaptiveAvgPoolWithAtenAvgPoolPass,
24472455
ReplaceAtenAvgPoolWithJarvisAvgPoolPass,
24482456
ReplaceWhereWithFullArgsWithWhereScalar,
2449-
ReplaceAtenApproxGeluWithApproxGeluPass,
2450-
ReplaceSplitWithSlicePass,
2451-
ReplacePowWithMulPass,
2452-
ReplaceMulTensorWithMulAndFullOpsPass,
24532457
]
2458+
passes = GenericReplaceOpsInGraph.passes + cadence_specific_passes

0 commit comments

Comments
 (0)