Search in sources :

Example 1 with PerformanceTester

use of com.simiacryptus.mindseye.test.unit.PerformanceTester in project MindsEye by SimiaCryptus.

the class ImgCropLayerTest method getPerformanceTester.

@Nullable
@Override
public ComponentTest<ToleranceStatistics> getPerformanceTester() {
    @Nonnull ComponentTest<ToleranceStatistics> inner = new PerformanceTester().setSamples(100).setBatches(10);
    return new ComponentTestBase<ToleranceStatistics>() {

        @Override
        public ToleranceStatistics test(@Nonnull NotebookOutput log, Layer component, Tensor... inputPrototype) {
            @Nullable PrintStream apiLog = null;
            try {
                apiLog = new PrintStream(log.file("cuda_perf.log"));
                CudaSystem.addLog(apiLog);
                return inner.test(log, component, inputPrototype);
            } finally {
                log.p(log.file((String) null, "cuda_perf.log", "GPU Log"));
                if (null != apiLog) {
                    apiLog.close();
                    CudaSystem.apiLog.remove(apiLog);
                }
            }
        }

        @Override
        protected void _free() {
            inner.freeRef();
            super._free();
        }
    };
}
Also used : ComponentTestBase(com.simiacryptus.mindseye.test.unit.ComponentTestBase) PrintStream(java.io.PrintStream) Tensor(com.simiacryptus.mindseye.lang.Tensor) Nonnull(javax.annotation.Nonnull) NotebookOutput(com.simiacryptus.util.io.NotebookOutput) ToleranceStatistics(com.simiacryptus.mindseye.test.ToleranceStatistics) PerformanceTester(com.simiacryptus.mindseye.test.unit.PerformanceTester) Layer(com.simiacryptus.mindseye.lang.Layer) Nullable(javax.annotation.Nullable) Nullable(javax.annotation.Nullable)

Example 2 with PerformanceTester

use of com.simiacryptus.mindseye.test.unit.PerformanceTester in project MindsEye by SimiaCryptus.

the class CudaLayerTestBase method getPerformanceTester.

@Nullable
@Override
public ComponentTest<ToleranceStatistics> getPerformanceTester() {
    @Nullable ComponentTest<ToleranceStatistics> inner = new PerformanceTester().setBatches(testingBatchSize);
    return new ComponentTestBase<ToleranceStatistics>() {

        @Override
        protected void _free() {
            inner.freeRef();
            super._free();
        }

        @Override
        public ToleranceStatistics test(@Nonnull NotebookOutput log, Layer component, Tensor... inputPrototype) {
            @Nullable PrintStream apiLog = null;
            try {
                @Nonnull String logName = "cuda_" + log.getName() + "_perf.log";
                log.p(log.file((String) null, logName, "GPU Log"));
                apiLog = new PrintStream(log.file(logName));
                CudaSystem.addLog(apiLog);
                return inner.test(log, component, inputPrototype);
            } finally {
                if (null != apiLog) {
                    apiLog.close();
                    CudaSystem.apiLog.remove(apiLog);
                }
            }
        }
    };
}
Also used : ComponentTestBase(com.simiacryptus.mindseye.test.unit.ComponentTestBase) PrintStream(java.io.PrintStream) Tensor(com.simiacryptus.mindseye.lang.Tensor) Nonnull(javax.annotation.Nonnull) NotebookOutput(com.simiacryptus.util.io.NotebookOutput) ToleranceStatistics(com.simiacryptus.mindseye.test.ToleranceStatistics) PerformanceTester(com.simiacryptus.mindseye.test.unit.PerformanceTester) Layer(com.simiacryptus.mindseye.lang.Layer) Nullable(javax.annotation.Nullable) Nullable(javax.annotation.Nullable)

Aggregations

Layer (com.simiacryptus.mindseye.lang.Layer)2 Tensor (com.simiacryptus.mindseye.lang.Tensor)2 ToleranceStatistics (com.simiacryptus.mindseye.test.ToleranceStatistics)2 ComponentTestBase (com.simiacryptus.mindseye.test.unit.ComponentTestBase)2 PerformanceTester (com.simiacryptus.mindseye.test.unit.PerformanceTester)2 NotebookOutput (com.simiacryptus.util.io.NotebookOutput)2 PrintStream (java.io.PrintStream)2 Nonnull (javax.annotation.Nonnull)2 Nullable (javax.annotation.Nullable)2