get parameter in function signature from yaml element, e.g. - name: input type: str produces ["const std::string &"] and ["input_name"] :param elem: yaml element of a input :return: A tuple, (type, name)
(elem: dict)
| 42 | |
| 43 | |
| 44 | def get_param(elem: dict) -> Dict[str, str]: |
| 45 | """ |
| 46 | get parameter in function signature from yaml element, e.g. |
| 47 | - |
| 48 | name: input |
| 49 | type: str |
| 50 | produces ["const std::string &"] and ["input_name"] |
| 51 | :param elem: yaml element of a input |
| 52 | :return: A tuple, (type, name) |
| 53 | """ |
| 54 | if elem['cpp_type'] == 'str': |
| 55 | ret = {'type': 'const std::string &', 'name': elem['name']} |
| 56 | elif elem['cpp_type'] == 'optional_str': |
| 57 | ret = {'type': 'const dnn::optional<std::string> &', 'name': elem['name']} |
| 58 | elif elem['cpp_type'] == 'str_list': |
| 59 | ret = {'type': 'const std::vector<std::string> &', 'name': elem['name']} |
| 60 | elif elem['cpp_type'] == 'int32_list': |
| 61 | ret = {'type': 'const std::vector<int32_t> &', 'name': elem['name']} |
| 62 | else: |
| 63 | ret = {'type': elem['cpp_type'], 'name': elem['name']} |
| 64 | # If we make some input (e.g. api 29 new input) optional, the outputs (after inputs in arg list) |
| 65 | # have to be optional too, so disable it. |
| 66 | # if 'default' in elem: |
| 67 | # ret['default'] = elem['default'] |
| 68 | return ret |
| 69 | |
| 70 | |
| 71 | def add_optional_bias(): |
nothing calls this directly
no outgoing calls
no test coverage detected