You can use the to method:
#include <torch/torch.h>
#include <iostream>

int main() {
    torch::Tensor tensor = torch::rand({2, 3});
    auto x = tensor.to(torch::kInt);
  std::cout << tensor << std::endl;
  std::cout << x << std::endl;
}