* Copyright (c) 2026 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
*/
#ifndef GE_FRAMEWORK_RUNTIME_DUMP_MODEL_DUMP_MANAGER_H_
#define GE_FRAMEWORK_RUNTIME_DUMP_MODEL_DUMP_MANAGER_H_
#include <cstdint>
#include <memory>
#include "framework/common/ge_types.h"
#include "framework/common/ge_visibility.h"
#include "framework/runtime/dump/model_dump_c_api.h"
#include "rt_external_base.h"
namespace ge {
namespace dump {
class DataDumpImpl;
class ExceptionDumpImpl;
class OverflowDumpImpl;
class ProfilingImpl;
using GertModelTaskIoEntry = ::GertModelTaskIoEntry;
using GertModelTaskDesc = ::GertModelTaskDesc;
struct ModelDumpInfo {
uint32_t model_id;
const char *model_name;
const char *root_graph_name;
uint32_t device_id;
void *rt_model_handle;
uint64_t step_id_addr;
uint64_t loop_cond_addr;
uint64_t iterations_per_loop_addr;
};
class VISIBILITY_EXPORT ModelDumpManager {
public:
static Status GlobalInit();
explicit ModelDumpManager(uint32_t model_id);
~ModelDumpManager();
ModelDumpManager(const ModelDumpManager &) = delete;
ModelDumpManager &operator=(const ModelDumpManager &) = delete;
Status SetModelDumpInfo(const ModelDumpInfo &model_info);
ModelDumpInfo &GetModelDumpInfo() {
return model_info_;
}
void SetClearDfxCacheFlagAfterLoad(bool clear_cache);
Status ReportModelLoadBegin() const;
Status ReportModelLoadEnd() const;
Status ReportRunInfoPreprocess(uint64_t model_id, uint64_t step_id, aclrtStream stream) const;
Status ReportRunInfoPostprocess(uint64_t model_id, uint64_t step_id, aclrtStream stream) const;
bool IsProfilingEnabled() const;
Status AddOm2TaskInfo(const GertModelTaskDesc &task_info);
Status PreprocessOm2TaskInfo(const GertModelTaskDesc &task_info);
Status IsDataDumpEnabled(const char *op_name, uint8_t *is_data_dump) const;
Status DispatchDumpInfo();
bool GetOpDescInfo(const OpDescInfoId &op_id, ge::OpDescInfo &op_info) const;
void Clear();
private:
uint32_t model_id_;
ModelDumpInfo model_info_{};
bool need_clear_dfx_cache_{false};
std::unique_ptr<DataDumpImpl> data_dump_impl_;
std::unique_ptr<ExceptionDumpImpl> exception_impl_;
std::unique_ptr<OverflowDumpImpl> overflow_impl_;
std::unique_ptr<ProfilingImpl> profiling_impl_;
};
}
}
#endif