Skip to content

Commit

Permalink
Fix expectations about the source of internal/external objects.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 306519238
Change-Id: Idd97a4de4fb0b5a88d905b5e846a76294d2e5951
  • Loading branch information
tensorflower-gardener committed Apr 14, 2020
1 parent 7c4341c commit 4000a5c
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tensorflow/lite/delegates/gpu/gl/api2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -585,18 +585,26 @@ class InferenceBuilderImpl : public InferenceBuilder {
std::vector<TensorTieDef> links;
links.reserve(values.size());
for (const auto& value : values) {
TensorObjectDef def;
TensorObjectDef external_def;
// So far the compiler always forces inputs and outputs to be in the fixed
// format.
const auto& shape = value->tensor.shape;
def.dimensions = Dimensions(shape.b, shape.h, shape.w, shape.c);
def.object_def.data_type = DataType::FLOAT32;
def.object_def.data_layout = DataLayout::DHWC4;
def.object_def.object_type = gpu::ObjectType::OPENGL_SSBO;
def.object_def.user_provided = true;
external_def.dimensions = Dimensions(shape.b, shape.h, shape.w, shape.c);
external_def.object_def.data_type = DataType::FLOAT32;
external_def.object_def.data_layout = DataLayout::DHWC4;
external_def.object_def.object_type = gpu::ObjectType::OPENGL_SSBO;

// Internal object is not expected to be provided by user because: if
// external and internal objects have same defs, the external object is
// propagated and just used as an internal one; otherwise, if they have
// different defs, internal object will be created, because it is not
// provided by user.
TensorObjectDef internal_def = external_def;
external_def.object_def.user_provided = true;
internal_def.object_def.user_provided = false;
AccessType access =
graph_.IsGraphInput(value->id) ? AccessType::READ : AccessType::WRITE;
links.push_back({value->id, access, def, def});
links.push_back({value->id, access, external_def, internal_def});
}
return links;
}
Expand Down

0 comments on commit 4000a5c

Please sign in to comment.