my code looks like this, i write a forward hook,and try to move ‘QPs’ to the ‘output’ tensor device then do some operations, but my ‘assert’ code failed , because two tensor are not on the same device, i am confused…BTY,i use dataparallel but i think it doesn’t matter… so what happens?
def layer1_hook_fn_forward(module, input, output):
    # output shape 2, 64, 10, 56, 56
    global QPs
    QPs = output.new(QPs)
    print('**************')
    print(output.device)
    print(QPs.device)
    print('**************')
    assert QPs.device == output.device, "tensor device not match"
    return output.mul(QPs)


besides , i tried QPs.to(output.device), it still wrong…