forked from zhongkaifu/TensorSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModelPrimitives.cs
More file actions
48 lines (44 loc) · 1.68 KB
/
Copy pathModelPrimitives.cs
File metadata and controls
48 lines (44 loc) · 1.68 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
// Copyright (c) Zhongkai Fu. All rights reserved.
// https://github.com/zhongkaifu/TensorSharp
//
// This file is part of TensorSharp.
//
// TensorSharp is licensed under the BSD-3-Clause license found in the LICENSE file in the root directory of this source tree.
//
// TensorSharp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the BSD-3-Clause License for more details.
namespace TensorSharp.Runtime
{
public enum BackendType
{
Cpu,
Cuda,
Mlx,
GgmlCpu,
GgmlMetal,
GgmlCuda,
GgmlVulkan,
}
public class ModelConfig
{
public string Architecture { get; set; } = string.Empty;
public int HiddenSize { get; set; }
public int NumHeads { get; set; }
public int NumKVHeads { get; set; }
public int KeyLength { get; set; }
public int ValueLength { get; set; }
public float Eps { get; set; }
public float RopeBase { get; set; }
public float RopeScale { get; set; } = 1f;
public int NumLayers { get; set; }
public int VocabSize { get; set; }
public int IntermediateSize { get; set; }
public string ChatTemplate { get; set; } = string.Empty;
public int NumExperts { get; set; }
public int NumExpertsUsed { get; set; }
public int SlidingWindow { get; set; }
public bool UsesCircularKvCache { get; set; }
public int OriginalContextLength { get; set; }
public int HeadDim => KeyLength > 0 ? KeyLength : (ValueLength > 0 ? ValueLength : HiddenSize / NumHeads);
}
}