Code:

for(auto& batch : trainloader) {
auto inputs = at::_cast_Long(batch.data).to(device);
auto targets  = at::_cast_Long(batch.target).to(device);
            totalsize = totalsize + inputs.size(0);
            optimizer.zero_grad();
            auto output = Net.forward(inputs);
            auto loss = torch::nn::functional::cross_entropy(inputs, targets);
            loss.backward();
            optimizer.step();

Error Message:
terminate called after throwing an instance of ‘c10::Error’
what():  “log_softmax_lastdim_kernel_impl” not implemented for ‘Long’ (operator() at aten/src/ATen/native/cpu/SoftMaxKernel.cpp.AVX2.cpp:238)
frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) + 0x6a (0x7f6e629dcaaa in /libtorch/lib/libc10.so)
frame #1:  + 0x154c8ff (0x7f6e54fe58ff in /libtorch/lib/libtorch_cpu.so)
frame #2: at::native::log_softmax_cpu(at::Tensor const&, long, bool) + 0x54a (0x7f6e548ecc1a in /libtorch/lib/libtorch_cpu.so)
frame #3:  + 0x115ef07 (0x7f6e54bf7f07 in /libtorch/lib/libtorch_cpu.so)
frame #4:  + 0x11b16ab (0x7f6e54c4a6ab in /libtorch/lib/libtorch_cpu.so)
frame #5:  + 0x2d497a2 (0x7f6e567e27a2 in /libtorch/lib/libtorch_cpu.so)
frame #6:  + 0x11b16ab (0x7f6e54c4a6ab in /libtorch/lib/libtorch_cpu.so)
frame #7: at::native::log_softmax(at::Tensor const&, long, c10::optionalc10::ScalarType) + 0x160 (0x7f6e548ea0e0 in /libtorch/lib/libtorch_cpu.so)
frame #8:  + 0x1227333 (0x7f6e54cc0333 in /libtorch/lib/libtorch_cpu.so)
frame #9:  + 0x2ce3cf5 (0x7f6e5677ccf5 in /libtorch/lib/libtorch_cpu.so)
frame #10:  + 0x12987cc (0x7f6e54d317cc in /libtorch/lib/libtorch_cpu.so)