{"action":"created","comment":{"url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/pulls/comments/198542123","pull_request_review_id":132489346,"id":198542123,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5ODU0MjEyMw==","diff_hunk":"@@ -88,36 +88,96 @@ namespace nd4j {\n         }\n     }\n \n+    /**\n+ * This is cpu version, so leave it here as inline, to avoid templates instantiation\n+ *\n+ * @tparam S source type\n+ * @tparam T target type\n+ * @tparam T intermediate type\n+ * @param dx\n+ * @param N\n+ * @param dz\n+ */\n+    template<typename S, typename T>\n+    void TypeCast::convertDirectGeneric(Nd4jPointer * extras, void *dx, Nd4jLong N, void *dz) {\n+        auto x = reinterpret_cast<S *>(dx);\n+        auto z = reinterpret_cast<T *>(dz);\n+\n+        if (N < nd4j::Environment::getInstance()->elementwiseThreshold()) {\n+#pragma omp simd\n+            for (int i = 0; i < N; i++) {\n+                z[i] = static_cast<T>(x[i]);\n+            }\n+        } else {\n+\n+#pragma omp parallel for\n+            for (int i = 0; i < N; i++) {\n+                z[i] = static_cast<T>(x[i]);\n+            }\n+        }\n+    };\n+\n     /**\n      * This is cpu version, so leave it here as inline, to avoid templates instantiation\n      *\n-     * @tparam S\n-     * @tparam T\n+     * @tparam S source type\n+     * @tparam T target type\n+     * @tparam T intermediate type\n      * @param dx\n      * @param N\n      * @param dz\n      */\n-    template<typename S, typename T>\n+    template<typename S, typename T, typename I>\n     void TypeCast::convertGeneric(Nd4jPointer * extras, void *dx, Nd4jLong N, void *dz) {\n         auto x = reinterpret_cast<S *>(dx);\n         auto z = reinterpret_cast<T *>(dz);\n \n         if (N < nd4j::Environment::getInstance()->elementwiseThreshold()) {\n #pragma omp simd\n             for (int i = 0; i < N; i++) {\n-                // FIXME: get rid of through-float though\n-                z[i] = static_cast<T>(static_cast<float>(x[i]));\n+                // FIXME: get rid of through-I though\n+                z[i] = static_cast<T>(static_cast<I>(x[i]));\n             }\n         } else {\n \n #pragma omp parallel for\n             for (int i = 0; i < N; i++) {\n-                // FIXME: get rid of through-float though\n-                z[i] = static_cast<T>(static_cast<float>(x[i]));\n+                // FIXME: get rid of through-I though","path":"libnd4j/include/loops/cpu/type_conversions.cpp","position":65,"original_position":65,"commit_id":"a619decd7ec2ff8e3d08e1df6e475450b493bcd0","original_commit_id":"a619decd7ec2ff8e3d08e1df6e475450b493bcd0","user":{"login":"raver119","id":12250879,"node_id":"MDQ6VXNlcjEyMjUwODc5","avatar_url":"https://avatars2.githubusercontent.com/u/12250879?v=4","gravatar_id":"","url":"https://api.github.com/users/raver119","html_url":"https://github.com/raver119","followers_url":"https://api.github.com/users/raver119/followers","following_url":"https://api.github.com/users/raver119/following{/other_user}","gists_url":"https://api.github.com/users/raver119/gists{/gist_id}","starred_url":"https://api.github.com/users/raver119/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raver119/subscriptions","organizations_url":"https://api.github.com/users/raver119/orgs","repos_url":"https://api.github.com/users/raver119/repos","events_url":"https://api.github.com/users/raver119/events{/privacy}","received_events_url":"https://api.github.com/users/raver119/received_events","type":"User","site_admin":false},"body":"All this stuff is NOT need. \r\nReason of that FIXME message isn't related to precision.","created_at":"2018-06-27T15:34:36Z","updated_at":"2018-06-27T15:35:39Z","html_url":"https://github.com/deeplearning4j/deeplearning4j/pull/5725#discussion_r198542123","pull_request_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/pulls/5725","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/deeplearning4j/deeplearning4j/pulls/comments/198542123"},"html":{"href":"https://github.com/deeplearning4j/deeplearning4j/pull/5725#discussion_r198542123"},"pull_request":{"href":"https://api.github.com/repos/deeplearning4j/deeplearning4j/pulls/5725"}}},"pull_request":{"url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/pulls/5725","id":197769860,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk3NzY5ODYw","html_url":"https://github.com/deeplearning4j/deeplearning4j/pull/5725","diff_url":"https://github.com/deeplearning4j/deeplearning4j/pull/5725.diff","patch_url":"https://github.com/deeplearning4j/deeplearning4j/pull/5725.patch","issue_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/issues/5725","number":5725,"state":"open","locked":false,"title":"Add convertType in libnd4j for long and int arrays","user":{"login":"emillynge","id":7023052,"node_id":"MDQ6VXNlcjcwMjMwNTI=","avatar_url":"https://avatars2.githubusercontent.com/u/7023052?v=4","gravatar_id":"","url":"https://api.github.com/users/emillynge","html_url":"https://github.com/emillynge","followers_url":"https://api.github.com/users/emillynge/followers","following_url":"https://api.github.com/users/emillynge/following{/other_user}","gists_url":"https://api.github.com/users/emillynge/gists{/gist_id}","starred_url":"https://api.github.com/users/emillynge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emillynge/subscriptions","organizations_url":"https://api.github.com/users/emillynge/orgs","repos_url":"https://api.github.com/users/emillynge/repos","events_url":"https://api.github.com/users/emillynge/events{/privacy}","received_events_url":"https://api.github.com/users/emillynge/received_events","type":"User","site_admin":false},"body":"Dear Maintainers, this PR seeks to add native conversion of LongBuffer and IntBuffer in the same way there already exists conversion functionality between Half, Float and Double buffers.\r\n\r\nI realize that this approach may be a misuse of the `DataBuffer.DataTypeEx` enum, in which case I would be grateful for any guidance as to how to otherwise provide fast conversion from LongBuffer to DoubleBuffer and back again.\r\n\r\nMy usecase is that I am working with sparse matrices that store indices in a LongBuffer. Sometimes, it is helpful to do some arithmetic on said indices, but most ops only supports `DataType.FLOAT` and `DataType.DOUBLE`.\r\nTherefore I need a way of quickly converting the indices to a DoubleBuffer, do the math and the convert back to LongFloat.\r\n\r\nAlso note, that having such a conversion opens the possibility to directly index INDArrays using another INDArray.\r\n\r\nI made some changes to  `convertGeneric` in order to avoid:\r\n\r\n1. downcasting when converting between 64bit data types.\r\n2. calling `static_cast` twice on types where there is not need for an intermediate data type.\r\n\r\nTo solve (1) `convertGeneric` now has an additional typename I, which denotes the intermediate data type used to bridge the gap between 2 other data types. (before, `float` was always used for this.\r\n\r\n`convert64Generic` was added for data types that needs a 64bit intermediate data type (`double`)\r\n\r\n`convert32Generic` was added for data types that needs a 32bit intermediate data type (`float`)\r\n\r\nTo to solve (2), `convertDirectGeneric` was added to which does the same as `convertGeneric`, except that it does not cast to an intermediate data type.\r\n","created_at":"2018-06-27T15:24:27Z","updated_at":"2018-06-27T15:35:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4439c1075b3188f8f2970a7395acb8cd549237b2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/pulls/5725/commits","review_comments_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/pulls/5725/comments","review_comment_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/pulls/comments{/number}","comments_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/issues/5725/comments","statuses_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/statuses/a619decd7ec2ff8e3d08e1df6e475450b493bcd0","head":{"label":"emillynge:nd4j/intconversion","ref":"nd4j/intconversion","sha":"a619decd7ec2ff8e3d08e1df6e475450b493bcd0","user":{"login":"emillynge","id":7023052,"node_id":"MDQ6VXNlcjcwMjMwNTI=","avatar_url":"https://avatars2.githubusercontent.com/u/7023052?v=4","gravatar_id":"","url":"https://api.github.com/users/emillynge","html_url":"https://github.com/emillynge","followers_url":"https://api.github.com/users/emillynge/followers","following_url":"https://api.github.com/users/emillynge/following{/other_user}","gists_url":"https://api.github.com/users/emillynge/gists{/gist_id}","starred_url":"https://api.github.com/users/emillynge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emillynge/subscriptions","organizations_url":"https://api.github.com/users/emillynge/orgs","repos_url":"https://api.github.com/users/emillynge/repos","events_url":"https://api.github.com/users/emillynge/events{/privacy}","received_events_url":"https://api.github.com/users/emillynge/received_events","type":"User","site_admin":false},"repo":{"id":136488546,"node_id":"MDEwOlJlcG9zaXRvcnkxMzY0ODg1NDY=","name":"deeplearning4j","full_name":"emillynge/deeplearning4j","owner":{"login":"emillynge","id":7023052,"node_id":"MDQ6VXNlcjcwMjMwNTI=","avatar_url":"https://avatars2.githubusercontent.com/u/7023052?v=4","gravatar_id":"","url":"https://api.github.com/users/emillynge","html_url":"https://github.com/emillynge","followers_url":"https://api.github.com/users/emillynge/followers","following_url":"https://api.github.com/users/emillynge/following{/other_user}","gists_url":"https://api.github.com/users/emillynge/gists{/gist_id}","starred_url":"https://api.github.com/users/emillynge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emillynge/subscriptions","organizations_url":"https://api.github.com/users/emillynge/orgs","repos_url":"https://api.github.com/users/emillynge/repos","events_url":"https://api.github.com/users/emillynge/events{/privacy}","received_events_url":"https://api.github.com/users/emillynge/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/emillynge/deeplearning4j","description":"Deeplearning4j, ND4J, DataVec and more - deep learning & linear algebra for Java/Scala with GPUs + Spark - From Skymind","fork":true,"url":"https://api.github.com/repos/emillynge/deeplearning4j","forks_url":"https://api.github.com/repos/emillynge/deeplearning4j/forks","keys_url":"https://api.github.com/repos/emillynge/deeplearning4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/emillynge/deeplearning4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/emillynge/deeplearning4j/teams","hooks_url":"https://api.github.com/repos/emillynge/deeplearning4j/hooks","issue_events_url":"https://api.github.com/repos/emillynge/deeplearning4j/issues/events{/number}","events_url":"https://api.github.com/repos/emillynge/deeplearning4j/events","assignees_url":"https://api.github.com/repos/emillynge/deeplearning4j/assignees{/user}","branches_url":"https://api.github.com/repos/emillynge/deeplearning4j/branches{/branch}","tags_url":"https://api.github.com/repos/emillynge/deeplearning4j/tags","blobs_url":"https://api.github.com/repos/emillynge/deeplearning4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/emillynge/deeplearning4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/emillynge/deeplearning4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/emillynge/deeplearning4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/emillynge/deeplearning4j/statuses/{sha}","languages_url":"https://api.github.com/repos/emillynge/deeplearning4j/languages","stargazers_url":"https://api.github.com/repos/emillynge/deeplearning4j/stargazers","contributors_url":"https://api.github.com/repos/emillynge/deeplearning4j/contributors","subscribers_url":"https://api.github.com/repos/emillynge/deeplearning4j/subscribers","subscription_url":"https://api.github.com/repos/emillynge/deeplearning4j/subscription","commits_url":"https://api.github.com/repos/emillynge/deeplearning4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/emillynge/deeplearning4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/emillynge/deeplearning4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/emillynge/deeplearning4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/emillynge/deeplearning4j/contents/{+path}","compare_url":"https://api.github.com/repos/emillynge/deeplearning4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/emillynge/deeplearning4j/merges","archive_url":"https://api.github.com/repos/emillynge/deeplearning4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/emillynge/deeplearning4j/downloads","issues_url":"https://api.github.com/repos/emillynge/deeplearning4j/issues{/number}","pulls_url":"https://api.github.com/repos/emillynge/deeplearning4j/pulls{/number}","milestones_url":"https://api.github.com/repos/emillynge/deeplearning4j/milestones{/number}","notifications_url":"https://api.github.com/repos/emillynge/deeplearning4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/emillynge/deeplearning4j/labels{/name}","releases_url":"https://api.github.com/repos/emillynge/deeplearning4j/releases{/id}","deployments_url":"https://api.github.com/repos/emillynge/deeplearning4j/deployments","created_at":"2018-06-07T14:23:35Z","updated_at":"2018-06-07T14:23:58Z","pushed_at":"2018-06-27T15:06:32Z","git_url":"git://github.com/emillynge/deeplearning4j.git","ssh_url":"git@github.com:emillynge/deeplearning4j.git","clone_url":"https://github.com/emillynge/deeplearning4j.git","svn_url":"https://github.com/emillynge/deeplearning4j","homepage":"http://deeplearning4j.org","size":562975,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"deeplearning4j:master","ref":"master","sha":"3987aaa49d3aad29249004d718be1faa83e56871","user":{"login":"deeplearning4j","id":10988606,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwOTg4NjA2","avatar_url":"https://avatars2.githubusercontent.com/u/10988606?v=4","gravatar_id":"","url":"https://api.github.com/users/deeplearning4j","html_url":"https://github.com/deeplearning4j","followers_url":"https://api.github.com/users/deeplearning4j/followers","following_url":"https://api.github.com/users/deeplearning4j/following{/other_user}","gists_url":"https://api.github.com/users/deeplearning4j/gists{/gist_id}","starred_url":"https://api.github.com/users/deeplearning4j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deeplearning4j/subscriptions","organizations_url":"https://api.github.com/users/deeplearning4j/orgs","repos_url":"https://api.github.com/users/deeplearning4j/repos","events_url":"https://api.github.com/users/deeplearning4j/events{/privacy}","received_events_url":"https://api.github.com/users/deeplearning4j/received_events","type":"Organization","site_admin":false},"repo":{"id":14734876,"node_id":"MDEwOlJlcG9zaXRvcnkxNDczNDg3Ng==","name":"deeplearning4j","full_name":"deeplearning4j/deeplearning4j","owner":{"login":"deeplearning4j","id":10988606,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwOTg4NjA2","avatar_url":"https://avatars2.githubusercontent.com/u/10988606?v=4","gravatar_id":"","url":"https://api.github.com/users/deeplearning4j","html_url":"https://github.com/deeplearning4j","followers_url":"https://api.github.com/users/deeplearning4j/followers","following_url":"https://api.github.com/users/deeplearning4j/following{/other_user}","gists_url":"https://api.github.com/users/deeplearning4j/gists{/gist_id}","starred_url":"https://api.github.com/users/deeplearning4j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deeplearning4j/subscriptions","organizations_url":"https://api.github.com/users/deeplearning4j/orgs","repos_url":"https://api.github.com/users/deeplearning4j/repos","events_url":"https://api.github.com/users/deeplearning4j/events{/privacy}","received_events_url":"https://api.github.com/users/deeplearning4j/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/deeplearning4j/deeplearning4j","description":"Deeplearning4j, ND4J, DataVec and more - deep learning & linear algebra for Java/Scala with GPUs + Spark - From Skymind","fork":false,"url":"https://api.github.com/repos/deeplearning4j/deeplearning4j","forks_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/forks","keys_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/teams","hooks_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/hooks","issue_events_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/issues/events{/number}","events_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/events","assignees_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/assignees{/user}","branches_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/branches{/branch}","tags_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/tags","blobs_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/statuses/{sha}","languages_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/languages","stargazers_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/stargazers","contributors_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/contributors","subscribers_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/subscribers","subscription_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/subscription","commits_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/contents/{+path}","compare_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/merges","archive_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/downloads","issues_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/issues{/number}","pulls_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/pulls{/number}","milestones_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/milestones{/number}","notifications_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/labels{/name}","releases_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/releases{/id}","deployments_url":"https://api.github.com/repos/deeplearning4j/deeplearning4j/deployments","created_at":"2013-11-27T02:03:28Z","updated_at":"2018-06-27T14:43:25Z","pushed_at":"2018-06-27T15:24:27Z","git_url":"git://github.com/deeplearning4j/deeplearning4j.git","ssh_url":"git@github.com:deeplearning4j/deeplearning4j.git","clone_url":"https://github.com/deeplearning4j/deeplearning4j.git","svn_url":"https://github.com/deeplearning4j/deeplearning4j","homepage":"http://deeplearning4j.org","size":563036,"stargazers_count":9190,"watchers_count":9190,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4319,"mirror_url":null,"archived":false,"open_issues_count":594,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":4319,"open_issues":594,"watchers":9190,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/deeplearning4j/deeplearning4j/pulls/5725"},"html":{"href":"https://github.com/deeplearning4j/deeplearning4j/pull/5725"},"issue":{"href":"https://api.github.com/repos/deeplearning4j/deeplearning4j/issues/5725"},"comments":{"href":"https://api.github.com/repos/deeplearning4j/deeplearning4j/issues/5725/comments"},"review_comments":{"href":"https://api.github.com/repos/deeplearning4j/deeplearning4j/pulls/5725/comments"},"review_comment":{"href":"https://api.github.com/repos/deeplearning4j/deeplearning4j/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/deeplearning4j/deeplearning4j/pulls/5725/commits"},"statuses":{"href":"https://api.github.com/repos/deeplearning4j/deeplearning4j/statuses/a619decd7ec2ff8e3d08e1df6e475450b493bcd0"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"raver119"}}