-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* no module constrain for fusion eval * fix external data larger than 2GB * power of 2 to square * change buffer size from int to long
- Loading branch information
Showing
9 changed files
with
91 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Canaan Inc. All rights reserved. | ||
// Licensed under the Apache license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Linq; | ||
using Nncase.IR; | ||
using Nncase.IR.Math; | ||
using Nncase.IR.Tensors; | ||
using Nncase.PatternMatch; | ||
using static Nncase.IR.F.Math; | ||
using static Nncase.IR.TypePatternUtility; | ||
using static Nncase.PatternMatch.F.Math; | ||
using static Nncase.PatternMatch.F.NN; | ||
using static Nncase.PatternMatch.Utility; | ||
|
||
namespace Nncase.Passes.Rules.Neutral; | ||
|
||
[RuleGenerator] | ||
public sealed partial class PowOf2ToSquare : RewriteRule<CallPattern> | ||
{ | ||
/// <inheritdoc/> | ||
public override CallPattern Pattern { get; } = | ||
IsBinary( | ||
"pow", | ||
"call", | ||
p => p.BinaryOp is BinaryOp.Pow, | ||
IsWildcard("input"), | ||
IsTensorConst("power")); | ||
|
||
private Expr? GetReplace(Expr input, TensorConst power) | ||
{ | ||
if (power.Value.ToArray<float>().All(x => x == 2)) | ||
{ | ||
return Unary(UnaryOp.Square, input); | ||
} | ||
|
||
return null; | ||
} | ||
} |