a=tf.Variable(1,name=“variable_a”)
print(a.dtype)
在python层面上述代码产生一个int32_ref的tensor,吃a的op必须和variable_a在同一设备上,并且tensor a 和variable_a共享同一块buffer(共享buffer肯定要在同一设备上)。上述代码产生的pb图如下:
tensorlfow数据类型之reference type
我们看看read的属性:
tensorlfow数据类型之reference type
注意_class属性,loc:@Variable表示此op的输出tensor和Variable这个op共享buffer,也必须在同一设备上。
再从c++底层解析:
看tensorflow-r1.14\tensorflow\core\ops\state_ops.cc
tensorlfow数据类型之reference type
注册Variable op的时候,就限制其输出为Ref。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-07
  • 2021-11-28
  • 2022-01-08
  • 2022-12-23
猜你喜欢
  • 2021-06-17
  • 2022-12-23
  • 2021-10-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案