diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/runtime/CL/functions/CLFullyConnectedLayer.cpp | 16 | ||||
-rw-r--r-- | src/runtime/gpu/cl/operators/ClGemm.cpp | 1 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/runtime/CL/functions/CLFullyConnectedLayer.cpp b/src/runtime/CL/functions/CLFullyConnectedLayer.cpp index c719a667a7..6836c12022 100644 --- a/src/runtime/CL/functions/CLFullyConnectedLayer.cpp +++ b/src/runtime/CL/functions/CLFullyConnectedLayer.cpp @@ -76,7 +76,7 @@ void CLFullyConnectedLayer::configure(const CLCompileContext &compile_context, c _impl->op = std::make_unique<opencl::ClFullyConnected>(); _impl->original_weights = weights; - _impl->is_prepared = false; + _impl->is_prepared = fc_info.retain_internal_weights; _impl->op->configure(compile_context, input->info(), weights->info(), (biases != nullptr) ? biases->info() : nullptr, output->info(), fc_info); @@ -85,9 +85,17 @@ void CLFullyConnectedLayer::configure(const CLCompileContext &compile_context, c _impl->weights_manager->manage(weights); } - _impl->aux_mem_req = _impl->op->workspace(); - _impl->run_pack = { { ACL_SRC_0, input }, { ACL_SRC_1, weights }, { ACL_SRC_2, biases }, { ACL_DST, output } }; - _impl->workspace = manage_workspace<CLTensor>(_impl->aux_mem_req, _impl->memory_group, _impl->run_pack, _impl->run_pack); + if(!_impl->is_prepared) + { + _impl->aux_mem_req = _impl->op->workspace(); + _impl->run_pack = { { ACL_SRC_0, input }, { ACL_SRC_1, weights }, { ACL_SRC_2, biases }, { ACL_DST, output } }; + _impl->workspace = manage_workspace<CLTensor>(_impl->aux_mem_req, _impl->memory_group, _impl->run_pack, _impl->run_pack); + } + else + { + _impl->run_pack.add_tensor(ACL_SRC_0, input); + _impl->run_pack.add_tensor(ACL_DST, output); + } } Status CLFullyConnectedLayer::validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, diff --git a/src/runtime/gpu/cl/operators/ClGemm.cpp b/src/runtime/gpu/cl/operators/ClGemm.cpp index 2792dc470d..59bbabba26 100644 --- a/src/runtime/gpu/cl/operators/ClGemm.cpp +++ b/src/runtime/gpu/cl/operators/ClGemm.cpp @@ -564,6 +564,7 @@ void ClGemm::configure(const CLCompileContext &compile_context, ITensorInfo *a, // Check if we need to reshape the matrix B only on the first run _reshape_b_only_on_first_run = gemm_info.reshape_b_only_on_first_run(); + _is_prepared = gemm_info.retain_internal_weights(); bool reinterpret_input_as_3d = gemm_info.reinterpret_input_as_3d(); const unsigned int m = reinterpret_input_as_3d ? (a->dimension(1) * a->dimension(2)) : a->dimension(1); |