| 735 | } |
| 736 | |
| 737 | tensorflow::Status ConvertConstOperator( |
| 738 | const NodeDef& node, const TensorFlowImportFlags& tf_import_flags, |
| 739 | const ModelFlags& model_flags, Model* model) { |
| 740 | CHECK_EQ(node.op(), "Const"); |
| 741 | const auto& tensor = GetTensorAttr(node, "value"); |
| 742 | const auto dtype = GetDataTypeAttr(node, "dtype"); |
| 743 | |
| 744 | tensorflow::Status status = tensorflow::Status::OK(); |
| 745 | |
| 746 | auto& array = model->GetOrCreateArray(node.name()); |
| 747 | switch (dtype) { |
| 748 | case DT_FLOAT: |
| 749 | array.data_type = ArrayDataType::kFloat; |
| 750 | status = ImportFloatArray(tensor, &array); |
| 751 | break; |
| 752 | case DT_INT32: |
| 753 | array.data_type = ArrayDataType::kInt32; |
| 754 | status = ImportInt32Array(tensor, &array); |
| 755 | break; |
| 756 | case DT_QUINT8: |
| 757 | array.data_type = ArrayDataType::kUint8; |
| 758 | status = ImportQuint8Array(tensor, &array); |
| 759 | break; |
| 760 | case DT_INT64: |
| 761 | array.data_type = ArrayDataType::kInt64; |
| 762 | status = ImportInt64Array(tensor, &array); |
| 763 | break; |
| 764 | case DT_STRING: |
| 765 | array.data_type = ArrayDataType::kString; |
| 766 | status = ImportStringArray(tensor, &array); |
| 767 | break; |
| 768 | case DT_BOOL: |
| 769 | array.data_type = ArrayDataType::kBool; |
| 770 | status = ImportBoolArray(tensor, &array); |
| 771 | break; |
| 772 | case DT_COMPLEX64: |
| 773 | array.data_type = ArrayDataType::kComplex64; |
| 774 | status = ImportComplex64Array(tensor, &array); |
| 775 | break; |
| 776 | default: |
| 777 | array.data_type = ArrayDataType::kNone; |
| 778 | // do nothing, silently ignore the Const data. |
| 779 | // We just make a dummy buffer to indicate that |
| 780 | // this array does not rely on external input. |
| 781 | array.GetMutableBuffer<ArrayDataType::kNone>(); |
| 782 | break; |
| 783 | } |
| 784 | TF_RETURN_WITH_CONTEXT_IF_ERROR( |
| 785 | status, " (while processing node '" + node.name() + "')"); |
| 786 | return tensorflow::Status::OK(); |
| 787 | } |
| 788 | |
| 789 | tensorflow::Status ConvertConvOperator( |
| 790 | const NodeDef& node, const TensorFlowImportFlags& tf_import_flags, |
no test coverage detected