Commit adc06e6f by Tianqi Chen Committed by GitHub

[RUNTIME][ABI] Remove TVMValue as argument, use address (#236)

parent cd29c18c
...@@ -243,10 +243,12 @@ TVM_DLL int TVMFuncCall(TVMFunctionHandle func, ...@@ -243,10 +243,12 @@ TVM_DLL int TVMFuncCall(TVMFunctionHandle func,
* \param ret The return value handle, pass by ret in TVMPackedCFunc * \param ret The return value handle, pass by ret in TVMPackedCFunc
* \param value The value to be returned. * \param value The value to be returned.
* \param type_code The type of the value to be returned. * \param type_code The type of the value to be returned.
* \param num_ret Number of return values, for now only 1 is supported.
*/ */
TVM_DLL int TVMCFuncSetReturn(TVMRetValueHandle ret, TVM_DLL int TVMCFuncSetReturn(TVMRetValueHandle ret,
TVMValue value, TVMValue* value,
int type_code); int* type_code,
int num_ret);
/*! /*!
* \brief Inplace translate callback argument value to return value. * \brief Inplace translate callback argument value to return value.
......
...@@ -64,7 +64,7 @@ def convert_to_tvm_func(pyfunc): ...@@ -64,7 +64,7 @@ def convert_to_tvm_func(pyfunc):
values, tcodes, _ = _make_tvm_args((rv,), temp_args) values, tcodes, _ = _make_tvm_args((rv,), temp_args)
if not isinstance(ret, TVMRetValueHandle): if not isinstance(ret, TVMRetValueHandle):
ret = TVMRetValueHandle(ret) ret = TVMRetValueHandle(ret)
check_call(_LIB.TVMCFuncSetReturn(ret, values[0], ctypes.c_int(tcodes[0]))) check_call(_LIB.TVMCFuncSetReturn(ret, values, tcodes, ctypes.c_int(1)))
_ = temp_args _ = temp_args
_ = rv _ = rv
return 0 return 0
......
...@@ -73,8 +73,9 @@ cdef extern from "tvm/runtime/c_runtime_api.h": ...@@ -73,8 +73,9 @@ cdef extern from "tvm/runtime/c_runtime_api.h":
int* ret_type_code) int* ret_type_code)
int TVMFuncFree(TVMFunctionHandle func) int TVMFuncFree(TVMFunctionHandle func)
int TVMCFuncSetReturn(TVMRetValueHandle ret, int TVMCFuncSetReturn(TVMRetValueHandle ret,
TVMValue value, TVMValue* value,
int type_code) int* type_code,
int num_ret)
int TVMFuncCreateFromCFunc(TVMPackedCFunc func, int TVMFuncCreateFromCFunc(TVMPackedCFunc func,
void* resource_handle, void* resource_handle,
TVMPackedCFuncFinalizer fin, TVMPackedCFuncFinalizer fin,
......
...@@ -44,7 +44,7 @@ cdef int tvm_callback(TVMValue* args, ...@@ -44,7 +44,7 @@ cdef int tvm_callback(TVMValue* args,
raise ValueError("PackedFunction can only support one return value") raise ValueError("PackedFunction can only support one return value")
temp_args = [] temp_args = []
make_arg(rv, &value, &tcode, temp_args) make_arg(rv, &value, &tcode, temp_args)
CALL(TVMCFuncSetReturn(ret, value, tcode)) CALL(TVMCFuncSetReturn(ret, &value, &tcode, 1))
return 0 return 0
......
...@@ -323,11 +323,13 @@ int TVMFuncCall(TVMFunctionHandle func, ...@@ -323,11 +323,13 @@ int TVMFuncCall(TVMFunctionHandle func,
} }
int TVMCFuncSetReturn(TVMRetValueHandle ret, int TVMCFuncSetReturn(TVMRetValueHandle ret,
TVMValue value, TVMValue* value,
int type_code) { int* type_code,
int num_ret) {
API_BEGIN(); API_BEGIN();
CHECK_EQ(num_ret, 1);
TVMRetValue* rv = static_cast<TVMRetValue*>(ret); TVMRetValue* rv = static_cast<TVMRetValue*>(ret);
*rv = TVMArgValue(value, type_code); *rv = TVMArgValue(value[0], type_code[0]);
API_END(); API_END();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment