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

Function InsertCopyOperator

tensorflow/lite/toco/tooling_util.cc:1377–1401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1375} // namespace
1376
1377void InsertCopyOperator(Model* model, const string& source_array_name,
1378 const string& target_array_name) {
1379 // Reshape to the same size. This should be a no-op.
1380 const Array& source_array = model->GetArray(source_array_name);
1381 std::vector<int> shape = source_array.shape().dims();
1382
1383 // Drop constant data from the target array as the copy will be done at
1384 // runtime.
1385 Array& target_array = model->GetOrCreateArray(target_array_name);
1386 target_array.buffer.reset();
1387 CopyArrayAttribs(source_array, &target_array);
1388
1389 // Insert copy operator.
1390 auto* copy_op = new TensorFlowReshapeOperator;
1391 copy_op->inputs = {
1392 source_array_name,
1393 CreateInt32Array(
1394 model, AvailableArrayName(*model, target_array_name + "_copy_shape"),
1395 shape)};
1396 copy_op->outputs = {target_array_name};
1397 if (target_array.has_shape()) {
1398 copy_op->shape = target_array.shape().dims();
1399 }
1400 model->operators.emplace_back(copy_op);
1401}
1402
1403void CloneArray(Model* model, const string& source_array_name,
1404 const string& target_array_name) {

Callers 3

FixEdgeArraysFunction · 0.85
RunMethod · 0.85

Calls 8

CopyArrayAttribsFunction · 0.85
CreateInt32ArrayFunction · 0.85
AvailableArrayNameFunction · 0.85
has_shapeMethod · 0.80
dimsMethod · 0.45
shapeMethod · 0.45
resetMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected