* 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_C_API_H_
#define GE_FRAMEWORK_RUNTIME_DUMP_MODEL_DUMP_C_API_H_
#include <stdint.h>
#include <stddef.h>
#if defined(_MSC_VER)
#define OM2_C_API_EXPORT __declspec(dllexport)
#else
#define OM2_C_API_EXPORT __attribute__((visibility("default")))
#endif
#ifdef __cplusplus
extern "C" {
#endif
* @brief OM2 算子输入或输出 Tensor 的基础信息。
*/
struct Om2Tensor {
uint64_t device_address;
uint64_t size;
int32_t data_type;
int32_t format;
const int64_t* shape_dims;
uint64_t shape_dims_num;
};
* @brief OM2 算子单个输入或输出 Tensor 与 args buffer 地址槽位的映射信息。
*/
struct Om2TaskIoEntry {
const struct Om2Tensor* tensor;
uint64_t offset;
};
* @brief L0 异常 dump 的 kernel 参数槽位类型。
*/
enum Om2L0ArgKind {
OM2_L0_ARG_INPUT = 0,
OM2_L0_ARG_OUTPUT = 1,
OM2_L0_ARG_WORKSPACE = 2,
OM2_L0_ARG_TILING = 3,
OM2_L0_ARG_SHAPE_INFO = 4,
OM2_L0_ARG_LEVEL1_DESC = 5,
OM2_L0_ARG_PLACEHOLDER = 6,
OM2_L0_ARG_CUSTOM_VALUE = 7,
OM2_L0_ARG_FFTS_ADDR = 8,
OM2_L0_ARG_EVENT_ADDR = 9,
OM2_L0_ARG_OVERFLOW_ADDR = 10,
OM2_L0_ARG_EMPTY_ADDR = 11
};
* @brief L0 异常 dump 的单个 kernel 参数槽位原始信息。
*/
struct Om2L0ArgSlotInfo {
uint32_t kind;
uint32_t flags;
uint64_t args_offset;
uint64_t value;
uint32_t related_index;
uint32_t event_id;
uint64_t level1_target_offset;
};
* @brief L0 异常 dump 的 kernel 参数原始信息列表。
*/
struct Om2L0TaskRawInfo {
uint32_t version;
uint32_t need_assert_or_printf;
uint64_t arg_num;
const struct Om2L0ArgSlotInfo* args;
};
* @brief OM2 算子任务 dump 信息。
*/
struct Om2TaskInfo {
const char* op_name;
const char* op_type;
uint32_t task_id;
uint32_t stream_id;
uint32_t context_id;
uint32_t thread_id;
uint64_t op_desc_id;
uintptr_t args_base;
uint64_t args_size;
uint64_t input_num;
const struct Om2TaskIoEntry* inputs;
uint32_t output_num;
const struct Om2TaskIoEntry* outputs;
uint32_t workspace_num;
const uint64_t* workspace_addrs;
const uint64_t* workspace_sizes;
uint32_t task_type;
void* stream;
uint32_t is_raw_address;
const struct Om2L0TaskRawInfo* l0_exception_dump_info;
};
* @brief 在 OM2 算子任务 launch 前执行 DFX 预处理。
* @param model_id 输入,模型 ID。当前预留,接口内部暂不使用。
* @param instance_handle 输入,ModelDumpManager 实例指针,不允许为空。
* @param task_info 输入,算子任务 dump 信息指针,不允许为空。
* @param extended_attrs 输入,预留扩展属性指针,当前必须为空指针。
* @param extended_attrs_size 输入,预留扩展属性大小,单位为字节,当前必须为 0。
* @return 返回 0 表示成功,返回其他值表示失败。
*/
int32_t OM2_C_API_EXPORT ReportDfxTaskPreprocess(uint32_t model_id,
void* instance_handle,
const struct Om2TaskInfo* task_info,
const void* extended_attrs,
size_t extended_attrs_size);
* @brief 在 OM2 算子任务 launch 后保存 DFX 任务信息。
* @param model_id 输入,模型 ID。当前预留,接口内部暂不使用。
* @param instance_handle 输入,ModelDumpManager 实例指针,不允许为空。
* @param task_info 输入,算子任务 dump 信息指针,不允许为空。
* @param extended_attrs 输入,预留扩展属性指针,当前必须为空指针。
* @param extended_attrs_size 输入,预留扩展属性大小,单位为字节,当前必须为 0。
* @return 返回 0 表示成功,返回其他值表示失败。
*/
int32_t OM2_C_API_EXPORT ReportDfxTaskPostprocess(uint32_t model_id,
void* instance_handle,
const struct Om2TaskInfo* task_info,
const void* extended_attrs,
size_t extended_attrs_size);
* @brief 查询指定算子是否需要 Data Dump。
* @param model_id 输入,模型 ID。当前预留,接口内部暂不使用。
* @param instance_handle 输入,ModelDumpManager 实例指针,不允许为空。
* @param op_name 输入,算子名称。
* @param is_data_dump 输出,该算子是否需要 Data Dump,0 表示不需要,1 表示需要。
* @return 返回 0 表示成功,返回其他值表示失败。
*/
int32_t OM2_C_API_EXPORT IsDataDumpEnabled(uint32_t model_id,
void* instance_handle,
const char* op_name,
uint8_t* is_data_dump);
#ifdef __cplusplus
}
#endif
#endif