已合并
[bugfix] AddLora新增对于参数ySliceSize和yOffset的校验 #2973
qiansunchi159创建于 5月27日
[bugfix] AddLora新增对于参数ySliceSize和yOffset的校验 #2973
已合并
共 2 个文件变更+33-5
| @@ -225,11 +225,21 @@ ge::graphStatus AddLoraTiling::CheckInputAttrLimit() | |||
| 225 | return ge::GRAPH_FAILED); | 225 | return ge::GRAPH_FAILED); |
| 226 | scale_ = *scalePtr; | 226 | scale_ = *scalePtr; |
| 227 | 227 | ||
| 228 | + return CheckYSliceAttrs(); | ||
| 229 | +} | ||
| 230 | + | ||
| 231 | +ge::graphStatus AddLoraTiling::CheckYSliceAttrs() | ||
| 232 | +{ | ||
| 228 | const int64_t *yOffsetPtr = attrs_->GetAttrPointer<int64_t>(Y_OFFSET_ATTR_INDEX); | 233 | const int64_t *yOffsetPtr = attrs_->GetAttrPointer<int64_t>(Y_OFFSET_ATTR_INDEX); |
| 229 | OP_CHECK_IF(yOffsetPtr == nullptr, OP_LOGE(context_->GetNodeName(), "AddLora attr yOffset is nullptr."), | 234 | OP_CHECK_IF(yOffsetPtr == nullptr, OP_LOGE(context_->GetNodeName(), "AddLora attr yOffset is nullptr."), |
| 230 | return ge::GRAPH_FAILED); | 235 | return ge::GRAPH_FAILED); |
| 231 | - yOffset_ = static_cast<uint32_t>(*yOffsetPtr); | 236 | + int64_t yOffsetValue = *yOffsetPtr; |
| 232 | - OP_CHECK_IF(yOffset_ > H3_, | 237 | + OP_CHECK_IF(yOffsetValue < 0, |
| 238 | + OP_LOGE(context_->GetNodeName(), | ||
| 239 | + "AddLora attr yOffset must be non-negative, current is %ld.", yOffsetValue), | ||
| 240 | + return ge::GRAPH_FAILED); | ||
| 241 | + yOffset_ = static_cast<uint32_t>(yOffsetValue); | ||
| 242 | + OP_CHECK_IF(yOffset_ >= H3_, | ||
| 233 | OP_LOGE(context_->GetNodeName(), | 243 | OP_LOGE(context_->GetNodeName(), |
| 234 | "AddLora attr yOffset must less than y dim 1, current is %u.", yOffset_), | 244 | "AddLora attr yOffset must less than y dim 1, current is %u.", yOffset_), |
| 235 | return ge::GRAPH_FAILED); | 245 | return ge::GRAPH_FAILED); |
| @@ -237,10 +247,26 @@ ge::graphStatus AddLoraTiling::CheckInputAttrLimit() | |||
| 237 | const int64_t *ySliceSizePtr = attrs_->GetAttrPointer<int64_t>(Y_SLICE_SIZE_ATTR_INDEX); | 247 | const int64_t *ySliceSizePtr = attrs_->GetAttrPointer<int64_t>(Y_SLICE_SIZE_ATTR_INDEX); |
| 238 | OP_CHECK_IF(ySliceSizePtr == nullptr, OP_LOGE(context_->GetNodeName(), "AddLora attr ySliceSize is nullptr."), | 248 | OP_CHECK_IF(ySliceSizePtr == nullptr, OP_LOGE(context_->GetNodeName(), "AddLora attr ySliceSize is nullptr."), |
| 239 | return ge::GRAPH_FAILED); | 249 | return ge::GRAPH_FAILED); |
| 240 | - ySliceSize_ = static_cast<uint32_t>(*ySliceSizePtr); | 250 | + int64_t ySliceSizeValue = *ySliceSizePtr; |
| 241 | - OP_CHECK_IF(ySliceSize_ > H3_, | 251 | + if (ySliceSizeValue == Y_SLICE_SIZE_DEFAULT) { |
| 252 | + ySliceSize_ = H2_; | ||
| 253 | + } else { | ||
| 254 | + OP_CHECK_IF(ySliceSizeValue < 0, | ||
| 255 | + OP_LOGE(context_->GetNodeName(), | ||
| 256 | + "AddLora attr ySliceSize must be non-negative or %ld, current is %ld.", | ||
| 257 | + Y_SLICE_SIZE_DEFAULT, ySliceSizeValue), | ||
| 258 | + return ge::GRAPH_FAILED); | ||
| 259 | + ySliceSize_ = static_cast<uint32_t>(ySliceSizeValue); | ||
| 260 | + } | ||
| 261 | + OP_CHECK_IF(ySliceSize_ > H2_, | ||
| 242 | OP_LOGE(context_->GetNodeName(), | 262 | OP_LOGE(context_->GetNodeName(), |
| 243 | - "AddLora attr ySliceSize must less than y dim 1, current is %u.", ySliceSize_), | 263 | + "AddLora attr ySliceSize must not exceed weightB dim 2 (H2), current ySliceSize is %u, H2 is %u.", |
| 264 | + ySliceSize_, H2_), | ||
| 265 | + return ge::GRAPH_FAILED); | ||
| 266 | + OP_CHECK_IF(yOffset_ + H2_ > H3_, | ||
| 267 | + OP_LOGE(context_->GetNodeName(), | ||
| 268 | + "AddLora yOffset + H2 must not exceed y dim 1, yOffset is %u, H2 is %u, y dim 1 is %u.", | ||
| 269 | + yOffset_, H2_, H3_), | ||
| 244 | return ge::GRAPH_FAILED); | 270 | return ge::GRAPH_FAILED); |
| 245 | return ge::GRAPH_SUCCESS; | 271 | return ge::GRAPH_SUCCESS; |
| 246 | } | 272 | } |
| @@ -45,6 +45,7 @@ constexpr uint32_t MAX_WEIGHT_NUM = 32; | |||
| 45 | constexpr uint32_t MAX_LAYER_NUM = 32; | 45 | constexpr uint32_t MAX_LAYER_NUM = 32; |
| 46 | constexpr uint32_t MAX_HIDDEN_SIZE = 131072; | 46 | constexpr uint32_t MAX_HIDDEN_SIZE = 131072; |
| 47 | constexpr uint32_t BATCH_MODE = 1; | 47 | constexpr uint32_t BATCH_MODE = 1; |
| 48 | +constexpr int64_t Y_SLICE_SIZE_DEFAULT = -1; | ||
| 48 | 49 | ||
| 49 | namespace optiling { | 50 | namespace optiling { |
| 50 | enum class TilingKeyInfo : int { | 51 | enum class TilingKeyInfo : int { |
| @@ -117,6 +118,7 @@ protected: | |||
| 117 | ge::graphStatus CheckInputTensorShape(); | 118 | ge::graphStatus CheckInputTensorShape(); |
| 118 | ge::graphStatus CheckOptionalInputTensorShape(); | 119 | ge::graphStatus CheckOptionalInputTensorShape(); |
| 119 | ge::graphStatus CheckInputAttrLimit(); | 120 | ge::graphStatus CheckInputAttrLimit(); |
| 121 | + ge::graphStatus CheckYSliceAttrs(); | ||
| 120 | ge::graphStatus CheckInputLimits(); | 122 | ge::graphStatus CheckInputLimits(); |
| 121 | // 3、计算数据切分TilingData | 123 | // 3、计算数据切分TilingData |
| 122 | ge::graphStatus DoOpTiling() override; | 124 | ge::graphStatus DoOpTiling() override; |