Improved stability for benchmarks and merge from dev

This commit is contained in:
rgrit91 2021-01-11 10:44:52 +00:00
commit 8967691b7d
3 changed files with 12 additions and 8 deletions

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -119,6 +119,8 @@ kotlin {
"-Wl,-rpath=$cppBuildDir",
"-lctorch"
)
optimized = true
debuggable = false
}
}
}

View File

@ -5,6 +5,7 @@ import kotlin.time.measureTime
internal fun benchmarkingDoubleMatrixMultiplication(
scale: Int,
numWarmUp: Int,
numIter: Int,
device: TorchDevice = TorchDevice.TorchCPU
): Unit {
@ -13,20 +14,21 @@ internal fun benchmarkingDoubleMatrixMultiplication(
setSeed(SEED)
val lhs = randNormal(shape = intArrayOf(scale, scale), device = device)
val rhs = randNormal(shape = intArrayOf(scale, scale), device = device)
lhs dotAssign rhs
repeat(numWarmUp) { lhs dotAssign rhs }
val measuredTime = measureTime { repeat(numIter) { lhs dotAssign rhs } }
println(" ${measuredTime / numIter} p.o. with $numIter iterations")
}
}
class BenchmarksDouble {
class BenchmarkMatrixMultiplicationDouble {
@Test
fun benchmarkMatrixMultiplication20() = benchmarkingDoubleMatrixMultiplication(20, 100000)
@Test
fun benchmarkMatrixMultiplication200() = benchmarkingDoubleMatrixMultiplication(200, 10000)
@Test
fun benchmarkMatrixMultiplication2000() = benchmarkingDoubleMatrixMultiplication(2000, 10)
fun benchmarkMatrixMultiplication20() = benchmarkingDoubleMatrixMultiplication(20, 10, 100000)
@Test
fun benchmarkMatrixMultiplication200() = benchmarkingDoubleMatrixMultiplication(200, 10, 10000)
@Test
fun benchmarkMatrixMultiplication2000() = benchmarkingDoubleMatrixMultiplication(2000, 3, 20)
}