public Tensor Softmax(Tensor result, Tensor src) { int ndim = src.DimensionCount; long storageSize = TensorDimensionHelpers.GetStorageSize(src.Sizes, src.Strides); long cols = src.Sizes[ndim - 1]; if (storageSize % cols != 0) { throw new Exception($"Invalid tensor storage size = '{storageSize}', and cols = '{cols}'"); } long rows = storageSize / cols; Tensor writeTarget = TensorResultBuilder.GetWriteTarget(result, src, true, src.Sizes); TensorApplyCPU.Softmax(writeTarget, src, (int)rows, (int)cols); return(writeTarget); }