{"action":"opened","issue":{"url":"https://api.github.com/repos/onnx/onnx/issues/1190","repository_url":"https://api.github.com/repos/onnx/onnx","labels_url":"https://api.github.com/repos/onnx/onnx/issues/1190/labels{/name}","comments_url":"https://api.github.com/repos/onnx/onnx/issues/1190/comments","events_url":"https://api.github.com/repos/onnx/onnx/issues/1190/events","html_url":"https://github.com/onnx/onnx/issues/1190","id":340681983,"node_id":"MDU6SXNzdWUzNDA2ODE5ODM=","number":1190,"title":"Creating Constant operator with float16 data type causes error.","user":{"login":"arogowie-intel","id":36447190,"node_id":"MDQ6VXNlcjM2NDQ3MTkw","avatar_url":"https://avatars0.githubusercontent.com/u/36447190?v=4","gravatar_id":"","url":"https://api.github.com/users/arogowie-intel","html_url":"https://github.com/arogowie-intel","followers_url":"https://api.github.com/users/arogowie-intel/followers","following_url":"https://api.github.com/users/arogowie-intel/following{/other_user}","gists_url":"https://api.github.com/users/arogowie-intel/gists{/gist_id}","starred_url":"https://api.github.com/users/arogowie-intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arogowie-intel/subscriptions","organizations_url":"https://api.github.com/users/arogowie-intel/orgs","repos_url":"https://api.github.com/users/arogowie-intel/repos","events_url":"https://api.github.com/users/arogowie-intel/events{/privacy}","received_events_url":"https://api.github.com/users/arogowie-intel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-12T15:13:13Z","updated_at":"2018-07-12T15:13:13Z","closed_at":null,"author_association":"NONE","body":"Hi, \r\n\r\nI was trying to run this code:\r\n```\r\nvalues = np.random.randn(5, 5).astype(np.float16)\r\nnode = onnx.helper.make_node(\r\n    'Constant',\r\n    inputs=[],\r\n    outputs=['values'],\r\n    value=onnx.helper.make_tensor(\r\n        name='const_tensor',\r\n        data_type=onnx.TensorProto.FLOAT16,\r\n        dims=values.shape,\r\n        vals=values.flatten(),\r\n    ),\r\n)\r\n```\r\n\r\nCreating and running such node with onnx version 1.2.2 installed with flag `--no-binary` from `pip` causes following error:\r\n```\r\n>           getattr(tensor, field).extend(vals)\r\nE           TypeError: -0.2021 has type numpy.float16, but expected one of: int, long\r\n\r\n../../../../.virtualenvs/onnx/lib/python3.5/site-packages/onnx/helper.py:152: TypeError\r\n```"}}
{"actor":{"display_login":"arogowie-intel"}}