[Mlir-commits] [mlir] 9b1513e - [mlir][runner] Add more printMemref functions.

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Dec 12 09:37:55 PST 2022


Author: bixia1
Date: 2022-12-12T09:37:50-08:00
New Revision: 9b1513eee4a09dd0a1e4a6767683df141382d0b6

URL: https://github.com/llvm/llvm-project/commit/9b1513eee4a09dd0a1e4a6767683df141382d0b6
DIFF: https://github.com/llvm/llvm-project/commit/9b1513eee4a09dd0a1e4a6767683df141382d0b6.diff

LOG: [mlir][runner] Add more printMemref functions.

Add printMemref for complex data types and index type. Add printMemref for 1d
type beyond f32.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D139475

Added: 
    

Modified: 
    mlir/include/mlir/ExecutionEngine/RunnerUtils.h
    mlir/lib/ExecutionEngine/RunnerUtils.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/ExecutionEngine/RunnerUtils.h b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
index 952ab1ba72c84..fb86305bc061d 100644
--- a/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
+++ b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
@@ -33,6 +33,7 @@
 
 #include <assert.h>
 #include <cmath>
+#include <complex>
 #include <iostream>
 
 #include "mlir/ExecutionEngine/CRunnerUtils.h"
@@ -72,6 +73,10 @@ void printUnrankedMemRefMetaData(StreamType &os, UnrankedMemRefType<T> &v) {
 // Templated instantiation follows.
 ////////////////////////////////////////////////////////////////////////////////
 namespace impl {
+using index_type = uint64_t;
+using complex64 = std::complex<double>;
+using complex32 = std::complex<float>;
+
 template <typename T, int M, int... Dims>
 std::ostream &operator<<(std::ostream &os, const Vector<T, M, Dims...> &v);
 
@@ -350,6 +355,12 @@ extern "C" MLIR_RUNNERUTILS_EXPORT void
 _mlir_ciface_printMemrefShapeF32(UnrankedMemRefType<float> *m);
 extern "C" MLIR_RUNNERUTILS_EXPORT void
 _mlir_ciface_printMemrefShapeF64(UnrankedMemRefType<double> *m);
+extern "C" MLIR_RUNNERUTILS_EXPORT void
+_mlir_ciface_printMemrefShapeInd(UnrankedMemRefType<impl::index_type> *m);
+extern "C" MLIR_RUNNERUTILS_EXPORT void
+_mlir_ciface_printMemrefShapeC32(UnrankedMemRefType<impl::complex32> *m);
+extern "C" MLIR_RUNNERUTILS_EXPORT void
+_mlir_ciface_printMemrefShapeC64(UnrankedMemRefType<impl::complex64> *m);
 
 extern "C" MLIR_RUNNERUTILS_EXPORT void
 _mlir_ciface_printMemrefI8(UnrankedMemRefType<int8_t> *m);
@@ -361,6 +372,12 @@ extern "C" MLIR_RUNNERUTILS_EXPORT void
 _mlir_ciface_printMemrefF32(UnrankedMemRefType<float> *m);
 extern "C" MLIR_RUNNERUTILS_EXPORT void
 _mlir_ciface_printMemrefF64(UnrankedMemRefType<double> *m);
+extern "C" MLIR_RUNNERUTILS_EXPORT void
+_mlir_ciface_printMemrefInd(UnrankedMemRefType<impl::index_type> *m);
+extern "C" MLIR_RUNNERUTILS_EXPORT void
+_mlir_ciface_printMemrefC32(UnrankedMemRefType<impl::complex32> *m);
+extern "C" MLIR_RUNNERUTILS_EXPORT void
+_mlir_ciface_printMemrefC64(UnrankedMemRefType<impl::complex64> *m);
 
 extern "C" MLIR_RUNNERUTILS_EXPORT int64_t _mlir_ciface_nanoTime();
 
@@ -368,6 +385,9 @@ extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefI32(int64_t rank, void *ptr);
 extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefI64(int64_t rank, void *ptr);
 extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefF32(int64_t rank, void *ptr);
 extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefF64(int64_t rank, void *ptr);
+extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefInd(int64_t rank, void *ptr);
+extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefC32(int64_t rank, void *ptr);
+extern "C" MLIR_RUNNERUTILS_EXPORT void printMemrefC64(int64_t rank, void *ptr);
 extern "C" MLIR_RUNNERUTILS_EXPORT void printCString(char *str);
 
 extern "C" MLIR_RUNNERUTILS_EXPORT void
@@ -381,6 +401,21 @@ _mlir_ciface_printMemref3dF32(StridedMemRefType<float, 3> *m);
 extern "C" MLIR_RUNNERUTILS_EXPORT void
 _mlir_ciface_printMemref4dF32(StridedMemRefType<float, 4> *m);
 
+extern "C" MLIR_RUNNERUTILS_EXPORT void
+_mlir_ciface_printMemref1dI8(StridedMemRefType<int8_t, 1> *m);
+extern "C" MLIR_RUNNERUTILS_EXPORT void
+_mlir_ciface_printMemref1dI32(StridedMemRefType<int32_t, 1> *m);
+extern "C" MLIR_RUNNERUTILS_EXPORT void
+_mlir_ciface_printMemref1dI64(StridedMemRefType<int64_t, 1> *m);
+extern "C" MLIR_RUNNERUTILS_EXPORT void
+_mlir_ciface_printMemref1dF64(StridedMemRefType<double, 1> *m);
+extern "C" MLIR_RUNNERUTILS_EXPORT void
+_mlir_ciface_printMemref1dInd(StridedMemRefType<impl::index_type, 1> *m);
+extern "C" MLIR_RUNNERUTILS_EXPORT void
+_mlir_ciface_printMemref1dC32(StridedMemRefType<impl::complex32, 1> *m);
+extern "C" MLIR_RUNNERUTILS_EXPORT void
+_mlir_ciface_printMemref1dC64(StridedMemRefType<impl::complex64, 1> *m);
+
 extern "C" MLIR_RUNNERUTILS_EXPORT void _mlir_ciface_printMemrefVector4x4xf32(
     StridedMemRefType<Vector2D<4, 4, float>, 2> *m);
 
@@ -390,6 +425,15 @@ extern "C" MLIR_RUNNERUTILS_EXPORT int64_t _mlir_ciface_verifyMemRefF32(
     UnrankedMemRefType<float> *actual, UnrankedMemRefType<float> *expected);
 extern "C" MLIR_RUNNERUTILS_EXPORT int64_t _mlir_ciface_verifyMemRefF64(
     UnrankedMemRefType<double> *actual, UnrankedMemRefType<double> *expected);
+extern "C" MLIR_RUNNERUTILS_EXPORT int64_t
+_mlir_ciface_verifyMemRefInd(UnrankedMemRefType<impl::index_type> *actual,
+                             UnrankedMemRefType<impl::index_type> *expected);
+extern "C" MLIR_RUNNERUTILS_EXPORT int64_t
+_mlir_ciface_verifyMemRefC32(UnrankedMemRefType<impl::complex32> *actual,
+                             UnrankedMemRefType<impl::complex32> *expected);
+extern "C" MLIR_RUNNERUTILS_EXPORT int64_t
+_mlir_ciface_verifyMemRefC64(UnrankedMemRefType<impl::complex64> *actual,
+                             UnrankedMemRefType<impl::complex64> *expected);
 
 extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefI32(int64_t rank,
                                                            void *actualPtr,
@@ -400,5 +444,14 @@ extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefF32(int64_t rank,
 extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefF64(int64_t rank,
                                                            void *actualPtr,
                                                            void *expectedPtr);
+extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefInd(int64_t rank,
+                                                           void *actualPtr,
+                                                           void *expectedPtr);
+extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefC32(int64_t rank,
+                                                           void *actualPtr,
+                                                           void *expectedPtr);
+extern "C" MLIR_RUNNERUTILS_EXPORT int64_t verifyMemRefC64(int64_t rank,
+                                                           void *actualPtr,
+                                                           void *expectedPtr);
 
 #endif // MLIR_EXECUTIONENGINE_RUNNERUTILS_H

diff  --git a/mlir/lib/ExecutionEngine/RunnerUtils.cpp b/mlir/lib/ExecutionEngine/RunnerUtils.cpp
index a9ad4a9b7d6e7..ccf5309487637 100644
--- a/mlir/lib/ExecutionEngine/RunnerUtils.cpp
+++ b/mlir/lib/ExecutionEngine/RunnerUtils.cpp
@@ -51,6 +51,27 @@ _mlir_ciface_printMemrefShapeF64(UnrankedMemRefType<double> *M) {
   std::cout << "\n";
 }
 
+extern "C" void
+_mlir_ciface_printMemrefShapeInd(UnrankedMemRefType<impl::index_type> *M) {
+  std::cout << "Unranked Memref ";
+  printMemRefMetaData(std::cout, DynamicMemRefType<impl::index_type>(*M));
+  std::cout << "\n";
+}
+
+extern "C" void
+_mlir_ciface_printMemrefShapeC32(UnrankedMemRefType<impl::complex32> *M) {
+  std::cout << "Unranked Memref ";
+  printMemRefMetaData(std::cout, DynamicMemRefType<impl::complex32>(*M));
+  std::cout << "\n";
+}
+
+extern "C" void
+_mlir_ciface_printMemrefShapeC64(UnrankedMemRefType<impl::complex64> *M) {
+  std::cout << "Unranked Memref ";
+  printMemRefMetaData(std::cout, DynamicMemRefType<impl::complex64>(*M));
+  std::cout << "\n";
+}
+
 extern "C" void _mlir_ciface_printMemrefVector4x4xf32(
     StridedMemRefType<Vector2D<4, 4, float>, 2> *M) {
   impl::printMemRef(*M);
@@ -76,6 +97,21 @@ extern "C" void _mlir_ciface_printMemrefF64(UnrankedMemRefType<double> *M) {
   impl::printMemRef(*M);
 }
 
+extern "C" void
+_mlir_ciface_printMemrefInd(UnrankedMemRefType<impl::index_type> *M) {
+  impl::printMemRef(*M);
+}
+
+extern "C" void
+_mlir_ciface_printMemrefC32(UnrankedMemRefType<impl::complex32> *M) {
+  impl::printMemRef(*M);
+}
+
+extern "C" void
+_mlir_ciface_printMemrefC64(UnrankedMemRefType<impl::complex64> *M) {
+  impl::printMemRef(*M);
+}
+
 extern "C" int64_t _mlir_ciface_nanoTime() {
   auto now = std::chrono::high_resolution_clock::now();
   auto duration = now.time_since_epoch();
@@ -104,6 +140,24 @@ extern "C" void printMemrefF64(int64_t rank, void *ptr) {
   _mlir_ciface_printMemrefF64(&descriptor);
 }
 
+// Assume index_type is in fact uint64_t.
+static_assert(std::is_same<impl::index_type, uint64_t>::value,
+              "Expected index_type == uint64_t");
+extern "C" void printMemrefInd(int64_t rank, void *ptr) {
+  UnrankedMemRefType<impl::index_type> descriptor = {rank, ptr};
+  _mlir_ciface_printMemrefInd(&descriptor);
+}
+
+extern "C" void printMemrefC32(int64_t rank, void *ptr) {
+  UnrankedMemRefType<impl::complex32> descriptor = {rank, ptr};
+  _mlir_ciface_printMemrefC32(&descriptor);
+}
+
+extern "C" void printMemrefC64(int64_t rank, void *ptr) {
+  UnrankedMemRefType<impl::complex64> descriptor = {rank, ptr};
+  _mlir_ciface_printMemrefC64(&descriptor);
+}
+
 extern "C" void printCString(char *str) { printf("%s", str); }
 
 extern "C" void _mlir_ciface_printMemref0dF32(StridedMemRefType<float, 0> *M) {
@@ -122,6 +176,39 @@ extern "C" void _mlir_ciface_printMemref4dF32(StridedMemRefType<float, 4> *M) {
   impl::printMemRef(*M);
 }
 
+extern "C" void _mlir_ciface_printMemref1dI8(StridedMemRefType<int8_t, 1> *M) {
+  impl::printMemRef(*M);
+}
+
+extern "C" void
+_mlir_ciface_printMemref1dI32(StridedMemRefType<int32_t, 1> *M) {
+  impl::printMemRef(*M);
+}
+
+extern "C" void
+_mlir_ciface_printMemref1dI64(StridedMemRefType<int64_t, 1> *M) {
+  impl::printMemRef(*M);
+}
+
+extern "C" void _mlir_ciface_printMemref1dF64(StridedMemRefType<double, 1> *M) {
+  impl::printMemRef(*M);
+}
+
+extern "C" void
+_mlir_ciface_printMemref1dInd(StridedMemRefType<impl::index_type, 1> *M) {
+  impl::printMemRef(*M);
+}
+
+extern "C" void
+_mlir_ciface_printMemref1dC32(StridedMemRefType<impl::complex32, 1> *M) {
+  impl::printMemRef(*M);
+}
+
+extern "C" void
+_mlir_ciface_printMemref1dC64(StridedMemRefType<impl::complex64, 1> *M) {
+  impl::printMemRef(*M);
+}
+
 extern "C" int64_t
 _mlir_ciface_verifyMemRefI32(UnrankedMemRefType<int32_t> *actual,
                              UnrankedMemRefType<int32_t> *expected) {
@@ -140,6 +227,24 @@ _mlir_ciface_verifyMemRefF64(UnrankedMemRefType<double> *actual,
   return impl::verifyMemRef(*actual, *expected);
 }
 
+extern "C" int64_t
+_mlir_ciface_verifyMemRefInd(UnrankedMemRefType<impl::index_type> *actual,
+                             UnrankedMemRefType<impl::index_type> *expected) {
+  return impl::verifyMemRef(*actual, *expected);
+}
+
+extern "C" int64_t
+_mlir_ciface_verifyMemRefC32(UnrankedMemRefType<impl::complex32> *actual,
+                             UnrankedMemRefType<impl::complex32> *expected) {
+  return impl::verifyMemRef(*actual, *expected);
+}
+
+extern "C" int64_t
+_mlir_ciface_verifyMemRefC64(UnrankedMemRefType<impl::complex64> *actual,
+                             UnrankedMemRefType<impl::complex64> *expected) {
+  return impl::verifyMemRef(*actual, *expected);
+}
+
 extern "C" int64_t verifyMemRefI32(int64_t rank, void *actualPtr,
                                    void *expectedPtr) {
   UnrankedMemRefType<int32_t> actualDesc = {rank, actualPtr};
@@ -161,4 +266,25 @@ extern "C" int64_t verifyMemRefF64(int64_t rank, void *actualPtr,
   return _mlir_ciface_verifyMemRefF64(&actualDesc, &expectedDesc);
 }
 
+extern "C" int64_t verifyMemRefInd(int64_t rank, void *actualPtr,
+                                   void *expectedPtr) {
+  UnrankedMemRefType<impl::index_type> actualDesc = {rank, actualPtr};
+  UnrankedMemRefType<impl::index_type> expectedDesc = {rank, expectedPtr};
+  return _mlir_ciface_verifyMemRefInd(&actualDesc, &expectedDesc);
+}
+
+extern "C" int64_t verifyMemRefC32(int64_t rank, void *actualPtr,
+                                   void *expectedPtr) {
+  UnrankedMemRefType<impl::complex32> actualDesc = {rank, actualPtr};
+  UnrankedMemRefType<impl::complex32> expectedDesc = {rank, expectedPtr};
+  return _mlir_ciface_verifyMemRefC32(&actualDesc, &expectedDesc);
+}
+
+extern "C" int64_t verifyMemRefC64(int64_t rank, void *actualPtr,
+                                   void *expectedPtr) {
+  UnrankedMemRefType<impl::complex64> actualDesc = {rank, actualPtr};
+  UnrankedMemRefType<impl::complex64> expectedDesc = {rank, expectedPtr};
+  return _mlir_ciface_verifyMemRefC64(&actualDesc, &expectedDesc);
+}
+
 // NOLINTEND(*-identifier-naming)


        


More information about the Mlir-commits mailing list