diff --git a/mobile/src/operators/kernel/cl/elementwise_add_kernel.cpp b/mobile/src/operators/kernel/cl/elementwise_add_kernel.cpp index be051e1942ed3539c2cf2798283e67e4a28c35fc..1506956280a489ebf9631099101c1ac0f0bf03ec 100644 --- a/mobile/src/operators/kernel/cl/elementwise_add_kernel.cpp +++ b/mobile/src/operators/kernel/cl/elementwise_add_kernel.cpp @@ -25,17 +25,27 @@ bool ElementwiseAddKernel::Init( DLOG << "-----init add-----"; CLImage *bias = reinterpret_cast(const_cast(param->InputY())); - if (!bias->isInit()) { - bias->InitNormalCLImage(cl_helper_.CLContext(), - this->cl_helper_.CLCommandQueue()); - } - DLOG << " bias: " << *bias; if (bias->dims().size() == 4) { + if (!bias->isInit()) { + bias->InitNormalCLImage(cl_helper_.CLContext(), + this->cl_helper_.CLCommandQueue()); + } + DLOG << " bias: " << *bias; this->cl_helper_.AddKernel("elementwise_add", "elementwise_add_kernel.cl"); } else if (param->InputY()->dims().size() == 1) { if (param->Axis() == param->InputX()->dims().size() - 1) { + if (!bias->isInit()) { + bias->InitNormalCLImage(cl_helper_.CLContext(), + this->cl_helper_.CLCommandQueue()); + } + DLOG << " bias: " << *bias; this->cl_helper_.AddKernel("width_add", "channel_add_kernel.cl"); } else if (param->Axis() == param->InputX()->dims().size() - 3) { + if (!bias->isInit()) { + bias->InitCLImage(cl_helper_.CLContext(), + this->cl_helper_.CLCommandQueue()); + } + DLOG << " bias: " << *bias; this->cl_helper_.AddKernel("channel_add", "channel_add_kernel.cl"); } else { DLOG << "error:bias dims is error"; diff --git a/mobile/tools/python/fluidtools/run.py b/mobile/tools/python/fluidtools/run.py index 2bf704fb8d119b657ba114fc90c01f92020bc7ce..06ffdd11b986cd3afcff5c12a5a9daf8d674d049 100644 --- a/mobile/tools/python/fluidtools/run.py +++ b/mobile/tools/python/fluidtools/run.py @@ -285,8 +285,9 @@ def save_all_op_output(feed_kv=None): for fetch in fetches: fetch_names.append(fetch.name) feed_names = feeds - for fetch_name in fetch_names: - output_var_filter.append(fetch_name) + if len(output_var_filter) > 0: + for fetch_name in fetch_names: + output_var_filter.append(fetch_name) for i in range(len(ops)): op = ops[i] var_name = None diff --git a/mobile/tools/shell/change_mobile_namespace.sh b/mobile/tools/shell/change_mobile_namespace.sh new file mode 100755 index 0000000000000000000000000000000000000000..5de87448446a4b7bdd9b82085d1853b148fc416e --- /dev/null +++ b/mobile/tools/shell/change_mobile_namespace.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# set -o xtrace + +extension=$1 + +convert () { + perl -pi -e "s/namespace paddle_mobile/namespace paddle_mobile_${1}/g" "${2}" + perl -pi -e "s/paddle_mobile::/paddle_mobile_${1}::/g" "${2}" +} + +revert () { + perl -pi -e "s/namespace paddle_mobile_[\w]*/namespace paddle_mobile/g" "${2}" + perl -pi -e "s/paddle_mobile_[\w]*::/paddle_mobile::/g" "${2}" +} + +if [[ $2 == "revert" ]]; then + for file in $(find src -name "*\.*") + do + echo "reverting ${file}" + revert $extension $file + done + for file in $(find test -name "*\.*") + do + echo "reverting ${file}" + revert $extension $file + done +else + for file in $(find src -name "*\.*") + do + echo "converting ${file}" + convert $extension $file + done + # for file in $(find test -name "*\.*") + # do + # echo "converting ${file}" + # convert $extension $file + # done +fi