Commit 38b49eb
committed
fix: add comprehensive validation to DistributedTeacherModel constructor
The constructor was accessing _workers[0] without validating the array,
which could cause IndexOutOfRangeException or inconsistent behavior.
Added validation to fail fast in the constructor:
1. Check that workers array is non-empty (Length > 0)
2. Check that no worker is null
3. Check that all workers have the same OutputDimension
This prevents runtime errors when OutputDimension or GetLogits is invoked
and provides clear, actionable error messages indicating which validation failed.
Addresses code review comment from @coderabbitai.1 parent 2bc248f commit 38b49eb
File tree
1 file changed
+24
-0
lines changed- src/KnowledgeDistillation/Teachers
1 file changed
+24
-0
lines changedLines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 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 | + | |
21 | 45 | | |
22 | 46 | | |
23 | 47 | | |
| |||
0 commit comments