@chenyuntc Ah! now I found out what was the issue. It was not about the shape but about the indices I was passing to the C. (actually C is sth like D[indicestensor]. Some malicious values were passed as an index caused ‘index going out of boundaries’ error…! thx!