mkatanbaf commented on code in PR #10967:
URL: https://github.com/apache/tvm/pull/10967#discussion_r852331956


##########
src/runtime/minrpc/minrpc_logger.cc:
##########
@@ -0,0 +1,307 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "minrpc_logger.h"
+
+#include <string.h>
+#include <time.h>
+#include <tvm/runtime/c_runtime_api.h>
+#include <tvm/runtime/logging.h>
+
+#include <functional>
+#include <iostream>
+#include <sstream>
+#include <unordered_map>
+
+#include "minrpc_intrfc.h"
+#include "rpc_reference.h"
+
+namespace tvm {
+namespace runtime {
+
+void Logger::LogTVMValue(int tcode, TVMValue value) {
+  switch (tcode) {
+    case kDLInt:
+      this->LogVal<int64_t>("(int64)", value.v_int64);
+      break;
+    case kDLUInt:
+      this->LogVal<uint64_t>("(uint64)", value.v_int64);
+      break;
+    case kDLFloat: {
+      this->LogVal<float>("(float)", value.v_float64);
+      break;
+    }
+    case kTVMDataType: {
+      this->LogDLData("DLDataType(code,bits,lane)", &value.v_type);
+      break;
+    }
+    case kDLDevice: {
+      this->LogDLDevice("DLDevice(type,id)", &value.v_device);
+      break;
+    }
+    case kTVMPackedFuncHandle: {
+      this->LogVal<void*>("(PackedFuncHandle)", value.v_handle);
+      break;
+    }
+    case kTVMModuleHandle: {
+      this->LogVal<void*>("(ModuleHandle)", value.v_handle);
+      break;
+    }
+    case kTVMOpaqueHandle: {
+      this->LogVal<void*>("(OpaqueHandle)", value.v_handle);
+      break;
+    }
+    case kTVMDLTensorHandle: {
+      this->LogVal<void*>("(TensorHandle)", value.v_handle);
+      break;
+    }
+    case kTVMNDArrayHandle: {
+      this->LogVal<void*>("kTVMNDArrayHandle", value.v_handle);
+      break;
+    }
+    case kTVMNullptr:
+      this->LogString("Nullptr");
+      break;
+    case kTVMStr: {
+      this->LogString("\"");
+      this->LogString(value.v_str);
+      this->LogString("\"");
+      break;
+    }
+    case kTVMBytes: {
+      TVMByteArray* bytes = static_cast<TVMByteArray*>(value.v_handle);
+      int len = bytes->size;
+      this->LogVal<int64_t>("(Bytes) [size]: ", len);
+      if (PRINT_BYTES) {
+        this->LogString(", [Values]:");
+        this->LogString(" { ");
+        if (len > 0) {
+          this->LogVal<uint64_t>("", (uint8_t)bytes->data[0]);
+        }
+        for (int j = 1; j < len; j++) this->LogVal<uint64_t>(" - ", 
(uint8_t)bytes->data[j]);
+        this->LogString(" } ");
+      }
+      break;
+    }
+    default: {
+      this->LogString("ERROR-kUnknownTypeCode)");
+      break;
+    }
+  }
+  this->LogString("; ");
+}
+
+std::stringstream Logger::LogTime() {
+  char buf[100];
+  time_t t;
+  struct tm *timeptr, result, temp;
+  std::stringstream ss;
+
+  t = time(NULL);
+  timeptr = localtime_r(&t, &temp);
+  strftime(buf, sizeof(buf), "%a %m/%d/%Y %r", timeptr);
+
+  if (strptime(buf, "%a %m/%d/%Y %r", &result) == NULL) {

Review Comment:
   since I end up using LOG(INFO) to output the log, and LOG(INFO) adds a 
timestamp, I removed the LogTime function.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tvm.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to