protected Variable(Type dataType, VariableType type, Expr initializer) { DataType = dataType; Type = type; _shape = initializer != null ? new PartialShape(initializer.Shape.AsArray) : null; _initializer = initializer; _owner = null; }
protected Variable(Type dataType, VariableType type, PartialShape shape) { DataType = dataType; Type = type; _shape = shape; _initializer = null; _owner = null; }
private void SetForwardOrder(Differentiable op, HashSet <Differentiable> cache) { if (cache.Contains(op)) { return; } foreach (var input in op.Inputs) { SetForwardOrder(input, cache); } _forwardOrder.Add(op); cache.Add(op); }
private void AddData(Differentiable op, HashSet <Differentiable> cache) { if (cache.Contains(op)) { return; } foreach (var input in op.Inputs) { AddData(input, cache); } foreach (var auxVar in op.AuxVars) { AddData(auxVar, cache); } foreach (var output in op.Outputs) { _data.Add(output, new Data(Context, output)); } cache.Add(op); }