Tensor.expand() lead to c10::Error

I’m using Libtorch 1.10 Release Version on windows with VS 2022. The following code:


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

namespace F = torch::nn::functional;
using namespace std;

int main()
{
	torch::Tensor ox1 = torch::rand({ 3,3 });
	cout << ox1.expand({6,3}) << endl;

lead to

Unhandled exception at 0x00007FFAB6924B89 in test_libtorch.exe: Microsoft C++ exception: c10::Error at memory location 0x000000E83D4FEFD0.

But if replace expand with repeat then there is no problem.

Finally I find that expand can only be used on a tensor with size on some dimensions is exactly 1.