Returns a local backend. Args: name: the backend name. If `None`, a default local backend is returned, typically `gpu` if one is present, or `cpu` if not. If a string, the named backend is returned or an exception raised. Returns: A LocalBackend object.
(name=None)
| 240 | |
| 241 | |
| 242 | def get_local_backend(name=None): |
| 243 | """Returns a local backend. |
| 244 | |
| 245 | Args: |
| 246 | name: the backend name. If `None`, a default local backend is returned, |
| 247 | typically `gpu` if one is present, or `cpu` if not. If a string, the named |
| 248 | backend is returned or an exception raised. |
| 249 | |
| 250 | Returns: |
| 251 | A LocalBackend object. |
| 252 | """ |
| 253 | backends = _get_local_backends() |
| 254 | if name is not None: |
| 255 | try: |
| 256 | return backends[name] |
| 257 | except KeyError: |
| 258 | raise RuntimeError('Unknown backend {}'.format(name)) |
| 259 | |
| 260 | return list(backends.values())[-1] |
| 261 | |
| 262 | |
| 263 | class OpMetadata(object): |
no test coverage detected