I created an iterator and within it’s constructor, I want to hold the data it’s going to use in the .next(num) method. Hence, the idea was to allocate everything to host memory in one workspace.
I made it work tagging it for out of scope use & toggeling the workspace use off; this works for now. However, it spits some warnings (cause it’s turned off).
Here’s some snippet running in the constructor:
WorkspaceConfiguration hostBufferConfiguration = WorkspaceConfiguration.builder() .initialSize(size) .policyAllocation(AllocationPolicy.STRICT) .policySpill(SpillPolicy.FAIL) .policyLearning(LearningPolicy.NONE) .policyLocation(LocationPolicy.RAM) .policyMirroring(MirroringPolicy.HOST_ONLY) .build(); this.workspaceBuffer = Nd4j.getWorkspaceManager().createNewWorkspace(hostBufferConfiguration, workspaceName); this.workspaceBuffer.enableDebug(debug); this.workspaceBuffer.notifyScopeEntered(); this.data = data.migrate(); this.mask = mask.migrate(); this.workspaceBuffer.tagOutOfScopeUse(); this.workspaceBuffer.toggleWorkspaceUse(false); //never write to this ws again (just as read only buffer)
Whereas the next() method just accesses the INDArrays at this.data & this.mask.
Is that a valid approach or am I abusing the concept?