Thanks for the reply, sorry for this unclear question. The with context manager only work for python, IMHO.
However, if I want to implement a data parallel, I would have to rewrite the default TF’s pass,  in that case, how would I handle this in C++? Because as far as I know, TF’s tensor does not have the device’s information.