[mlir] NFC - Add runner util functions to only print MemRef metadata.

These are useful to debug execution, without having to print the whole
content of a memref.
This commit is contained in:
Nicolas Vasilache 2021-03-04 12:35:01 +00:00
parent 05882157db
commit 4f4f3f1e59
2 changed files with 56 additions and 0 deletions

View File

@ -191,6 +191,16 @@ void MemRefDataPrinter<T>::printLast(std::ostream &os, T *base, int64_t dim,
os << "]";
}
template <typename T, int N> void printMemRefShape(StridedMemRefType<T, N> &M) {
std::cout << "Memref ";
printMemRefMetaData(std::cout, DynamicMemRefType<T>(M));
}
template <typename T> void printMemRefShape(UnrankedMemRefType<T> &M) {
std::cout << "Unranked Memref ";
printMemRefMetaData(std::cout, DynamicMemRefType<T>(M));
}
template <typename T>
void printMemRef(const DynamicMemRefType<T> &M) {
printMemRefMetaData(std::cout, M);
@ -327,6 +337,17 @@ int64_t verifyMemRef(UnrankedMemRefType<T> &actual,
////////////////////////////////////////////////////////////////////////////////
// Currently exposed C API.
////////////////////////////////////////////////////////////////////////////////
extern "C" MLIR_RUNNERUTILS_EXPORT void
_mlir_ciface_print_memref_shape_i8(UnrankedMemRefType<int8_t> *M);
extern "C" MLIR_RUNNERUTILS_EXPORT void
_mlir_ciface_print_memref_shape_i32(UnrankedMemRefType<int32_t> *M);
extern "C" MLIR_RUNNERUTILS_EXPORT void
_mlir_ciface_print_memref_shape_i64(UnrankedMemRefType<int64_t> *M);
extern "C" MLIR_RUNNERUTILS_EXPORT void
_mlir_ciface_print_memref_shape_f32(UnrankedMemRefType<float> *M);
extern "C" MLIR_RUNNERUTILS_EXPORT void
_mlir_ciface_print_memref_shape_f64(UnrankedMemRefType<double> *M);
extern "C" MLIR_RUNNERUTILS_EXPORT void
_mlir_ciface_print_memref_i8(UnrankedMemRefType<int8_t> *M);
extern "C" MLIR_RUNNERUTILS_EXPORT void

View File

@ -15,6 +15,41 @@
#include "mlir/ExecutionEngine/RunnerUtils.h"
extern "C" void
_mlir_ciface_print_memref_shape_i8(UnrankedMemRefType<int8_t> *M) {
std::cout << "Unranked Memref ";
printMemRefMetaData(std::cout, DynamicMemRefType<int8_t>(*M));
std::cout << "\n";
}
extern "C" void
_mlir_ciface_print_memref_shape_i32(UnrankedMemRefType<int32_t> *M) {
std::cout << "Unranked Memref ";
printMemRefMetaData(std::cout, DynamicMemRefType<int32_t>(*M));
std::cout << "\n";
}
extern "C" void
_mlir_ciface_print_memref_shape_i64(UnrankedMemRefType<int64_t> *M) {
std::cout << "Unranked Memref ";
printMemRefMetaData(std::cout, DynamicMemRefType<int64_t>(*M));
std::cout << "\n";
}
extern "C" void
_mlir_ciface_print_memref_shape_f32(UnrankedMemRefType<float> *M) {
std::cout << "Unranked Memref ";
printMemRefMetaData(std::cout, DynamicMemRefType<float>(*M));
std::cout << "\n";
}
extern "C" void
_mlir_ciface_print_memref_shape_f64(UnrankedMemRefType<double> *M) {
std::cout << "Unranked Memref ";
printMemRefMetaData(std::cout, DynamicMemRefType<double>(*M));
std::cout << "\n";
}
extern "C" void _mlir_ciface_print_memref_vector_4x4xf32(
StridedMemRefType<Vector2D<4, 4, float>, 2> *M) {
impl::printMemRef(*M);