Skip to content

OpenCL: Add CPU fallback for unsupported operations #13621

Closed
@rmatif

Description

@rmatif

I'm trying to add OpenCL backend support to leejet/stable-diffusion.cpp#680, but it crashes when the backend encounters an unsupported operation.

Example for the SD1.5 model:

[DEBUG] ggml_extend.hpp:1134 - clip compute buffer size: 1.40 MB(VRAM)
[DEBUG] conditioner.hpp:485  - computing condition graph completed, taking 45 ms
[INFO ] stable-diffusion.cpp:1392 - get_learned_condition completed, taking 91 ms
[INFO ] stable-diffusion.cpp:1415 - sampling using Euler A method
[INFO ] stable-diffusion.cpp:1452 - generating image: 1/1 - seed 42
[DEBUG] stable-diffusion.cpp:821  - Sample
[DEBUG] ggml_extend.hpp:1134 - unet compute buffer size: 559.90 MB(VRAM)
ggml_backend_opencl_graph_compute: error: op not supported node_185 (GROUP_NORM)


../ggml/src/ggml-opencl/ggml-opencl.cpp:1679: GGML_ASSERT(ok) failed

Is it possible to add CPU fallback when some ops are not supported by the backend?
Ideally, the perfect solution would be to add the missing ops, but before this happens, a CPU fallback would be nice.

If interested, I listed all ops that stable-diffusion.cpp needs to run all the supported models, if someone has the motivation to implement some of the missing ones:

  • ADD
  • CONCAT
  • CONT
  • DIAG_MASK_INF
  • GET_ROWS
  • GROUP_NORM
  • IM2COL
  • MUL
  • MUL_MAT
  • NORM
  • PAD
  • PERMUTE
  • REPEAT
  • RESHAPE
  • RMS_NORM
  • SCALE
  • SOFT_MAX
  • TIMESTEP_EMBEDDING
  • UNARY
  • UPSCALE
  • VIEW

@lhez @max-krasnyansky

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions