TopArray is a Python module designed to facilitate the interaction between Python/PyTorch tensor operations and TouchDesigner TOPs. It provides a workflow for referencing CUDA memory from TOPs as tensors and for copying a tensor's data to a scriptTOP efficiently.
To use TopArray, clone or download the TopArray repository. Make sure to have PyTorch with CUDA installed in a TD compatible Python installation visible to Touch. Open ExampleTensorIO.toe and toggle the Active parameter on the TensorIO component.
The example transfers cudaMemory of either an 8 bit RGBA TOP or a 32 RGBA top to a Torch tensor, optionally filters the tensor (see TorchExt for details) then copies the new tensor to a ScriptTOP.
The example transfers cudaMemory of either an 8 bit RGBA TOP or a 32 RGBA top to a Torch tensor, optionally filters the tensor (see TorchExt for details) then copies the new tensor to a ScriptTOP.
This has only been tested on Windows machine with an RTX series GPU.