Open
[fix]add data[4] past kv to attention plugin #47
LitianciAdd on 12 days ago
[fix]add data[4] past kv to attention plugin #47
Open
Total: 3 files changed+251-6
| @@ -225,10 +225,13 @@ static Status ParseOpToGraphMoE(const ge::Operator& op, ge::Graph& graph) { | |||
| 225 | .set_input_x(cast_input) | 225 | .set_input_x(cast_input) |
| 226 | .set_attr_dtype(ge::DT_INT64); | 226 | .set_attr_dtype(ge::DT_INT64); |
| 227 | 227 | ||
| 228 | + // [NEG-IDX-ATTR] 直接打开 Gather 的 negative_index_support, 用 -1 表示末维 | ||
| 229 | + // (默认 false 时 -1 会算到基址之前 -> aivec: invalid GM address) | ||
| 228 | auto in_last_idx = make_shape_const(ori_name + "_in_lastIdx", {-1}); | 230 | auto in_last_idx = make_shape_const(ori_name + "_in_lastIdx", {-1}); |
| 229 | auto in_last_dim = ge::op::Gather((ori_name + "_in_LastDim").c_str()) | 231 | auto in_last_dim = ge::op::Gather((ori_name + "_in_LastDim").c_str()) |
| 230 | .set_input_x(in_shape) | 232 | .set_input_x(in_shape) |
| 231 | - .set_input_indices(in_last_idx); | 233 | + .set_input_indices(in_last_idx) |
| 234 | + .set_attr_negative_index_support(true); | ||
| 232 | 235 | ||
| 233 | auto in_neg_one = make_shape_const(ori_name + "_in_negOne", {-1}); | 236 | auto in_neg_one = make_shape_const(ori_name + "_in_negOne", {-1}); |
| 234 | auto in_flat_axis = make_shape_const(ori_name + "_in_flatAxis", {0}); | 237 | auto in_flat_axis = make_shape_const(ori_name + "_in_flatAxis", {0}); |
| @@ -3,17 +3,22 @@ if(NOT plugin_srcs) | |||
| 3 | return() | 3 | return() |
| 4 | endif() | 4 | endif() |
| 5 | 5 | ||
| 6 | -npu_op_library(cust_onnx_parsers ONNX_PLUGIN | 6 | +npu_op_library(attention_onnx_parsers ONNX_PLUGIN |
| 7 | ${plugin_srcs} | 7 | ${plugin_srcs} |
| 8 | ) | 8 | ) |
| 9 | 9 | ||
| 10 | +# npu_op_library 将 ONNX_PLUGIN 的 OUTPUT_NAME 硬编码为 cust_onnx_parsers | ||
| 11 | +# (fwk_modules/func.cmake set_target_properties ... OUTPUT_NAME cust_onnx_parsers), | ||
| 12 | +# 此处覆盖为带插件名的产物, 与 skiplayernorm_plugin (vendors/customize) 等包区分 | ||
| 13 | +set_target_properties(attention_onnx_parsers PROPERTIES OUTPUT_NAME attention_onnx_parsers) | ||
| 14 | + | ||
| 10 | # op_graph 算子原型头(reduce_ops.h / array_ops.h)与本地 nlohmann/json | 15 | # op_graph 算子原型头(reduce_ops.h / array_ops.h)与本地 nlohmann/json |
| 11 | -target_include_directories(cust_onnx_parsers PRIVATE | 16 | +target_include_directories(attention_onnx_parsers PRIVATE |
| 12 | ${ASCEND_CANN_PACKAGE_PATH}/opp/built-in/op_graph/inc/ | 17 | ${ASCEND_CANN_PACKAGE_PATH}/opp/built-in/op_graph/inc/ |
| 13 | ${CMAKE_CURRENT_SOURCE_DIR}/third_party | 18 | ${CMAKE_CURRENT_SOURCE_DIR}/third_party |
| 14 | ) | 19 | ) |
| 15 | 20 | ||
| 16 | npu_op_package_add(${package_name} | 21 | npu_op_package_add(${package_name} |
| 17 | LIBRARY | 22 | LIBRARY |
| 18 | - cust_onnx_parsers | 23 | + attention_onnx_parsers |
| 19 | ) | 24 | ) |
Mplugin/attention_plugin/framework/onnx_plugin/attention_onnx_plugin.cc+239-2File content is under review, please try again later