feat: 增加推理接口

Signed-off-by: YdrMaster <ydrml@hotmail.com>
This commit is contained in:
YdrMaster 2023-02-27 10:03:06 +08:00
parent 6e1af09dd0
commit c18845a2fd
1 changed files with 18 additions and 0 deletions

View File

@ -572,6 +572,24 @@ class OnnxStub:
return ctx.build(name) return ctx.build(name)
def init(self) -> None:
self.handler.data_malloc()
def run(self) -> None:
self.handler.run()
def put_int32(self, name: str) -> None:
self.handler.copy_int32(self.inputs[name])
def put_int64(self, name: str) -> None:
self.handler.copy_int64(self.inputs[name])
def put_float(self, name: str) -> None:
self.handler.copy_float(self.inputs[name])
def take_float(self) -> List[float]:
return next(self.handler.outputs.values()).copyFloats()
def from_onnx(model: ModelProto, runtime): def from_onnx(model: ModelProto, runtime):
stub = OnnxStub(model, runtime) stub = OnnxStub(model, runtime)