{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/machinelearning/pulls/comments/197220282","pull_request_review_id":130922749,"id":197220282,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NzIyMDI4Mg==","diff_hunk":"@@ -0,0 +1,164 @@\n+#include <cmath>\n+#include <cstring>\n+#include <limits>\n+#include <pmmintrin.h>\n+#include \"../Stdafx.h\"\n+\n+// Compute the output value of the field-aware factorization, as the sum of the linear part and the latent part. \n+// The linear part is the inner product of linearWeights and featureValues.\n+// The latent part is the sum of all intra-field interactions in one field f, for all fields possible. \n+EXPORT_API(void) CalculateIntermediateVariablesNative(int fieldCount, int latentDim, int count, _In_ int * fieldIndices, _In_ int * featureIndices, _In_ float * featureValues,\n+    _In_ float * linearWeights, _In_ float * latentWeights, _Inout_ float * latentSum, _Out_ float * response)\n+{\n+\t// The number of all possible fields\n+    const int m = fieldCount;\n+    const int d = latentDim;\n+    const int c = count;\n+    const int * pf = fieldIndices;\n+    const int * pi = featureIndices;\n+    const float * px = featureValues;\n+    const float * pw = linearWeights;\n+    const float * pv = latentWeights;\n+    float * pq = latentSum;\n+    float linearResponse = 0;\n+    float latentResponse = 0;\n+\n+    memset(pq, 0, sizeof(float) * m * m * d);\n+    __m128 _y = _mm_setzero_ps();\n+    __m128 _tmp = _mm_setzero_ps();\n+\n+    for (int i = 0; i < c; i++)\n+    {\n+        const int f = pf[i];\n+        const int j = pi[i];\n+        linearResponse += pw[j] * px[i];\n+\n+        const __m128 _x = _mm_load1_ps(px + i);\n+        const __m128 _xx = _mm_mul_ps(_x, _x);\n+\n+        // tmp -= <v_j,f, v_j,f> * x * x\n+        const int vBias = j * m * d + f * d;\n+\n+\t\t// j-th feature's latent vector in the f-th field hidden space\n+        const float * vjf = pv + vBias;\n+\n+        for (int k = 0; k + 4 <= d; k += 4)\n+        {\n+            const __m128 _v = _mm_load_ps(vjf + k);\n+            _tmp = _mm_sub_ps(_tmp, _mm_mul_ps(_mm_mul_ps(_v, _v), _xx));\n+        }\n+\n+        for (int fprime = 0; fprime < m; fprime++)\n+        {\n+            const int vBias = j * m * d + fprime * d;\n+            const int qBias = f * m * d + fprime * d;\n+            const float * vjfprime = pv + vBias;\n+            float * qffprime = pq + qBias;\n+\n+            // q_f,f' += v_j,f' * x\n+            for (int k = 0; k + 4 <= d; k += 4)\n+            {\n+                const __m128 _v = _mm_load_ps(vjfprime + k);\n+                __m128 _q = _mm_load_ps(qffprime + k);\n+                _q = _mm_add_ps(_q, _mm_mul_ps(_v, _x));\n+                _mm_store_ps(qffprime + k, _q);\n+            }\n+        }\n+    }\n+\n+    for (int f = 0; f < m; f++)\n+    {\n+        // tmp += <q_f,f, q_f,f>\n+        const float * qff = pq + f * m * d + f * d;\n+        for (int k = 0; k + 4 <= d; k += 4)\n+        {\n+            __m128 _qff = _mm_load_ps(qff + k);\n+            _tmp = _mm_add_ps(_tmp, _mm_mul_ps(_qff, _qff));\n+        }\n+\n+        // y += <q_f,f', q_f',f>, f != f'\n+        for (int fprime = f + 1; fprime < m; fprime++)\n+        {\n+\t\t\t// intra-field interactions\n+            const float * qffprime = pq + f * m * d + fprime * d;\n+            const float * qfprimef = pq + fprime * m * d + f * d;\n+            for (int k = 0; k + 4 <= d; k += 4)\n+            {\n+\t\t\t\t// inter-field interaction","path":"src/Native/FactorizationMachineNative/FactorizationMachineCore.cpp","position":87,"original_position":87,"commit_id":"a8d6ad30572bfcc3f2e6d04b1d950cf3c1acfc8f","original_commit_id":"a8d6ad30572bfcc3f2e6d04b1d950cf3c1acfc8f","user":{"login":"wschin","id":3524474,"node_id":"MDQ6VXNlcjM1MjQ0NzQ=","avatar_url":"https://avatars1.githubusercontent.com/u/3524474?v=4","gravatar_id":"","url":"https://api.github.com/users/wschin","html_url":"https://github.com/wschin","followers_url":"https://api.github.com/users/wschin/followers","following_url":"https://api.github.com/users/wschin/following{/other_user}","gists_url":"https://api.github.com/users/wschin/gists{/gist_id}","starred_url":"https://api.github.com/users/wschin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wschin/subscriptions","organizations_url":"https://api.github.com/users/wschin/orgs","repos_url":"https://api.github.com/users/wschin/repos","events_url":"https://api.github.com/users/wschin/events{/privacy}","received_events_url":"https://api.github.com/users/wschin/received_events","type":"User","site_admin":false},"body":"My comment line 79 means that we only handle inter-field interactions because f != f'.","created_at":"2018-06-21T17:41:48Z","updated_at":"2018-06-21T17:41:48Z","html_url":"https://github.com/dotnet/machinelearning/pull/383#discussion_r197220282","pull_request_url":"https://api.github.com/repos/dotnet/machinelearning/pulls/383","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/dotnet/machinelearning/pulls/comments/197220282"},"html":{"href":"https://github.com/dotnet/machinelearning/pull/383#discussion_r197220282"},"pull_request":{"href":"https://api.github.com/repos/dotnet/machinelearning/pulls/383"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/machinelearning/pulls/383","id":196200473,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2MjAwNDcz","html_url":"https://github.com/dotnet/machinelearning/pull/383","diff_url":"https://github.com/dotnet/machinelearning/pull/383.diff","patch_url":"https://github.com/dotnet/machinelearning/pull/383.patch","issue_url":"https://api.github.com/repos/dotnet/machinelearning/issues/383","number":383,"state":"open","locked":false,"title":"Adding Factorization Machines ","user":{"login":"sfilipi","id":19392467,"node_id":"MDQ6VXNlcjE5MzkyNDY3","avatar_url":"https://avatars1.githubusercontent.com/u/19392467?v=4","gravatar_id":"","url":"https://api.github.com/users/sfilipi","html_url":"https://github.com/sfilipi","followers_url":"https://api.github.com/users/sfilipi/followers","following_url":"https://api.github.com/users/sfilipi/following{/other_user}","gists_url":"https://api.github.com/users/sfilipi/gists{/gist_id}","starred_url":"https://api.github.com/users/sfilipi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfilipi/subscriptions","organizations_url":"https://api.github.com/users/sfilipi/orgs","repos_url":"https://api.github.com/users/sfilipi/repos","events_url":"https://api.github.com/users/sfilipi/events{/privacy}","received_events_url":"https://api.github.com/users/sfilipi/received_events","type":"User","site_admin":false},"body":"Adding FactorizationMachines and a test for it. \r\nAddresses #381 \r\n\r\n","created_at":"2018-06-20T16:28:28Z","updated_at":"2018-06-21T17:41:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0a09ead834a744064441ea8d32fff186af3cf0ea","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/machinelearning/pulls/383/commits","review_comments_url":"https://api.github.com/repos/dotnet/machinelearning/pulls/383/comments","review_comment_url":"https://api.github.com/repos/dotnet/machinelearning/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/machinelearning/issues/383/comments","statuses_url":"https://api.github.com/repos/dotnet/machinelearning/statuses/a8d6ad30572bfcc3f2e6d04b1d950cf3c1acfc8f","head":{"label":"sfilipi:FactorizationMachine","ref":"FactorizationMachine","sha":"a8d6ad30572bfcc3f2e6d04b1d950cf3c1acfc8f","user":{"login":"sfilipi","id":19392467,"node_id":"MDQ6VXNlcjE5MzkyNDY3","avatar_url":"https://avatars1.githubusercontent.com/u/19392467?v=4","gravatar_id":"","url":"https://api.github.com/users/sfilipi","html_url":"https://github.com/sfilipi","followers_url":"https://api.github.com/users/sfilipi/followers","following_url":"https://api.github.com/users/sfilipi/following{/other_user}","gists_url":"https://api.github.com/users/sfilipi/gists{/gist_id}","starred_url":"https://api.github.com/users/sfilipi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfilipi/subscriptions","organizations_url":"https://api.github.com/users/sfilipi/orgs","repos_url":"https://api.github.com/users/sfilipi/repos","events_url":"https://api.github.com/users/sfilipi/events{/privacy}","received_events_url":"https://api.github.com/users/sfilipi/received_events","type":"User","site_admin":false},"repo":{"id":132529754,"node_id":"MDEwOlJlcG9zaXRvcnkxMzI1Mjk3NTQ=","name":"machinelearning-1","full_name":"sfilipi/machinelearning-1","owner":{"login":"sfilipi","id":19392467,"node_id":"MDQ6VXNlcjE5MzkyNDY3","avatar_url":"https://avatars1.githubusercontent.com/u/19392467?v=4","gravatar_id":"","url":"https://api.github.com/users/sfilipi","html_url":"https://github.com/sfilipi","followers_url":"https://api.github.com/users/sfilipi/followers","following_url":"https://api.github.com/users/sfilipi/following{/other_user}","gists_url":"https://api.github.com/users/sfilipi/gists{/gist_id}","starred_url":"https://api.github.com/users/sfilipi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfilipi/subscriptions","organizations_url":"https://api.github.com/users/sfilipi/orgs","repos_url":"https://api.github.com/users/sfilipi/repos","events_url":"https://api.github.com/users/sfilipi/events{/privacy}","received_events_url":"https://api.github.com/users/sfilipi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sfilipi/machinelearning-1","description":"ML.NET is the core library of machine learning in .net.","fork":true,"url":"https://api.github.com/repos/sfilipi/machinelearning-1","forks_url":"https://api.github.com/repos/sfilipi/machinelearning-1/forks","keys_url":"https://api.github.com/repos/sfilipi/machinelearning-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sfilipi/machinelearning-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sfilipi/machinelearning-1/teams","hooks_url":"https://api.github.com/repos/sfilipi/machinelearning-1/hooks","issue_events_url":"https://api.github.com/repos/sfilipi/machinelearning-1/issues/events{/number}","events_url":"https://api.github.com/repos/sfilipi/machinelearning-1/events","assignees_url":"https://api.github.com/repos/sfilipi/machinelearning-1/assignees{/user}","branches_url":"https://api.github.com/repos/sfilipi/machinelearning-1/branches{/branch}","tags_url":"https://api.github.com/repos/sfilipi/machinelearning-1/tags","blobs_url":"https://api.github.com/repos/sfilipi/machinelearning-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sfilipi/machinelearning-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sfilipi/machinelearning-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/sfilipi/machinelearning-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sfilipi/machinelearning-1/statuses/{sha}","languages_url":"https://api.github.com/repos/sfilipi/machinelearning-1/languages","stargazers_url":"https://api.github.com/repos/sfilipi/machinelearning-1/stargazers","contributors_url":"https://api.github.com/repos/sfilipi/machinelearning-1/contributors","subscribers_url":"https://api.github.com/repos/sfilipi/machinelearning-1/subscribers","subscription_url":"https://api.github.com/repos/sfilipi/machinelearning-1/subscription","commits_url":"https://api.github.com/repos/sfilipi/machinelearning-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/sfilipi/machinelearning-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/sfilipi/machinelearning-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/sfilipi/machinelearning-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/sfilipi/machinelearning-1/contents/{+path}","compare_url":"https://api.github.com/repos/sfilipi/machinelearning-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sfilipi/machinelearning-1/merges","archive_url":"https://api.github.com/repos/sfilipi/machinelearning-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sfilipi/machinelearning-1/downloads","issues_url":"https://api.github.com/repos/sfilipi/machinelearning-1/issues{/number}","pulls_url":"https://api.github.com/repos/sfilipi/machinelearning-1/pulls{/number}","milestones_url":"https://api.github.com/repos/sfilipi/machinelearning-1/milestones{/number}","notifications_url":"https://api.github.com/repos/sfilipi/machinelearning-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sfilipi/machinelearning-1/labels{/name}","releases_url":"https://api.github.com/repos/sfilipi/machinelearning-1/releases{/id}","deployments_url":"https://api.github.com/repos/sfilipi/machinelearning-1/deployments","created_at":"2018-05-08T00:04:48Z","updated_at":"2018-06-21T16:47:23Z","pushed_at":"2018-06-21T16:47:21Z","git_url":"git://github.com/sfilipi/machinelearning-1.git","ssh_url":"git@github.com:sfilipi/machinelearning-1.git","clone_url":"https://github.com/sfilipi/machinelearning-1.git","svn_url":"https://github.com/sfilipi/machinelearning-1","homepage":"","size":18586,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"8b01fc5a8875fd8543777d8ec4d0bf370bc590f5","user":{"login":"dotnet","id":9141961,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNDE5NjE=","avatar_url":"https://avatars0.githubusercontent.com/u/9141961?v=4","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":132021166,"node_id":"MDEwOlJlcG9zaXRvcnkxMzIwMjExNjY=","name":"machinelearning","full_name":"dotnet/machinelearning","owner":{"login":"dotnet","id":9141961,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNDE5NjE=","avatar_url":"https://avatars0.githubusercontent.com/u/9141961?v=4","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/machinelearning","description":"ML.NET is an open source and cross-platform machine learning framework for .NET.","fork":false,"url":"https://api.github.com/repos/dotnet/machinelearning","forks_url":"https://api.github.com/repos/dotnet/machinelearning/forks","keys_url":"https://api.github.com/repos/dotnet/machinelearning/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/machinelearning/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/machinelearning/teams","hooks_url":"https://api.github.com/repos/dotnet/machinelearning/hooks","issue_events_url":"https://api.github.com/repos/dotnet/machinelearning/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/machinelearning/events","assignees_url":"https://api.github.com/repos/dotnet/machinelearning/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/machinelearning/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/machinelearning/tags","blobs_url":"https://api.github.com/repos/dotnet/machinelearning/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/machinelearning/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/machinelearning/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/machinelearning/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/machinelearning/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/machinelearning/languages","stargazers_url":"https://api.github.com/repos/dotnet/machinelearning/stargazers","contributors_url":"https://api.github.com/repos/dotnet/machinelearning/contributors","subscribers_url":"https://api.github.com/repos/dotnet/machinelearning/subscribers","subscription_url":"https://api.github.com/repos/dotnet/machinelearning/subscription","commits_url":"https://api.github.com/repos/dotnet/machinelearning/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/machinelearning/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/machinelearning/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/machinelearning/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/machinelearning/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/machinelearning/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/machinelearning/merges","archive_url":"https://api.github.com/repos/dotnet/machinelearning/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/machinelearning/downloads","issues_url":"https://api.github.com/repos/dotnet/machinelearning/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/machinelearning/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/machinelearning/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/machinelearning/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/machinelearning/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/machinelearning/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/machinelearning/deployments","created_at":"2018-05-03T16:20:42Z","updated_at":"2018-06-21T15:01:11Z","pushed_at":"2018-06-21T17:39:30Z","git_url":"git://github.com/dotnet/machinelearning.git","ssh_url":"git@github.com:dotnet/machinelearning.git","clone_url":"https://github.com/dotnet/machinelearning.git","svn_url":"https://github.com/dotnet/machinelearning","homepage":"http://dot.net/ml","size":18515,"stargazers_count":2781,"watchers_count":2781,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":344,"mirror_url":null,"archived":false,"open_issues_count":143,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":344,"open_issues":143,"watchers":2781,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/machinelearning/pulls/383"},"html":{"href":"https://github.com/dotnet/machinelearning/pull/383"},"issue":{"href":"https://api.github.com/repos/dotnet/machinelearning/issues/383"},"comments":{"href":"https://api.github.com/repos/dotnet/machinelearning/issues/383/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/machinelearning/pulls/383/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/machinelearning/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/machinelearning/pulls/383/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/machinelearning/statuses/a8d6ad30572bfcc3f2e6d04b1d950cf3c1acfc8f"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"wschin"}}