Skip to content

Make CpuMath not depending on ML.Core again #1724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 27, 2018
2 changes: 1 addition & 1 deletion src/Microsoft.ML.Core/BestFriendAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#if PRIVATE_CONTRACTS
// CpuMath has its own BestFriend and WantsToBeBestFriends attributes for making itself a standalone module
namespace Microsoft.ML.Hidden
namespace Microsoft.ML.Runtime.Internal.CpuMath.Core
#else
// This namespace contains the BestFriend and WantsToBeBestFriends attributes generally used in ML.NET project settings
namespace Microsoft.ML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
namespace Microsoft.ML
#else
// CpuMath module has its own PublicKey for isolating itself from Microsoft.ML.Core
// CpuMath has its own BestFriend defined in Microsoft.ML.Hidden.
using Microsoft.ML.Hidden;
namespace Microsoft.ML.Runtime.Internal.CpuMath
// Note that CpuMath uses its own BestFriend defined in Microsoft.ML.Runtime.Internal.CpuMath.Core.
namespace Microsoft.ML.Runtime.Internal.CpuMath.Core
#endif
{
[BestFriend]
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.Core/Utilities/Contracts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using System.Threading;

#if PRIVATE_CONTRACTS
namespace Microsoft.ML.Hidden
namespace Microsoft.ML.Runtime.Internal.CpuMath.Core
#else
namespace Microsoft.ML.Runtime
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.CpuMath/AlignedArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using Microsoft.ML.Hidden;
using Microsoft.ML.Runtime.Internal.CpuMath.Core;

namespace Microsoft.ML.Runtime.Internal.CpuMath
{
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.CpuMath/AlignedMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using Float = System.Single;

using Microsoft.ML.Hidden;
using Microsoft.ML.Runtime.Internal.CpuMath.Core;
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.ML.CpuMath/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.ML.Hidden;
using Microsoft.ML.Runtime.Internal.CpuMath.Core;
using System.Runtime.CompilerServices;
using Microsoft.ML.Runtime.Internal.CpuMath;

[assembly: InternalsVisibleTo("Microsoft.ML.CpuMath.UnitTests.netstandard" + PublicKey.TestValue)]
[assembly: InternalsVisibleTo("Microsoft.ML.CpuMath.UnitTests.netcoreapp" + PublicKey.TestValue)]
Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.ML.CpuMath/CpuAligenedMathUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.ML.Hidden;

using Microsoft.ML.Runtime.Internal.CpuMath.Core;
namespace Microsoft.ML.Runtime.Internal.CpuMath
{
[BestFriend]
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.CpuMath/CpuMathUtils.netcoreapp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.ML.Private;
using Microsoft.ML.Runtime.Internal.CpuMath.Core;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics.X86;
using System;
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.CpuMath/CpuMathUtils.netstandard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.ML.Hidden;
using Microsoft.ML.Runtime.Internal.CpuMath.Core;
using System;
using System.Runtime.CompilerServices;

Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.ML.CpuMath/EigenUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.ML.Runtime.Internal.CpuMath.Core;
using System;
using Float = System.Single;

using Microsoft.ML.Hidden;

namespace Microsoft.ML.Runtime.Internal.CpuMath
{
[BestFriend]
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.CpuMath/ICpuBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.ML.Hidden;
using Microsoft.ML.Runtime.Internal.CpuMath.Core;
using System;
using System.Collections.Generic;
using Float = System.Single;
Expand Down
3 changes: 1 addition & 2 deletions src/Microsoft.ML.CpuMath/IntUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.ML.Hidden;
using System;
using Microsoft.ML.Runtime.Internal.CpuMath.Core;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Security;
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.CpuMath/Microsoft.ML.CpuMath.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<Compile Include="..\Microsoft.ML.Core\Utilities\Contracts.cs" />
<Compile Include="..\Microsoft.ML.Core\BestFriendAttribute.cs" />
<Compile Include="..\Microsoft.ML.Core\Properties\PublicKey.cs" />
<Compile Include="..\Microsoft.ML.Core\PublicKey.cs" />

<!-- Workaround https://github.com/dotnet/project-system/issues/935 -->
<None Include="**/*.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.CpuMath/ProbabilityFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.ML.Hidden;
using Microsoft.ML.Runtime.Internal.CpuMath.Core;
using System;

namespace Microsoft.ML.Runtime.Internal.CpuMath
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.CpuMath/Sse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.ML.Hidden;
using Microsoft.ML.Runtime.Internal.CpuMath.Core;
using System;
using System.Runtime.InteropServices;

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.CpuMath/Thunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.ML.Hidden;
using Microsoft.ML.Runtime.Internal.CpuMath.Core;
using System.Runtime.InteropServices;
using System.Security;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public sealed class BestFriendAnalyzer : DiagnosticAnalyzer
new DiagnosticDescriptor(DiagnosticId, Title, Format, Category,
DiagnosticSeverity.Warning, isEnabledByDefault: true, description: Description);

private const string AttributeName = "Microsoft.ML.BestFriendAttribute (or Microsoft.ML.Runtime.Internal.CpuMath.BestFriendAttribute)";
private const string AssemblyAttributeName = "Microsoft.ML.WantsToBeBestFriendsAttribute (or Microsoft.ML.Runtime.Internal.CpuMath.WantsToBeBestFriendsAttribute)";
private const string AttributeName = "Microsoft.ML.BestFriendAttribute";
private const string AssemblyAttributeName = "Microsoft.ML.WantsToBeBestFriendsAttribute";

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics =>
ImmutableArray.Create(Rule);
Expand Down Expand Up @@ -111,7 +111,7 @@ private void AnalyzeCore(SemanticModelAnalysisContext context, string attributeN
private void Analyze(SemanticModelAnalysisContext context)
{
AnalyzeCore(context, "Microsoft.ML.BestFriendAttribute", "Microsoft.ML.WantsToBeBestFriendsAttribute");
AnalyzeCore(context, "Microsoft.ML.Hidden.BestFriendAttribute", "Microsoft.ML.Hidden.WantsToBeBestFriendsAttribute");
AnalyzeCore(context, "Microsoft.ML.Runtime.Internal.CpuMath.Core.BestFriendAttribute", "Microsoft.ML.Runtime.Internal.CpuMath.Core.WantsToBeBestFriendsAttribute");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,11 @@ private static void Analyze(SyntaxNodeAnalysisContext context)
var containingSymbolName = methodSymbol.ContainingSymbol.ToString();
// The "internal" version is one used by some projects that want to benefit from Contracts,
// but for some reason cannot reference MLCore.
// Contract functions defined Microsoft.ML.Hidden are introduced for breaking the dependencies
// from CpuMath project to Microsoft.ML.Core.
if (containingSymbolName != "Microsoft.ML.Runtime.Contracts" &&
containingSymbolName != "Microsoft.ML.Runtime.Internal.Contracts")
containingSymbolName != "Microsoft.ML.Runtime.Internal.Contracts" &&
containingSymbolName != "Microsoft.ML.Runtime.Internal.CpuMath.Core.Contracts")
{
return;
}
Expand Down