Spawn an HTTP server to handle tensor input and output requests.
This function does not return. The default port is 3000.
// any function with tensor inputs/outputs can be servedfunction genRandTensor() { return sm.rand([128])}// async functions can be served as wellasync function talkToServer() { const t = await sm.network.tfetch(different_server) return t.mul(sm.rand([128]))}sm.network.serve({ genRandTensor: genRandTensor, remoteCall: talkToServer})
The above functions are accessible from a different process with network.tfetch:
network.tfetch
const t0 = await sm.network.tfetch(`${host}:3000/genRandTensor`)const t1 = await sm.network.tfetch(`${host}:3000/remoteCall`)
A map of endpoint names to the underlying (possibly async) function calls.
A set of options passed to the underlying Bun.serve call.
Generated using TypeDoc
Spawn an HTTP server to handle tensor input and output requests.
Remarks
This function does not return. The default port is 3000.
Example
The above functions are accessible from a different process with
network.tfetch
: