manupa-arm commented on a change in pull request #7266:
URL: https://github.com/apache/tvm/pull/7266#discussion_r561206556
##########
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:
Alright, I think its OK to use the different rng function given the
compilation flows. However, I was referring to difference in handling (and
absence of it) the tail. Would it be possible to have that kind of code with
the different rng here as well ?
----------------------------------------------------------------
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:
[email protected]