Skip to content

[WebNN EP] Fail to run some models with in-memory external data #25078

Open
@Honry

Description

@Honry

Description

In this PR, some initializers will be stored as in-memory external data during graph transformation.

In the WebNN EP, it doesn't handle the in-memory external data, this will cause error (External mounted files are not available.) when it tries to register such initializers (in memory external data) to WebNN constant at here.

  if (utils::HasExternalData(tensor)) {
    // Create WebNN Constant from external data.
    std::basic_string<ORTCHAR_T> external_file_path;
    onnxruntime::FileOffsetType data_offset;
    SafeInt<size_t> tensor_byte_size;
    ORT_RETURN_IF_ERROR(utils::GetExternalDataInfo(
        tensor, graph_viewer_.ModelPath(), external_file_path, data_offset, tensor_byte_size));

    auto webnnRegisterMLConstant = emscripten::val::module_property("webnnRegisterMLConstant");
    operand = webnnRegisterMLConstant(emscripten::val(external_file_path),
                                      static_cast<int32_t>(data_offset),
                                      static_cast<int32_t>(tensor_byte_size),
                                      wnn_builder,
                                      desc,
                                      should_convert_int64_to_int32);

Metadata

Metadata

Assignees

No one assigned

    Labels

    ep:WebNNWebNN execution provider

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions