File tree Expand file tree Collapse file tree
packages/react-native-executorch
common/rnexecutorch/data_processing
src/modules/natural_language_processing Expand file tree Collapse file tree Original file line number Diff line number Diff 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) {
Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments