Avoid cpuinfo dependency in Emscripten builds
- OSS cpuinfo doesn't support Emscripten.
- Removing cpuinfo dependency reduces build size.
- cpuinfo on Emscripten is of little value anyway, because no information about
CPU is provided by the environment.
PiperOrigin-RevId: 273307573
diff --git a/src/init.c b/src/init.c
index fec29dc..1296eb6 100644
--- a/src/init.c
+++ b/src/init.c
@@ -12,7 +12,9 @@
#include <pthread.h>
-#include <cpuinfo.h>
+#ifndef __EMSCRIPTEN__
+ #include <cpuinfo.h>
+#endif
#include <xnnpack.h>
#include <xnnpack/argmaxpool.h>
@@ -953,9 +955,11 @@
}
enum xnn_status xnn_initialize(void) {
- if (!cpuinfo_initialize()) {
- return xnn_status_out_of_memory;
- }
+ #ifndef __EMSCRIPTEN__
+ if (!cpuinfo_initialize()) {
+ return xnn_status_out_of_memory;
+ }
+ #endif
pthread_once(&init_guard, &init);
if (xnn_params.initialized) {
return xnn_status_success;
@@ -965,6 +969,8 @@
}
enum xnn_status xnn_deinitialize(void) {
- cpuinfo_deinitialize();
+ #ifndef __EMSCRIPTEN__
+ cpuinfo_deinitialize();
+ #endif
return xnn_status_success;
}
diff --git a/src/wasm-stubs.c b/src/wasm-stubs.c
index b9273c5..ae9ee1a 100644
--- a/src/wasm-stubs.c
+++ b/src/wasm-stubs.c
@@ -5,9 +5,10 @@
#include <stdint.h>
-#include <cpuinfo.h>
#include <fp16.h>
+#include <xnnpack/common.h>
+
uint32_t xnn_stub_wasm_f32_sub(uint32_t a, uint32_t b) {
return fp32_to_bits(fp32_from_bits(a) - fp32_from_bits(b));
}