mirror of https://github.com/kendryte/nncase.git
67 lines
1.7 KiB
Plaintext
67 lines
1.7 KiB
Plaintext
<#@ template debug="false" hostspecific="false" language="C#" #>
|
|
<#@ assembly name="System.Core" #>
|
|
<#@ import namespace="System.IO" #>
|
|
<#@ import namespace="System.Linq" #>
|
|
<#@ import namespace="System.Text" #>
|
|
<#@ import namespace="System.Collections.Generic" #>
|
|
<#@ output extension=".cs" #>
|
|
<#@ include file="IRListParser.tt"#>
|
|
//---------------------------------------------------------------------------------------------------
|
|
// <auto-generated>
|
|
// This code was generated by T4 template.
|
|
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
|
|
// </auto-generated>
|
|
//---------------------------------------------------------------------------------------------------
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reactive;
|
|
|
|
namespace Nncase.IR;
|
|
|
|
public partial class ExprCloner<TContext>
|
|
{
|
|
<#
|
|
foreach (var ir in irs.Where(x => x.IsDerived))
|
|
{
|
|
#>
|
|
/// <inheritdoc />
|
|
protected override Expr VisitLeaf<#=ir.Name#>(<#=ir.Namespace#><#=ir.Name#> expr, TContext context)
|
|
{
|
|
<#
|
|
if (ir.IsFunction)
|
|
{
|
|
#>
|
|
if (!CanVisitFunctionBody(expr))
|
|
{
|
|
return expr;
|
|
}
|
|
|
|
<#
|
|
}
|
|
#>
|
|
return expr.With(
|
|
<#
|
|
for (int i = 0; i < ir.Fields.Length; i++)
|
|
{
|
|
var field = ir.Fields[i];
|
|
var func = field.StartsWith("@") ? "CloneArray" : "Clone";
|
|
var fieldName = field.TrimStart('@');
|
|
var paramName = $"{char.ToLowerInvariant(fieldName[0])}{fieldName.Substring(1)}";
|
|
if (paramName == "else")
|
|
{
|
|
paramName = "@" + paramName;
|
|
}
|
|
#>
|
|
<#=paramName#>: <#=func#>(expr.<#=fieldName#>, context)<#=i == ir.Fields.Length - 1 ? string.Empty : ","#>
|
|
<#
|
|
}
|
|
#>
|
|
);
|
|
}
|
|
|
|
<#
|
|
}
|
|
#>
|
|
}
|