File inference_factory.cpp
File List > common > src > inference > inference_factory.cpp
Go to the documentation of this file
#include "inference_backend.hpp"
#include "stub_backend.hpp"
#ifdef EMULATOR_HAS_LIBTORCH
#include "libtorch_backend.hpp"
#endif
namespace emulator {
namespace inference {
std::unique_ptr<InferenceBackend> create_backend(BackendType type) {
switch (type) {
case BackendType::STUB:
return std::make_unique<StubBackend>();
#ifdef EMULATOR_HAS_LIBTORCH
case BackendType::LIBTORCH:
return std::make_unique<LibTorchBackend>();
#endif
default:
// Fall back to stub for unknown or unavailable backends
return std::make_unique<StubBackend>();
}
}
std::unique_ptr<InferenceBackend>
create_backend(const InferenceConfig &config) {
auto backend = create_backend(config.backend);
if (backend && !backend->initialize(config)) {
return nullptr;
}
return backend;
}
} // namespace inference
} // namespace emulator