mirror of https://github.com/llvm/torch-mlir
TorchOnnxToTorch: Fix stack-use-after-free (#3480)
We used to move the SmallVector into an ArrayRef and then the SmallVector left the scope. Found by asan.pull/3525/head
parent
3225f20ab1
commit
6ea6a6c2fe
|
@ -1569,11 +1569,12 @@ void mlir::torch::onnx_c::populateDefaultDomainGtoP(
|
||||||
|
|
||||||
auto transpose = [&](Value m) -> Value {
|
auto transpose = [&](Value m) -> Value {
|
||||||
auto tty = cast<Torch::ValueTensorType>(m.getType());
|
auto tty = cast<Torch::ValueTensorType>(m.getType());
|
||||||
auto shape = tty.getOptionalSizes();
|
std::optional<ArrayRef<int64_t>> shape = tty.getOptionalSizes();
|
||||||
|
llvm::SmallVector<int64_t> newShape;
|
||||||
if (shape.has_value()) {
|
if (shape.has_value()) {
|
||||||
llvm::SmallVector<int64_t> newShape(shape.value());
|
newShape.append(shape.value().begin(), shape.value().end());
|
||||||
std::reverse(newShape.begin(), newShape.end());
|
std::reverse(newShape.begin(), newShape.end());
|
||||||
shape = std::move(newShape);
|
shape = newShape;
|
||||||
}
|
}
|
||||||
auto oty = Torch::ValueTensorType::get(tty.getContext(), shape,
|
auto oty = Torch::ValueTensorType::get(tty.getContext(), shape,
|
||||||
tty.getOptionalDtype());
|
tty.getOptionalDtype());
|
||||||
|
|
Loading…
Reference in New Issue