[llvm] 9cffabc - [mlgo][nfc] Better pretty printing of interactive mode reply

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 2 07:53:24 PST 2023


Author: Mircea Trofin
Date: 2023-02-02T07:53:15-08:00
New Revision: 9cffabc68ca380be937e192be909feff7b144822

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

LOG: [mlgo][nfc] Better pretty printing of interactive mode reply

Also simplified the `-interactive-model-runner-echo-reply` flag to a
bool, because the header will contain the advice spec, so there is an
explicit agreement between the compiler and the host as to what that
should be shaped as.

Added: 
    

Modified: 
    llvm/lib/Analysis/InteractiveModelRunner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InteractiveModelRunner.cpp b/llvm/lib/Analysis/InteractiveModelRunner.cpp
index 2e9a906964b1..a0f42fb59190 100644
--- a/llvm/lib/Analysis/InteractiveModelRunner.cpp
+++ b/llvm/lib/Analysis/InteractiveModelRunner.cpp
@@ -18,18 +18,10 @@
 
 using namespace llvm;
 
-#define _IMR_CL_VALS(T, N) clEnumValN(TensorType::N, #T, #T),
-
-static cl::opt<TensorType> DebugReply(
-    "interactive-model-runner-echo-type", cl::init(TensorType::Invalid),
-    cl::Hidden,
+static cl::opt<bool> DebugReply(
+    "interactive-model-runner-echo-reply", cl::init(false), cl::Hidden,
     cl::desc("The InteractiveModelRunner will echo back to stderr "
-             "the data received "
-             "from the host as the specified type (for debugging purposes)."),
-    cl::values(SUPPORTED_TENSOR_TYPES(_IMR_CL_VALS)
-                   clEnumValN(TensorType::Invalid, "disable", "Don't echo")));
-
-#undef _IMR_CL_VALS
+             "the data received from the host (for debugging purposes)."));
 
 InteractiveModelRunner::InteractiveModelRunner(
     LLVMContext &Ctx, const std::vector<TensorSpec> &Inputs,
@@ -75,15 +67,15 @@ void *InteractiveModelRunner::evaluateUntyped() {
   const size_t Limit = OutputBuffer.size();
   while (InsPoint < Limit) {
     auto ReadOrErr = ::sys::fs::readNativeFile(
-        sys::fs::convertFDToNativeFile(Inbound),
-        {Buff + InsPoint, OutputBuffer.size() - InsPoint});
+        Inbound, {Buff + InsPoint, OutputBuffer.size() - InsPoint});
     if (ReadOrErr.takeError()) {
       Ctx.emitError("Failed reading from inbound file");
       break;
     }
     InsPoint += *ReadOrErr;
   }
-  if (DebugReply != TensorType::Invalid)
-    dbgs() << tensorValueToString(OutputBuffer.data(), OutputSpec);
+  if (DebugReply)
+    dbgs() << OutputSpec.name() << ": "
+           << tensorValueToString(OutputBuffer.data(), OutputSpec) << "\n";
   return OutputBuffer.data();
 }


        


More information about the llvm-commits mailing list