MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ConvertConstOperator

Function ConvertConstOperator

tensorflow/lite/toco/import_tensorflow.cc:737–787  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

735}
736
737tensorflow::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
789tensorflow::Status ConvertConvOperator(
790 const NodeDef& node, const TensorFlowImportFlags& tf_import_flags,

Callers 1

Calls 10

GetDataTypeAttrFunction · 0.85
ImportFloatArrayFunction · 0.85
ImportInt32ArrayFunction · 0.85
ImportQuint8ArrayFunction · 0.85
ImportInt64ArrayFunction · 0.85
ImportStringArrayFunction · 0.85
ImportBoolArrayFunction · 0.85
ImportComplex64ArrayFunction · 0.85
nameMethod · 0.65
opMethod · 0.45

Tested by

no test coverage detected