-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix #6949 * add MoveForwardToAttribute to assembly.cs and fix search space sub namespace
- Loading branch information
1 parent
d0d8569
commit ac6d130
Showing
13 changed files
with
226 additions
and
185 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/Microsoft.ML.Core/SearchSpace/BoolearnChoiceAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
namespace Microsoft.ML.SearchSpace; | ||
|
||
/// <summary> | ||
/// Boolean choice attribute | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = false, AllowMultiple = false)] | ||
public sealed class BooleanChoiceAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Create a <see cref="BooleanChoiceAttribute"/>. | ||
/// </summary> | ||
public BooleanChoiceAttribute() | ||
{ | ||
DefaultValue = true; | ||
} | ||
|
||
/// <summary> | ||
/// Create a <see cref="BooleanChoiceAttribute"/> with default value. | ||
/// </summary> | ||
/// <param name="defaultValue">default value for this option.</param> | ||
public BooleanChoiceAttribute(bool defaultValue) | ||
{ | ||
DefaultValue = defaultValue; | ||
} | ||
|
||
public bool DefaultValue { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Diagnostics.Contracts; | ||
using System.Linq; | ||
|
||
namespace Microsoft.ML.SearchSpace; | ||
|
||
/// <summary> | ||
/// Choice attribute | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = false, AllowMultiple = false)] | ||
public sealed class ChoiceAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Create a <see cref="ChoiceAttribute"/> with <paramref name="candidates"/>. | ||
/// </summary> | ||
public ChoiceAttribute(params object[] candidates) | ||
{ | ||
var candidatesType = candidates.Select(o => o.GetType()).Distinct(); | ||
Contract.Assert(candidatesType.Count() == 1, "multiple candidates type detected"); | ||
this.Candidates = candidates; | ||
this.DefaultValue = null; | ||
} | ||
|
||
/// <summary> | ||
/// Create a <see cref="ChoiceAttribute"/> with <paramref name="candidates"/> and <paramref name="defaultValue"/>. | ||
/// </summary> | ||
public ChoiceAttribute(object[] candidates, object defaultValue) | ||
{ | ||
var candidatesType = candidates.Select(o => o.GetType()).Distinct(); | ||
Contract.Assert(candidatesType.Count() == 1, "multiple candidates type detected"); | ||
Contract.Assert(candidatesType.First() == defaultValue.GetType(), "candidates type doesn't match with defaultValue type"); | ||
|
||
this.Candidates = candidates; | ||
this.DefaultValue = defaultValue; | ||
} | ||
|
||
/// <summary> | ||
/// Get the candidates of this option. | ||
/// </summary> | ||
public object[] Candidates { get; } | ||
|
||
/// <summary> | ||
/// Get the default value of this option. | ||
/// </summary> | ||
public object DefaultValue { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
namespace Microsoft.ML.SearchSpace; | ||
|
||
/// <summary> | ||
/// attribution class for nest option. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = false, AllowMultiple = false)] | ||
public sealed class NestOptionAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Create an <see cref="NestOptionAttribute"/>. | ||
/// </summary> | ||
public NestOptionAttribute() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
namespace Microsoft.ML.SearchSpace; | ||
|
||
/// <summary> | ||
/// Range attribute | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = false, AllowMultiple = false)] | ||
public sealed class RangeAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Create a <see cref="RangeAttribute"/> | ||
/// </summary> | ||
public RangeAttribute(double min, double max, bool logBase = false) | ||
{ | ||
this.Min = min; | ||
this.Max = max; | ||
this.Init = null; | ||
this.LogBase = logBase; | ||
} | ||
|
||
/// <summary> | ||
/// Create a <see cref="RangeAttribute"/> | ||
/// </summary> | ||
public RangeAttribute(double min, double max, double init, bool logBase = false) | ||
{ | ||
this.Min = min; | ||
this.Max = max; | ||
this.Init = init; | ||
this.LogBase = logBase; | ||
} | ||
|
||
/// <summary> | ||
/// Create a <see cref="RangeAttribute"/> | ||
/// </summary> | ||
public RangeAttribute(int min, int max, bool logBase = false) | ||
{ | ||
this.Min = min; | ||
this.Max = max; | ||
this.Init = null; | ||
this.LogBase = logBase; | ||
} | ||
|
||
/// <summary> | ||
/// Create a <see cref="RangeAttribute"/> | ||
/// </summary> | ||
public RangeAttribute(int min, int max, int init, bool logBase = false) | ||
{ | ||
this.Min = min; | ||
this.Max = max; | ||
this.Init = init; | ||
this.LogBase = logBase; | ||
} | ||
|
||
/// <summary> | ||
/// Create a <see cref="RangeAttribute"/> | ||
/// </summary> | ||
public RangeAttribute(float min, float max, bool logBase = false) | ||
{ | ||
this.Min = min; | ||
this.Max = max; | ||
this.Init = null; | ||
this.LogBase = logBase; | ||
} | ||
|
||
/// <summary> | ||
/// Create a <see cref="RangeAttribute"/> | ||
/// </summary> | ||
public RangeAttribute(float min, float max, float init, bool logBase = false) | ||
{ | ||
this.Min = min; | ||
this.Max = max; | ||
this.Init = init; | ||
this.LogBase = logBase; | ||
} | ||
|
||
public object Min { get; } | ||
|
||
public object Max { get; } | ||
|
||
public object Init { get; } | ||
|
||
public bool LogBase { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
src/Microsoft.ML.SearchSpace/Attribute/BooleanChoiceAttribute.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
src/Microsoft.ML.SearchSpace/Attribute/NestOptionAttribute.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.