RuntimeOptions get_options_from_kwargs()

in source/neuropod/bindings/neuropod_native.cc [110:141]


RuntimeOptions get_options_from_kwargs(py::kwargs &kwargs)
{
    RuntimeOptions options;

    for (const auto &item : kwargs)
    {
        const auto  key   = item.first.cast<std::string>();
        const auto &value = item.second;

        if (key == "visible_gpu")
        {
            if (value.is_none())
            {
                options.visible_device = Device::CPU;
            }
            else
            {
                options.visible_device = value.cast<int>();
            }
        }
        else if (key == "use_ope")
        {
            options.use_ope = value.cast<bool>();
        }
        else
        {
            NEUROPOD_ERROR("Got unexpected keyword argument {}", key);
        }
    }

    return options;
}