コード例 #1
0
 /// <inheritdoc/>
 Tensor IOps.Reshape(Tensor X, TensorShape shape)
 {
     m_Alu += 0;
     m_Mem += 0;
     RegisterLayerStats();
     return(m_Ops.Reshape(X, shape));
 }
コード例 #2
0
 /// <inheritdoc/>
 Tensor IOps.Flatten(Tensor X)
 {
     m_Alu += 0;
     m_Mem += 0;
     RegisterLayerStats();
     return(m_Ops.Flatten(X));
 }
コード例 #3
0
        /// <inheritdoc/>
        Tensor IOps.SpaceToDepth(Tensor X, int[] scale)
        {
            var O = m_Ops.SpaceToDepth(X, scale);

            m_Mem += (long)X.length + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #4
0
        /// <inheritdoc/>
        Tensor IOps.DepthToSpace(Tensor X, int[] scale, Layer.DepthToSpaceMode mode)
        {
            var O = m_Ops.DepthToSpace(X, scale, mode);

            m_Mem += (long)X.length + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #5
0
        /// <inheritdoc/>
        Tensor IOps.Dense3(Tensor X, Tensor W, Tensor B)
        {
            var O = m_Ops.Dense3(X, W, B);

            m_Alu += (long)X.height * (long)X.width * (long)W.width * 2L * (long)X.batch * (long)X.channels;
            m_Mem += (long)X.length + (long)W.length + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #6
0
        /// <inheritdoc/>
        Tensor IOps.NonMaxSuppression(Tensor[] tensors, int maxOutputBoxesPerClass, float iouThreshold, float scoreThreshold, int centerPointBox)
        {
            var O = m_Ops.NonMaxSuppression(tensors, maxOutputBoxesPerClass, iouThreshold, scoreThreshold, centerPointBox);

            m_Alu += 0;
            m_Mem += 0;
            RegisterLayerStats();
            return(O);
        }
コード例 #7
0
        /// <inheritdoc/>
        Tensor IOps.Expand(Tensor X, TensorShape shape)
        {
            var O = m_Ops.Expand(X, shape);

            m_Alu += 0;
            m_Mem += (long)X.length + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #8
0
        /// <inheritdoc/>
        Tensor IOps.GlobalAvgVariancePool2D(Tensor X)
        {
            var O = m_Ops.GlobalAvgVariancePool2D(X);

            m_Alu += (long)X.length * 2L + (long)O.length;
            m_Mem += (long)X.length + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #9
0
        /// <inheritdoc/>
        Tensor IOps.Upsample3D(Tensor X, int[] scale, bool trilinear)
        {
            var O = m_Ops.Upsample3D(X, scale, trilinear);

            m_Alu += (long)O.length * (trilinear ? 18 : 1);
            m_Mem += (long)X.length * (trilinear ? 8 : 1) + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #10
0
        /// <inheritdoc/>
        Tensor IOps.Resample2D(Tensor X, int[] size, bool bilinear)
        {
            var O = m_Ops.Resample2D(X, size, bilinear);

            m_Alu += (long)O.length * (bilinear ? 8 : 1);
            m_Mem += (long)X.length * (bilinear ? 4 : 1) + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #11
0
        /// <inheritdoc/>
        Tensor IOps.MatMul(Tensor X, bool xTranspose, Tensor Y, bool yTranspose)
        {
            var O = m_Ops.MatMul(X, xTranspose, Y, yTranspose);

            m_Alu += (long)X.flatHeight * (long)X.flatWidth * (long)Y.flatWidth * 2L;
            m_Mem += (long)X.length + (long)Y.length + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #12
0
        /// <inheritdoc/>
        Tensor IOps.Border3D(Tensor X, int[] pad, float value)
        {
            var O = m_Ops.Border3D(X, pad, value);

            m_Alu += 0;
            m_Mem += (long)X.length + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #13
0
ファイル: StatsOps.cs プロジェクト: mantasp/barracuda-release
        /// <inheritdoc/>
        Tensor IOps.RoiAlign(Tensor X, Tensor rois, Tensor indices, int outputHeight, int outputWidth, int samplingRatio, float spatialScale)
        {
            var O = m_Ops.RoiAlign(X, rois, indices, outputHeight, outputWidth, samplingRatio, spatialScale);

            m_Alu += 4 * outputHeight * outputWidth * samplingRatio * samplingRatio;
            m_Mem += 4 * outputHeight * outputWidth * samplingRatio * samplingRatio;
            RegisterLayerStats();
            return(O);
        }
コード例 #14
0
        /// <inheritdoc/>
        Tensor IOps.Normalization(Tensor X, Tensor S, Tensor B, int pool, int axis, float epsilon, Layer.FusedActivation fusedActivation)
        {
            var O = m_Ops.Normalization(X, S, B, pool, axis, epsilon, fusedActivation);

            m_Alu += (long)X.length * 4L + (long)O.length * 2L;
            m_Mem += (long)X.length + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #15
0
        /// <inheritdoc/>
        Tensor IOps.MatMul(Tensor X, int rankX, Tensor Y, int rankY)
        {
            var O = m_Ops.MatMul(X, rankX, Y, rankY);

            m_Alu += (long)X.height * (long)X.width * (long)Y.width * 2L * (long)X.batch * (long)X.channels;
            m_Mem += (long)X.length + (long)Y.length + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #16
0
        /// <inheritdoc/>
        Tensor IOps.Pad2DEdge(Tensor X, int[] pad)
        {
            var O = m_Ops.Pad2DEdge(X, pad);

            m_Alu += 0;
            m_Mem += (long)X.length + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #17
0
        /// <inheritdoc/>
        Tensor IOps.Dense(Tensor X, Tensor W, Tensor B, Layer.FusedActivation fusedActivation)
        {
            var O = m_Ops.Dense(X, W, B, fusedActivation);

            m_Alu += (long)X.flatHeight * (long)X.flatWidth * (long)W.flatWidth * 2L;
            m_Mem += (long)X.length + (long)W.length + (long)B.length + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #18
0
        /// <inheritdoc/>
        public Tensor TopKValues(Tensor X, Tensor I, int axis)
        {
            var O = m_Ops.TopKValues(X, I, axis);

            // @TODO: not implemented
            m_Alu += 0;
            m_Mem += 0;
            RegisterLayerStats();
            return(O);
        }
コード例 #19
0
        /// <inheritdoc/>
        Tensor IOps.TopKIndices(Tensor X, int k, int axis, bool largest, bool sorted)
        {
            var O = m_Ops.TopKIndices(X, k, axis, largest, sorted);

            // @TODO: not implemented
            m_Alu += 0;
            m_Mem += 0;
            RegisterLayerStats();
            return(O);
        }
コード例 #20
0
        /// <inheritdoc/>
        Tensor IOps.OneHot(Tensor X, int depth, float onValue, float offValue)
        {
            var O = m_Ops.OneHot(X, depth, onValue, offValue);

            // @TODO: not implemented
            m_Alu += 0;
            m_Mem += 0;
            RegisterLayerStats();
            return(O);
        }
コード例 #21
0
        /// <inheritdoc/>
        Tensor IOps.Multinomial(Tensor X, int count, int seed)
        {
            var O = m_Ops.Multinomial(X, count, seed);

            // @TODO: not implemented
            m_Alu += 0;
            m_Mem += 0;
            RegisterLayerStats();
            return(O);
        }
コード例 #22
0
        /// <inheritdoc/>
        Tensor IOps.RandomUniform(TensorShape s, float mean, float scale, int seed)
        {
            var O = m_Ops.RandomUniform(s, mean, scale, seed);

            // @TODO: not implemented
            m_Alu += 0;
            m_Mem += 0;
            RegisterLayerStats();
            return(O);
        }
コード例 #23
0
        /// <inheritdoc/>
        public Tensor NonZero(Tensor X)
        {
            var O = m_Ops.NonZero(X);

            // @TODO: not implemented
            m_Alu += 0;
            m_Mem += 0;
            RegisterLayerStats();
            return(O);
        }
コード例 #24
0
        /// <inheritdoc/>
        public Tensor[] LSTM(Tensor X, Tensor[] W, Tensor[] R, Tensor[] Wb, Tensor[] Rb, Tensor hidden, Tensor cell)
        {
            var O = m_Ops.LSTM(X, W, R, Wb, Rb, hidden, cell);

            // @TODO: not implemented
            m_Alu += 0;
            m_Mem += 0;
            RegisterLayerStats();
            return(O);
        }
コード例 #25
0
        internal void ElementwiseBroadcast(Tensor[] tensors, Tensor X, long aluOperationsPerElement = 1L)
        {
            m_Alu += (long)X.length * aluOperationsPerElement;
            long mem = (long)X.length;

            foreach (var t in tensors)
            {
                mem += (long)t.length;
            }
            m_Mem += mem;
        }
コード例 #26
0
        /// <inheritdoc/>
        Tensor IOps.LRN(Tensor X, float alpha, float beta, float bias, int size)
        {
            var O = m_Ops.LRN(X, alpha, beta, bias, size);
            //A bit over conservative. Number of read/alu is lower than `size` when normalisation windows is too large for data at current index.
            long sizeL = size;

            m_Alu += (long)X.length * (5L + sizeL * 2L);
            m_Mem += (long)X.length * (sizeL + 2L);
            RegisterLayerStats();
            return(O);
        }
コード例 #27
0
        /// <inheritdoc/>
        Tensor IOps.DepthwiseConv2D(Tensor X, Tensor K, Tensor B, int[] stride, int[] pad, Layer.FusedActivation fusedActivation)
        {
            var  O = m_Ops.DepthwiseConv2D(X, K, B, stride, pad, fusedActivation);
            long m = (long)O.batch * (long)O.width * (long)O.height;
            long n = (long)X.channels;
            long k = (long)K.kernelWidth * (long)K.kernelHeight;

            m_Alu += m * n * k * 2L;
            m_Mem += (long)X.length + (long)K.length + (long)B.length + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #28
0
        /// <inheritdoc/>
        Tensor IOps.Conv2DTrans(Tensor X, Tensor K, Tensor B, int[] stride, int[] pad, int[] outputAdjustment, Layer.FusedActivation fusedActivation)
        {
            var  O = m_Ops.Conv2DTrans(X, K, B, stride, pad, outputAdjustment, fusedActivation);
            long m = (long)O.batch * (long)O.width * (long)O.height;
            long n = (long)X.channels;
            long k = (long)(K.kernelWidth / stride[1]) * (long)(K.kernelHeight / stride[0]) * (long)K.channels;

            m_Alu += m * n * k * 2L;
            m_Mem += (long)X.length + (long)K.length + (long)B.length + (long)O.length;
            RegisterLayerStats();
            return(O);
        }
コード例 #29
0
 internal void Reduce(Tensor X, Tensor O, long aluOperationsPerElement = 1L)
 {
     m_Alu += (long)X.length * aluOperationsPerElement;
     m_Mem += (long)X.length + (long)O.length;
 }
コード例 #30
0
 /// <summary>
 /// Create `StatsOps`
 /// </summary>
 /// <param name="ops">target ops</param>
 public StatsOps(IOps ops)
 {
     m_Ops = ops;
     m_Alu = new LayerStat(0L, 0L);
     m_Mem = new LayerStat(0L, 0L);
 }