Skip to content

Commit

Permalink
Merge branch 'master' into fix-range-of-marker
Browse files Browse the repository at this point in the history
  • Loading branch information
FusionBolt authored Aug 21, 2023
2 parents a290500 + 5f64821 commit 280b6cf
Show file tree
Hide file tree
Showing 197 changed files with 7,095 additions and 2,311 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Canaan Inc. All rights reserved.
// Licensed under the Apache license. See LICENSE file in the project root for full license information.
/* This file is generated by tools/stackvm_gen/IsaGen at 2023/7/12 15:04:16 +08:00. */
/* This file is generated by tools/stackvm_gen/IsaGen at 2023/7/12 17:07:39 +08:00. */

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -262,6 +262,18 @@ private void EmitTensorCall(Op op)
case IR.Tensors.Where top:
Emitter.T.Where(top.IsTfWhere);
break;
case IR.ShapeExpr.BroadcastShape top:
Emitter.T.BroadcastShape();
break;
case IR.ShapeExpr.Conv2DShape top:
Emitter.T.Conv2DShape();
break;
case IR.ShapeExpr.Conv2DTransposeShape top:
Emitter.T.Conv2DTransposeShape();
break;
case IR.ShapeExpr.MatMulShape top:
Emitter.T.MatMulShape();
break;
case IR.Random.Normal top:
Emitter.T.Normal(top.Type);
break;
Expand Down
11 changes: 6 additions & 5 deletions modules/Nncase.Modules.StackVM/CodeGen/StackVM/CodegenVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ internal partial class CodeGenVisitor : ExprVisitor<TextSnippet, IRType>

private readonly BaseFunction _function;
private readonly CodeGenContext _context;
private readonly HashSet<TextSnippet> _refTextSnippets = new();
private readonly List<TextSnippet> _refTextSnippets = new();

private TextSnippet? _currentTextSnippet;
private BasicBlock? _currentBasicBlock;
Expand All @@ -172,7 +172,7 @@ public CodeGenVisitor(BaseFunction function, CodeGenContext context)

private StackVMEmitter Emitter => CurrentTextSnippet.Emitter;

public (BasicBlock BB, HashSet<TextSnippet> SnippetSet) SubBlock(Expr expr)
public (BasicBlock BB, List<TextSnippet> SnippetSet) SubBlock(Expr expr)
{
var visitor = new CodeGenVisitor(_function, _context);
var subBlockFirst = visitor.CurrentBasicBlock;
Expand All @@ -185,7 +185,8 @@ public CodeGenVisitor(BaseFunction function, CodeGenContext context)

visitor.Visit(expr);
var refTextSnippets = visitor._refTextSnippets;
return (subBlockFirst, refTextSnippets);
var subBlockEnd = visitor.CurrentBasicBlock;
return (subBlockEnd, refTextSnippets);
}

protected override TextSnippet VisitLeafConst(Const expr)
Expand Down Expand Up @@ -389,9 +390,9 @@ protected override TextSnippet VisitLeafIf(If @if)
return endSnippet;
}

private void MergeSnippetSet(HashSet<TextSnippet> thenSet, HashSet<TextSnippet> elseSet, TextSnippet endSnippet)
private void MergeSnippetSet(List<TextSnippet> thenSet, List<TextSnippet> elseSet, TextSnippet endSnippet)
{
var useSnippetSet = thenSet.Union(elseSet).ToHashSet();
var useSnippetSet = thenSet.Concat(elseSet).ToHashSet();
foreach (var snippet in useSnippetSet)
{
snippet.AddUseCount();
Expand Down
Loading

0 comments on commit 280b6cf

Please sign in to comment.