Exemplo n.º 1
0
        public IFor AddOutput_(ITensor expr)
        {
            SequencesLocked = true;

            var f = expr.Match(
                (Tensor <float> exprF) => (IFor) new Tensor <float> .For(this, Fors.Count, exprF, null, null),
                (Tensor <int> exprI) => new Tensor <int> .For(this, Fors.Count, exprI, null, null),
                null
                );

            Fors.Add(f);
            return(f);
        }
Exemplo n.º 2
0
        /// <summary> Add a recursive For to the loop. Returns the For created. </summary>
        public IFor AddRecursive_(ITensor expr, ITensor seed, string name)
        {
            if (seed == null)
            {
                throw new ArgumentException($"{nameof(seed)} can't be null, use AddOutput instead", nameof(seed));
            }

            ITensorVar variable = seed.Match(
                (Tensor <float> exprF) => new Tensor <float> .Var(seed.Shape, name),
                (Tensor <int> exprI) => new Tensor <int> .Var(seed.Shape, name),
                () => { throw new NotImplementedException(); return((ITensorVar)null); }
                );

            return(AddRecursive_(expr, seed, variable));
        }
Exemplo n.º 3
0
        /// <summary> Add a recursive For to the loop. Returns the For created. </summary>
        public IFor AddRecursive_(ITensor expr, ITensor seed, ITensorVar variable)
        {
            if (seed == null)
            {
                throw new ArgumentException($"{nameof(seed)} can't be null, use AddOutput instead", nameof(seed));
            }
            SequencesLocked = true;

            var f = expr.Match(
                (Tensor <float> exprF) => (IFor) new Tensor <float> .For(this, Fors.Count, exprF, (Tensor <float>)seed, (Tensor <float> .Var)variable),
                (Tensor <int> exprI) => new Tensor <int> .For(this, Fors.Count, exprI, (Tensor <int>)seed, (Tensor <int> .Var)variable),
                null
                );

            Fors.Add(f);
            _variables.Add(f, variable);
            return(f);
        }