{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/machinelearning/pulls/comments/204618188","pull_request_review_id":139728279,"id":204618188,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNDYxODE4OA==","diff_hunk":"@@ -0,0 +1,362 @@\n+﻿// Licensed to the .NET Foundation under one or more agreements.\n+// The .NET Foundation licenses this file to you under the MIT license.\n+// See the LICENSE file in the project root for more information.\n+\n+using System.Runtime.Intrinsics.X86;\n+using System;\n+\n+namespace Microsoft.ML.Runtime.Internal.CpuMath\n+{\n+    public static partial class CpuMathUtils\n+    {\n+        public const int CbAlign = 16;\n+\n+        private static bool Compat(AlignedArray a)\n+        {\n+            Contracts.AssertValue(a);\n+            Contracts.Assert(a.Size > 0);\n+            return a.CbAlign == CbAlign;\n+        }\n+\n+        private unsafe static float* Ptr(AlignedArray a, float* p)\n+        {\n+            Contracts.AssertValue(a);\n+            float* q = p + a.GetBase((long)p);\n+            Contracts.Assert(((long)q & (CbAlign - 1)) == 0);\n+            return q;\n+        }\n+\n+        public static void Scale(float a, float[] dst, int count)\n+        {\n+            Contracts.AssertNonEmpty(dst);\n+            Contracts.Assert(0 < count && count <= dst.Length);\n+\n+            if (Sse.IsSupported)\n+            {\n+                SseIntrinsics.ScaleU(a, dst, count);\n+            }\n+            else\n+            {\n+                for (int i = 0; i < dst.Length; i++)\n+                {\n+                    dst[i] *= a;\n+                }\n+            }\n+        }\n+\n+        public static void Scale(float a, float[] dst, int offset, int count)\n+        {\n+            Contracts.AssertNonEmpty(dst);\n+            Contracts.Assert(0 < count);\n+            Contracts.Assert(0 <= offset && offset < dst.Length - count);\n+\n+            ArraySegment<float> dstSeg = new ArraySegment<float>(dst, offset, count);\n+            Scale(a, dstSeg.Array, count);","path":"src/Microsoft.ML.CpuMath/CpuMathUtils.DotNetCoreApp.cs","position":54,"original_position":54,"commit_id":"f0f81a5019a3c8cbd795a970e40d633e9e1770c1","original_commit_id":"f0f81a5019a3c8cbd795a970e40d633e9e1770c1","user":{"login":"briancylui","id":18178086,"node_id":"MDQ6VXNlcjE4MTc4MDg2","avatar_url":"https://avatars1.githubusercontent.com/u/18178086?v=4","gravatar_id":"","url":"https://api.github.com/users/briancylui","html_url":"https://github.com/briancylui","followers_url":"https://api.github.com/users/briancylui/followers","following_url":"https://api.github.com/users/briancylui/following{/other_user}","gists_url":"https://api.github.com/users/briancylui/gists{/gist_id}","starred_url":"https://api.github.com/users/briancylui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briancylui/subscriptions","organizations_url":"https://api.github.com/users/briancylui/orgs","repos_url":"https://api.github.com/users/briancylui/repos","events_url":"https://api.github.com/users/briancylui/events{/privacy}","received_events_url":"https://api.github.com/users/briancylui/received_events","type":"User","site_admin":false},"body":"Thank you so much! Edited :)","created_at":"2018-07-24T04:05:13Z","updated_at":"2018-07-24T04:05:13Z","html_url":"https://github.com/dotnet/machinelearning/pull/562#discussion_r204618188","pull_request_url":"https://api.github.com/repos/dotnet/machinelearning/pulls/562","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/dotnet/machinelearning/pulls/comments/204618188"},"html":{"href":"https://github.com/dotnet/machinelearning/pull/562#discussion_r204618188"},"pull_request":{"href":"https://api.github.com/repos/dotnet/machinelearning/pulls/562"}},"in_reply_to_id":204056549},"pull_request":{"url":"https://api.github.com/repos/dotnet/machinelearning/pulls/562","id":202766623,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAyNzY2NjIz","html_url":"https://github.com/dotnet/machinelearning/pull/562","diff_url":"https://github.com/dotnet/machinelearning/pull/562.diff","patch_url":"https://github.com/dotnet/machinelearning/pull/562.patch","issue_url":"https://api.github.com/repos/dotnet/machinelearning/issues/562","number":562,"state":"open","locked":false,"title":"Port C# hardware intrinsics APIs for SSE from SIMD native algorithms","user":{"login":"briancylui","id":18178086,"node_id":"MDQ6VXNlcjE4MTc4MDg2","avatar_url":"https://avatars1.githubusercontent.com/u/18178086?v=4","gravatar_id":"","url":"https://api.github.com/users/briancylui","html_url":"https://github.com/briancylui","followers_url":"https://api.github.com/users/briancylui/followers","following_url":"https://api.github.com/users/briancylui/following{/other_user}","gists_url":"https://api.github.com/users/briancylui/gists{/gist_id}","starred_url":"https://api.github.com/users/briancylui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briancylui/subscriptions","organizations_url":"https://api.github.com/users/briancylui/orgs","repos_url":"https://api.github.com/users/briancylui/repos","events_url":"https://api.github.com/users/briancylui/events{/privacy}","received_events_url":"https://api.github.com/users/briancylui/received_events","type":"User","site_admin":false},"body":"- with unit tests and performance tests for two target frameworks: .NET Core App 3.0 and .NET Standard 2.0.\r\n- .NET Core App 3.0 gets the new C# hardware intrinsics APIs, while .NET Standard 2.0 gets the original native SIMD algorithms.\r\n- Several things have made this multi-targeting feature possible.\r\n   1. The new CpuMathUtils class that contains the new APIs is implemented as a partial class with method definitions split into two separate files (src\\Microsoft.ML.CpuMath\\CpuMathUtils.[target].cs), only one of which is compiled based on the target framework.\r\n   2. The Microsoft.ML.CpuMath.csproj file makes the switching decision to compile the right files based on the target framework.\r\n\r\n### Structure:\r\n1. All new hardware intrinsics APIs are contained in src\\Microsoft.ML.CpuMath.\r\n2. Unit tests for the two target frameworks live in test\\Microsoft.ML.CpuMath.UnitTests.[target], and contain the same content except for the target framework in .csproj.\r\n3. Performance tests live in test\\Microsoft.ML.CpuMath.PerformanceTests.\r\n\r\n### Changes to users:\r\n1. Originally, users call intrinsics APIs via the SseUtils class in src\\Microsoft.ML.CpuMath\\Sse.cs, but now they call them via the new CpuMathUtils class, which will handle switching between SSE and AVX in the future.\r\n2. CpuMathUtils methods and SseUtils methods share the same signature, but CpuMathUtils methods additionally call a new helper class (SseIntrinsics) for C# implementations of SSE operations.\r\n\r\n### Note for reviews:\r\n1. Thank you for your feedback, and please feel free to ignore the src/Native/CpuMath folder for the moment.  It is a folder I created as my initial separate working folder, and is now deprecated.  None of the functions in IntrinsicsUtils are called, and the unit tests and performance tests inside are not used.  Sorry for any inconvenience caused, and thank you for your understanding.\r\n\r\n### Update (July 22):\r\n1. I have edited the files based on most comments, but haven't pushed them yet since I have changed the names of some files.  Will follow up.\r\n","created_at":"2018-07-20T07:22:05Z","updated_at":"2018-07-24T04:05:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"899ebabfe1d01a6c885ca77da013ce6da1dd90ec","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/machinelearning/pulls/562/commits","review_comments_url":"https://api.github.com/repos/dotnet/machinelearning/pulls/562/comments","review_comment_url":"https://api.github.com/repos/dotnet/machinelearning/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/machinelearning/issues/562/comments","statuses_url":"https://api.github.com/repos/dotnet/machinelearning/statuses/f0f81a5019a3c8cbd795a970e40d633e9e1770c1","head":{"label":"briancylui:SseKey","ref":"SseKey","sha":"f0f81a5019a3c8cbd795a970e40d633e9e1770c1","user":{"login":"briancylui","id":18178086,"node_id":"MDQ6VXNlcjE4MTc4MDg2","avatar_url":"https://avatars1.githubusercontent.com/u/18178086?v=4","gravatar_id":"","url":"https://api.github.com/users/briancylui","html_url":"https://github.com/briancylui","followers_url":"https://api.github.com/users/briancylui/followers","following_url":"https://api.github.com/users/briancylui/following{/other_user}","gists_url":"https://api.github.com/users/briancylui/gists{/gist_id}","starred_url":"https://api.github.com/users/briancylui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briancylui/subscriptions","organizations_url":"https://api.github.com/users/briancylui/orgs","repos_url":"https://api.github.com/users/briancylui/repos","events_url":"https://api.github.com/users/briancylui/events{/privacy}","received_events_url":"https://api.github.com/users/briancylui/received_events","type":"User","site_admin":false},"repo":{"id":137632092,"node_id":"MDEwOlJlcG9zaXRvcnkxMzc2MzIwOTI=","name":"machinelearning","full_name":"briancylui/machinelearning","owner":{"login":"briancylui","id":18178086,"node_id":"MDQ6VXNlcjE4MTc4MDg2","avatar_url":"https://avatars1.githubusercontent.com/u/18178086?v=4","gravatar_id":"","url":"https://api.github.com/users/briancylui","html_url":"https://github.com/briancylui","followers_url":"https://api.github.com/users/briancylui/followers","following_url":"https://api.github.com/users/briancylui/following{/other_user}","gists_url":"https://api.github.com/users/briancylui/gists{/gist_id}","starred_url":"https://api.github.com/users/briancylui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briancylui/subscriptions","organizations_url":"https://api.github.com/users/briancylui/orgs","repos_url":"https://api.github.com/users/briancylui/repos","events_url":"https://api.github.com/users/briancylui/events{/privacy}","received_events_url":"https://api.github.com/users/briancylui/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/briancylui/machinelearning","description":"ML.NET is an open source and cross-platform machine learning framework for .NET.","fork":true,"url":"https://api.github.com/repos/briancylui/machinelearning","forks_url":"https://api.github.com/repos/briancylui/machinelearning/forks","keys_url":"https://api.github.com/repos/briancylui/machinelearning/keys{/key_id}","collaborators_url":"https://api.github.com/repos/briancylui/machinelearning/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/briancylui/machinelearning/teams","hooks_url":"https://api.github.com/repos/briancylui/machinelearning/hooks","issue_events_url":"https://api.github.com/repos/briancylui/machinelearning/issues/events{/number}","events_url":"https://api.github.com/repos/briancylui/machinelearning/events","assignees_url":"https://api.github.com/repos/briancylui/machinelearning/assignees{/user}","branches_url":"https://api.github.com/repos/briancylui/machinelearning/branches{/branch}","tags_url":"https://api.github.com/repos/briancylui/machinelearning/tags","blobs_url":"https://api.github.com/repos/briancylui/machinelearning/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/briancylui/machinelearning/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/briancylui/machinelearning/git/refs{/sha}","trees_url":"https://api.github.com/repos/briancylui/machinelearning/git/trees{/sha}","statuses_url":"https://api.github.com/repos/briancylui/machinelearning/statuses/{sha}","languages_url":"https://api.github.com/repos/briancylui/machinelearning/languages","stargazers_url":"https://api.github.com/repos/briancylui/machinelearning/stargazers","contributors_url":"https://api.github.com/repos/briancylui/machinelearning/contributors","subscribers_url":"https://api.github.com/repos/briancylui/machinelearning/subscribers","subscription_url":"https://api.github.com/repos/briancylui/machinelearning/subscription","commits_url":"https://api.github.com/repos/briancylui/machinelearning/commits{/sha}","git_commits_url":"https://api.github.com/repos/briancylui/machinelearning/git/commits{/sha}","comments_url":"https://api.github.com/repos/briancylui/machinelearning/comments{/number}","issue_comment_url":"https://api.github.com/repos/briancylui/machinelearning/issues/comments{/number}","contents_url":"https://api.github.com/repos/briancylui/machinelearning/contents/{+path}","compare_url":"https://api.github.com/repos/briancylui/machinelearning/compare/{base}...{head}","merges_url":"https://api.github.com/repos/briancylui/machinelearning/merges","archive_url":"https://api.github.com/repos/briancylui/machinelearning/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/briancylui/machinelearning/downloads","issues_url":"https://api.github.com/repos/briancylui/machinelearning/issues{/number}","pulls_url":"https://api.github.com/repos/briancylui/machinelearning/pulls{/number}","milestones_url":"https://api.github.com/repos/briancylui/machinelearning/milestones{/number}","notifications_url":"https://api.github.com/repos/briancylui/machinelearning/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/briancylui/machinelearning/labels{/name}","releases_url":"https://api.github.com/repos/briancylui/machinelearning/releases{/id}","deployments_url":"https://api.github.com/repos/briancylui/machinelearning/deployments","created_at":"2018-06-17T05:47:45Z","updated_at":"2018-07-20T03:27:37Z","pushed_at":"2018-07-20T03:27:36Z","git_url":"git://github.com/briancylui/machinelearning.git","ssh_url":"git@github.com:briancylui/machinelearning.git","clone_url":"https://github.com/briancylui/machinelearning.git","svn_url":"https://github.com/briancylui/machinelearning","homepage":"http://dot.net/ml","size":19966,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"8ce2a232e907d518979e7105842ae575a7427377","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-07-23T22:45:13Z","pushed_at":"2018-07-23T23:36:25Z","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":"https://dot.net/ml","size":19957,"stargazers_count":3195,"watchers_count":3195,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":442,"mirror_url":null,"archived":false,"open_issues_count":196,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":442,"open_issues":196,"watchers":3195,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/machinelearning/pulls/562"},"html":{"href":"https://github.com/dotnet/machinelearning/pull/562"},"issue":{"href":"https://api.github.com/repos/dotnet/machinelearning/issues/562"},"comments":{"href":"https://api.github.com/repos/dotnet/machinelearning/issues/562/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/machinelearning/pulls/562/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/machinelearning/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/machinelearning/pulls/562/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/machinelearning/statuses/f0f81a5019a3c8cbd795a970e40d633e9e1770c1"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"briancylui"}}