ATen create new intermediate tensors (device and type)

Tensors in Pytorch have new_zeros, new_empty that make sure devices are consistent. While ATen has at::zeros_like and at::empty_like it seems the tensors do not have new_zeros.
So if I call:

auto ious = at::zeros(xy.type(), {10, 3, 1, 1, 2});
  1. It makes sure the type is same as xy, but what about the device?

If I want to create a tensor with a new type (e.g. int) I can call:

auto gt_target = at::empty(at::CUDA(at::kInt), {10, 3, 1, 1, 2});
  1. Which device will this tensor be using? can I multiply ious to gt_target

I got part of the answer I was looking for

  1. Yes .type() also has the device information, so ious.device == xy.device

  2. Not sure still, it will be cuda of course but if there are multiple devices I do not know which index will be used

I think this PR and this issue are related to my question:

ATen currently does not have any concept of a “device” beyond CPU vs. CUDA (i.e. the “ordinal” part is missing from ATen’s model). I’m working on changing this right now, so you can expect this to be fixed soon