Added new stage in life of intermediate representation.

PiperOrigin-RevId: 334719764
Change-Id: I2bdb2ab42da6a6b1249037e9726593655823cdf2
This commit is contained in:
Raman Sarokin 2020-09-30 18:10:24 -07:00 committed by TensorFlower Gardener
parent 960263f58c
commit 145f6b1a17
4 changed files with 12 additions and 1 deletions

View File

@ -843,11 +843,16 @@ absl::Status Arguments::AllocateObjects(CLContext* context) {
for (auto& t : objects_) {
RETURN_IF_ERROR(
t.second.descriptor->CreateGPUObject(context, &t.second.obj_ptr));
t.second.descriptor->Release();
}
return absl::OkStatus();
}
void Arguments::ReleaseCPURepresentation() {
for (auto& t : objects_) {
t.second.descriptor->Release();
}
}
absl::Status Arguments::AddObjectArgs() {
for (auto& t : objects_) {
AddGPUResources(t.first, t.second.descriptor->GetGPUResources());

View File

@ -55,6 +55,7 @@ class Arguments {
absl::Status Merge(Arguments&& args, const std::string& postfix);
absl::Status AllocateObjects(CLContext* context);
void ReleaseCPURepresentation();
absl::Status TransformToCLCode(
const DeviceInfo& device_info,
const std::map<std::string, std::string>& linkables, std::string* code);

View File

@ -182,6 +182,10 @@ absl::Status InferenceContext::InitFromGraph(
RETURN_IF_ERROR(Compile(creation_context));
RETURN_IF_ERROR(UpdateParams());
for (auto& node : nodes_) {
node.operation->args_.ReleaseCPURepresentation();
}
TuningParameters tuning_parameters;
tuning_parameters.queue = env->profiling_queue();
tuning_parameters.info = &env->device().info_;

View File

@ -55,6 +55,7 @@ absl::Status ExecuteGPUOperation(const std::vector<TensorFloat32>& src_cpu,
RETURN_IF_ERROR(operation->Compile(creation_context));
RETURN_IF_ERROR(operation->UpdateParams());
operation->args_.ReleaseCPURepresentation();
RETURN_IF_ERROR(operation->AddToQueue(creation_context.queue));
RETURN_IF_ERROR(creation_context.queue->WaitForCompletion());