#include <memory>
#include <charconv>
#include <mutex>
+#include <regex>
#undef MIN
#undef MAX
bool has_vector_subgroup_broadcast;
bool disable_fusion;
+ std::regex *opfilter = nullptr; // regex of ops to not claim
+
bool adreno_has_large_buffer;
bool adreno_use_large_buffer;
ggml_cl_compiler_version adreno_cl_compiler_version;
backend_ctx->disable_fusion = getenv("GGML_OPENCL_DISABLE_FUSION") != nullptr;
+ const char * str_opfilter = getenv("GGML_OPENCL_OPFILTER");
+ if (str_opfilter) {
+ backend_ctx->opfilter = new std::regex(str_opfilter, std::regex_constants::icase);
+ GGML_LOG_INFO("ggml_opencl: opfilter regex = \"%s\"\n", str_opfilter);
+ }
+
dev_ctx->backend_ctx = backend_ctx.release();
return dev_ctx->backend_ctx;
}
ggml_backend_opencl_device_context * dev_ctx = (ggml_backend_opencl_device_context *)dev->context;
ggml_backend_opencl_context * backend_ctx = dev_ctx->backend_ctx;
+ // reject ops that match the opfilter regex
+ if (backend_ctx->opfilter && std::regex_match(std::string(ggml_op_desc(op)), *backend_ctx->opfilter)) {
+ return false;
+ }
+
switch (op->op) {
case GGML_OP_NONE:
return true;