{"action":"created","issue":{"url":"https://api.github.com/repos/dmlc/tvm/issues/2959","repository_url":"https://api.github.com/repos/dmlc/tvm","labels_url":"https://api.github.com/repos/dmlc/tvm/issues/2959/labels{/name}","comments_url":"https://api.github.com/repos/dmlc/tvm/issues/2959/comments","events_url":"https://api.github.com/repos/dmlc/tvm/issues/2959/events","html_url":"https://github.com/dmlc/tvm/issues/2959","id":429043312,"node_id":"MDU6SXNzdWU0MjkwNDMzMTI=","number":2959,"title":"[CodeGen] Incorrect vectorization for fp16 on X86-64 (AVX512)","user":{"login":"baowenlei","id":40643946,"node_id":"MDQ6VXNlcjQwNjQzOTQ2","avatar_url":"https://avatars2.githubusercontent.com/u/40643946?v=4","gravatar_id":"","url":"https://api.github.com/users/baowenlei","html_url":"https://github.com/baowenlei","followers_url":"https://api.github.com/users/baowenlei/followers","following_url":"https://api.github.com/users/baowenlei/following{/other_user}","gists_url":"https://api.github.com/users/baowenlei/gists{/gist_id}","starred_url":"https://api.github.com/users/baowenlei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baowenlei/subscriptions","organizations_url":"https://api.github.com/users/baowenlei/orgs","repos_url":"https://api.github.com/users/baowenlei/repos","events_url":"https://api.github.com/users/baowenlei/events{/privacy}","received_events_url":"https://api.github.com/users/baowenlei/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2019-04-04T01:34:49Z","updated_at":"2019-10-16T03:01:43Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nThere seems a bug related to vectorization with type fp16 on skylake machine. \r\nBasically, when cast fp16 to uint8 using select for AVX512 machine, it will generate wrong result with vectorization on. \r\n\r\nThe generated `ll` code seems correct after checking dumped llvm code, but the generated `asm` code seems problematic. It might be some configurations when doing the code generation `/src/codegen/llvm/llvm_common.cc`\r\n\r\n```\r\nimport tvm\r\nimport numpy\r\n## shape cause wrong result\r\nm=3\r\nn=2\r\nk=2\r\n## shape cause LLVM ERROR\r\n# m=3\r\n# n=1\r\n# k=4\r\n\r\ndtype = \"float16\"\r\ntarget = 'llvm -mcpu=skylake-avx512'\r\nctx = tvm.context(target, 0)\r\n\r\ninput = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0]\r\nin_array = numpy.array(input).reshape(m,n,k).astype(dtype)\r\na = tvm.nd.array(in_array, ctx)\r\n\r\nX=tvm.placeholder((m,n,k), name='X', dtype=\"float16\")\r\nzero = tvm.const(0, \"uint8\")\r\none = tvm.const(1, \"uint8\")\r\nz16 = tvm.const(0, \"float16\")\r\n\r\nY=tvm.compute((m,n,k), lambda i,j,k: tvm.expr.Select(X[i,j,k] == z16, zero, one))\r\ns=tvm.create_schedule(Y.op)\r\ns[Y].vectorize(Y.op.axis[2])\r\nprint tvm.lower(s,[X,Y], simple_mode=True)\r\nfunc = tvm.build(s, [X,Y], target=target, name='bug')\r\nassert func\r\n\r\noutput = [False, True, True, True, True, True, True, True, True, True, True, True]\r\nout = numpy.array(output).reshape(m,n,k).astype(\"bool\")\r\nb= tvm.nd.array(numpy.zeros((m,n,k), dtype=\"bool\"), ctx)\r\nfunc(a,b)\r\n\r\ntvm.testing.assert_allclose(b.asnumpy(), out)\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/dmlc/tvm/issues/comments/542489203","html_url":"https://github.com/dmlc/tvm/issues/2959#issuecomment-542489203","issue_url":"https://api.github.com/repos/dmlc/tvm/issues/2959","id":542489203,"node_id":"MDEyOklzc3VlQ29tbWVudDU0MjQ4OTIwMw==","user":{"login":"topperc","id":22566570,"node_id":"MDQ6VXNlcjIyNTY2NTcw","avatar_url":"https://avatars0.githubusercontent.com/u/22566570?v=4","gravatar_id":"","url":"https://api.github.com/users/topperc","html_url":"https://github.com/topperc","followers_url":"https://api.github.com/users/topperc/followers","following_url":"https://api.github.com/users/topperc/following{/other_user}","gists_url":"https://api.github.com/users/topperc/gists{/gist_id}","starred_url":"https://api.github.com/users/topperc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/topperc/subscriptions","organizations_url":"https://api.github.com/users/topperc/orgs","repos_url":"https://api.github.com/users/topperc/repos","events_url":"https://api.github.com/users/topperc/events{/privacy}","received_events_url":"https://api.github.com/users/topperc/received_events","type":"User","site_admin":false},"created_at":"2019-10-16T03:01:43Z","updated_at":"2019-10-16T03:01:43Z","author_association":"NONE","body":"FYI, I think might have fixed the LLVM bug this was hitting here https://github.com/llvm/llvm-project/commit/7b49e8ac359bc35f95af548fbed4b7afd625caab"}}
{"actor":{"display_login":"topperc"}}