String error = null; try { available = backend.isAvailable(); } catch (Exception e) { error = e.getMessage(); Nd4jContext.getInstance().updateProperties(backend.getConfigurationResource().getInputStream()); } catch (IOException e) { e.printStackTrace(); loadLibrary(new File(uri)); return load();
/** * * @return * @throws IOException */ public Properties getProperties() throws IOException { return getContext().getConf(); }
@Override public int compare(Nd4jBackend o1, Nd4jBackend o2) { // high-priority first return o2.getPriority() - o1.getPriority(); } });
public static Cloner newCloner() { Cloner cloner = new Cloner(); //Implement custom cloning for INDArrays (default can have problems with off-heap and pointers) //Sadly: the cloner library does NOT support interfaces here, hence we need to use the actual classes //cloner.registerFastCloner(INDArray.class, new INDArrayFastCloner()); //Does not work due to interface IFastCloner fc = new INDArrayFastCloner(); cloner.registerFastCloner(Nd4j.getBackend().getNDArrayClass(), fc); cloner.registerFastCloner(Nd4j.getBackend().getComplexNDArrayClass(), fc); //Same thing with DataBuffers: off heap -> cloner library chokes on them, but need to know the concrete // buffer classes, not just the interface IFastCloner fc2 = new DataBufferFastCloner(); DataBufferFactory d = Nd4j.getDataBufferFactory(); doReg(cloner, fc2, d.intBufferClass()); doReg(cloner, fc2, d.longBufferClass()); doReg(cloner, fc2, d.halfBufferClass()); doReg(cloner, fc2, d.floatBufferClass()); doReg(cloner, fc2, d.doubleBufferClass()); doReg(cloner, fc2, CompressedDataBuffer.class); return cloner; }
/** * Initializes nd4j */ public synchronized void initContext() { try { Nd4jBackend backend = Nd4jBackend.load(); initWithBackend(backend); } catch (NoAvailableBackendException e) { throw new RuntimeException(e); } }
private void updateNd4jContext() throws IOException { try (InputStream is = backend.getConfigurationResource().getInputStream()) { Nd4jContext.getInstance().updateProperties(is); } }
.forName(pp.toString(MEMORY_MANAGER)); allowsOrder = backend.allowsOrder(); String rand = pp.toString(RANDOM_PROVIDER, DefaultRandom.class.getName()); randomClazz = (Class<? extends org.nd4j.linalg.api.rng.Random>) Class.forName(rand);
@Override public void registerClasses(Kryo kryo) { kryo.register(Nd4j.getBackend().getNDArrayClass(), new Nd4jSerializer()); kryo.register(Nd4j.getBackend().getComplexNDArrayClass(), new Nd4jSerializer()); //Also register Java types (synchronized/unmodifiable collections), which will fail by default UnmodifiableCollectionsSerializer.registerSerializers(kryo); SynchronizedCollectionsSerializer.registerSerializers(kryo); } }
/** * Initializes nd4j */ public synchronized void initContext() { try { Nd4jBackend backend = Nd4jBackend.load(); initWithBackend(backend); } catch (NoAvailableBackendException e) { throw new RuntimeException(e); } }
private void updateNd4jContext() throws IOException { try (InputStream is = backend.getConfigurationResource().getInputStream()) { Nd4jContext.getInstance().updateProperties(is); } }
.forName(System.getProperty(MEMORY_MANAGER, props.get(MEMORY_MANAGER).toString())); allowsOrder = backend.allowsOrder(); String rand = props.getProperty(RANDOM_PROVIDER, DefaultRandom.class.getName()); randomClazz = (Class<? extends org.nd4j.linalg.api.rng.Random>) Class.forName(rand);
String error = null; try { available = backend.isAvailable(); } catch (Exception e) { error = e.getMessage(); Nd4jContext.getInstance().updateProperties(backend.getConfigurationResource().getInputStream()); } catch (IOException e) { e.printStackTrace(); String error = null; try { available = backend.isAvailable(); } catch (Exception e) { error = e.getMessage(); Nd4jContext.getInstance().updateProperties(backend.getConfigurationResource().getInputStream()); } catch (IOException e) { e.printStackTrace(); loadLibrary(new File(uri)); return load();
@Override public int compare(Nd4jBackend o1, Nd4jBackend o2) { // high-priority first return o2.getPriority() - o1.getPriority(); } });
/** * * @return * @throws IOException */ public Properties getProperties() throws IOException { return getContext().getConf(); }
@Override public int compare(Nd4jBackend o1, Nd4jBackend o2) { // high-priority first return o2.getPriority() - o1.getPriority(); } });