Commit 06dad2d
committed
fix: add comprehensive validation to MultiModalTeacherModel constructor
The constructor was dividing by modalityTeachers.Length (line 24) and accessing
_modalityTeachers[0] (lines 14, 36) without validating the array, which could
cause DivideByZeroException, IndexOutOfRangeException, or inconsistent behavior.
Added validation to fail fast in the constructor:
1. Check that modality teachers array is non-empty (Length > 0)
2. Check that no teacher is null
3. Check that all teachers have the same OutputDimension
4. Improved modalityWeights validation with clearer error message
This prevents runtime errors when OutputDimension or GetLogits is invoked
and provides clear, actionable error messages indicating which validation failed.
Similar to the fix applied to DistributedTeacherModel.1 parent 38b49eb commit 06dad2d
File tree
1 file changed
+27
-1
lines changed- src/KnowledgeDistillation/Teachers
1 file changed
+27
-1
lines changedLines changed: 27 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 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 | + | |
22 | 46 | | |
23 | 47 | | |
24 | 48 | | |
25 | 49 | | |
26 | 50 | | |
27 | 51 | | |
28 | 52 | | |
29 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
30 | 56 | | |
31 | 57 | | |
32 | 58 | | |
| |||
0 commit comments