Hi everyone. I keep getting this runtime error every time I run the code about inplace operation. However, the operation is slicing a tensor in this case and since the tensor adj is not leaf slicing should not affect backprop but it does. I cant figure out why this happens.
If anyone can help me that would be great
Thank you
def convert_adj_to_coo_batch(new_node, new_edge):
# batch = Batch(x=new_node, adj=new_edge)
adj = new_edge.clone()
offset, row, col = (adj > 0).nonzero().t()
**edge_weight = adj[offset, row, col]**
row += offset * new_node.shape[1]
col += offset * new_node.shape[1]
edge_index = torch.stack([row, col], dim=0)
x = new_node.view(new_node.shape[0] * new_node.shape[1], new_node.shape[2])
return x, edge_weight, edge_index
The error is in edge_weight. The code where I do an inplace operation however is here
def introduce_interventions(input_gnn):
index = torch.randint(1, input_gnn.shape[1], (1,))
input_gnn[:, index , :] = 0
input_gnn_cl = input_gnn.clone()
return input_gnn_cl
This function is called before the erroneous function.