Skip to content

Commit

Permalink
Fix Apple silicon WASM development (#6098)
Browse files Browse the repository at this point in the history
Upgrade xnnpack and emsdk to support WASM development on Apple silicon.
  • Loading branch information
mattsoulanille authored Feb 16, 2022
1 parent c754027 commit 23c7251
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ esbuild_repositories(npm_repository = "npm")
# Emscripten toolchain
http_archive(
name = "emsdk",
sha256 = "7a58a9996b113d3e0675df30b5f17e28aa47de2e684a844f05394fe2f6f12e8e",
strip_prefix = "emsdk-c1589b55641787d55d53e883852035beea9aec3f/bazel",
url = "/~https://github.com/emscripten-core/emsdk/archive/c1589b55641787d55d53e883852035beea9aec3f.tar.gz",
sha256 = "7dc13d967705582e11ff62ae143425dbc63c38372f1a1b14f0cb681fda413714",
strip_prefix = "emsdk-3.1.4/bazel",
urls = ["/~https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.4.tar.gz"],
)

load("@emsdk//:deps.bzl", emsdk_deps = "deps")
Expand All @@ -103,9 +103,9 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
# xnnpack used for fast vectorized wasm operations
git_repository(
name = "xnnpack",
commit = "3bfbdaf00211b313b143af39279bb6bf1f7effc0",
commit = "5e8033a72a8d0f1c2b1f06e29137cc697c6b661d",
remote = "/~https://github.com/google/XNNPACK.git",
shallow_since = "1617056836 -0700",
shallow_since = "1643627844 -0800",
)

# The libraries below are transitive dependencies of XNNPACK that we need to
Expand Down
2 changes: 1 addition & 1 deletion tfjs-backend-wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
"devDependencies": {
"@babel/polyfill": "^7.8.7",
"@bazel/bazelisk": "^1.7.5",
"@bazel/bazelisk": "^1.11.0",
"@bazel/buildifier": "^4.0.1",
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
Expand Down
5 changes: 2 additions & 3 deletions tfjs-backend-wasm/src/cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BASE_LINKOPTS = [
"-s FILESYSTEM=0",
"-s EXIT_RUNTIME=0",
"-s EXPORTED_FUNCTIONS='[\"_malloc\", \"_free\"]'",
"-s EXTRA_EXPORTED_RUNTIME_METHODS='[\"cwrap\"]'",
"-s EXPORTED_RUNTIME_METHODS='[\"cwrap\"]'",
"-s MODULARIZE=1",
"-s MALLOC=emmalloc",
# TODO(mattsoulanille): Mark these files as dependencies so Bazel rebuilds
Expand Down Expand Up @@ -61,7 +61,6 @@ cc_binary(
"-s EXPORT_NAME=WasmBackendModuleThreadedSimd",
"-s MALLOC=emmalloc",
"-s USE_PTHREADS=1",
"-s PROXY_TO_PTHREAD=1",
# Pre-create 8 webworkers (threads). The actual number of threads that
# will be used by XNNPACK for creating the threadpool might be fewer. It
# is by default set to the number of logical cores which in most cases
Expand Down Expand Up @@ -106,7 +105,7 @@ tfjs_cc_library(
deps = [
":check_macros",
":util",
"@xnnpack//:xnnpack_operators_nhwc_f32",
"@xnnpack//:xnnpack_for_tfjs",
],
)

Expand Down
3 changes: 2 additions & 1 deletion tfjs-backend-wasm/src/setup_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,9 @@ const TEST_FILTERS: TestFilter[] = [
include: 'clip',
excludes: [
'gradient',
'propagates NaNs' // clip delegates to XNNPACK which does not make
'propagates NaNs', // clip delegates to XNNPACK which does not make
// guarantees about behavior of nans.
'basic vec4' // basic vec4 also includes nans.
]
},
{include: 'addN'},
Expand Down
8 changes: 4 additions & 4 deletions tfjs-backend-wasm/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -839,10 +839,10 @@
lodash "^4.17.19"
to-fast-properties "^2.0.0"

"@bazel/bazelisk@^1.7.5":
version "1.7.5"
resolved "https://registry.yarnpkg.com/@bazel/bazelisk/-/bazelisk-1.7.5.tgz#dd1a52e3d23464f72de55aa3dc4777847fa85373"
integrity sha512-JHwP9JhfZUSoj4sku471Bjw4uE773U2Agujnx0CdPkeRk25khy1l3VyjaPaHB+z1fmMnM6ED3M7tetQUsovUQg==
"@bazel/bazelisk@^1.11.0":
version "1.11.0"
resolved "https://registry.yarnpkg.com/@bazel/bazelisk/-/bazelisk-1.11.0.tgz#f98d8438b4c14e3328126618b96775d271caa5f8"
integrity sha512-lxiQzVqSGDG0PIDQGJdVDjp7T+50p5NnM4EnRJa76mkZp6u5ul19GJNKhPKi81TZQALZEZDxAgxVqQKkWTUOxA==

"@bazel/buildifier@^4.0.1":
version "4.0.1"
Expand Down

0 comments on commit 23c7251

Please sign in to comment.