areusch commented on a change in pull request #7266:
URL: https://github.com/apache/tvm/pull/7266#discussion_r561228097



##########
File path: src/runtime/crt/host/main.cc
##########
@@ -93,6 +94,20 @@ tvm_crt_error_t TVMPlatformTimerStop(double* 
elapsed_time_seconds) {
   g_utvm_timer_running = 0;
   return kTvmErrorNoError;
 }
+
+static_assert(RAND_MAX >= (1 << 8), "RAND_MAX is smaller than acceptable");
+unsigned int random_seed = 0;
+tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) {
+  if (random_seed == 0) {
+    random_seed = (unsigned int)time(NULL);
+  }
+  for (size_t i = 0; i < num_bytes; ++i) {
+    int random = rand_r(&random_seed);
+    buffer[i] = (uint8_t)random;

Review comment:
       ah I see. I am being a little bit lazy here as right now, this mainly 
serves (in the tvm repo) to support tests/python/unittest/test_crt.py. I can 
implement a better RNG here if it would help.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to