forked from jiuyuan/InfiniTensor
feat: 增加推理接口
Signed-off-by: YdrMaster <ydrml@hotmail.com>
This commit is contained in:
parent
6e1af09dd0
commit
c18845a2fd
|
@ -572,6 +572,24 @@ class OnnxStub:
|
|||
|
||||
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):
|
||||
stub = OnnxStub(model, runtime)
|
||||
|
|
Loading…
Reference in New Issue