offsets = [0, (x1_shape[1] - x2_shape[1]) // 2, (x1_shape[2] - x2_shape[2]) // 2, 0]
size = [-1, x2_shape[1], x2_shape[2], -1]
offsets = [0, (x1_shape[1] - x2_shape[1]) // 2, (x1_shape[2] - x2_shape[2]) // 2, 0]
size = [-1, x2_shape[1], x2_shape[2], -1]
If you pass the -1
to an operation, which expects a dimension, it would select the “last dimension”.
In your current code snippet it’s unclear, how size
is used, so I can only speculate.
The TF docs might be helpful:
If
size[i]
is -1, all remaining elements in dimension i are included in the slice. In other words, this is equivalent to setting:
size[i] = input_.dim_size(i) - begin[i]
If you provide the input and desired output (+ shapes), we could try to come up with the corresponding method in PyTorch.