Description
Add tf.util.fetch()
as a cross-platform utility which mimics browser's fetch
.
The weights loader should use this util instead of the global fetch (see weights_loader.ts) if the user hasn't provided a custom fetchFunc
.
tf.util.fetch()
should first check for the existence of a global fetch using tf.ENV.global.fetch
. Then fallback for platform-specific solutions. The current platform-specific solution should be to use node-fetch
when the environment is node.
Platforms such as wechat can override their global fetch fetch = customFetch
, which will then be used by all fetching inside the TF.js eco-system (model loading, weights loading, etc)