Skip to content

Commit 9cffabc

Browse files
committed
[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.
1 parent 6d0e137 commit 9cffabc

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

llvm/lib/Analysis/InteractiveModelRunner.cpp

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,10 @@
1818

1919
using namespace llvm;
2020

21-
#define _IMR_CL_VALS(T, N) clEnumValN(TensorType::N, #T, #T),
22-
23-
static cl::opt<TensorType> DebugReply(
24-
"interactive-model-runner-echo-type", cl::init(TensorType::Invalid),
25-
cl::Hidden,
21+
static cl::opt<bool> DebugReply(
22+
"interactive-model-runner-echo-reply", cl::init(false), cl::Hidden,
2623
cl::desc("The InteractiveModelRunner will echo back to stderr "
27-
"the data received "
28-
"from the host as the specified type (for debugging purposes)."),
29-
cl::values(SUPPORTED_TENSOR_TYPES(_IMR_CL_VALS)
30-
clEnumValN(TensorType::Invalid, "disable", "Don't echo")));
31-
32-
#undef _IMR_CL_VALS
24+
"the data received from the host (for debugging purposes)."));
3325

3426
InteractiveModelRunner::InteractiveModelRunner(
3527
LLVMContext &Ctx, const std::vector<TensorSpec> &Inputs,
@@ -75,15 +67,15 @@ void *InteractiveModelRunner::evaluateUntyped() {
7567
const size_t Limit = OutputBuffer.size();
7668
while (InsPoint < Limit) {
7769
auto ReadOrErr = ::sys::fs::readNativeFile(
78-
sys::fs::convertFDToNativeFile(Inbound),
79-
{Buff + InsPoint, OutputBuffer.size() - InsPoint});
70+
Inbound, {Buff + InsPoint, OutputBuffer.size() - InsPoint});
8071
if (ReadOrErr.takeError()) {
8172
Ctx.emitError("Failed reading from inbound file");
8273
break;
8374
}
8475
InsPoint += *ReadOrErr;
8576
}
86-
if (DebugReply != TensorType::Invalid)
87-
dbgs() << tensorValueToString(OutputBuffer.data(), OutputSpec);
77+
if (DebugReply)
78+
dbgs() << OutputSpec.name() << ": "
79+
<< tensorValueToString(OutputBuffer.data(), OutputSpec) << "\n";
8880
return OutputBuffer.data();
8981
}

0 commit comments

Comments
 (0)