提交 b68a3f2e 编写于 作者: Y Yunxing Dai 提交者: TensorFlower Gardener

Iterating through a map in protobuf is essentially nondeterministic. This CL...

Iterating through a map in protobuf is essentially nondeterministic. This CL enables us to traverse the map in a deterministic order by sorting the keys first.

PiperOrigin-RevId: 172918084
上级 58bdae2f
......@@ -20,6 +20,7 @@ limitations under the License.
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>
#include "tensorflow/compiler/xla/layout_util.h"
#include "tensorflow/compiler/xla/literal_util.h"
......@@ -1843,10 +1844,17 @@ UserComputation::GetEmbeddedComputations(
XLA_VLOG_LINES(3, session_computation_.DebugString());
std::vector<VersionedComputationHandle> computations;
std::vector<int64> sorted_handles;
for (const auto& handle_request : session_computation_.requests()) {
int64 handle_value = handle_request.first;
sorted_handles.push_back(handle_request.first);
}
std::sort(sorted_handles.begin(), sorted_handles.end());
for (int64 handle : sorted_handles) {
const auto& handle_request = session_computation_.requests().find(handle);
CHECK(handle_request != session_computation_.requests().end());
int64 handle_value = handle_request->first;
if (handle_value <= version) {
const OperationRequest& request = handle_request.second;
const OperationRequest& request = handle_request->second;
switch (request.request().op_case()) {
case OpRequest::kCallRequest: {
CHECK_EQ(1, request.embedded_computation_versions_size());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册