What am I doing wrong here?

I’m getting this error: Unhandled exception at 0x00007FFC0F5CA799 in example-app.exe: Microsoft C++ exception: c10::Error at memory location 0x0000007EF84FC760.

I want to to max pooling of a random tensor like this:
torch::Tensor det = torch::rand({ 512, 512 });
torch::Tensor maxm = torch::max_pool2d(det, { 5, 5 }, {}, 2 );

Fixed it using torch::Tensor det = torch::rand({ 1,512,512 });
instead of torch::Tensor det = torch::rand({ 512, 512 });
also added torch::NoGradGuard no_grad_guard; line right after for extra measure.