コード例 #1
0
        public Tensor BuildTriMask(Tensor result, float value, float maskedValue)
        {
            int  ndim        = result.DimensionCount;
            long storageSize = TensorDimensionHelpers.GetStorageSize(result.Sizes, result.Strides);
            long cols        = result.Sizes[ndim - 1];

            if (storageSize % cols != 0)
            {
                throw new Exception($"Invalid tensor storage size = '{storageSize}', and cols = '{cols}'");
            }

            long rows = storageSize / cols;

            TensorApplyCPU.BuildTriMask(result, (int)rows, (int)cols, value, maskedValue);
            return(result);
        }