Check if tensor_a is view of tensor_b

Maybe This thread can help you.

BTW, this snippet works for your case:

import torch
def same_storage(x, y):
	x_ptrs = set(e.data_ptr() for e in x.view(-1))
	y_ptrs = set(e.data_ptr() for e in y.view(-1))
	return (x_ptrs <= y_ptrs) or (y_ptrs <= x_ptrs)

same_storage(parent, child1) # False
same_storage(parent, child2) # True
same_storage(parent, child3) # True