Search in sources :

Example 1 with LifecycleException

use of com.simiacryptus.mindseye.lang.LifecycleException in project MindsEye by SimiaCryptus.

the class StandardLayerTests method tests.

private void tests(final NotebookOutput log, final List<ComponentTest<?>> tests, @Nonnull final Invocation invocation, @Nonnull final ArrayList<TestError> exceptions) {
    tests.stream().filter(x -> null != x).forEach((ComponentTest<?> test) -> {
        @Nonnull Layer layer = invocation.getLayer().copy();
        Tensor[] inputs = randomize(invocation.getDims());
        try {
            test.test(log, layer, inputs);
        } catch (LifecycleException e) {
            throw e;
        } catch (Throwable e) {
            exceptions.add(new TestError(e, test, layer));
        } finally {
            for (@Nonnull Tensor tensor : inputs) tensor.freeRef();
            layer.freeRef();
            test.freeRef();
            System.gc();
        }
    });
}
Also used : JsonObject(com.google.gson.JsonObject) Graphviz(guru.nidi.graphviz.engine.Graphviz) Arrays(java.util.Arrays) Tensor(com.simiacryptus.mindseye.lang.Tensor) ReferenceCountingBase(com.simiacryptus.mindseye.lang.ReferenceCountingBase) NotebookReportBase(com.simiacryptus.mindseye.test.NotebookReportBase) HashMap(java.util.HashMap) Random(java.util.Random) Result(com.simiacryptus.mindseye.lang.Result) DataSerializer(com.simiacryptus.mindseye.lang.DataSerializer) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Format(guru.nidi.graphviz.engine.Format) Map(java.util.Map) Layer(com.simiacryptus.mindseye.lang.Layer) CudaError(com.simiacryptus.mindseye.lang.cudnn.CudaError) NotebookOutput(com.simiacryptus.util.io.NotebookOutput) ReferenceCounting(com.simiacryptus.mindseye.lang.ReferenceCounting) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) SysOutInterceptor(com.simiacryptus.util.test.SysOutInterceptor) Collection(java.util.Collection) TestUtil(com.simiacryptus.mindseye.test.TestUtil) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) LayerBase(com.simiacryptus.mindseye.lang.LayerBase) Explodable(com.simiacryptus.mindseye.layers.cudnn.Explodable) ToleranceStatistics(com.simiacryptus.mindseye.test.ToleranceStatistics) DAGNetwork(com.simiacryptus.mindseye.network.DAGNetwork) LifecycleException(com.simiacryptus.mindseye.lang.LifecycleException) LifecycleException(com.simiacryptus.mindseye.lang.LifecycleException) Tensor(com.simiacryptus.mindseye.lang.Tensor) Nonnull(javax.annotation.Nonnull) Layer(com.simiacryptus.mindseye.lang.Layer)

Example 2 with LifecycleException

use of com.simiacryptus.mindseye.lang.LifecycleException in project MindsEye by SimiaCryptus.

the class StandardLayerTests method bigTests.

/**
 * Big tests.
 *
 * @param log        the log
 * @param seed       the seed
 * @param perfLayer  the perf layer
 * @param exceptions the exceptions
 */
public void bigTests(NotebookOutput log, long seed, @Nonnull Layer perfLayer, @Nonnull ArrayList<TestError> exceptions) {
    getBigTests().stream().filter(x -> null != x).forEach(test -> {
        @Nonnull Layer layer = perfLayer.copy();
        try {
            Tensor[] input = randomize(getLargeDims(new Random(seed)));
            try {
                test.test(log, layer, input);
            } finally {
                for (@Nonnull Tensor t : input) {
                    t.freeRef();
                }
            }
        } catch (LifecycleException e) {
            throw e;
        } catch (CudaError e) {
            throw e;
        } catch (Throwable e) {
            exceptions.add(new TestError(e, test, layer));
        } finally {
            layer.freeRef();
            test.freeRef();
            System.gc();
        }
    });
}
Also used : JsonObject(com.google.gson.JsonObject) Graphviz(guru.nidi.graphviz.engine.Graphviz) Arrays(java.util.Arrays) Tensor(com.simiacryptus.mindseye.lang.Tensor) ReferenceCountingBase(com.simiacryptus.mindseye.lang.ReferenceCountingBase) NotebookReportBase(com.simiacryptus.mindseye.test.NotebookReportBase) HashMap(java.util.HashMap) Random(java.util.Random) Result(com.simiacryptus.mindseye.lang.Result) DataSerializer(com.simiacryptus.mindseye.lang.DataSerializer) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Format(guru.nidi.graphviz.engine.Format) Map(java.util.Map) Layer(com.simiacryptus.mindseye.lang.Layer) CudaError(com.simiacryptus.mindseye.lang.cudnn.CudaError) NotebookOutput(com.simiacryptus.util.io.NotebookOutput) ReferenceCounting(com.simiacryptus.mindseye.lang.ReferenceCounting) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) SysOutInterceptor(com.simiacryptus.util.test.SysOutInterceptor) Collection(java.util.Collection) TestUtil(com.simiacryptus.mindseye.test.TestUtil) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) LayerBase(com.simiacryptus.mindseye.lang.LayerBase) Explodable(com.simiacryptus.mindseye.layers.cudnn.Explodable) ToleranceStatistics(com.simiacryptus.mindseye.test.ToleranceStatistics) DAGNetwork(com.simiacryptus.mindseye.network.DAGNetwork) LifecycleException(com.simiacryptus.mindseye.lang.LifecycleException) CudaError(com.simiacryptus.mindseye.lang.cudnn.CudaError) LifecycleException(com.simiacryptus.mindseye.lang.LifecycleException) Tensor(com.simiacryptus.mindseye.lang.Tensor) Random(java.util.Random) Nonnull(javax.annotation.Nonnull) Layer(com.simiacryptus.mindseye.lang.Layer)

Aggregations

JsonObject (com.google.gson.JsonObject)2 DataSerializer (com.simiacryptus.mindseye.lang.DataSerializer)2 Layer (com.simiacryptus.mindseye.lang.Layer)2 LayerBase (com.simiacryptus.mindseye.lang.LayerBase)2 LifecycleException (com.simiacryptus.mindseye.lang.LifecycleException)2 ReferenceCounting (com.simiacryptus.mindseye.lang.ReferenceCounting)2 ReferenceCountingBase (com.simiacryptus.mindseye.lang.ReferenceCountingBase)2 Result (com.simiacryptus.mindseye.lang.Result)2 Tensor (com.simiacryptus.mindseye.lang.Tensor)2 CudaError (com.simiacryptus.mindseye.lang.cudnn.CudaError)2 Explodable (com.simiacryptus.mindseye.layers.cudnn.Explodable)2 DAGNetwork (com.simiacryptus.mindseye.network.DAGNetwork)2 NotebookReportBase (com.simiacryptus.mindseye.test.NotebookReportBase)2 TestUtil (com.simiacryptus.mindseye.test.TestUtil)2 ToleranceStatistics (com.simiacryptus.mindseye.test.ToleranceStatistics)2 NotebookOutput (com.simiacryptus.util.io.NotebookOutput)2 SysOutInterceptor (com.simiacryptus.util.test.SysOutInterceptor)2 Format (guru.nidi.graphviz.engine.Format)2 Graphviz (guru.nidi.graphviz.engine.Graphviz)2 File (java.io.File)2