29 lines
799 B
Python
29 lines
799 B
Python
from __future__ import annotations
|
|
|
|
from typing import Protocol, Sequence
|
|
|
|
|
|
class SimulatorBackend(Protocol):
|
|
def simulate(self, input_data: Sequence, **kwargs):
|
|
"""Run E2E simulation and return results."""
|
|
|
|
|
|
class KneronSimulatorBackend:
|
|
def simulate(self, input_data: Sequence, **kwargs):
|
|
import ktc
|
|
|
|
return ktc.kneron_inference(
|
|
input_data,
|
|
onnx_file=kwargs.get("onnx_file"),
|
|
bie_file=kwargs.get("bie_file"),
|
|
nef_file=kwargs.get("nef_file"),
|
|
input_names=kwargs.get("input_names"),
|
|
platform=kwargs.get("platform"),
|
|
model_id=kwargs.get("model_id"),
|
|
)
|
|
|
|
|
|
def get_simulator_backend(name: str | None = None) -> SimulatorBackend:
|
|
_ = name
|
|
return KneronSimulatorBackend()
|