Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit 651d55e

Browse files
committed
Add optional Precision field
1 parent 509f3a5 commit 651d55e

File tree

8 files changed

+19
-3
lines changed

8 files changed

+19
-3
lines changed

OnnxStack.Core/Config/IOnnxModelSetConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ public interface IOnnxModelSetConfig : IOnnxModel
1010
int IntraOpNumThreads { get; set; }
1111
ExecutionMode ExecutionMode { get; set; }
1212
ExecutionProvider ExecutionProvider { get; set; }
13+
OnnxModelPrecision Precision { get; set; }
1314
}
1415
}

OnnxStack.Core/Config/OnnxModelConfig.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public record OnnxModelConfig
2222
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2323
public ExecutionProvider? ExecutionProvider { get; set; }
2424

25+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
26+
public OnnxModelPrecision? Precision { get; set; }
27+
2528
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
2629
public int RequiredMemory { get; set; }
2730
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace OnnxStack.Core.Config
2+
{
3+
public enum OnnxModelPrecision
4+
{
5+
F32 = 0,
6+
F16 = 1
7+
}
8+
}

OnnxStack.Core/Extensions/Extensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public static T ApplyDefaults<T>(this T config, IOnnxModelSetConfig defaults) wh
6565
config.ExecutionProvider ??= defaults.ExecutionProvider;
6666
config.InterOpNumThreads ??= defaults.InterOpNumThreads;
6767
config.IntraOpNumThreads ??= defaults.IntraOpNumThreads;
68+
config.Precision ??= defaults.Precision;
6869
return config;
6970
}
7071

OnnxStack.FeatureExtractor/Common/FeatureExtractorModelSet.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public record FeatureExtractorModelSet : IOnnxModelSetConfig
1313
public int IntraOpNumThreads { get; set; }
1414
public ExecutionMode ExecutionMode { get; set; }
1515
public ExecutionProvider ExecutionProvider { get; set; }
16+
public OnnxModelPrecision Precision { get; set; }
1617

1718
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1819
public FeatureExtractorModelConfig FeatureExtractorConfig { get; set; }

OnnxStack.ImageUpscaler/Common/UpscaleModelSet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public record UpscaleModelSet : IOnnxModelSetConfig
1313
public int IntraOpNumThreads { get; set; }
1414
public ExecutionMode ExecutionMode { get; set; }
1515
public ExecutionProvider ExecutionProvider { get; set; }
16-
16+
public OnnxModelPrecision Precision { get; set; }
1717

1818
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1919
public UpscaleModelConfig UpscaleModelConfig { get; set; }

OnnxStack.StableDiffusion/Config/ControlNetModelSet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public record ControlNetModelSet : IOnnxModelSetConfig
1717
public int IntraOpNumThreads { get; set; }
1818
public ExecutionMode ExecutionMode { get; set; }
1919
public ExecutionProvider ExecutionProvider { get; set; }
20-
20+
public OnnxModelPrecision Precision { get; set; }
2121

2222
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2323
public ControlNetModelConfig ControlNetConfig { get; set; }

OnnxStack.StableDiffusion/Config/StableDiffusionModelSet.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public record StableDiffusionModelSet : IOnnxModelSetConfig
2020
public int IntraOpNumThreads { get; set; }
2121
public ExecutionMode ExecutionMode { get; set; }
2222
public ExecutionProvider ExecutionProvider { get; set; }
23-
23+
public OnnxModelPrecision Precision { get; set; }
2424

2525
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2626
public TokenizerModelConfig TokenizerConfig { get; set; }
@@ -45,5 +45,7 @@ public record StableDiffusionModelSet : IOnnxModelSetConfig
4545

4646
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
4747
public SchedulerOptions SchedulerOptions { get; set; }
48+
49+
4850
}
4951
}

0 commit comments

Comments
 (0)