Skip to content

Commit

Permalink
Remove SimplifyForDimension cache
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnycase committed Mar 6, 2025
1 parent b39a7bd commit cbf77b8
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/Nncase.Passes/SimplifyProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ internal sealed class SimplifyProvider : ISimplifyProvider
{
private readonly CompileSession _compileSession;
private readonly IRewriteRule[] _rules;
private readonly ConditionalWeakTable<Expr, Expr> _simplifiedExprs = new();

public SimplifyProvider()
{
Expand All @@ -73,21 +72,15 @@ public Expr SimplifyForDimension(Expr expr)
#if true
if (expr.CheckedType is DistributedType || expr is not (Const or Var))
{
if (!_simplifiedExprs.TryGetValue(expr, out var simplifiedExpr))
var simplifiedExpr = expr;
if (expr.CheckedType is DistributedType)
{
simplifiedExpr = expr;
if (expr.CheckedType is DistributedType)
{
simplifiedExpr = new RemoveBoxingCloner().Clone(expr, default);
}

using var compileScope = new CompileSessionScope(CompileSessionScope.Current ?? _compileSession);
using var dumpScope = new DumpScope(NullDumpper.Instance);
simplifiedExpr = CompilerServices.Rewrite(simplifiedExpr, _rules, new RunPassContext());
_simplifiedExprs.Add(expr, simplifiedExpr);
_simplifiedExprs.TryAdd(simplifiedExpr, simplifiedExpr);
simplifiedExpr = new RemoveBoxingCloner().Clone(expr, default);
}

using var compileScope = new CompileSessionScope(CompileSessionScope.Current ?? _compileSession);
using var dumpScope = new DumpScope(NullDumpper.Instance);
simplifiedExpr = CompilerServices.Rewrite(simplifiedExpr, _rules, new RunPassContext());
return simplifiedExpr;
}

Expand Down

0 comments on commit cbf77b8

Please sign in to comment.