{"action":"created","issue":{"url":"https://api.github.com/repos/facebookresearch/Detectron/issues/752","repository_url":"https://api.github.com/repos/facebookresearch/Detectron","labels_url":"https://api.github.com/repos/facebookresearch/Detectron/issues/752/labels{/name}","comments_url":"https://api.github.com/repos/facebookresearch/Detectron/issues/752/comments","events_url":"https://api.github.com/repos/facebookresearch/Detectron/issues/752/events","html_url":"https://github.com/facebookresearch/Detectron/issues/752","id":381131174,"node_id":"MDU6SXNzdWUzODExMzExNzQ=","number":752,"title":"Check failed: output->dims() == Input(i).dims() (detectron model -> caffe2 model -> onnx model)","user":{"login":"lilichu","id":28217651,"node_id":"MDQ6VXNlcjI4MjE3NjUx","avatar_url":"https://avatars0.githubusercontent.com/u/28217651?v=4","gravatar_id":"","url":"https://api.github.com/users/lilichu","html_url":"https://github.com/lilichu","followers_url":"https://api.github.com/users/lilichu/followers","following_url":"https://api.github.com/users/lilichu/following{/other_user}","gists_url":"https://api.github.com/users/lilichu/gists{/gist_id}","starred_url":"https://api.github.com/users/lilichu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lilichu/subscriptions","organizations_url":"https://api.github.com/users/lilichu/orgs","repos_url":"https://api.github.com/users/lilichu/repos","events_url":"https://api.github.com/users/lilichu/events{/privacy}","received_events_url":"https://api.github.com/users/lilichu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-11-15T12:03:55Z","updated_at":"2018-11-18T06:04:00Z","closed_at":null,"author_association":"NONE","body":"hi!\r\nI run `./tools/convert_pkl_to_pb.py` to convert detectron model to caffe2 model successfully.\r\nThen I run the code to convert caffe2 model to onnx model:\r\n```\r\nimport onnx\r\nimport caffe2.python.onnx.frontend\r\nfrom caffe2.proto import caffe2_pb2\r\n\r\n# We need to provide type and shape of the model inputs,\r\n# see above Note section for explanation\r\ndata_type = onnx.TensorProto.FLOAT\r\ndata_shape = (1, 3, 720, 1280)\r\nvalue_info = {\r\n    'data': (data_type, data_shape)\r\n}\r\n\r\npredict_net = caffe2_pb2.NetDef()\r\nwith open('model.pb', 'rb') as f:\r\n# with open('predict_net.pb', 'rb') as f:\r\n    predict_net.ParseFromString(f.read())\r\n\r\n\r\ninit_net = caffe2_pb2.NetDef()\r\nwith open('model_init.pb', 'rb') as f:\r\n# with open('init_net.pb', 'rb') as f:\r\n    init_net.ParseFromString(f.read())\r\n\r\nonnx_model = caffe2.python.onnx.frontend.caffe2_net_to_onnx_model(\r\n    predict_net,\r\n    init_net,\r\n    value_info,\r\n)\r\n\r\nonnx.checker.check_model(onnx_model)\r\n```\r\nI encounter the issue:\r\n`RuntimeError: [enforce fail at operator.cc:213] op. Cannot create operator of type 'BatchPermutation' on the device 'CPU'. Verify that implementation for the corresponding device exist. It might also happen if the binary is not linked with the operator implementation code. If Python frontend is used it might happen if dyndep.InitOpsLibrary call is missing. Operator def: input: \"roi_feat_shuffled\" input: \"rois_idx_restore_int32\" output: \"roi_feat\" name: \"\" type: \"BatchPermutation\" device_option { } engine: `\r\n\r\nIs it because that `BatchPermutation` belongs to detectron? I try to  add these code:\r\n```\r\nfrom caffe2.python import dyndep\r\ndetectron_ops_lib = '/home/user/pytorch/build/lib/libcaffe2_detectron_ops_gpu.so'\r\ndyndep.InitOpsLibrary(detectron_ops_lib)\r\n```\r\nThe issue disappear. But I encounter the new issue:\r\n```\r\nRuntimeError: [enforce fail at utility_ops.h:275] . Check failed: output->dims() == Input(i).dims().Description: Input #1, input dimension:[1, 256, 46, 80] should match output dimension: [1, 256, 45, 80]\r\nError from operator: \r\ninput: \"fpn_inner_res4_5_sum_lateral\" input: \"fpn_inner_res4_5_sum_topdown\" output: \"fpn_inner_res4_5_sum\" name: \"\" type: \"Sum\" device_option { } engine: \"\"frame #0: c10::ThrowEnforceNotMet(char const*, int, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, void const*) + 0x76 (0x7ff40d388b86 in /home/user/.local/lib/python2.7/site-packages/caffe2/python/../../torch/lib/libc10.so)\r\n```\r\nWhy the input dimension and output dimention are different? Could you please help me? Thanks!\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/facebookresearch/Detectron/issues/comments/439670216","html_url":"https://github.com/facebookresearch/Detectron/issues/752#issuecomment-439670216","issue_url":"https://api.github.com/repos/facebookresearch/Detectron/issues/752","id":439670216,"node_id":"MDEyOklzc3VlQ29tbWVudDQzOTY3MDIxNg==","user":{"login":"jeremyolsen","id":503898,"node_id":"MDQ6VXNlcjUwMzg5OA==","avatar_url":"https://avatars2.githubusercontent.com/u/503898?v=4","gravatar_id":"","url":"https://api.github.com/users/jeremyolsen","html_url":"https://github.com/jeremyolsen","followers_url":"https://api.github.com/users/jeremyolsen/followers","following_url":"https://api.github.com/users/jeremyolsen/following{/other_user}","gists_url":"https://api.github.com/users/jeremyolsen/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremyolsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremyolsen/subscriptions","organizations_url":"https://api.github.com/users/jeremyolsen/orgs","repos_url":"https://api.github.com/users/jeremyolsen/repos","events_url":"https://api.github.com/users/jeremyolsen/events{/privacy}","received_events_url":"https://api.github.com/users/jeremyolsen/received_events","type":"User","site_admin":false},"created_at":"2018-11-18T06:04:00Z","updated_at":"2018-11-18T06:04:00Z","author_association":"NONE","body":"@lilichu - This issue look to be a duplicate of pytorch/pytorch#10849.  The required ops are not in the ONNX spec yet and are in progresses.  Check onnx/onnx#1010 for more details."}}
{"actor":{"display_login":"jeremyolsen"}}