Skip to content

Commit 7ace914

Browse files
committed
fix: review suggestions
1 parent d7e23ca commit 7ace914

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

packages/react-native-executorch/common/rnexecutorch/data_processing/Numerical.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ void normalize(std::span<float> span) {
2424
sum += val * val;
2525
}
2626

27+
// Early return if all values are 0
28+
if (sum == 0.0f) {
29+
return;
30+
}
31+
2732
// Preventing divison by 0
2833
float norm = std::max(std::sqrt(sum), 1e-9f);
2934
for (auto &val : span) {

packages/react-native-executorch/src/modules/natural_language_processing/TextEmbeddingsModule.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export class TextEmbeddingsModule extends BaseNonStaticModule {
2121
paths[1] || ''
2222
);
2323
if (meanPooling === undefined) {
24+
this.meanPooling = true;
2425
console.warn(
2526
"You haven't passed meanPooling flag. It is defaulting to true, if your model doesn't require mean pooling it may return wrong results."
2627
);

0 commit comments

Comments
 (0)