Skip to content

Commit 9e4c106

Browse files
PraChetittensorflower-gardener
authored andcommitted
Changes the use of dict to OrderedDict in py_utils.py
PiperOrigin-RevId: 421627563
1 parent 05e8783 commit 9e4c106

File tree

1 file changed

+3
-2
lines changed
  • tensorflow_model_optimization/python/core/internal/tensor_encoding/utils

1 file changed

+3
-2
lines changed

tensorflow_model_optimization/python/core/internal/tensor_encoding/utils/py_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from __future__ import division
2121
from __future__ import print_function
2222

23+
import collections
2324
import enum
2425
import numpy as np
2526
import six
@@ -99,7 +100,7 @@ def split_dict_py_tf(dictionary):
99100
"""
100101
if not isinstance(dictionary, dict):
101102
raise TypeError
102-
d_py, d_tf = {}, {}
103+
d_py, d_tf = collections.OrderedDict(), collections.OrderedDict()
103104
for k, v in six.iteritems(dictionary):
104105
if isinstance(v, dict):
105106
d_py[k], d_tf[k] = split_dict_py_tf(v)
@@ -134,7 +135,7 @@ def merge_dicts(dict1, dict2):
134135
ValueError:
135136
If the input dictionaries do not have corresponding structure.
136137
"""
137-
merged_dict = {}
138+
merged_dict = collections.OrderedDict()
138139
if not (isinstance(dict1, dict) and isinstance(dict2, dict)):
139140
raise TypeError
140141

0 commit comments

Comments
 (0)