示例#1
0
        public override Tensor Evaluate(Tensor writeTarget)
        {
            using (var s = src.Evaluate(null))
                using (var i = indices.Evaluate(null))
                {
                    if (!writeTarget.Equals(s))
                    {
                        Ops.Copy(writeTarget, s);
                    }
                    Ops.ScatterFill(writeTarget, value.Evaluate(), dimension, i);
                }

            return(writeTarget);
        }
示例#2
0
 public static SVar Lerp(SVar a, SVar b, SVar weight)
 {
     return(new SVar(new DelegateScalarExpression(() => LerpFloat(a.Evaluate(), b.Evaluate(), weight.Evaluate()))));
 }
示例#3
0
        // public TVar Pow(TVar y) { return new TVar(new BinaryScalarTensorExpression(this.Expression, y.Expression, Ops.Tpow)); }


        public static SVar Atan2(SVar y, SVar x)
        {
            return(new SVar(new DelegateScalarExpression(() => (float)Math.Atan2(y.Evaluate(), x.Evaluate()))));
        }
示例#4
0
 public static TVar RandomBernoulli(SeedSource seedSource, SVar p, IAllocator allocator, DType type, params long[] sizes)
 {
     return(new TVar(new FillExpression(allocator, type, sizes, res => Ops.RandomBernoulli(res, seedSource, p.Evaluate()))));
 }
示例#5
0
 public static TVar RandomLogNormal(SeedSource seedSource, SVar mean, SVar stdv, IAllocator allocator, DType type, params long[] sizes)
 {
     return(new TVar(new FillExpression(allocator, type, sizes, res => Ops.RandomLogNormal(res, seedSource, mean.Evaluate(), stdv.Evaluate()))));
 }
示例#6
0
 public static TVar Fill(SVar value, IAllocator allocator, DType type, params long[] sizes)
 {
     return(new TVar(new FillExpression(allocator, type, sizes, res => Ops.Fill(res, value.Evaluate()))));
 }
示例#7
0
 public static TVar RandomCauchy(SeedSource seedSource, SVar median, SVar sigma, IAllocator allocator, DType type, params long[] sizes)
 {
     return(new TVar(new FillExpression(allocator, type, sizes, res => Ops.RandomCauchy(res, seedSource, median.Evaluate(), sigma.Evaluate()))));
 }
示例#8
0
 public static TVar RandomExponential(SeedSource seedSource, SVar lambda, IAllocator allocator, DType type, params long[] sizes)
 {
     return(new TVar(new FillExpression(allocator, type, sizes, res => Ops.RandomExponential(res, seedSource, lambda.Evaluate()))));
 }
示例#9
0
 public static TVar RandomUniform(SeedSource seedSource, SVar min, SVar max, IAllocator allocator, DType type, params long[] sizes)
 {
     return(new TVar(new FillExpression(allocator, type, sizes, res => Ops.RandomUniform(res, seedSource, min.Evaluate(), max.Evaluate()))));
 }
示例#10
0
 public static TVar Lerp(TVar a, TVar b, SVar weight)
 {
     return(new TVar(new BinaryTensorTensorExpression(a.Expression, b.Expression, (res, aVal, bVal) => Ops.Lerp(res, aVal, bVal, weight.Evaluate()))));
 }
示例#11
0
 public TVar Clamp(SVar min, SVar max)
 {
     return(new TVar(new UnaryTensorExpression(this.Expression, (res, src) => Ops.Clamp(res, src, min.Evaluate(), max.Evaluate()))));
 }