def apply(self, model): streamline_transformations = [ ConvertSubToAdd(), ConvertDivToMul(), BatchNormToAffine(), ConvertSignToThres(), MoveMulPastMaxPool(), MoveScalarLinearPastInvariants(), AbsorbSignBiasIntoMultiThreshold(), MoveAddPastMul(), MoveScalarAddPastMatMul(), MoveAddPastConv(), MoveScalarMulPastMatMul(), MoveScalarMulPastConv(), MoveAddPastMul(), CollapseRepeatedAdd(), CollapseRepeatedMul(), MoveMulPastMaxPool(), AbsorbAddIntoMultiThreshold(), FactorOutMulSignMagnitude(), AbsorbMulIntoMultiThreshold(), Absorb1BitMulIntoMatMul(), Absorb1BitMulIntoConv(), RoundAndClipThresholds(), ] for trn in streamline_transformations: model = model.transform(trn) model = model.transform(RemoveIdentityOps()) model = model.transform(GiveUniqueNodeNames()) model = model.transform(GiveReadableTensorNames()) model = model.transform(InferDataTypes()) return (model, False)
def step_resnet50_streamline_linear(model: ModelWrapper, cfg: DataflowBuildConfig): streamline_transformations = [ AbsorbScalarMulAddIntoTopK( ), # before MoveAddPastMul to avoid int->float ConvertSubToAdd(), ConvertDivToMul(), RemoveIdentityOps(), CollapseRepeatedMul(), BatchNormToAffine(), ConvertSignToThres(), MoveAddPastMul(), MoveScalarAddPastMatMul(), MoveAddPastConv(), MoveScalarMulPastMatMul(), MoveScalarMulPastConv(), MoveScalarLinearPastInvariants(), MoveAddPastMul(), CollapseRepeatedAdd(), CollapseRepeatedMul(), AbsorbAddIntoMultiThreshold(), FactorOutMulSignMagnitude(), MoveMaxPoolPastMultiThreshold(), AbsorbMulIntoMultiThreshold(), Absorb1BitMulIntoMatMul(), Absorb1BitMulIntoConv(), RoundAndClipThresholds(), ] for trn in streamline_transformations: model = model.transform(trn) model = model.transform(GiveUniqueNodeNames()) return model