Skip to content

Don't transfer input ArrayBuffers #566

@reillyeon

Description

@reillyeon

Right now the input and output ArrayBuffers passed to MLContext's compute() method are transferred so that their contents cannot be modified by script during the computation. It seems appropriate that an ArrayBuffer passed to MLGraphBuilder's constant() method should be treated the same way, though it would be better if the transfer were delayed until build() is called so that multiple ArrayBufferViews using the same backing ArrayBuffer can be passed as constants. build() would construct a list of unique backing ArrayBuffers to transfer rather than the naive approach of simply iterating over the ArrayBufferViews themselves.

I'll note that transferring ArrayBuffer parameters makes an API harder to call from WebAssembly, but I think that any argument for why compute inputs and outputs are transferred should also apply to constants.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions