/// <summary>
 /// Initializes a new instance of the <see cref="ScatterFillExpression"/> class.
 /// </summary>
 /// <param name="src">The source.</param>
 /// <param name="value">The value.</param>
 /// <param name="dimension">The dimension.</param>
 /// <param name="indices">The indices.</param>
 public ScatterFillExpression(VariableExpression src, ScalarVar value, int dimension, VariableExpression indices)
 {
     this.src       = src;
     this.value     = value;
     this.dimension = dimension;
     this.indices   = indices;
 }
Exemple #2
0
 /// <summary>
 /// Randoms the cauchy.
 /// </summary>
 /// <param name="seedSource">The seed source.</param>
 /// <param name="median">The median.</param>
 /// <param name="sigma">The sigma.</param>
 /// <param name="allocator">The allocator.</param>
 /// <param name="type">The type.</param>
 /// <param name="sizes">The sizes.</param>
 /// <returns>TVar.</returns>
 public static Variable RandomCauchy(SeedSource seedSource, ScalarVar median, ScalarVar sigma, IAllocator allocator, DType type, params long[] sizes)
 {
     return(new Variable(new FillExpression(allocator, type, sizes, res => Ops.RandomCauchy(res, seedSource, median.Evaluate(), sigma.Evaluate()))));
 }
Exemple #3
0
 /// <summary>
 /// Randoms the exponential.
 /// </summary>
 /// <param name="seedSource">The seed source.</param>
 /// <param name="lambda">The lambda.</param>
 /// <param name="allocator">The allocator.</param>
 /// <param name="type">The type.</param>
 /// <param name="sizes">The sizes.</param>
 /// <returns>TVar.</returns>
 public static Variable RandomExponential(SeedSource seedSource, ScalarVar lambda, IAllocator allocator, DType type, params long[] sizes)
 {
     return(new Variable(new FillExpression(allocator, type, sizes, res => Ops.RandomExponential(res, seedSource, lambda.Evaluate()))));
 }
Exemple #4
0
 /// <summary>
 /// Randoms the normal.
 /// </summary>
 /// <param name="seedSource">The seed source.</param>
 /// <param name="mean">The mean.</param>
 /// <param name="stdv">The STDV.</param>
 /// <param name="allocator">The allocator.</param>
 /// <param name="type">The type.</param>
 /// <param name="sizes">The sizes.</param>
 /// <returns>TVar.</returns>
 public static Variable RandomNormal(SeedSource seedSource, ScalarVar mean, ScalarVar stdv, IAllocator allocator, DType type, params long[] sizes)
 {
     return(new Variable(new FillExpression(allocator, type, sizes, res => Ops.RandomNormal(res, seedSource, mean.Evaluate(), stdv.Evaluate()))));
 }
Exemple #5
0
 /// <summary>
 /// Randoms the uniform.
 /// </summary>
 /// <param name="seedSource">The seed source.</param>
 /// <param name="min">The minimum.</param>
 /// <param name="max">The maximum.</param>
 /// <param name="allocator">The allocator.</param>
 /// <param name="type">The type.</param>
 /// <param name="sizes">The sizes.</param>
 /// <returns>TVar.</returns>
 public static Variable RandomUniform(SeedSource seedSource, ScalarVar min, ScalarVar max, IAllocator allocator, DType type, params long[] sizes)
 {
     return(new Variable(new FillExpression(allocator, type, sizes, res => Ops.RandomUniform(res, seedSource, min.Evaluate(), max.Evaluate()))));
 }
Exemple #6
0
 // Returns a copy of this tensor, with the given indices filled with the given value.
 // If, when this op is evaluated, the write target is the same tensor as this, then the copy is unnecessary and is skipped.
 /// <summary>
 /// Scatters the fill.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <param name="dimension">The dimension.</param>
 /// <param name="indices">The indices.</param>
 /// <returns>TVar.</returns>
 public Variable ScatterFill(ScalarVar value, int dimension, Variable indices)
 {
     return(new Variable(new ScatterFillExpression(this.Expression, value, dimension, indices.Expression)));
 }
Exemple #7
0
 /// <summary>
 /// Lerps the specified a.
 /// </summary>
 /// <param name="a">a.</param>
 /// <param name="b">The b.</param>
 /// <param name="weight">The weight.</param>
 /// <returns>TVar.</returns>
 public static Variable Lerp(Variable a, Variable b, ScalarVar weight)
 {
     return(new Variable(new BinaryTensorTensorExpression(a.Expression, b.Expression, (res, aVal, bVal) => Ops.Lerp(res, aVal, bVal, weight.Evaluate()))));
 }
