Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GNNE-1891 Shape bucket opt #1040

Merged
merged 110 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
52eac73
kernel opt
FusionBolt Jun 26, 2023
7b8059a
ShapeBucket opt
FusionBolt Jun 26, 2023
9953a0d
remove unused
FusionBolt Jun 26, 2023
b9dcc97
Fix GetItem
FusionBolt Jun 27, 2023
eb5508f
update Compiler.cs
FusionBolt Jun 27, 2023
0abcdbf
add BucketFusionGroupMutator
FusionBolt Jun 27, 2023
8dbd6d5
fix build
FusionBolt Jun 27, 2023
df52a39
close topk
FusionBolt Jun 27, 2023
0b650c2
resolve merge
FusionBolt Jun 27, 2023
02cec27
Apply code-format changes
FusionBolt Jun 27, 2023
d5d74bb
fix FoldGetItem
FusionBolt Jun 28, 2023
1a09c50
resolve review
FusionBolt Jun 28, 2023
a08e012
Apply code-format changes
FusionBolt Jun 28, 2023
3e3fa6c
Merge branch 'master' into dynamic-opt
FusionBolt Jun 29, 2023
a447b67
Merge branch 'master' into dynamic-opt
FusionBolt Jun 29, 2023
27dd9a8
add op for compute shape
FusionBolt Jun 30, 2023
99aeb55
Refactor MergePrevCall and support multi input prev
FusionBolt Jul 3, 2023
b3cf8d2
add MergePrevCall Test
FusionBolt Jul 3, 2023
2fe03dc
fix bug for MergePrevCall
FusionBolt Jul 4, 2023
9743d3f
fix TestMergeStackWithConstant
FusionBolt Jul 4, 2023
1142a1b
add DupVar eliminate
FusionBolt Jul 5, 2023
41ab9eb
fix MergePrev
FusionBolt Jul 5, 2023
131af73
Merge branch 'master' into dynamic-opt
FusionBolt Jul 5, 2023
39c775d
update compiler.cs
FusionBolt Jul 5, 2023
afbcc66
dotnet format
FusionBolt Jul 5, 2023
3ff4981
fix build
FusionBolt Jul 5, 2023
ee0f849
Merge remote-tracking branch 'origin/dynamic-opt' into ir-shape-expr
FusionBolt Jul 5, 2023
0b18676
fix shape evaluator
FusionBolt Jul 7, 2023
3ded9a5
move rule file and add some new rule
FusionBolt Jul 7, 2023
74bcdc1
add lost helper method
FusionBolt Jul 7, 2023
f4a0145
fix marker
FusionBolt Jul 7, 2023
dfb4ddf
add MergeMultiUserFusion
FusionBolt Jul 7, 2023
d699919
pass TestHasSameInput
FusionBolt Jul 10, 2023
3319a72
passs TestComplexExpr
FusionBolt Jul 10, 2023
aa13c18
fix MergePrevCall marker
FusionBolt Jul 11, 2023
ecb69a7
fix shape expr
FusionBolt Jul 12, 2023
b78bdd2
add trilu support
FusionBolt Jul 12, 2023
a5ed82e
add ring limit for MergeFusion
FusionBolt Jul 12, 2023
a2ab3f4
Merge branch 'feature/trilu' into ir-shape-expr
FusionBolt Jul 12, 2023
fdaf38c
fix build
FusionBolt Jul 12, 2023
00fb05e
fix reduce shape expr and slice infer
FusionBolt Jul 12, 2023
ba507c1
isa gen
FusionBolt Jul 12, 2023
17088d0
add multi user call to fusion
FusionBolt Jul 14, 2023
cfd2703
fix for ring
FusionBolt Jul 17, 2023
e827510
add merge tuple fusion
FusionBolt Jul 17, 2023
236b26a
update
FusionBolt Jul 18, 2023
bd8647b
support multiuser getItem + fusion
FusionBolt Jul 18, 2023
fa09fba
pass TestGetItemWithRing
FusionBolt Jul 19, 2023
7744326
fix CallToFusion when input is tuple
FusionBolt Jul 19, 2023
9cc9eb6
fix MergeUserWithSameInput
FusionBolt Jul 20, 2023
95afd05
add ReshapeMatMul
FusionBolt Jul 20, 2023
7d82572
Merge remote-tracking branch 'origin/master' into ir-shape-expr
FusionBolt Jul 20, 2023
b055fcf
Apply code-format changes
FusionBolt Jul 20, 2023
93c50fa
Merge remote-tracking branch 'origin/reshape-matmul' into ir-shape-expr
FusionBolt Jul 20, 2023
6ed2146
fix ConcatToFusion when tuple has constant
FusionBolt Jul 20, 2023
a613ef9
Merge remote-tracking branch 'origin/master' into feature/trilu
FusionBolt Jul 24, 2023
43aec09
add trilu test
FusionBolt Jul 24, 2023
91b65b7
fix evaluator
FusionBolt Jul 24, 2023
cd256f7
Apply code-format changes
FusionBolt Jul 24, 2023
ed240bf
fix type infer
FusionBolt Jul 24, 2023
d74300b
update compiler.cs
FusionBolt Jul 24, 2023
7f4f168
Apply code-format changes
FusionBolt Jul 24, 2023
c899a0c
add some check
FusionBolt Jul 24, 2023
68c9b59
fix nest if in then
FusionBolt Jul 24, 2023
cf0d8ed
Merge remote-tracking branch 'origin/feature/trilu' into ir-shape-expr
FusionBolt Jul 24, 2023
b0d88e2
remove print for fix nest if in then
FusionBolt Jul 24, 2023
7485a8f
fix MergeNext multi user
FusionBolt Jul 25, 2023
d19bef5
add Range ShapeExpr
FusionBolt Jul 25, 2023
79479ca
fix TestTupleGetItemUsersLargeThanOutputs
FusionBolt Jul 27, 2023
fc17a5f
fix dup call and target
FusionBolt Jul 27, 2023
91a7a0e
fix TestTupleGetItemOutputIsSingle
FusionBolt Jul 28, 2023
513264f
fix ShapeEvaluatorContent
FusionBolt Jul 28, 2023
2f4ec00
add checker and fix for const
FusionBolt Jul 28, 2023
da297bd
add more check
FusionBolt Jul 28, 2023
32e21f1
Merge remote-tracking branch 'origin/master' into ir-shape-expr
FusionBolt Jul 28, 2023
4073596
rebuild dynamic bucket body
FusionBolt Jul 31, 2023
6dc4493
refactor ShapeBucket
FusionBolt Jul 31, 2023
37302c9
add ShapeExprCache
FusionBolt Jul 31, 2023
a064750
Merge remote-tracking branch 'origin/shape-bucket-opt' into ir-shape-…
FusionBolt Aug 1, 2023
a3357d5
fix merge
FusionBolt Aug 1, 2023
2ce6344
add IMetricEvaluator
FusionBolt Aug 1, 2023
353bf61
add test for ShapeExprCache and FusionBucket Rebuild
FusionBolt Aug 1, 2023
8a4fe0b
fix cache
FusionBolt Aug 1, 2023
8a22585
add broadcast marker
FusionBolt Aug 1, 2023
f851fc2
Merge remote-tracking branch 'origin/broadcast-marker' into ir-shape-…
FusionBolt Aug 1, 2023
470e6dd
add TfConv2DTransposeToFusion
FusionBolt Aug 2, 2023
54d4c1b
fix TfCon2DTransposeToFusion and add simplify for bucket
FusionBolt Aug 4, 2023
8e02c65
fix rebuild
FusionBolt Aug 7, 2023
1e63230
fix shape expr
FusionBolt Aug 7, 2023
eacd360
fix
FusionBolt Aug 7, 2023
dff6ee3
fix infer and shape expr
FusionBolt Aug 7, 2023
0c9eb16
update
FusionBolt Aug 7, 2023
93c2001
Merger master
FusionBolt Aug 7, 2023
1925b52
fix tflite
FusionBolt Aug 7, 2023
6df6604
fix
FusionBolt Aug 7, 2023
eabe1dc
Apply code-format changes
FusionBolt Aug 7, 2023
264fa10
fix space to batch
FusionBolt Aug 7, 2023
8fa86d5
Apply code-format changes
FusionBolt Aug 7, 2023
49bc8a5
fix build
FusionBolt Aug 7, 2023
a803474
move test
FusionBolt Aug 7, 2023
4d0827b
fix test
FusionBolt Aug 7, 2023
300d52b
fix Compiler.cs
FusionBolt Aug 7, 2023
33b7faa
Apply code-format changes
FusionBolt Aug 7, 2023
4445eb0
Merge fix-tflite
FusionBolt Aug 7, 2023
a76b5ba
add lost file
FusionBolt Aug 7, 2023
a245c5d
simple review
FusionBolt Aug 7, 2023
6daa546
Apply code-format changes
FusionBolt Aug 7, 2023
aac9f6c
fix test
FusionBolt Aug 18, 2023
30dba0f
remove rebuild
FusionBolt Aug 18, 2023
4b59fd1
Merge branch 'master' into shape-bucket-opt
FusionBolt Aug 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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