public void Evaluate(TVar result) { if (!result.Expression.IsValidLvalue) { throw new InvalidOperationException("cannot write to given result - it is not a valid lvalue"); } using (var res = result.Expression.Evaluate(null)) { this.expression.Evaluate(res); } }
public TVar Pow(TVar y) { return(new TVar(new BinaryScalarTensorExpression(this.Expression, y.Expression, Ops.Tpow))); }
// 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. public TVar ScatterFill(SVar value, int dimension, TVar indices) { return(new TVar(new ScatterFillExpression(this.Expression, value, dimension, indices.Expression))); }
public TVar Scatter(int dimension, TVar indices) { return(new TVar(new BinaryTensorTensorExpression(this.Expression, indices.Expression, (res, src, ind) => Ops.Scatter(res, src, dimension, ind)))); }
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())))); }
public static TVar Atan2(TVar y, TVar x) { return(new TVar(new BinaryTensorTensorExpression(x.Expression, y.Expression, Ops.Atan2))); }
public TVar CDiv(TVar rhs) { return(new TVar(new BinaryTensorTensorExpression(this.Expression, rhs.Expression, Ops.Div))); }
// Returns beta * this + alpha * m1 * m2 public TVar Addmm(float beta, float alpha, TVar m1, TVar m2) { return(new TVar(new AddmmExpression(beta, this.Expression, alpha, m1.Expression, m2.Expression))); }