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

Function Unflatten

tensorflow/python/framework/python_op_gen.cc:78–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78void Unflatten(const string& prefix, const std::vector<string>& output_sizes,
79 const string& var, string* result) {
80 for (int i = 0; i < output_sizes.size(); ++i) {
81 if (!output_sizes[i].empty()) {
82 strings::StrAppend(result, prefix, var, " = ");
83 if (i > 0) strings::StrAppend(result, var, "[:", i, "] + ");
84 if (i + 1 < output_sizes.size()) {
85 // Special case i == 0 to avoid "0 +" in the generated code.
86 if (i == 0) {
87 strings::StrAppend(result, "[", var, "[:", output_sizes[i], "]] + ",
88 var, "[", output_sizes[i], ":]");
89 } else {
90 strings::StrAppend(result, "[", var, "[", i, ":", i, " + ",
91 output_sizes[i], "]] + ", var, "[", i, " + ",
92 output_sizes[i], ":]");
93 }
94 } else {
95 strings::StrAppend(result, "[", var, "[", i, ":]]");
96 }
97 strings::StrAppend(result, "\n");
98 }
99 }
100}
101
102string TensorPBString(const TensorProto& pb) {
103 // Note: This gets used in the argument list, and so must survive naive

Callers 2

AddEagerInferredAttrsMethod · 0.85

Calls 3

StrAppendFunction · 0.50
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected