{"action":"created","comment":{"url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments/29593506","id":29593506,"diff_hunk":"@@ -0,0 +1,130 @@\n+/*\n+ * Copyright (c) The Shogun Machine Learning Toolbox\n+ * Written (w) 2015 Soumyajit De\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions are met:\n+ *\n+ * 1. Redistributions of source code must retain the above copyright notice, this\n+ *    list of conditions and the following disclaimer.\n+ * 2. Redistributions in binary form must reproduce the above copyright notice,\n+ *    this list of conditions and the following disclaimer in the documentation\n+ *    and/or other materials provided with the distribution.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ *\n+ * The views and conclusions contained in the software and documentation are those\n+ * of the authors and should not be interpreted as representing official policies,\n+ * either expressed or implied, of the Shogun Development Team.\n+ */\n+\n+#include <shogun/lib/SGMatrix.h>\n+#include <shogun/lib/GPUMatrix.h>\n+#include <shogun/mathematics/linalg/linalg.h>\n+#include <vector>\n+#include <algorithm>\n+#include <hayai/hayai.hpp>\n+\n+using namespace shogun;\n+\n+/**\n+ * Instructions :\n+ * 1. Install benchmarking toolkit \"hayai\" (https://github.com/nickbruun/hayai)\n+ * 2. Compile against libhayai_main, e.g.\n+ * g++ -O3 -std=c++11 elementwise_benchmark.cpp -I/usr/include/eigen3 -lshogun -lhayai_main -lOpenCL -o benchmark\n+ * 3. ./benchmark\n+ */\n+\n+/** Generate data only once */\n+struct Data\n+{\n+\tData()\n+\t{\n+\t\tinit();\n+\t}\n+\n+\tvoid init()\n+\t{\n+\t\tm_cpu=SGMatrix<float32_t>(num_rows, num_cols);\n+\t\tstd::iota(m_cpu.data(), m_cpu.data()+m_cpu.size(), 1);\n+\t\tm_gpu=CGPUMatrix<float32_t>(m_cpu);\n+\t}\n+\n+\tSGMatrix<float32_t> m_cpu;\n+\tCGPUMatrix<float32_t> m_gpu;\n+\n+\tstatic constexpr index_t num_rows=1000;\n+\tstatic constexpr index_t num_cols=1000;\n+};\n+\n+Data data;\n+\n+BENCHMARK(SGMatrix, elementwise, 10, 1000)\n+{\n+\tfloat32_t weights=0.6;\n+\tfloat32_t std_dev=0.2;\n+\tfloat32_t mean=0.01;\n+\n+\tSGMatrix<float32_t> result=linalg::elementwise_compute(data.m_cpu,\n+\t[&weights, &std_dev, &mean](float32_t& sqr_dist)","path":"benchmarks/elementwise_benchmark.cpp","position":79,"original_position":79,"commit_id":"35c609bce2c1d1a7357a5eac96404d69892b391d","original_commit_id":"b43b2d08f7abbf669a428cc66955c0f925ead1e5","user":{"login":"karlnapf","id":699071,"avatar_url":"https://avatars.githubusercontent.com/u/699071?v=3","gravatar_id":"","url":"https://api.github.com/users/karlnapf","html_url":"https://github.com/karlnapf","followers_url":"https://api.github.com/users/karlnapf/followers","following_url":"https://api.github.com/users/karlnapf/following{/other_user}","gists_url":"https://api.github.com/users/karlnapf/gists{/gist_id}","starred_url":"https://api.github.com/users/karlnapf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karlnapf/subscriptions","organizations_url":"https://api.github.com/users/karlnapf/orgs","repos_url":"https://api.github.com/users/karlnapf/repos","events_url":"https://api.github.com/users/karlnapf/events{/privacy}","received_events_url":"https://api.github.com/users/karlnapf/received_events","type":"User","site_admin":false},"body":"haha, awesome!!! :)","created_at":"2015-05-04T15:26:12Z","updated_at":"2015-05-04T15:26:12Z","html_url":"https://github.com/shogun-toolbox/shogun/pull/2830#discussion_r29593506","pull_request_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2830","_links":{"self":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments/29593506"},"html":{"href":"https://github.com/shogun-toolbox/shogun/pull/2830#discussion_r29593506"},"pull_request":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2830"}}},"pull_request":{"url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2830","id":34102280,"html_url":"https://github.com/shogun-toolbox/shogun/pull/2830","diff_url":"https://github.com/shogun-toolbox/shogun/pull/2830.diff","patch_url":"https://github.com/shogun-toolbox/shogun/pull/2830.patch","issue_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/2830","number":2830,"state":"closed","locked":false,"title":"Added element-wise unary operators in linalg","user":{"login":"lambday","id":3088401,"avatar_url":"https://avatars.githubusercontent.com/u/3088401?v=3","gravatar_id":"","url":"https://api.github.com/users/lambday","html_url":"https://github.com/lambday","followers_url":"https://api.github.com/users/lambday/followers","following_url":"https://api.github.com/users/lambday/following{/other_user}","gists_url":"https://api.github.com/users/lambday/gists{/gist_id}","starred_url":"https://api.github.com/users/lambday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lambday/subscriptions","organizations_url":"https://api.github.com/users/lambday/orgs","repos_url":"https://api.github.com/users/lambday/repos","events_url":"https://api.github.com/users/lambday/events{/privacy}","received_events_url":"https://api.github.com/users/lambday/received_events","type":"User","site_admin":false},"body":"- Works with predefined operations (sin, cos, log, exp etc.)\r\n- Works with custom unary operators as well (functors, std::function, lambda expressions, function pointers) that developers can provide.\r\n- Implicit type conversion is **turned off** for CPU to/from GPU matrix/vector data-types. NATIVE/EIGEN3 works only with SG-types and VIENNACL works only with CGPU-types.\r\n- Type safety ensured.\r\n- A benchmark of element-wise operation with a custom unary operator.\r\n","created_at":"2015-04-25T07:23:07Z","updated_at":"2015-05-04T15:26:12Z","closed_at":"2015-05-02T10:57:39Z","merged_at":"2015-05-02T10:57:39Z","merge_commit_sha":"83c1f5782a2070fecda69cf1b60d441276076fba","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2830/commits","review_comments_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2830/comments","review_comment_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments{/number}","comments_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/2830/comments","statuses_url":"https://api.github.com/repos/shogun-toolbox/shogun/statuses/35c609bce2c1d1a7357a5eac96404d69892b391d","head":{"label":"lambday:develop","ref":"develop","sha":"35c609bce2c1d1a7357a5eac96404d69892b391d","user":{"login":"lambday","id":3088401,"avatar_url":"https://avatars.githubusercontent.com/u/3088401?v=3","gravatar_id":"","url":"https://api.github.com/users/lambday","html_url":"https://github.com/lambday","followers_url":"https://api.github.com/users/lambday/followers","following_url":"https://api.github.com/users/lambday/following{/other_user}","gists_url":"https://api.github.com/users/lambday/gists{/gist_id}","starred_url":"https://api.github.com/users/lambday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lambday/subscriptions","organizations_url":"https://api.github.com/users/lambday/orgs","repos_url":"https://api.github.com/users/lambday/repos","events_url":"https://api.github.com/users/lambday/events{/privacy}","received_events_url":"https://api.github.com/users/lambday/received_events","type":"User","site_admin":false},"repo":{"id":8764626,"name":"shogun","full_name":"lambday/shogun","owner":{"login":"lambday","id":3088401,"avatar_url":"https://avatars.githubusercontent.com/u/3088401?v=3","gravatar_id":"","url":"https://api.github.com/users/lambday","html_url":"https://github.com/lambday","followers_url":"https://api.github.com/users/lambday/followers","following_url":"https://api.github.com/users/lambday/following{/other_user}","gists_url":"https://api.github.com/users/lambday/gists{/gist_id}","starred_url":"https://api.github.com/users/lambday/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lambday/subscriptions","organizations_url":"https://api.github.com/users/lambday/orgs","repos_url":"https://api.github.com/users/lambday/repos","events_url":"https://api.github.com/users/lambday/events{/privacy}","received_events_url":"https://api.github.com/users/lambday/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lambday/shogun","description":"The Shogun Machine Learning Toolbox (Source Code)","fork":true,"url":"https://api.github.com/repos/lambday/shogun","forks_url":"https://api.github.com/repos/lambday/shogun/forks","keys_url":"https://api.github.com/repos/lambday/shogun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lambday/shogun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lambday/shogun/teams","hooks_url":"https://api.github.com/repos/lambday/shogun/hooks","issue_events_url":"https://api.github.com/repos/lambday/shogun/issues/events{/number}","events_url":"https://api.github.com/repos/lambday/shogun/events","assignees_url":"https://api.github.com/repos/lambday/shogun/assignees{/user}","branches_url":"https://api.github.com/repos/lambday/shogun/branches{/branch}","tags_url":"https://api.github.com/repos/lambday/shogun/tags","blobs_url":"https://api.github.com/repos/lambday/shogun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lambday/shogun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lambday/shogun/git/refs{/sha}","trees_url":"https://api.github.com/repos/lambday/shogun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lambday/shogun/statuses/{sha}","languages_url":"https://api.github.com/repos/lambday/shogun/languages","stargazers_url":"https://api.github.com/repos/lambday/shogun/stargazers","contributors_url":"https://api.github.com/repos/lambday/shogun/contributors","subscribers_url":"https://api.github.com/repos/lambday/shogun/subscribers","subscription_url":"https://api.github.com/repos/lambday/shogun/subscription","commits_url":"https://api.github.com/repos/lambday/shogun/commits{/sha}","git_commits_url":"https://api.github.com/repos/lambday/shogun/git/commits{/sha}","comments_url":"https://api.github.com/repos/lambday/shogun/comments{/number}","issue_comment_url":"https://api.github.com/repos/lambday/shogun/issues/comments{/number}","contents_url":"https://api.github.com/repos/lambday/shogun/contents/{+path}","compare_url":"https://api.github.com/repos/lambday/shogun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lambday/shogun/merges","archive_url":"https://api.github.com/repos/lambday/shogun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lambday/shogun/downloads","issues_url":"https://api.github.com/repos/lambday/shogun/issues{/number}","pulls_url":"https://api.github.com/repos/lambday/shogun/pulls{/number}","milestones_url":"https://api.github.com/repos/lambday/shogun/milestones{/number}","notifications_url":"https://api.github.com/repos/lambday/shogun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lambday/shogun/labels{/name}","releases_url":"https://api.github.com/repos/lambday/shogun/releases{/id}","created_at":"2013-03-14T00:22:35Z","updated_at":"2015-05-01T08:48:19Z","pushed_at":"2015-05-01T08:48:17Z","git_url":"git://github.com/lambday/shogun.git","ssh_url":"git@github.com:lambday/shogun.git","clone_url":"https://github.com/lambday/shogun.git","svn_url":"https://github.com/lambday/shogun","homepage":"http://www.shogun-toolbox.org","size":52174,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"shogun-toolbox:develop","ref":"develop","sha":"82faf98a6462d12393adcdcf9bc3690236da2203","user":{"login":"shogun-toolbox","id":690673,"avatar_url":"https://avatars.githubusercontent.com/u/690673?v=3","gravatar_id":"","url":"https://api.github.com/users/shogun-toolbox","html_url":"https://github.com/shogun-toolbox","followers_url":"https://api.github.com/users/shogun-toolbox/followers","following_url":"https://api.github.com/users/shogun-toolbox/following{/other_user}","gists_url":"https://api.github.com/users/shogun-toolbox/gists{/gist_id}","starred_url":"https://api.github.com/users/shogun-toolbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shogun-toolbox/subscriptions","organizations_url":"https://api.github.com/users/shogun-toolbox/orgs","repos_url":"https://api.github.com/users/shogun-toolbox/repos","events_url":"https://api.github.com/users/shogun-toolbox/events{/privacy}","received_events_url":"https://api.github.com/users/shogun-toolbox/received_events","type":"Organization","site_admin":false},"repo":{"id":1555094,"name":"shogun","full_name":"shogun-toolbox/shogun","owner":{"login":"shogun-toolbox","id":690673,"avatar_url":"https://avatars.githubusercontent.com/u/690673?v=3","gravatar_id":"","url":"https://api.github.com/users/shogun-toolbox","html_url":"https://github.com/shogun-toolbox","followers_url":"https://api.github.com/users/shogun-toolbox/followers","following_url":"https://api.github.com/users/shogun-toolbox/following{/other_user}","gists_url":"https://api.github.com/users/shogun-toolbox/gists{/gist_id}","starred_url":"https://api.github.com/users/shogun-toolbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shogun-toolbox/subscriptions","organizations_url":"https://api.github.com/users/shogun-toolbox/orgs","repos_url":"https://api.github.com/users/shogun-toolbox/repos","events_url":"https://api.github.com/users/shogun-toolbox/events{/privacy}","received_events_url":"https://api.github.com/users/shogun-toolbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shogun-toolbox/shogun","description":"The Shogun Machine Learning Toolbox (Source Code)","fork":false,"url":"https://api.github.com/repos/shogun-toolbox/shogun","forks_url":"https://api.github.com/repos/shogun-toolbox/shogun/forks","keys_url":"https://api.github.com/repos/shogun-toolbox/shogun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shogun-toolbox/shogun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shogun-toolbox/shogun/teams","hooks_url":"https://api.github.com/repos/shogun-toolbox/shogun/hooks","issue_events_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/events{/number}","events_url":"https://api.github.com/repos/shogun-toolbox/shogun/events","assignees_url":"https://api.github.com/repos/shogun-toolbox/shogun/assignees{/user}","branches_url":"https://api.github.com/repos/shogun-toolbox/shogun/branches{/branch}","tags_url":"https://api.github.com/repos/shogun-toolbox/shogun/tags","blobs_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/refs{/sha}","trees_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shogun-toolbox/shogun/statuses/{sha}","languages_url":"https://api.github.com/repos/shogun-toolbox/shogun/languages","stargazers_url":"https://api.github.com/repos/shogun-toolbox/shogun/stargazers","contributors_url":"https://api.github.com/repos/shogun-toolbox/shogun/contributors","subscribers_url":"https://api.github.com/repos/shogun-toolbox/shogun/subscribers","subscription_url":"https://api.github.com/repos/shogun-toolbox/shogun/subscription","commits_url":"https://api.github.com/repos/shogun-toolbox/shogun/commits{/sha}","git_commits_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/commits{/sha}","comments_url":"https://api.github.com/repos/shogun-toolbox/shogun/comments{/number}","issue_comment_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/comments{/number}","contents_url":"https://api.github.com/repos/shogun-toolbox/shogun/contents/{+path}","compare_url":"https://api.github.com/repos/shogun-toolbox/shogun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shogun-toolbox/shogun/merges","archive_url":"https://api.github.com/repos/shogun-toolbox/shogun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shogun-toolbox/shogun/downloads","issues_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues{/number}","pulls_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls{/number}","milestones_url":"https://api.github.com/repos/shogun-toolbox/shogun/milestones{/number}","notifications_url":"https://api.github.com/repos/shogun-toolbox/shogun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shogun-toolbox/shogun/labels{/name}","releases_url":"https://api.github.com/repos/shogun-toolbox/shogun/releases{/id}","created_at":"2011-04-01T10:44:32Z","updated_at":"2015-05-04T12:41:34Z","pushed_at":"2015-05-04T12:41:34Z","git_url":"git://github.com/shogun-toolbox/shogun.git","ssh_url":"git@github.com:shogun-toolbox/shogun.git","clone_url":"https://github.com/shogun-toolbox/shogun.git","svn_url":"https://github.com/shogun-toolbox/shogun","homepage":"http://www.shogun-toolbox.org","size":193766,"stargazers_count":771,"watchers_count":771,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":451,"mirror_url":null,"open_issues_count":369,"forks":451,"open_issues":369,"watchers":771,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2830"},"html":{"href":"https://github.com/shogun-toolbox/shogun/pull/2830"},"issue":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/issues/2830"},"comments":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/issues/2830/comments"},"review_comments":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2830/comments"},"review_comment":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/2830/commits"},"statuses":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/statuses/35c609bce2c1d1a7357a5eac96404d69892b391d"}}}}