(t)
| 544 | |
| 545 | |
| 546 | def unify_type(t): |
| 547 | # If type is None, we deduce type from source file. |
| 548 | if t is None: |
| 549 | return graph_def_pb2.DataTypePb.UNKNOWN |
| 550 | if isinstance(t, str): |
| 551 | return _unify_str_type(t) |
| 552 | elif isinstance(t, type): |
| 553 | unify_types = { |
| 554 | int: graph_def_pb2.LONG, |
| 555 | np.int32: graph_def_pb2.INT, |
| 556 | np.int64: graph_def_pb2.LONG, |
| 557 | np.uint32: graph_def_pb2.UINT, |
| 558 | np.uint64: graph_def_pb2.ULONG, |
| 559 | float: graph_def_pb2.DOUBLE, |
| 560 | np.float32: graph_def_pb2.FLOAT, |
| 561 | np.float64: graph_def_pb2.DOUBLE, |
| 562 | str: graph_def_pb2.STRING, |
| 563 | np.str_: graph_def_pb2.STRING, |
| 564 | bool: graph_def_pb2.BOOL, |
| 565 | np.bool8: graph_def_pb2.BOOL, |
| 566 | list: graph_def_pb2.INT_LIST, |
| 567 | tuple: graph_def_pb2.INT_LIST, |
| 568 | dict: graph_def_pb2.DYNAMIC, |
| 569 | } |
| 570 | return unify_types[t] |
| 571 | elif isinstance(t, int): # graph_def_pb2.DataType |
| 572 | return t |
| 573 | raise TypeError("Not supported type {}".format(t)) |
| 574 | |
| 575 | |
| 576 | def data_type_to_cpp(t): |
no test coverage detected