Skip to content

Commit 5eb8850

Browse files
committed
fix
Signed-off-by: BubbleCal <bubble-cal@outlook.com>
1 parent fc02fe9 commit 5eb8850

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

protos/index.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ message IVF {
6868
Tensor centroids_tensor = 4;
6969

7070
// KMeans loss.
71-
double loss = 5;
71+
optional double loss = 5;
7272
}
7373

7474
// Product Quantization.

rust/lance-index/src/vector/ivf/storage.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl TryFrom<&IvfModel> for PbIvf {
180180
lengths,
181181
offsets: ivf.offsets.iter().map(|x| *x as u64).collect(),
182182
centroids_tensor: ivf.centroids.as_ref().map(|c| c.try_into()).transpose()?,
183-
loss: ivf.loss.unwrap_or_default(),
183+
loss: ivf.loss,
184184
})
185185
}
186186
}
@@ -229,7 +229,7 @@ impl TryFrom<PbIvf> for IvfModel {
229229
centroids,
230230
offsets,
231231
lengths: proto.lengths,
232-
loss: Some(proto.loss),
232+
loss: proto.loss,
233233
})
234234
}
235235
}
@@ -311,7 +311,7 @@ mod tests {
311311
lengths: vec![2, 2],
312312
offsets: vec![0, 2],
313313
centroids_tensor: None,
314-
loss: 0.0,
314+
loss: None,
315315
};
316316

317317
let ivf = IvfModel::try_from(pb_ivf).unwrap();

0 commit comments

Comments
 (0)