protected void init() { observables = new LinkedBlockingQueue<>(queueLimit); int numDevices = Nd4j.getAffinityManager().getNumberOfDevices(); int currentDevice = Nd4j.getAffinityManager().getDeviceForCurrentThread(); AtomicBoolean assignedRoot = new AtomicBoolean(false); zoo = new InferenceWorker[workers]; for (int i = 0; i < workers; i++) { int cDevice = i % numDevices; boolean cRoot = !assignedRoot.get() && cDevice == currentDevice; assignedRoot.compareAndSet(false, cRoot); zoo[i] = new InferenceWorker(i, model, observables, cRoot); Nd4j.getAffinityManager().attachThreadToDevice(zoo[i], cDevice); zoo[i].setDaemon(true); zoo[i].start(); } if (inferenceMode == InferenceMode.BATCHED) { log.info("Initializing ObservablesProvider..."); provider = new ObservablesProvider(nanos, batchLimit, observables); } }
protected void init() { observables = new LinkedBlockingQueue<>(queueLimit); int numDevices = Nd4j.getAffinityManager().getNumberOfDevices(); int currentDevice = Nd4j.getAffinityManager().getDeviceForCurrentThread(); AtomicBoolean assignedRoot = new AtomicBoolean(false); zoo = new InferenceWorker[workers]; for (int i = 0; i < workers; i++) { int cDevice = i % numDevices; boolean cRoot = !assignedRoot.get() && cDevice == currentDevice; assignedRoot.compareAndSet(false, cRoot); zoo[i] = new InferenceWorker(i, model, observables, cRoot); Nd4j.getAffinityManager().attachThreadToDevice(zoo[i], cDevice); zoo[i].setDaemon(true); zoo[i].start(); } if (inferenceMode == InferenceMode.BATCHED) { log.info("Initializing ObservablesProvider..."); provider = new ObservablesProvider(nanos, batchLimit, observables); } }
protected long getWorkerCounter(int workerIdx) { return zoo[workerIdx].getCounterValue(); }
protected long getWorkerCounter(int workerIdx) { return zoo[workerIdx].getCounterValue(); }