You need to match the scalar type to the tensor’s scalar_type, so:
If you instantiated a torch::kLong tensor (that’s 64 bit integers), use int64_t. For kInt (32 bit) use int32_t, for nothing (aka kFloat), float.
Note that you usually do not need packed_accessor for CPU tensors, they are intended for passing to CUDA kernels. accessor will do for CPU (pointing to the Tensor’s stride and size arrays) - unless you want 32 indexing (on ARM?, probably not on x86).
(And you can use auto for less repetitive code.)
Best regards
Thomas