Function serve

  • 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 served
    function genRandTensor() {
    return sm.rand([128])

    // async functions can be served as well
    async function talkToServer() {
    const t = await
    return t.mul(sm.rand([128]))
    genRandTensor: genRandTensor,
    remoteCall: talkToServer

    The above functions are accessible from a different process with network.tfetch:

    const t0 = await`${host}:3000/genRandTensor`)
    const t1 = await`${host}:3000/remoteCall`)


    • request_dict: Record<string, ((...args: unknown[]) => unknown)>

      A map of endpoint names to the underlying (possibly async) function calls.

    • options: ServeOptions

      A set of options passed to the underlying Bun.serve call.

    Returns void

Generated using TypeDoc