[libclc] [libcxxabi] [compiler-rt] [mlir] [flang] [clang] [lld] [clang-tools-extra] [llvm] [libcxx] [libc] [libunwind] [lldb] [mlir][sparse][CRunnerUtils] Add shuffle in CRunnerUtils (PR #77124)

Aart Bik via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 9 11:36:53 PST 2024


================
@@ -176,6 +177,14 @@ extern "C" void rtdrand(void *g) {
   delete generator;
 }
 
+extern "C" void _mlir_ciface_shuffle(StridedMemRefType<uint64_t, 1> *mref,
+                                     void *g) {
+  std::mt19937 *generator = static_cast<std::mt19937 *>(g);
+  uint64_t s = mref->sizes[0];
----------------
aartbik wrote:

One last nit, we may want to ensure that the rank one tensor has the right properties

assert(mref->strides[0] == 1);  // consecutive

also,although offset is typically zero, I think we need to compute

uint64_t *data = mref->data + mref->offset

and then do

std::iota(data, data + s, 0);

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


More information about the cfe-commits mailing list