Create a collector which will dispose the collected NDArrays automatically.
Create a collector which will dispose the collected NDArrays automatically.
an auto-disposable collector.
Collect the NDArrays into the collector of the current thread.
Collect the NDArrays into the collector of the current thread.
NDArrays need to be collected.
Create a collector allows users to later dispose the collected NDArray manually.
Create a collector allows users to later dispose the collected NDArray manually.
a manually-disposable collector.
A collector to store NDArrays. It provides a scope, NDArrays allocated in the scope can either
If the return type of scope is NDArray or NDArrayFuncReturn, the collector is smart enough NOT to collect or dispose the returned NDArray.
However in other cases, it is users' responsibility NOT to leak allocated NDArrays outside, (e.g., store to a global variable and use later, pass to another thread, etc.)
Usage Example: In the case above, the intermediate NDArrays (created by NDArray.relu and +) will be disposed automatically.
User can also decide to dispose the collected NDArrays later:
For Java users: