From 4706624ed98faf73f5275549a1b6d68940030254 Mon Sep 17 00:00:00 2001 From: Tianqi Chen Date: Thu, 9 Apr 2020 12:48:51 -0700 Subject: [PATCH] [BUGFIX] Fix CRT static test bug (#5293) * [CI][DOCS] Make sure to refresh the cython part * [BUGFIX] Fix CRT static test bug * Fix demo_static * resolve review comment --- apps/bundle_deploy/demo_static.c | 19 ++++++++++--------- apps/bundle_deploy/test_static.c | 26 ++++++++++++++------------ tests/scripts/task_python_docs.sh | 1 + tests/scripts/task_sphinx_precheck.sh | 7 ++++++- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/apps/bundle_deploy/demo_static.c b/apps/bundle_deploy/demo_static.c index 7a7554523284..ed003738b0e6 100644 --- a/apps/bundle_deploy/demo_static.c +++ b/apps/bundle_deploy/demo_static.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "bundle.h" @@ -56,7 +57,7 @@ int main(int argc, char **argv) { DLDataType dtype = {kDLFloat, 32, 1}; input.dtype = dtype; int64_t shape [4] = {1, 3, 224, 224}; - input.shape = &shape; + input.shape = shape; input.strides = NULL; input.byte_offset = 0; @@ -74,8 +75,8 @@ int main(int argc, char **argv) { output.ndim = 2; DLDataType out_dtype = {kDLFloat, 32, 1}; output.dtype = out_dtype; - int64_t out_shape [2] = {1, OUTPUT_LEN}; - output.shape = &out_shape; + int64_t out_shape[2] = {1, OUTPUT_LEN}; + output.shape = out_shape; output.strides = NULL; output.byte_offset = 0; @@ -98,11 +99,11 @@ int main(int argc, char **argv) { max_index, max_iter); printf("timing: %.2f ms (create), %.2f ms (set_input), %.2f ms (run), " "%.2f ms (get_output), %.2f ms (destroy)\n", - (t1.tv_sec-t0.tv_sec)*1000000 + (t1.tv_usec-t0.tv_usec)/1000.f, - (t2.tv_sec-t1.tv_sec)*1000000 + (t2.tv_usec-t1.tv_usec)/1000.f, - (t3.tv_sec-t2.tv_sec)*1000000 + (t3.tv_usec-t2.tv_usec)/1000.f, - (t4.tv_sec-t3.tv_sec)*1000000 + (t4.tv_usec-t3.tv_usec)/1000.f, - (t5.tv_sec-t4.tv_sec)*1000000 + (t5.tv_usec-t4.tv_usec)/1000.f); - + (t1.tv_sec-t0.tv_sec)*1000 + (t1.tv_usec-t0.tv_usec)/1000.f, + (t2.tv_sec-t1.tv_sec)*1000 + (t2.tv_usec-t1.tv_usec)/1000.f, + (t3.tv_sec-t2.tv_sec)*1000 + (t3.tv_usec-t2.tv_usec)/1000.f, + (t4.tv_sec-t3.tv_sec)*1000 + (t4.tv_usec-t3.tv_usec)/1000.f, + (t5.tv_sec-t4.tv_sec)*1000 + (t5.tv_usec-t4.tv_usec)/1000.f); + return 0; } diff --git a/apps/bundle_deploy/test_static.c b/apps/bundle_deploy/test_static.c index 3a8669699e69..05928744ba81 100644 --- a/apps/bundle_deploy/test_static.c +++ b/apps/bundle_deploy/test_static.c @@ -21,6 +21,8 @@ #include #include +#include +#include #include #include @@ -71,8 +73,8 @@ int main(int argc, char **argv) { input.ndim = 2; DLDataType dtype = {kDLFloat, 32, 1}; input.dtype = dtype; - int64_t shape [2] = {10, 5}; - input.shape = &shape; + int64_t shape[2] = {10, 5}; + input.shape = shape; input.strides = NULL; input.byte_offset = 0; @@ -90,15 +92,15 @@ int main(int argc, char **argv) { output.ndim = 2; DLDataType out_dtype = {kDLFloat, 32, 1}; output.dtype = out_dtype; - int64_t out_shape [2] = {10, 5}; - output.shape = &out_shape; + int64_t out_shape[2] = {10, 5}; + output.shape = out_shape; output.strides = NULL; output.byte_offset = 0; - + tvm_runtime_get_output(handle, 0, &output); gettimeofday(&t4, 0); - for (auto i = 0; i < 10 * 5; ++i) { + for (int i = 0; i < 10 * 5; ++i) { assert(fabs(output_storage[i] - result_storage[i]) < 1e-5f); if (fabs(output_storage[i] - result_storage[i]) >= 1e-5f) { printf("got %f, expected %f\n", output_storage[i], result_storage[i]); @@ -110,14 +112,14 @@ int main(int argc, char **argv) { printf("timing: %.2f ms (create), %.2f ms (set_input), %.2f ms (run), " "%.2f ms (get_output), %.2f ms (destroy)\n", - (t1.tv_sec-t0.tv_sec)*1000000 + (t1.tv_usec-t0.tv_usec)/1000.f, - (t2.tv_sec-t1.tv_sec)*1000000 + (t2.tv_usec-t1.tv_usec)/1000.f, - (t3.tv_sec-t2.tv_sec)*1000000 + (t3.tv_usec-t2.tv_usec)/1000.f, - (t4.tv_sec-t3.tv_sec)*1000000 + (t4.tv_usec-t3.tv_usec)/1000.f, - (t5.tv_sec-t4.tv_sec)*1000000 + (t5.tv_usec-t4.tv_usec)/1000.f); + (t1.tv_sec-t0.tv_sec)*1000 + (t1.tv_usec-t0.tv_usec)/1000.f, + (t2.tv_sec-t1.tv_sec)*1000 + (t2.tv_usec-t1.tv_usec)/1000.f, + (t3.tv_sec-t2.tv_sec)*1000 + (t3.tv_usec-t2.tv_usec)/1000.f, + (t4.tv_sec-t3.tv_sec)*1000 + (t4.tv_usec-t3.tv_usec)/1000.f, + (t5.tv_sec-t4.tv_sec)*1000 + (t5.tv_usec-t4.tv_usec)/1000.f); free(json_data); free(params_data); - + return 0; } diff --git a/tests/scripts/task_python_docs.sh b/tests/scripts/task_python_docs.sh index 50790621c3ce..d24ed1af63ea 100755 --- a/tests/scripts/task_python_docs.sh +++ b/tests/scripts/task_python_docs.sh @@ -32,6 +32,7 @@ rm -rf docs/vta/tutorials # cleanup stale log files find . -type f -path "*.log" | xargs rm -f find . -type f -path "*.pyc" | xargs rm -f +make cython3 cd docs PYTHONPATH=`pwd`/../python make html diff --git a/tests/scripts/task_sphinx_precheck.sh b/tests/scripts/task_sphinx_precheck.sh index 2179cb0cfedf..6709b281a88d 100755 --- a/tests/scripts/task_sphinx_precheck.sh +++ b/tests/scripts/task_sphinx_precheck.sh @@ -23,7 +23,11 @@ set -o pipefail cleanup() { - rm -rf /tmp/$$.* + # cat error log if non zero exit + if [ $? ]; then + cat /tmp/$$.log.txt + fi + rm -rf /tmp/$$.* } trap cleanup 0 @@ -31,6 +35,7 @@ trap cleanup 0 rm -rf docs/tutorials rm -rf docs/vta/tutorials find . -type f -path "*.pyc" | xargs rm -f +make cython3 echo "PreCheck sphinx doc generation WARNINGS.." cd docs