[Mlir-commits] [mlir] [mlir][sparse][CRunnerUtils] Add shuffle in CRunnerUtils (PR #77124)

Peiming Liu llvmlistbot at llvm.org
Mon Jan 8 09:32:37 PST 2024


================
@@ -176,6 +177,16 @@ extern "C" void rtdrand(void *g) {
   delete generator;
 }
 
+extern "C" void _mlir_ciface_shuffle(StridedMemRefType<uint64_t, 1> *m,
+                                     void *g) {
+  std::mt19937 *generator = static_cast<std::mt19937 *>(g);
+  uint64_t s = m->sizes[0];
+  std::vector<uint64_t> arr(s);
+  std::iota(arr.begin(), arr.end(), 0);
+  std::shuffle(arr.begin(), arr.end(), *generator);
+  std::copy(arr.begin(), arr.end(), m->data);
----------------
PeimingLiu wrote:

Can we avoid the copy?

https://github.com/llvm/llvm-project/pull/77124


More information about the Mlir-commits mailing list