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

Function ConvertPackOperator

tensorflow/lite/toco/import_tensorflow.cc:2006–2026  ·  view source on GitHub ↗

Note that it's easy to confuse/conflate "Stack" and "Pack" operators, but they aren't the same thing. tf.stack results in a "Pack" operator. "Stack" operators also exist, but involve manipulating the TF runtime stack, and are not directly related to tf.stack() usage.

Source from the content-addressed store, hash-verified

2004// operators also exist, but involve manipulating the TF runtime stack, and are
2005// not directly related to tf.stack() usage.
2006tensorflow::Status ConvertPackOperator(
2007 const NodeDef& node, const TensorFlowImportFlags& tf_import_flags,
2008 const ModelFlags& model_flags, Model* model) {
2009 CHECK_EQ(node.op(), "Pack");
2010 auto op = absl::make_unique<PackOperator>();
2011 const int num_inputs = GetInputsCount(node, tf_import_flags);
2012 QCHECK_GE(num_inputs, 1)
2013 << node.op()
2014 << " node expects at least 1 input other than control dependencies: "
2015 << node.DebugString();
2016 CHECK_EQ(num_inputs, GetIntAttr(node, "N"));
2017 for (int i = 0; i < num_inputs; ++i) {
2018 op->inputs.push_back(node.input(i));
2019 }
2020 op->values_count = HasAttr(node, "N") ? GetIntAttr(node, "N") : num_inputs;
2021 op->axis = HasAttr(node, "axis") ? GetIntAttr(node, "axis") : 0;
2022 op->dtype = ConvertDataType(toco::GetDataTypeAttr(node, "T"));
2023 op->outputs.push_back(node.name());
2024 model->operators.emplace_back(std::move(op));
2025 return tensorflow::Status::OK();
2026}
2027
2028tensorflow::Status ConvertUnpackOperator(
2029 const NodeDef& node, const TensorFlowImportFlags& tf_import_flags,

Callers

nothing calls this directly

Calls 11

GetInputsCountFunction · 0.85
GetIntAttrFunction · 0.85
HasAttrFunction · 0.85
GetDataTypeAttrFunction · 0.85
ConvertDataTypeFunction · 0.70
nameMethod · 0.65
opMethod · 0.45
DebugStringMethod · 0.45
push_backMethod · 0.45
inputMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected