ResourceVariables shouldn't need twice the memory when initializing.
ResourceVariables shouldn't need twice the memory when initializing.

This is safe because all ops which write to resource variables check whether
there are other outstanding references to the buffer and copy if that's the
case. So we can safely reuse the buffer of initializer tensors even in weird
cases such as initializing from a constant (which should never be mutated)
or using the same tensor to initialize multiple variables.

PiperOrigin-RevId: 206211065

seanli9jan/tensorflow,kobejean/tensorflow,Intel-Corporation/tensorflow,ghchinoy/tensorflow,theflofly/tensorflow,tensorflow/tensorflow,Bismarrck/tensorflow,ZhangXinNan/tensorflow,dancingdan/tensorflow,adit-chandra/tensorflow,jendap/tensorflow,yongtang/tensorflow,gunan/tensorflow,ageron/tensorflow,ageron/tensorflow,petewarden/tensorflow,Intel-tensorflow/tensorflow,hfp/tensorflow-xsmm,yongtang/tensorflow,asimshankar/tensorflow,davidzchen/tensorflow,aam-at/tensorflow,karllessard/tensorflow,hfp/tensorflow-xsmm,gautam1858/tensorflow,yongtang/tensorflow,brchiu/tensorflow,xodus7/tensorflow,DavidNorman/tensorflow,aam-at/tensorflow,manipopopo/tensorflow,annarev/tensorflow,jbedorf/tensorflow,asimshankar/tensorflow,tensorflow/tensorflow,petewarden/tensorflow,jbedorf/tensorflow,renyi533/tensorflow,chemelnucfin/tensorflow,dongjoon-hyun/tensorflow,brchiu/tensorflow,AnishShah/tensorflow,paolodedios/tensorflow,alshedivat/tensorflow,AnishShah/tensorflow,arborh/tensorflow,DavidNorman/tensorflow,ghchinoy/tensorflow,seanli9jan/tensorflow,brchiu/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,seanli9jan/tensorflow,girving/tensorflow,sarvex/tensorflow,theflofly/tensorflow,jendap/tensorflow,sarvex/tensorflow,manipopopo/tensorflow,frreiss/tensorflow-fred,adit-chandra/tensorflow,dongjoon-hyun/tensorflow,alsrgv/tensorflow,gautam1858/tensorflow,arborh/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,karllessard/tensorflow,snnn/tensorflow,tensorflow/tensorflow,theflofly/tensorflow,hfp/tensorflow-xsmm,ZhangXinNan/tensorflow,hehongliang/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,chemelnucfin/tensorflow,karllessard/tensorflow,petewarden/tensorflow,alsrgv/tensorflow,dongjoon-hyun/tensorflow,ppwwyyxx/tensorflow,manipopopo/tensorflow,ZhangXinNan/tensorflow,ZhangXinNan/tensorflow,snnn/tensorflow,gunan/tensorflow,petewarden/tensorflow,tensorflow/tensorflow-pywrap_saved_model,apark263/tensorflow,xzturn/tensorflow,jhseu/tensorflow,freedomtan/tensorflow,alsrgv/tensorflow,freedomtan/tensorflow,alsrgv/tensorflow,alsrgv/tensorflow,annarev/tensorflow,yongtang/tensorflow,ZhangXinNan/tensorflow,renyi533/tensorflow,alshedivat/tensorflow,tensorflow/tensorflow-pywrap_saved_model,alshedivat/tensorflow,adit-chandra/tensorflow,asimshankar/tensorflow,ppwwyyxx/tensorflow,alshedivat/tensorflow,snnn/tensorflow,apark263/tensorflow,gunan/tensorflow,aldian/tensorflow,aam-at/tensorflow,cxxgtxy/tensorflow,ppwwyyxx/tensorflow,asimshankar/tensorflow,jhseu/tensorflow,girving/tensorflow,brchiu/tensorflow,jbedorf/tensorflow,arborh/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,apark263/tensorflow,yongtang/tensorflow,paolodedios/tensorflow,gautam1858/tensorflow,alsrgv/tensorflow,renyi533/tensorflow,xzturn/tensorflow,tensorflow/tensorflow,asimshankar/tensorflow,jendap/tensorflow,ppwwyyxx/tensorflow,ghchinoy/tensorflow,xzturn/tensorflow,manipopopo/tensorflow,jbedorf/tensorflow,jbedorf/tensorflow,frreiss/tensorflow-fred,aam-at/tensorflow,alshedivat/tensorflow,brchiu/tensorflow,petewarden/tensorflow,jhseu/tensorflow,aselle/tensorflow,AnishShah/tensorflow,jbedorf/tensorflow,jhseu/tensorflow,xodus7/tensorflow,arborh/tensorflow,annarev/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,aldian/tensorflow,davidzchen/tensorflow,hehongliang/tensorflow,jhseu/tensorflow,Bismarrck/tensorflow,hfp/tensorflow-xsmm,tensorflow/tensorflow,ageron/tensorflow,cxxgtxy/tensorflow,yongtang/tensorflow,karllessard/tensorflow,kobejean/tensorflow,tensorflow/tensorflow-pywrap_saved_model,tensorflow/tensorflow,xzturn/tensorflow,paolodedios/tensorflow,dancingdan/tensorflow,kevin-coder/tensorflow-fork,gautam1858/tensorflow,Intel-Corporation/tensorflow,tensorflow/tensorflow,jendap/tensorflow,yongtang/tensorflow,Intel-Corporation/tensorflow,DavidNorman/tensorflow,ageron/tensorflow,petewarden/tensorflow,manipopopo/tensorflow,adit-chandra/tensorflow,DavidNorman/tensorflow,ZhangXinNan/tensorflow,aldian/tensorflow,aselle/tensorflow,tensorflow/tensorflow-pywrap_saved_model,ageron/tensorflow,snnn/tensorflow,dancingdan/tensorflow,asimshankar/tensorflow,ghchinoy/tensorflow,xodus7/tensorflow,yongtang/tensorflow,adit-chandra/tensorflow,Intel-Corporation/tensorflow,aam-at/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,xodus7/tensorflow,DavidNorman/tensorflow,xodus7/tensorflow,Bismarrck/tensorflow,xzturn/tensorflow,cxxgtxy/tensorflow,kobejean/tensorflow,ppwwyyxx/tensorflow,Intel-tensorflow/tensorflow,jendap/tensorflow,davidzchen/tensorflow,frreiss/tensorflow-fred,Intel-tensorflow/tensorflow,annarev/tensorflow,apark263/tensorflow,hfp/tensorflow-xsmm,girving/tensorflow,tensorflow/tensorflow,arborh/tensorflow,AnishShah/tensorflow,hfp/tensorflow-xsmm,kevin-coder/tensorflow-fork,kobejean/tensorflow,alshedivat/tensorflow,aldian/tensorflow,snnn/tensorflow,freedomtan/tensorflow,hfp/tensorflow-xsmm,dongjoon-hyun/tensorflow,snnn/tensorflow,davidzchen/tensorflow,asimshankar/tensorflow,seanli9jan/tensorflow,Bismarrck/tensorflow,ZhangXinNan/tensorflow,brchiu/tensorflow,dongjoon-hyun/tensorflow,ghchinoy/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,karllessard/tensorflow,yongtang/tensorflow,xzturn/tensorflow,kobejean/tensorflow,dancingdan/tensorflow,aselle/tensorflow,karllessard/tensorflow,jbedorf/tensorflow,adit-chandra/tensorflow,snnn/tensorflow,alshedivat/tensorflow,alshedivat/tensorflow,annarev/tensorflow,tensorflow/tensorflow,jhseu/tensorflow,Intel-tensorflow/tensorflow,ghchinoy/tensorflow,AnishShah/tensorflow,girving/tensorflow,jbedorf/tensorflow,xzturn/tensorflow,aselle/tensorflow,xzturn/tensorflow,jbedorf/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,manipopopo/tensorflow,AnishShah/tensorflow,ghchinoy/tensorflow,aselle/tensorflow,adit-chandra/tensorflow,chemelnucfin/tensorflow,AnishShah/tensorflow,annarev/tensorflow,Bismarrck/tensorflow,jbedorf/tensorflow,alsrgv/tensorflow,kevin-coder/tensorflow-fork,kevin-coder/tensorflow-fork,alshedivat/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,ageron/tensorflow,paolodedios/tensorflow,freedomtan/tensorflow,ghchinoy/tensorflow,annarev/tensorflow,sarvex/tensorflow,kevin-coder/tensorflow-fork,dancingdan/tensorflow,girving/tensorflow,DavidNorman/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,ZhangXinNan/tensorflow,aam-at/tensorflow,dancingdan/tensorflow,ageron/tensorflow,paolodedios/tensorflow,jhseu/tensorflow,frreiss/tensorflow-fred,frreiss/tensorflow-fred,hfp/tensorflow-xsmm,chemelnucfin/tensorflow,alsrgv/tensorflow,adit-chandra/tensorflow,brchiu/tensorflow,DavidNorman/tensorflow,freedomtan/tensorflow,kobejean/tensorflow,xzturn/tensorflow,freedomtan/tensorflow,alshedivat/tensorflow,Intel-Corporation/tensorflow,davidzchen/tensorflow,jbedorf/tensorflow,gunan/tensorflow,annarev/tensorflow,hehongliang/tensorflow,Intel-tensorflow/tensorflow,freedomtan/tensorflow,Intel-tensorflow/tensorflow,chemelnucfin/tensorflow,theflofly/tensorflow,renyi533/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,seanli9jan/tensorflow,kobejean/tensorflow,arborh/tensorflow,ZhangXinNan/tensorflow,davidzchen/tensorflow,Bismarrck/tensorflow,ZhangXinNan/tensorflow,gunan/tensorflow,xodus7/tensorflow,karllessard/tensorflow,hfp/tensorflow-xsmm,gautam1858/tensorflow,Bismarrck/tensorflow,jhseu/tensorflow,petewarden/tensorflow,davidzchen/tensorflow,gunan/tensorflow,renyi533/tensorflow,Bismarrck/tensorflow,annarev/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,xodus7/tensorflow,aldian/tensorflow,jhseu/tensorflow,brchiu/tensorflow,DavidNorman/tensorflow,kevin-coder/tensorflow-fork,gunan/tensorflow,renyi533/tensorflow,seanli9jan/tensorflow,aam-at/tensorflow,jhseu/tensorflow,cxxgtxy/tensorflow,arborh/tensorflow,sarvex/tensorflow,chemelnucfin/tensorflow,paolodedios/tensorflow,renyi533/tensorflow,aam-at/tensorflow,freedomtan/tensorflow,gunan/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,petewarden/tensorflow,theflofly/tensorflow,frreiss/tensorflow-fred,karllessard/tensorflow,DavidNorman/tensorflow,AnishShah/tensorflow,DavidNorman/tensorflow,dancingdan/tensorflow,Intel-Corporation/tensorflow,chemelnucfin/tensorflow,snnn/tensorflow,seanli9jan/tensorflow,apark263/tensorflow,jendap/tensorflow,jendap/tensorflow,arborh/tensorflow,cxxgtxy/tensorflow,aselle/tensorflow,asimshankar/tensorflow,manipopopo/tensorflow,kevin-coder/tensorflow-fork,dongjoon-hyun/tensorflow,theflofly/tensorflow,petewarden/tensorflow,gautam1858/tensorflow,kobejean/tensorflow,Intel-Corporation/tensorflow,hehongliang/tensorflow,aselle/tensorflow,renyi533/tensorflow,snnn/tensorflow,adit-chandra/tensorflow,sarvex/tensorflow,aam-at/tensorflow,Intel-tensorflow/tensorflow,frreiss/tensorflow-fred,alsrgv/tensorflow,kevin-coder/tensorflow-fork,kevin-coder/tensorflow-fork,chemelnucfin/tensorflow,frreiss/tensorflow-fred,aam-at/tensorflow,gunan/tensorflow,Bismarrck/tensorflow,ageron/tensorflow,asimshankar/tensorflow,seanli9jan/tensorflow,aselle/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,gunan/tensorflow,hehongliang/tensorflow,Intel-tensorflow/tensorflow,hehongliang/tensorflow,sarvex/tensorflow,theflofly/tensorflow,chemelnucfin/tensorflow,aselle/tensorflow,aselle/tensorflow,aselle/tensorflow,gautam1858/tensorflow,aldian/tensorflow,paolodedios/tensorflow,Intel-tensorflow/tensorflow,davidzchen/tensorflow,seanli9jan/tensorflow,dancingdan/tensorflow,dancingdan/tensorflow,jhseu/tensorflow,manipopopo/tensorflow,AnishShah/tensorflow,sarvex/tensorflow,ppwwyyxx/tensorflow,tensorflow/tensorflow-pywrap_saved_model,davidzchen/tensorflow,frreiss/tensorflow-fred,ppwwyyxx/tensorflow,ageron/tensorflow,ppwwyyxx/tensorflow,ppwwyyxx/tensorflow,girving/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,brchiu/tensorflow,gunan/tensorflow,apark263/tensorflow,DavidNorman/tensorflow,dongjoon-hyun/tensorflow,aam-at/tensorflow,xodus7/tensorflow,xodus7/tensorflow,karllessard/tensorflow,apark263/tensorflow,brchiu/tensorflow,theflofly/tensorflow,kevin-coder/tensorflow-fork,Intel-tensorflow/tensorflow,theflofly/tensorflow,kevin-coder/tensorflow-fork,dancingdan/tensorflow,annarev/tensorflow,tensorflow/tensorflow-pywrap_saved_model,gautam1858/tensorflow,petewarden/tensorflow,jendap/tensorflow,girving/tensorflow,snnn/tensorflow,adit-chandra/tensorflow,petewarden/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,arborh/tensorflow,arborh/tensorflow,Intel-tensorflow/tensorflow,renyi533/tensorflow,ppwwyyxx/tensorflow,gautam1858/tensorflow,annarev/tensorflow,davidzchen/tensorflow,girving/tensorflow,chemelnucfin/tensorflow,karllessard/tensorflow,manipopopo/tensorflow,jendap/tensorflow,ghchinoy/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,apark263/tensorflow,jhseu/tensorflow,tensorflow/tensorflow-pywrap_saved_model,girving/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,jendap/tensorflow,gautam1858/tensorflow,renyi533/tensorflow,aldian/tensorflow,theflofly/tensorflow,manipopopo/tensorflow,freedomtan/tensorflow,paolodedios/tensorflow,Bismarrck/tensorflow,xzturn/tensorflow,snnn/tensorflow,tensorflow/tensorflow-pywrap_saved_model,dongjoon-hyun/tensorflow,hfp/tensorflow-xsmm,renyi533/tensorflow,AnishShah/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,xodus7/tensorflow,karllessard/tensorflow,asimshankar/tensorflow,ppwwyyxx/tensorflow,ppwwyyxx/tensorflow,freedomtan/tensorflow,cxxgtxy/tensorflow,apark263/tensorflow,ZhangXinNan/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,ageron/tensorflow,aam-at/tensorflow,dancingdan/tensorflow,kobejean/tensorflow,paolodedios/tensorflow,alshedivat/tensorflow,xzturn/tensorflow,gautam1858/tensorflow,xodus7/tensorflow,gunan/tensorflow,aldian/tensorflow,paolodedios/tensorflow,ghchinoy/tensorflow,theflofly/tensorflow,cxxgtxy/tensorflow,alsrgv/tensorflow,tensorflow/tensorflow-pywrap_saved_model,yongtang/tensorflow,dongjoon-hyun/tensorflow,cxxgtxy/tensorflow,theflofly/tensorflow,petewarden/tensorflow,DavidNorman/tensorflow,Intel-Corporation/tensorflow,chemelnucfin/tensorflow,freedomtan/tensorflow,AnishShah/tensorflow,gautam1858/tensorflow,jendap/tensorflow,asimshankar/tensorflow,jbedorf/tensorflow,xzturn/tensorflow,girving/tensorflow,kobejean/tensorflow,tensorflow/tensorflow,arborh/tensorflow,alsrgv/tensorflow,apark263/tensorflow,seanli9jan/tensorflow,davidzchen/tensorflow,yongtang/tensorflow,seanli9jan/tensorflow,paolodedios/tensorflow,manipopopo/tensorflow,apark263/tensorflow,frreiss/tensorflow-fred,tensorflow/tensorflow-pywrap_saved_model,dongjoon-hyun/tensorflow,sarvex/tensorflow,tensorflow/tensorflow,kobejean/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,Bismarrck/tensorflow,hehongliang/tensorflow,arborh/tensorflow,frreiss/tensorflow-fred,adit-chandra/tensorflow,frreiss/tensorflow-fred,brchiu/tensorflow,adit-chandra/tensorflow,hfp/tensorflow-xsmm,ghchinoy/tensorflow,davidzchen/tensorflow,girving/tensorflow,chemelnucfin/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,renyi533/tensorflow,ghchinoy/tensorflow,dongjoon-hyun/tensorflow,alsrgv/tensorflow,ageron/tensorflow,tensorflow/tensorflow-pywrap_saved_model,ageron/tensorflow