Skip to content

Commit c7b243e

Browse files
authored
Fix overflowing risk (sgl-project#440)
* fix overflowing risk * fix overflowing risk --------- Co-authored-by: iridiumine <iridiumine@users.noreply.github.com>
1 parent acd885a commit c7b243e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

csrc/lightning_indexer/op_host/tiling/lightning_indexer_tiling.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,11 @@ ge::graphStatus LIInfoParser::GetS2SizeForPageAttention()
364364
return ge::GRAPH_FAILED;
365365
}
366366
maxBlockNumPerBatch_ = opParamInfo_.blockTable.tensor->GetStorageShape().GetDim(1);
367-
s2Size_ = maxBlockNumPerBatch_ * blockSize_;
367+
const int64_t s2SizeTemp = static_cast<int64_t>(maxBlockNumPerBatch_) * static_cast<int64_t>(blockSize_);
368+
if (s2SizeTemp > static_cast<int64_t>(std::numeric_limits<uint32_t>::max())) {
369+
return ge::GRAPH_FAILED;
370+
}
371+
s2Size_ = static_cast<uint32_t>(s2SizeTemp);
368372
return ge::GRAPH_SUCCESS;
369373
}
370374

0 commit comments

Comments
 (0)