Skip to content

Commit 6002727

Browse files
committed
feat: Make run_options optional
Signed-off-by: Anastassios Nanos <ananos@nubificus.co.uk>
1 parent aca7978 commit 6002727

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.PHONY: all
2-
all: noop classify exec nonser tf tflite exec_genop
2+
all: noop classify exec nonser tf tflite exec_genop torch
33

44
prepare:
55
@go mod tidy

vaccel/torch.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func TorchModelRun(
200200
inTensors []TorchTensor,
201201
outTensors *[]TorchTensor,
202202
) int {
203-
if sess == nil || model == nil || buffer == nil || outTensors == nil {
203+
if sess == nil || model == nil || outTensors == nil {
204204
return EINVAL
205205
}
206206

@@ -223,10 +223,17 @@ func TorchModelRun(
223223
cOutPtr := C.malloc(outBufSize)
224224
defer C.free(cOutPtr)
225225

226+
var bufPtr *C.struct_vaccel_torch_buffer
227+
if buffer != nil {
228+
bufPtr = &buffer.cTorchBuffer
229+
} else {
230+
bufPtr = nil
231+
}
232+
226233
ret := int(C.vaccel_torch_model_run(
227234
&sess.cSess,
228235
&model.cRes,
229-
&buffer.cTorchBuffer,
236+
bufPtr,
230237
(**C.struct_vaccel_torch_tensor)(cInPtr),
231238
C.int(nrInputs),
232239
(**C.struct_vaccel_torch_tensor)(cOutPtr),

0 commit comments

Comments
 (0)