From 2290df00d16f73e1dd4d9eaeb225987012568415 Mon Sep 17 00:00:00 2001 From: yangfei Date: Sun, 30 Sep 2018 14:33:19 +0800 Subject: [PATCH] load memory for CLImage --- src/framework/executor.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/framework/executor.cpp b/src/framework/executor.cpp index fc1030b639..9c898ba554 100644 --- a/src/framework/executor.cpp +++ b/src/framework/executor.cpp @@ -818,9 +818,21 @@ void Executor::InitMemory() { cl_context context = program_.scope->GetCLScpoe()->Context(); float *tensorInput = (float *)origin_data; + + const framework::TensorDesc &desc = var_desc->Tensor_desc(); framework::DDim ddim = cl_image->dims(); + cl_image->Init(context, tensorInput, ddim); delete origin_data; + }else{ + auto cl_image = var->template GetMutable(); + cl_context context = program_.scope->GetCLScpoe()->Context(); + + const framework::TensorDesc &desc = var_desc->Tensor_desc(); + framework::DDim ddim = cl_image->dims(); + + cl_image->Init(context, ddim); + } } } @@ -850,6 +862,7 @@ void Executor::InitCombineMemory() { cl_context context = program_.scope->GetCLScpoe()->Context(); + const framework::TensorDesc &desc = var_desc->Tensor_desc(); framework::DDim ddim = cl_image->dims(); int numel = 1; @@ -857,8 +870,16 @@ void Executor::InitCombineMemory() { numel = numel * ddim[i]; } float *tensorInput = data; - data += numel; cl_image->Init(context, tensorInput, ddim); + data += numel; + }else{ + auto cl_image = var->template GetMutable(); + cl_context context = program_.scope->GetCLScpoe()->Context(); + + const framework::TensorDesc &desc = var_desc->Tensor_desc(); + framework::DDim ddim = cl_image->dims(); + + cl_image->Init(context, ddim); } } } -- GitLab