Skip to content

Commit ddba277

Browse files
tomdzPenghuiCheng
authored andcommitted
Py3 fixes for layer_model_helper.py (pytorch#10525)
Summary: Fixes `__getattr__` to adhere to its Python API contract, and wraps `range()` call in a list since it does not return one anymore in Python 3. Pull Request resolved: pytorch#10525 Reviewed By: ezyang Differential Revision: D9441360 Pulled By: tomdz fbshipit-source-id: d489c0e7cefecc4699ca866fd55ddbfa629688d4
1 parent 59c5aba commit ddba277

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

caffe2/python/layer_model_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ def apply_operator(net, in_record, out_record, **kwargs):
529529
return self.add_layer(new_layer)
530530
return wrapper
531531
else:
532-
raise ValueError(
532+
raise AttributeError(
533533
"Trying to create non-registered layer: {}".format(layer))
534534

535535
@property
@@ -651,5 +651,5 @@ def breakdown_map(self, breakdown_map):
651651
# and change the assertion accordingly
652652
assert isinstance(breakdown_map, dict)
653653
assert all(isinstance(k, six.string_types) for k in breakdown_map)
654-
assert sorted(list(breakdown_map.values())) == range(len(breakdown_map))
654+
assert sorted(breakdown_map.values()) == list(range(len(breakdown_map)))
655655
self._breakdown_map = breakdown_map

0 commit comments

Comments
 (0)