Skip to content
This repository has been archived by the owner on Aug 30, 2018. It is now read-only.

Commit

Permalink
Python3 compatibility fixes (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
bddppq authored and ezyang committed Sep 11, 2017
1 parent caf0e42 commit ddab199
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion onnx_caffe2/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ def prepare(cls, predict_graph, device='CPU',
for init_tensor in predict_graph.initializer:
workspace.FeedBlob(init_tensor.name, to_array(init_tensor))
workspace.RunNetOnce(init_net)
uninitialized = filter(lambda x:not workspace.HasBlob(x), predict_net.external_input)
uninitialized = [x
for x in predict_net.external_input
if not workspace.HasBlob(x)]
return Caffe2Rep(init_net, predict_net, device, tmp_ws, uninitialized)

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion onnx_caffe2/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
_blacklist_caffe2_args = {'order', 'global_pooling'}

# expected argument values
_expected_arg_values = {'order': ['NCHW'], 'global_pooling': [1]}
_expected_arg_values = {'order': [b'NCHW'], 'global_pooling': [1]}

_renamed_args = {
'Squeeze': {'dims': 'axes'},
Expand Down
2 changes: 1 addition & 1 deletion tests/caffe2_ref_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_initializer(self):
name="test_initializer",
inputs=["X", "Y", "weight"],
outputs=["W"],
initializer=[helper.make_tensor("weight", onnx_pb2.TensorProto.FLOAT, [2, 2], weight.flatten())]
initializer=[helper.make_tensor("weight", onnx_pb2.TensorProto.FLOAT, [2, 2], weight.flatten().astype(float))]
)
def sigmoid(x):
return 1 / (1 + np.exp(-x))
Expand Down

0 comments on commit ddab199

Please sign in to comment.