The speed of index assignment of two vectors is very slow

I am a beginner of pytorch. Now I find a problem. Suppose I have two tensor sampling_relation and relation_db , they’re all in the GPU. When I execute the following code, it takes about 2 seconds.

sampling_relation[batchs, j, 0:total_length] = relation_db[item_id, 0:total_length]

Can anyone provide some optimization methods. I would appreciate it if you could help me! Thx!