Hi, I got a weird error when I ran my project. This is a brief view of my code:
def __init__(self):
    ...
    self.entity_embedding = nn.Embedding(self.entity_num, self.dim)
    self.relation_embedding = nn.Embedding(self.relation_num, self.dim)

def forward(self):
    r_and_t = self.entity_embedding(relation) * self.relation_embedding(tail)
    r_and_t = torch.unsqueeze(r_and_t, dim=1)
    r_and_t = r_and_t.expand(r_and_t.shape[0], self.entity_num, self.dim)
    embed_head = self.entity_embedding.weight.expand(r_and_t.shape[0], self.entity_num, self.dim)
    print(r_and_t.shape)
    print(embed_head.shape)
    print((embed_head * r_and_t).shape)  #should get the same shape as the two above

Both self.entity_embedding and self.relation_embedding are nn.Embedding.
Everything is fine until runing process gets to the line:
print((embed_head * r_and_t).shape)

where I got the following information:
torch.Size([512, 14951, 100])
torch.Size([512, 14951, 100])
C:/w/1/s/windows/pytorch/aten/src/THC/THCTensorIndex.cu:361: block: [78,0,0], thread: [116,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
C:/w/1/s/windows/pytorch/aten/src/THC/THCTensorIndex.cu:361: block: [78,0,0], thread: [117,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
C:/w/1/s/windows/pytorch/aten/src/THC/THCTensorIndex.cu:361: block: [78,0,0], thread: [118,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
C:/w/1/s/windows/pytorch/aten/src/THC/THCTensorIndex.cu:361: block: [78,0,0], thread: [119,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
C:/w/1/s/windows/pytorch/aten/src/THC/THCTensorIndex.cu:361: block: [78,0,0], thread: [120,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
C:/w/1/s/windows/pytorch/aten/src/THC/THCTensorIndex.cu:361: block: [78,0,0], thread: [121,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
C:/w/1/s/windows/pytorch/aten/src/THC/THCTensorIndex.cu:361: block: [78,0,0], thread: [122,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
C:/w/1/s/windows/pytorch/aten/src/THC/THCTensorIndex.cu:361: block: [78,0,0], thread: [123,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
C:/w/1/s/windows/pytorch/aten/src/THC/THCTensorIndex.cu:361: block: [78,0,0], thread: [124,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
C:/w/1/s/windows/pytorch/aten/src/THC/THCTensorIndex.cu:361: block: [78,0,0], thread: [125,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
C:/w/1/s/windows/pytorch/aten/src/THC/THCTensorIndex.cu:361: block: [78,0,0], thread: [126,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
C:/w/1/s/windows/pytorch/aten/src/THC/THCTensorIndex.cu:361: block: [78,0,0], thread: [127,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
Traceback (most recent call last):
  File "D:/PyCharm/Projects/OpenKGRL_Pytorch/DistMult/train.py", line 96, in <module>
    raw_head_hits1, raw_head_hits10, raw_head_ranks = model.head_predict(data[0], data[1], data[2])
  File "D:\PyCharm\Projects\OpenKGRL_Pytorch\DistMult\distMult.py", line 47, in head_predict
    print((embed_head * r_and_t).shape)
RuntimeError: CUDA error: device-side assert triggered

It looks that embed_head * r_and_t triggers error, but obviously embed_head and r_and_t are the same shape.  In some previous similar posts people said the reason is index out of bound. But I don’t know how could it happen in a multiplication process. I still have no idea how to debug.
Anything I should note? Or anyone can tell me where is the possible mistakes?