Exemple #8
0
 /// <summary>
 /// Clamps the specified minimum.
 /// </summary>
 /// <param name="min">The minimum.</param>
 /// <param name="max">The maximum.</param>
 /// <returns>TVar.</returns>
 public Variable Clamp(ScalarVar min, ScalarVar max)
 {
     return(new Variable(new UnaryTensorExpression(this.Expression, (res, src) => Ops.Clamp(res, src, min.Evaluate(), max.Evaluate()))));
 }
Exemple #9
0
 /// <summary>
 /// Pows the specified y.
 /// </summary>
 /// <param name="y">The y.</param>
 /// <returns>TVar.</returns>
 public Variable Pow(ScalarVar y)
 {
     return(new Variable(new BinaryTensorScalarExpression(this.Expression, y.Expression, Ops.Pow)));
 }
Exemple #10
0
 /// <summary>
 /// Divs the specified RHS.
 /// </summary>
 /// <param name="rhs">The RHS.</param>
 /// <returns>TVar.</returns>
 public Variable Div(ScalarVar rhs)
 {
     return(new Variable(new BinaryTensorScalarExpression(this.Expression, rhs.Expression, Ops.Div)));
 }
Exemple #11
0
 /// <summary>
 /// Fills the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <param name="allocator">The allocator.</param>
 /// <param name="type">The type.</param>
 /// <param name="sizes">The sizes.</param>
 /// <returns>TVar.</returns>
 public static Variable Fill(ScalarVar value, IAllocator allocator, DType type, params long[] sizes)
 {
     return(new Variable(new FillExpression(allocator, type, sizes, res => Ops.Fill(res, value.Evaluate()))));
 }
Exemple #12
0
 /// <summary>
 /// Randoms the bernoulli.
 /// </summary>
 /// <param name="seedSource">The seed source.</param>
 /// <param name="p">The p.</param>
 /// <param name="allocator">The allocator.</param>
 /// <param name="type">The type.</param>
 /// <param name="sizes">The sizes.</param>
 /// <returns>TVar.</returns>
 public static Variable RandomBernoulli(SeedSource seedSource, ScalarVar p, IAllocator allocator, DType type, params long[] sizes)
 {
     return(new Variable(new FillExpression(allocator, type, sizes, res => Ops.RandomBernoulli(res, seedSource, p.Evaluate()))));
 }
Exemple #13
0
 /// <summary>
 /// Lerps the specified a.
 /// </summary>
 /// <param name="a">a.</param>
 /// <param name="b">The b.</param>
 /// <param name="weight">The weight.</param>
 /// <returns>SVar.</returns>
 public static ScalarVar Lerp(ScalarVar a, ScalarVar b, ScalarVar weight)
 {
     return(new ScalarVar(new DelegateScalarExpression(() => (float)LerpFloat(a.Evaluate(), b.Evaluate(), weight.Evaluate()))));
 }
Exemple #14
0
 /// <summary>
 /// Atan2s the specified y.
 /// </summary>
 /// <param name="y">The y.</param>
 /// <param name="x">The x.</param>
 /// <returns>SVar.</returns>
 public static ScalarVar Atan2(ScalarVar y, ScalarVar x)
 {
     return(new ScalarVar(new DelegateScalarExpression(() => (float)Math.Atan2(y.Evaluate(), x.Evaluate()))));
 }
Exemple #15
0
 /// <summary>
 /// Clamps the specified minimum.
 /// </summary>
 /// <param name="min">The minimum.</param>
 /// <param name="max">The maximum.</param>
 /// <returns>SVar.</returns>
 public ScalarVar Clamp(ScalarVar min, ScalarVar max)
 {
     return(new ScalarVar(new DelegateScalarExpression(() => ClampFloat(this.expression.Evaluate(), min.expression.Evaluate(), max.expression.Evaluate()))));
 }
Exemple #16
0
 /// <summary>
 /// Pows the specified y.
 /// </summary>
 /// <param name="y">The y.</param>
 /// <returns>SVar.</returns>
 public ScalarVar Pow(ScalarVar y)
 {
     return(new ScalarVar(new BinaryScalarExpression(this.expression, y.expression, (xVal, yVal) => (float)Math.Pow(xVal, yVal))));
 }