- class unreal.NeuralTensor¶
For a general overview of NeuralNetworkInference (NNI), including documentation and code samples, See: UNeuralNetwork, the main class of NNI.
NNI’s users should not directly create or modify instances of FNeuralTensor. Instead, they should only interact with FNeuralNetwork and its input and output functions. E.g., See: FNeuralNetwork::GetInputTensor, FNeuralNetwork::SetInputFromArrayCopy, FNeuralNetwork::GetOutputTensor, etc.
FNeuralTensor is an auxiliary class of UNeuralNetwork which represents a tensor of the UNeuralNetwork model. It is Unreal Engine’s equivalent of torch.Tensor (PyTorch) or caffe::Blob (Caffe).
Most of FNeuralTensor’s functions run on the CPU, so CPUToRDGBuilder_RenderThread() must be called before running on GPU and after running any FNeuralTensor function that modifies the CPU memory. In addition, FNeuralTensor’s CPU functions are very similar to those of TArray<T>.
Editor Properties: (see get_editor_property/set_editor_property)
data_type(NeuralDataType): [Read-Only] Data Type: General variables and properties set by the FNeuralTensor constructor (or their setting functions) and saved on the FNeuralTensor UAsset. - DataType defines the underlying uint8 data type of the network (float, double, int32, etc). - Sizes defines the dimensions of the tensor. - Volume defines the total number of elements of the tensor. I.e., it is the product of the size of each dimension, or mathematically
Prod(Sizes[Index]) for all Indexes.
Name is used for GPU debugging and the ToString() function.
TensorType defines the type of the tensor on a network (Generic, Input, Intermediate(Not)Initialized, Output, Weight, etc.). It is currently only used when moving memory to the GPU.
enable_gpu(bool): [Read-Only] Enable GPU: GPU-related variables that are transient. They are not serialized and are re-configured every time a tensor is loaded. - bEnableGPU: By default false, meaning all GPU memory allocation will be disabled and GPU functions will do nothing. Enable to allow using
the GPU capabilities of the tensor.
PooledBuffer: FRDGPooledBuffer containing the GPU memory of this tensor.
BufferSRVRef: Casting of the PooledBuffer into a read-only SRV.
BufferUAVRef: Casting of the PooledBuffer into a read-write UAV.
name(str): [Read-Only] Name
sizes(Array(int64)): [Read-Only] Sizes
tensor_type(NeuralTensorType): [Read-Only] Tensor Type
volume(int64): [Read-Only] Volume