Exemplo n.º 1
0
        public NDArray VarAll(NDArray result, NDArray src)
        {
            if (src.DimensionCount == 0 || src.ElementCount() == 0)
            {
                throw new ArgumentException("src must be a non-empty tensor");
            }

            var mean        = Ops.MeanAll(src);
            var writeTarget = ReduceAllOp.Invoke(cudaReduceAllKernels, 0.0f, ReduceInitType.GivenValue, "en_norm", result, src, mean);

            Div(writeTarget, writeTarget, src.ElementCount() - 1);
            return(writeTarget);
        }
Exemplo n.º 2
0
 public NDArray NormAll(NDArray result, NDArray src, float value)
 {
     if (value == 0)
     {
         return(ReduceAllOp.Invoke(cudaReduceAllKernels, 0.0f, ReduceInitType.GivenValue, "e0_norm", result, src));
     }
     else if (value == 1)
     {
         return(ReduceAllOp.Invoke(cudaReduceAllKernels, 0.0f, ReduceInitType.GivenValue, "e1_norm", result, src));
     }
     else if (value == 2)
     {
         var writeTarget = ReduceAllOp.Invoke(cudaReduceAllKernels, 0.0f, ReduceInitType.GivenValue, "e2_norm", result, src);
         Pow(writeTarget, writeTarget, 0.5f);
         return(writeTarget);
     }
     else
     {
         var writeTarget = ReduceAllOp.Invoke(cudaReduceAllKernels, 0.0f, ReduceInitType.GivenValue, "en_norm", result, src, value);
         Pow(writeTarget, writeTarget, 1.0f / value);
         return(writeTarget);
     }
 }
Exemplo n.º 3
0
 public Tensor NormAll(Tensor result, Tensor src, float value)
 {
     if (value == 0)
     {
         return(ReduceAllOp.Invoke(cudaReduceAllKernels, 0.0f, ReduceInitType.GivenValue, "e0_normAll", result, src));
     }
     else if (value == 1)
     {
         return(ReduceAllOp.Invoke(cudaReduceAllKernels, 0.0f, ReduceInitType.GivenValue, "e1_normAll", result, src));
     }
     else if (value == 2)
     {
         Tensor writeTarget = ReduceAllOp.Invoke(cudaReduceAllKernels, 0.0f, ReduceInitType.GivenValue, "e2_normAll", result, src);
         Pow(writeTarget, writeTarget, 0.5f);
         return(writeTarget);
     }
     else
     {
         Tensor writeTarget = ReduceAllOp.Invoke(cudaReduceAllKernels, 0.0f, ReduceInitType.GivenValue, "en_normAll", result, src, value);
         Pow(writeTarget, writeTarget, 1.0f / value);
         return(writeTarget);
     }
 }
Exemplo n.º 4
0
 public NDArray MaxAll(NDArray result, NDArray src)
 {
     return(ReduceAllOp.Invoke(cudaReduceAllKernels, 0, ReduceInitType.MinValue, "maxAll", result, src));
 }
Exemplo n.º 5
0
 public NDArray ProdAll(NDArray result, NDArray src)
 {
     return(ReduceAllOp.Invoke(cudaReduceAllKernels, 1.0f, ReduceInitType.GivenValue, "prodAll", result, src));
 }
Exemplo n.º 6
0
 public Tensor MaxAll(Tensor result, Tensor src)
 {
     return(ReduceAllOp.Invoke(cudaReduceAllKernels, 0, ReduceInitType.MinValue, "maxAll", result, src));
 }
Exemplo n.º 7
0
 public Tensor ProdAll(Tensor result, Tensor src)
 {
     return(ReduceAllOp.Invoke(cudaReduceAllKernels, 1.0f, ReduceInitType.GivenValue, "prodAll", result, src));
 }