Will loop all ops in this Module
| 19 | |
| 20 | // Will loop all ops in this Module |
| 21 | nlohmann::json IRSerializer::visit(const ir::IRContext::ptr_t& ctx) { |
| 22 | // Before serialize |
| 23 | // 1. Timestamp |
| 24 | { |
| 25 | auto now = std::chrono::system_clock::now(); |
| 26 | auto time_t = std::chrono::system_clock::to_time_t(now); |
| 27 | std::stringstream ss; |
| 28 | ss << std::put_time(std::localtime(&time_t), "%Y-%m-%d %H:%M:%S"); |
| 29 | code_["compilation_time"] = ss.str(); |
| 30 | } |
| 31 | |
| 32 | // Little endian or big endian |
| 33 | code_["little_endian"] = isLittleEndian(); |
| 34 | |
| 35 | // Platform |
| 36 | code_["platform"] = MLLM_CURRENT_PLATFORM_STRING; |
| 37 | |
| 38 | // CPU Architecture |
| 39 | code_["cpu_architecture"] = mllm::cpu::CURRENT_ARCH_STRING; |
| 40 | |
| 41 | // Compiler information |
| 42 | #if defined(__clang__) |
| 43 | code_["cxx_compiler"] = "Clang"; |
| 44 | code_["cxx_compiler_version"] = |
| 45 | std::to_string(__clang_major__) + "." + std::to_string(__clang_minor__) + "." + std::to_string(__clang_patchlevel__); |
| 46 | #elif defined(__GNUC__) |
| 47 | code_["cxx_compiler"] = "GCC"; |
| 48 | code_["cxx_compiler_version"] = |
| 49 | std::to_string(__GNUC__) + "." + std::to_string(__GNUC_MINOR__) + "." + std::to_string(__GNUC_PATCHLEVEL__); |
| 50 | #elif defined(_MSC_VER) |
| 51 | code_["cxx_compiler"] = "MSVC"; |
| 52 | code_["cxx_compiler_version"] = std::to_string(_MSC_VER); |
| 53 | #else |
| 54 | code_["cxx_compiler"] = "unknown"; |
| 55 | code_["cxx_compiler_version"] = "unknown"; |
| 56 | #endif |
| 57 | |
| 58 | code_["cpp_standard"] = std::to_string(__cplusplus); |
| 59 | |
| 60 | // Start serialize |
| 61 | code_["code"] = visitBuiltinOp(ctx, ctx->topLevelOp()->cast_<ir::BuiltinIROp>()); |
| 62 | |
| 63 | // After serialize |
| 64 | // Count ops in __MLLM_JIT_PACKAGE_CODE_SEGMENT fragment |
| 65 | size_t op_counts = 0; |
| 66 | auto code_fragment = ctx->lookupSymbolTable("__MLLM_JIT_PACKAGE_CODE_SEGMENT"); |
| 67 | if (code_fragment && code_fragment->isa_<ir::program::FragmentOp>()) { |
| 68 | auto fragment_op = code_fragment->cast_<ir::program::FragmentOp>(); |
| 69 | op_counts = fragment_op->getTopRegion()->ops().size(); |
| 70 | } |
| 71 | code_["op_counts"] = op_counts; |
| 72 | |
| 73 | return code_; |
| 74 | } |
| 75 | |
| 76 | nlohmann::json IRSerializer::visitLinalgOp(const ir::IRContext::ptr_t& ctx, const ir::linalg::LinalgIROp::ptr_t& op) { |
| 77 | return {}; |
no test coverage detected