Rewrite the handling of threads==1, so it's a little more readable, and gets compiled with -O3 in a way that puts this case at the start of the function instead of at the end, which for a mysterious reason results in more stable performance.
Rewrite the handling of threads==1, so it's a little more readable, and gets compiled with -O3 in a way that puts this case at the start of the function instead of at the end, which for a mysterious reason results in more stable performance.

PiperOrigin-RevId: 262565366

jhseu/tensorflow,ppwwyyxx/tensorflow,aam-at/tensorflow,freedomtan/tensorflow,sarvex/tensorflow,chemelnucfin/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,aldian/tensorflow,gunan/tensorflow,annarev/tensorflow,karllessard/tensorflow,davidzchen/tensorflow,Intel-Corporation/tensorflow,yongtang/tensorflow,arborh/tensorflow,xzturn/tensorflow,aam-at/tensorflow,gautam1858/tensorflow,aam-at/tensorflow,adit-chandra/tensorflow,adit-chandra/tensorflow,renyi533/tensorflow,karllessard/tensorflow,renyi533/tensorflow,arborh/tensorflow,sarvex/tensorflow,paolodedios/tensorflow,ppwwyyxx/tensorflow,freedomtan/tensorflow,Intel-Corporation/tensorflow,ppwwyyxx/tensorflow,gautam1858/tensorflow,frreiss/tensorflow-fred,sarvex/tensorflow,arborh/tensorflow,chemelnucfin/tensorflow,ppwwyyxx/tensorflow,DavidNorman/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow,Intel-tensorflow/tensorflow,ppwwyyxx/tensorflow,petewarden/tensorflow,chemelnucfin/tensorflow,gautam1858/tensorflow,sarvex/tensorflow,chemelnucfin/tensorflow,tensorflow/tensorflow-pywrap_saved_model,tensorflow/tensorflow-pywrap_tf_optimizer,gautam1858/tensorflow,cxxgtxy/tensorflow,petewarden/tensorflow,adit-chandra/tensorflow,xzturn/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,sarvex/tensorflow,freedomtan/tensorflow,renyi533/tensorflow,jhseu/tensorflow,gautam1858/tensorflow,DavidNorman/tensorflow,chemelnucfin/tensorflow,petewarden/tensorflow,aldian/tensorflow,renyi533/tensorflow,paolodedios/tensorflow,petewarden/tensorflow,tensorflow/tensorflow,frreiss/tensorflow-fred,jhseu/tensorflow,DavidNorman/tensorflow,gunan/tensorflow,Intel-tensorflow/tensorflow,DavidNorman/tensorflow,Intel-tensorflow/tensorflow,frreiss/tensorflow-fred,petewarden/tensorflow,gunan/tensorflow,gunan/tensorflow,tensorflow/tensorflow-pywrap_saved_model,aam-at/tensorflow,jhseu/tensorflow,chemelnucfin/tensorflow,paolodedios/tensorflow,petewarden/tensorflow,aam-at/tensorflow,tensorflow/tensorflow-pywrap_saved_model,freedomtan/tensorflow,renyi533/tensorflow,gunan/tensorflow,Intel-Corporation/tensorflow,tensorflow/tensorflow,jhseu/tensorflow,xzturn/tensorflow,aldian/tensorflow,chemelnucfin/tensorflow,adit-chandra/tensorflow,davidzchen/tensorflow,jhseu/tensorflow,frreiss/tensorflow-fred,aam-at/tensorflow,xzturn/tensorflow,aam-at/tensorflow,gautam1858/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,davidzchen/tensorflow,sarvex/tensorflow,Intel-tensorflow/tensorflow,karllessard/tensorflow,arborh/tensorflow,ppwwyyxx/tensorflow,cxxgtxy/tensorflow,gunan/tensorflow,chemelnucfin/tensorflow,aldian/tensorflow,freedomtan/tensorflow,annarev/tensorflow,DavidNorman/tensorflow,ppwwyyxx/tensorflow,xzturn/tensorflow,adit-chandra/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,aam-at/tensorflow,tensorflow/tensorflow,gunan/tensorflow,paolodedios/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,jhseu/tensorflow,DavidNorman/tensorflow,annarev/tensorflow,karllessard/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow-pywrap_tf_optimizer,DavidNorman/tensorflow,davidzchen/tensorflow,gunan/tensorflow,gunan/tensorflow,xzturn/tensorflow,aldian/tensorflow,Intel-Corporation/tensorflow,yongtang/tensorflow,DavidNorman/tensorflow,freedomtan/tensorflow,xzturn/tensorflow,karllessard/tensorflow,cxxgtxy/tensorflow,arborh/tensorflow,annarev/tensorflow,cxxgtxy/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow,adit-chandra/tensorflow,frreiss/tensorflow-fred,Intel-tensorflow/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow-pywrap_saved_model,frreiss/tensorflow-fred,DavidNorman/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,Intel-Corporation/tensorflow,ppwwyyxx/tensorflow,aldian/tensorflow,renyi533/tensorflow,tensorflow/tensorflow-pywrap_saved_model,Intel-tensorflow/tensorflow,paolodedios/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,tensorflow/tensorflow,yongtang/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,arborh/tensorflow,frreiss/tensorflow-fred,annarev/tensorflow,paolodedios/tensorflow,davidzchen/tensorflow,xzturn/tensorflow,freedomtan/tensorflow,arborh/tensorflow,yongtang/tensorflow,cxxgtxy/tensorflow,annarev/tensorflow,tensorflow/tensorflow,karllessard/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,sarvex/tensorflow,chemelnucfin/tensorflow,freedomtan/tensorflow,yongtang/tensorflow,ppwwyyxx/tensorflow,arborh/tensorflow,karllessard/tensorflow,adit-chandra/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,arborh/tensorflow,freedomtan/tensorflow,frreiss/tensorflow-fred,petewarden/tensorflow,arborh/tensorflow,tensorflow/tensorflow,karllessard/tensorflow,jhseu/tensorflow,chemelnucfin/tensorflow,renyi533/tensorflow,arborh/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,renyi533/tensorflow,gautam1858/tensorflow,petewarden/tensorflow,adit-chandra/tensorflow,gautam1858/tensorflow,karllessard/tensorflow,gunan/tensorflow,paolodedios/tensorflow,gunan/tensorflow,jhseu/tensorflow,chemelnucfin/tensorflow,frreiss/tensorflow-fred,aam-at/tensorflow,tensorflow/tensorflow-pywrap_saved_model,yongtang/tensorflow,annarev/tensorflow,DavidNorman/tensorflow,tensorflow/tensorflow-pywrap_saved_model,tensorflow/tensorflow-pywrap_saved_model,xzturn/tensorflow,annarev/tensorflow,yongtang/tensorflow,Intel-Corporation/tensorflow,davidzchen/tensorflow,gunan/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,aam-at/tensorflow,adit-chandra/tensorflow,frreiss/tensorflow-fred,annarev/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,jhseu/tensorflow,arborh/tensorflow,DavidNorman/tensorflow,Intel-tensorflow/tensorflow,gautam1858/tensorflow,petewarden/tensorflow,gautam1858/tensorflow,aam-at/tensorflow,jhseu/tensorflow,yongtang/tensorflow,Intel-Corporation/tensorflow,aldian/tensorflow,cxxgtxy/tensorflow,davidzchen/tensorflow,paolodedios/tensorflow,karllessard/tensorflow,adit-chandra/tensorflow,adit-chandra/tensorflow,davidzchen/tensorflow,tensorflow/tensorflow-pywrap_saved_model,tensorflow/tensorflow-pywrap_saved_model,adit-chandra/tensorflow,xzturn/tensorflow,yongtang/tensorflow,gautam1858/tensorflow,renyi533/tensorflow,Intel-tensorflow/tensorflow,xzturn/tensorflow,karllessard/tensorflow,aam-at/tensorflow,paolodedios/tensorflow,chemelnucfin/tensorflow,gautam1858/tensorflow,ppwwyyxx/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow,davidzchen/tensorflow,renyi533/tensorflow,yongtang/tensorflow,yongtang/tensorflow,ppwwyyxx/tensorflow,xzturn/tensorflow,cxxgtxy/tensorflow,petewarden/tensorflow,paolodedios/tensorflow,sarvex/tensorflow,tensorflow/tensorflow,DavidNorman/tensorflow,frreiss/tensorflow-fred,renyi533/tensorflow,Intel-tensorflow/tensorflow,petewarden/tensorflow,jhseu/tensorflow,paolodedios/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,Intel-Corporation/tensorflow,davidzchen/tensorflow,annarev/tensorflow,Intel-tensorflow/tensorflow,frreiss/tensorflow-fred,cxxgtxy/tensorflow,Intel-tensorflow/tensorflow,renyi533/tensorflow,petewarden/tensorflow,davidzchen/tensorflow,tensorflow/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow-pywrap_saved_model,davidzchen/tensorflow,annarev/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,aldian/tensorflow,ppwwyyxx/tensorflow