Multi Task Loss Backpropagation with some Tasks on CPU

I have implemented a MultiTask Loss Function. For one of the task there is a custom loss function which is being implemented in CPU. How to create a reference for the same variable (prediction) on CPU so that the during backpropagation, it understands to accumulate the gradients pertaining to that variable?