Skip to content

Commit 539879c

Browse files
authored
Merge branch 'main' into zejun/add_unified_runtime_op_for_flow_in_json_trace_file
2 parents 6ff5f1b + 7ae1ce8 commit 539879c

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

libkineto/include/ActivityType.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ enum class ActivityType {
4141
XPU_RUNTIME, // host side xpu runtime events
4242
COLLECTIVE_COMM, // collective communication
4343
MTIA_WORKLOADD, // MTIA workloadd events
44+
MTIA_COLLECTIVE_COMM, // MTIA collective communication events
4445

4546
// PRIVATEUSE1 Activity types are used for custom backends.
4647
// The corresponding device type is `DeviceType::PrivateUse1` in PyTorch.

libkineto/src/ActivityType.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static constexpr std::array<ActivityTypeName, activityTypeCount + 1> map{
3939
{"xpu_runtime", ActivityType::XPU_RUNTIME},
4040
{"collective_comm", ActivityType::COLLECTIVE_COMM},
4141
{"mtia_workloadd", ActivityType::MTIA_WORKLOADD},
42+
{"mtia_collective_comm", ActivityType::MTIA_COLLECTIVE_COMM},
4243
{"privateuse1_runtime", ActivityType::PRIVATEUSE1_RUNTIME},
4344
{"privateuse1_driver", ActivityType::PRIVATEUSE1_DRIVER},
4445
{"ENUM_COUNT", ActivityType::ENUM_COUNT}}};

libkineto/src/output_json.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ void ChromeTraceLogger::sanitizeStrForJSON(std::string& value) {
7979
value.erase(std::remove(value.begin(), value.end(), '\n'), value.end());
8080
}
8181

82+
static void sanitizeForNonReadableChars(std::string& value) {
83+
for (auto& c : value) {
84+
if (!std::isprint(c)) {
85+
LOG(WARNING) << "Non JSON compliant character found in string: " << value
86+
<< " Replacing with 'unknown'";
87+
value = "unknown";
88+
break;
89+
}
90+
}
91+
}
92+
8293
static inline int32_t sanitizeTid(int32_t tid) {
8394
// Convert all negative tids to its positive value. Create a specific case
8495
// for INT_MIN so it is obvious how it is being handled.
@@ -521,6 +532,7 @@ void ChromeTraceLogger::handleActivity(const libkineto::ITraceActivity& op) {
521532
// TODO: Remove this once legacy tools are updated.
522533
std::string op_name = op.name() == "kernel" ? "Kernel" : op.name();
523534
sanitizeStrForJSON(op_name);
535+
sanitizeForNonReadableChars(op_name);
524536

525537
// clang-format off
526538
ts = transToRelativeTime(ts);

0 commit comments

Comments
 (0)