just a quick note to say that the NNE API has changed in 5.4 so if you were using NNE with 5.3, you will need to update your code (and the documentation hasn’t been updated yet, so take a look at the source).
Here are some pointers to help quickly update:
TArrayView<TWeakInterfacePtr<INNERuntime>> Runtimes = UE::NNE::GetAllRuntimes();
for (int32 i = 0; i < Runtimes.Num(); i++)
{
if (Runtimes[i].IsValid()) {
if (auto CPURuntime = Cast<INNERuntimeCPU>(Runtimes[i].Get())) {
CPURuntimes.Add(CPURuntime);
UE_LOG(LogTemp, Warning, TEXT("CPU runtime available: %s"), *Runtimes[i]->GetRuntimeName());
} else if (auto GPURuntime = Cast<INNERuntimeGPU>(Runtimes[i].Get())) {
GPURuntimes.Add(GPURuntime);
UE_LOG(LogTemp, Warning, TEXT("GPU runtime available: %s"), *Runtimes[i]->GetRuntimeName());
} else if (auto RDGRuntime = Cast<INNERuntimeRDG>(Runtimes[i].Get())) {
RDGRuntimes.Add(RDGRuntime);
UE_LOG(LogTemp, Warning, TEXT("RDG runtime available: %s"), *Runtimes[i]->GetRuntimeName());
} else {
UE_LOG(LogTemp, Warning, TEXT("Non CPU/GPU/RDG runtime: %s"), *Runtimes[i]->GetRuntimeName());
}
}
}
becomes:
for (const auto& Name : GetAllRuntimeNames()) {
UE_LOG(LogTemp, Warning, TEXT("Available runtime: %s"), *Name);
TWeakInterfacePtr<INNERuntime> Runtime = GetRuntime(Name);
if (Runtime.IsValid()) {
if (auto CPURuntime = Cast<INNERuntimeCPU>(Runtime.Get())) {
CPURuntimes.Add(CPURuntime);
UE_LOG(LogTemp, Warning, TEXT("CPU runtime available: %s"), *Name);
} else if (auto GPURuntime = Cast<INNERuntimeGPU>(Runtime.Get())) {
GPURuntimes.Add(GPURuntime);
UE_LOG(LogTemp, Warning, TEXT("GPU runtime available: %s"), *Name);
} else if (auto RDGRuntime = Cast<INNERuntimeRDG>(Runtime.Get())) {
RDGRuntimes.Add(RDGRuntime);
UE_LOG(LogTemp, Warning, TEXT("RDG runtime available: %s"), *Name);
} else {
UE_LOG(LogTemp, Warning, TEXT("Non CPU/GPU/RDG runtime: %s"), *Name);
}
}
}
Then you will notice that APIs might return shared pointers instead of unique pointers and the way you create models isn’t uniform anymore, the method names contain the model type (for instance CreateModelGPU()
).
Nicer error responses on some APIs: if (GPUModelInstance->SetInputTensorShapes(InputShapes) == EResultStatus::Fail)
Overall, nice cleanup and smooth upgrade.