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



##########
File path: tests/micro/qemu/zephyr-runtime/src/main.c
##########
@@ -161,6 +162,27 @@ tvm_crt_error_t TVMPlatformTimerStop(double* 
elapsed_time_seconds) {
   return kTvmErrorNoError;
 }
 
+tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) {
+  uint32_t random;  // one unit of random data.

Review comment:
       Maybe use modulo operator and remove `num_full_blocks`? Like:
   
   ```suggestion
     uint32_t random;  // one unit of random data.
   
     size_t block_size = sizeof(random);
     size_t num_blocks = num_bytes / block_size;
     size_t num_tail_bytes  = num_bytes % block_size;
   
     // Fill parts of `buffer` which are as large as `random`.
     for (int i = 0; i < num_blocks; ++i) {
       random = sys_rand32_get();
       memcpy(&buffer[i * block_size], &random, block_size);
     }
   
     // Fill any leftover tail which is smaller than `random`.
     if (num_tail_bytes > 0) {
       random = sys_rand32_get();
       memcpy(&buffer[num_bytes - num_tail_bytes], &random, num_tail_bytes);
     }
   ```

##########
File path: tests/micro/qemu/zephyr-runtime/src/main.c
##########
@@ -161,6 +162,27 @@ tvm_crt_error_t TVMPlatformTimerStop(double* 
elapsed_time_seconds) {
   return kTvmErrorNoError;
 }
 
+tvm_crt_error_t TVMPlatformGenerateRandom(uint8_t* buffer, size_t num_bytes) {
+  uint32_t random;  // one unit of random data.
+
+  // Fill parts of `buffer` which are as large as `random`.
+  size_t num_full_blocks = num_bytes / sizeof(random);
+  for (int i = 0; i < num_full_blocks; ++i) {
+    random = sys_rand32_get();
+    memcpy(&buffer[i * sizeof(random)], &random, sizeof(random));
+  }
+
+  // Fill any leftover tail which is smaller than `random.

Review comment:
       It's missing a closing single quote closing ` random`




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