Icemist commented on code in PR #11465:
URL: https://github.com/apache/tvm/pull/11465#discussion_r904433737
##########
src/runtime/crt/common/crt_runtime_api.c:
##########
@@ -528,23 +539,34 @@ tvm_crt_error_t RunTimeEvaluator(tvm_function_index_t
function_index, TVMValue*
}
result_byte_arr->data = NULL;
size_t data_size = sizeof(double) * g_time_evaluator_state.repeat;
- err = TVMPlatformMemoryAllocate(data_size, result_byte_dev,
(void*)&result_byte_arr->data);
+ err = TVMPlatformMemoryAllocate(data_size, result_byte_dev,
(void**)&result_byte_arr->data);
if (err != kTvmErrorNoError) {
goto release_and_return;
}
result_byte_arr->size = data_size;
+
+ // skip first time call, to activate lazy compilation components.
+ err = TVMFuncCall(g_time_evaluator_state.func_to_time, args, type_codes,
num_args, ret_val,
+ ret_type_code);
+ if (err != kTvmErrorNoError) {
+ goto release_and_return;
+ }
+
double min_repeat_seconds = ((double)g_time_evaluator_state.min_repeat_ms) /
1000;
double* iter = (double*)result_byte_arr->data;
for (int i = 0; i < g_time_evaluator_state.repeat; i++) {
- double repeat_res_seconds = 0.0;
- int exec_count = 0;
+ double curr_res_seconds = 0.0;
// do-while structure ensures we run even when `min_repeat_ms` isn't set
(i.e., is 0).
do {
+ if (curr_res_seconds > 0.0) {
+ double a = (min_repeat_seconds / (curr_res_seconds /
g_time_evaluator_state.number) + 1);
+ double b = g_time_evaluator_state.number * 1.618;
+ g_time_evaluator_state.number = (int64_t)(a > b ? a : b); // 1.618 is
chosen by random
Review Comment:
moved it up to the right place
##########
src/runtime/graph_executor/debug/graph_executor_debug.cc:
##########
@@ -176,10 +185,18 @@ class GraphExecutorDebug : public GraphExecutor {
}
TVMRetValue rv;
time_eval.CallPacked(TVMArgs(values.get(), type_codes.get(),
num_flat_args), &rv);
- std::string results = rv.operator std::string();
- const double* results_arr = reinterpret_cast<const
double*>(results.data());
- LOG(INFO) << "Got op timing: " << results_arr[0];
- return results_arr[0];
+ std::string results_str = rv.operator std::string();
+ const double* blob_ptr = reinterpret_cast<const
double*>(results_str.data());
+ for (int i = 0; i < repeat; ++i, ++blob_ptr) {
+ results[i] = *blob_ptr;
+ }
+
+ std::ostringstream os;
+ for (auto& repeat_data : results) {
+ os << std::to_string(repeat_data) + ", ";
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]