forked from TensorStack-AI/TensorStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModelOptimization.cs
More file actions
66 lines (55 loc) · 2.26 KB
/
ModelOptimization.cs
File metadata and controls
66 lines (55 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) TensorStack. All rights reserved.
// Licensed under the Apache 2.0 License.
using System;
using System.Collections.Generic;
using System.Linq;
namespace TensorStack.Common
{
public record ModelOptimization : IEquatable<ModelOptimization>
{
private readonly Optimization _optimizationLevel;
private readonly SortedDictionary<string, long> _dimensionOverrides;
/// <summary>
/// Initializes a new instance of the <see cref="ModelOptimization"/> class.
/// </summary>
public ModelOptimization() : this(Optimization.All) { }
/// <summary>
/// Initializes a new instance of the <see cref="ModelOptimization"/> class.
/// </summary>
/// <param name="freeDimensionOverrides">The free dimension overrides.</param>
public ModelOptimization(Optimization optimizationLevel)
{
_optimizationLevel = optimizationLevel;
_dimensionOverrides = new SortedDictionary<string, long>();
}
/// <summary>
/// Gets the optimization level.
/// </summary>
/// <value>The optimization level.</value>
public Optimization OptimizationLevel => _optimizationLevel;
/// <summary>
/// Gets the dimension overrides.
/// </summary>
/// <value>The dimension overrides.</value>
public SortedDictionary<string, long> DimensionOverrides => _dimensionOverrides;
/// <summary>
// Indicates whether the current ModelOptimization is equal to another
/// </summary>
/// <param name="other">The other.</param>
/// <returns><c>true</c> if equal, <c>false</c> otherwise.</returns>
public virtual bool Equals(ModelOptimization other)
{
if (other is null)
return false;
return other.DimensionOverrides.SequenceEqual(DimensionOverrides);
}
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
public override int GetHashCode()
{
return HashCode.Combine(DimensionOverrides.GetHashCode());
}
}
}