Linalg_norm crash with simple operation

The app crash after I call the linarg_norm api, it works fine in python

OS : win10 64bits
libtorch version : 1.9.0 cpu
compiler : vc2019

#include <iostream>
#include <torch/script.h>

int main()
{
    try{
        torch::Tensor input = torch::empty({1, 1, 2});
        torch::linalg_norm(input, 2, -1, true);
    }catch(std::exception const &ex){
        std::cerr<<ex.what()<<std::endl;
    }
}

error message :

exception:Dimension out of range (expected to be in range of [-3, 2], but got 140715421935248)
Exception raised from maybe_wrap_dim at ..\..\c10/core/WrapDimMinimal.h:33 (most recent call first):
00007FFAA37910D200007FFAA3791070 c10.dll!c10::Error::Error [<unknown file> @ <unknown line number>]
00007FFAA3763EE500007FFAA3763E70 c10.dll!c10::IndexError::IndexError [<unknown file> @ <unknown line number>]
00007FFA32EB8BC600007FFA32EB8A20 torch_cpu.dll!at::impl::MetaBase::maybe_get_output [<unknown file> @ <unknown line number>]
00007FFA330BA27F00007FFA330B97C0 torch_cpu.dll!at::native::lu_unpack_out [<unknown file> @ <unknown line number>]
00007FFA330B81D200007FFA330B8100 torch_cpu.dll!at::native::linalg_vector_norm [<unknown file> @ <unknown line number>]
00007FFA339A83B100007FFA338A9020 torch_cpu.dll!at::redispatch::zeros_outf [<unknown file> @ <unknown line number>]
00007FFA3398100000007FFA338A9020 torch_cpu.dll!at::redispatch::zeros_outf [<unknown file> @ <unknown line number>]
00007FFA3372EA8C00007FFA33702450 torch_cpu.dll!at::zeros_outf [<unknown file> @ <unknown line number>]
00007FFA3380812100007FFA33808060 torch_cpu.dll!at::redispatch::linalg_vector_norm [<unknown file> @ <unknown line number>]
00007FFA34C3218200007FFA34A166A0 torch_cpu.dll!torch::jit::Value::wrap [<unknown file> @ <unknown line number>]
00007FFA34C15A1E00007FFA34A166A0 torch_cpu.dll!torch::jit::Value::wrap [<unknown file> @ <unknown line number>]
00007FFA33618FB800007FFA33618E40 torch_cpu.dll!at::linalg_vector_norm [<unknown file> @ <unknown line number>]
00007FFA330B567E00007FFA330B4CD0 torch_cpu.dll!at::native::linalg_norm_out [<unknown file> @ <unknown line number>]
00007FFA330B49E200007FFA330B4870 torch_cpu.dll!at::native::linalg_norm [<unknown file> @ <unknown line number>]
00007FFA33AE300100007FFA338A9020 torch_cpu.dll!at::redispatch::zeros_outf [<unknown file> @ <unknown line number>]
00007FFA33ACDF2000007FFA338A9020 torch_cpu.dll!at::redispatch::zeros_outf [<unknown file> @ <unknown line number>]
00007FFA336116F800007FFA33611580 torch_cpu.dll!at::linalg_norm [<unknown file> @ <unknown line number>]
00007FF7A990A30F00007FF7A990A100 test_libtorch_model.exe!c10::ivalue::Future::waitAndThrow [<unknown file> @ <unknown line number>]
00007FF7A990ABB000007FF7A990A100 test_libtorch_model.exe!c10::ivalue::Future::waitAndThrow [<unknown file> @ <unknown line number>]
00007FFADE40703400007FFADE407020 KERNEL32.DLL!BaseThreadInitThunk [<unknown file> @ <unknown line number>]
00007FFADF0A265100007FFADF0A2630 ntdll.dll!RtlUserThreadStart [<unknown file> @ <unknown line number>]

Any clue how to use this api properly? Thanks

Could you create an issue on GitHub so that we can track and fix this issue, please?

1 Like