Repository: opencv/opencv
File: modules/gapi/src/backends/onnx/gonnxbackend.cpp (C++)

Code before:
        }
    }

    if (!params.const_inputs.empty()) {
        // Form input names order without const input names
        in_names_without_const.clear();
        std::copy_if(params.input_names.begin(), params.input_names.end(),
                     std::back_inserter(in_names_without_const),
                     [&](const std::string& name) {
                        const auto it = params.const_inputs.find(name);
                        return it == params.const_inputs.end();
                     });
    }

    // Pre-allocate vectors (not buffers) for runtime info
    in_data.resize(params.num_in);
    out_data.resize(params.num_out);
}

ONNXCompiled::~ONNXCompiled() {
    if(workload_type) {
        workload_type->removeListener(workload_listener_id);
    }
}

void ONNXCompiled::setWorkLoadType(const std::string &type) {
    const char* keys[] = {"ep.dynamic.workload_type"};
    const char* values[] = {type.c_str()};
    this_session.SetEpDynamicOptions(keys, values, 1);
}

void ONNXCompiled::configureWorkloadType(cv::gapi::onnx::WorkloadTypeOnnxPtr workload) {
    workload_type = workload;
    workload_listener_id = workload_type->addListener(std::bind(&ONNXCompiled::setWorkLoadType, this, std::placeholders::_1));
}

std::vector<TensorInfo> ONNXCompiled::getTensorInfo(TensorPosition pos) {
    GAPI_Assert(pos == INPUT || pos == OUTPUT);

    const auto num_nodes = pos == INPUT
        ? this_session.GetInputCount()
        : this_session.GetOutputCount();

    std::vector<TensorInfo> tensor_info;
    tensor_info.reserve(num_nodes);

    Ort::AllocatorWithDefaultOptions allocator;
    for (auto i : ade::util::iota(num_nodes)) {
        const auto info = pos == INPUT
            ? this_session.GetInputTypeInfo(i)
            : this_session.GetOutputTypeInfo(i);

Review comment (suggestion):
Please align everywhere: either use `WorkLoad` or `Workload` in the names

Code after:
    }

    if (!params.const_inputs.empty()) {
        // Form input names order without const input names
        in_names_without_const.clear();
        std::copy_if(params.input_names.begin(), params.input_names.end(),
                     std::back_inserter(in_names_without_const),
                     [&](const std::string& name) {
                        const auto it = params.const_inputs.find(name);
                        return it == params.const_inputs.end();
                     });
    }

    // Pre-allocate vectors (not buffers) for runtime info
    in_data.resize(params.num_in);
    out_data.resize(params.num_out);
}

ONNXCompiled::~ONNXCompiled() {
    if (m_workload_type) {
        m_workload_type->removeListener(m_workload_listener_id);
    }
}

void ONNXCompiled::setWorkloadType(const std::string &type) {
    const char* keys[] = {"ep.dynamic.workload_type"};
    const char* values[] = {type.c_str()};
    this_session.SetEpDynamicOptions(keys, values, 1);
}

void ONNXCompiled::listenToWorkloadType(cv::gapi::onnx::WorkloadTypeONNXPtr workload) {
    m_workload_type = workload;
    m_workload_listener_id = m_workload_type->addListener(std::bind(&ONNXCompiled::setWorkloadType, this, std::placeholders::_1));
}

std::vector<TensorInfo> ONNXCompiled::getTensorInfo(TensorPosition pos) {
    GAPI_Assert(pos == INPUT || pos == OUTPUT);

    const auto num_nodes = pos == INPUT
        ? this_session.GetInputCount()
        : this_session.GetOutputCount();

    std::vector<TensorInfo> tensor_info;
    tensor_info.reserve(num_nodes);

    Ort::AllocatorWithDefaultOptions allocator;
    for (auto i : ade::util::iota(num_nodes)) {
        const auto info = pos == INPUT
            ? this_session.GetInputTypeInfo(i)
            : this_session.GetOutputTypeInfo(i);
        tensor_info.emplace_back(info.GetTensorTypeAndShapeInfo());