Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

merge Arm lite to developing #455

Open
wants to merge 29 commits into
base: developing
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7f61c9d
Merge pull request #70 from PaddlePaddle/arm_lite
chenjiaoAngel Aug 23, 2018
f850727
fix bug in ios build
chenjiaoAngel Aug 23, 2018
5596a5e
some change for resize
yiicy Aug 23, 2018
3f6fb93
Merge branch 'arm_lite' into arm_lite
xyoungli Aug 23, 2018
6bfc841
Merge pull request #365 from chenjiaoAngel/lite3
cyj1986 Aug 23, 2018
e8b64bb
Merge branch 'arm_lite' into arm_lite
LittleMaer Aug 24, 2018
1d570e9
update softmax
chenjiaoAngel Aug 24, 2018
d6b67b6
Merge pull request #71 from PaddlePaddle/arm_lite
chenjiaoAngel Aug 24, 2018
aa81f67
update softmax
chenjiaoAngel Aug 24, 2018
6ebaeb6
fix bug in parse priorbox
chenjiaoAngel Aug 24, 2018
5f8bb54
update conv_dw3x3
chenjiaoAngel Aug 25, 2018
dd63fae
add shufflechannel param
xyoungli Aug 25, 2018
22c8212
Merge remote-tracking branch 'upstream/arm_lite' into lite4
xyoungli Aug 25, 2018
4bdad8a
Merge pull request #372 from chenjiaoAngel/lite3
xyoungli Aug 25, 2018
890b66f
change conv impl api
xyoungli Aug 25, 2018
406b42a
Merge remote-tracking branch 'upstream/arm_lite' into lite4
xyoungli Aug 25, 2018
1f044f8
Merge pull request #34 from PaddlePaddle/developing
xyoungli Aug 27, 2018
a18fc6b
Merge branch 'arm_lite' into lite4
xyoungli Aug 27, 2018
c50a675
Merge branch 'lite4' of https://github.com/xyoungli/Anakin into lite4
xyoungli Aug 27, 2018
4e97da0
Merge branch 'developing' into arm_lite
LittleMaer Aug 27, 2018
2fd1c08
Merge branch 'arm_lite' into arm_lite
LittleMaer Aug 27, 2018
54d867b
Merge remote-tracking branch 'upstream/developing' into lite4
xyoungli Sep 3, 2018
103dbe2
add bn to arm_lite
xyoungli Sep 4, 2018
b8c6962
Merge branch 'arm_lite' into lite4
xyoungli Sep 4, 2018
acd9cd5
Merge pull request #366 from yiicy/arm_lite
cyj1986 Sep 5, 2018
da1a65c
Merge branch 'arm_lite' into lite4
cyj1986 Sep 5, 2018
8fc25e3
Merge pull request #416 from xyoungli/lite4
xyoungli Sep 5, 2018
f940010
fix issue 428
xyoungli Sep 7, 2018
bfa0754
Merge pull request #434 from PaddlePaddle/xyoungli-patch-1
throneclay Sep 14, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cmake/ios/ios.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ endif (CMAKE_UNAME)

# Force the compilers to gcc for iOS
include (CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER (/usr/bin/clang Apple)
CMAKE_FORCE_CXX_COMPILER (/usr/bin/clang++ Apple)
set(CMAKE_C_COMPILER /usr/bin/clang)
set(CMAKE_CXX_COMPILER /usr/bin/clang++)
#CMAKE_FORCE_C_COMPILER (/usr/bin/clang Apple)
#CMAKE_FORCE_CXX_COMPILER (/usr/bin/clang++ Apple)
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)

# Skip the platform compiler checks for cross compiling
Expand Down
1 change: 0 additions & 1 deletion framework/lite/code_gen_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ void GenCPP<Ttype, Dtype, Ptype>::gen_header_start() {
_code<<"#include <saber/lite/funcs/saber_eltwise.h>\n";
_code<<"#include <saber/lite/funcs/saber_eltwise_act.h>\n";
_code<<"#include <saber/lite/funcs/saber_permute.h>\n";
_code<<"#include <saber/lite/funcs/saber_prelu.h>\n";
_code<<"#include <saber/lite/funcs/saber_power.h>\n";
_code<<"#include <saber/lite/funcs/saber_priorbox.h>\n";
_code<<"#include <saber/lite/funcs/saber_scale.h>\n";
Expand Down
85 changes: 83 additions & 2 deletions framework/lite/op_map_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1545,19 +1545,24 @@ std::string ParserPriorBox(graph::AttrInfo& attr,
//add
std::vector<float> fixed_size, fixed_ratio, density;
if (find_attr("fixed_size", attr) == SaberSuccess) {
LOG(ERROR) << "not exit";
auto fix_size = get_attr<PTuple<float>>("fixed_size", attr);
fixed_size = fix_size.vector();
} else {
LOG(WARNING) << "not fixed_size param in priorbox";
}

if (find_attr("fixed_ratio", attr) == SaberSuccess) {
auto fix_ratio = get_attr<PTuple<float>>("fixed_ratio", attr);
fixed_ratio = fix_ratio.vector();
} else {
LOG(WARNING) << "not fixed_ratio param in priorbox";
}

if (find_attr("density", attr) == SaberSuccess) {
auto den = get_attr<PTuple<float>>("density", attr);
density = den.vector();
} else {
LOG(WARNING) << "not density param in priorbox";
}

auto flip_flag = get_attr<bool>("is_flip", attr);
Expand Down Expand Up @@ -1740,7 +1745,7 @@ std::string ParserSlice(graph::AttrInfo& attr,
return code_w.get_code_string();
}

// SaberSlice
// SaberScale
std::string ParserScale(graph::AttrInfo& attr,
std::string& code_name,
std::string& op_class_name,
Expand Down Expand Up @@ -1790,6 +1795,81 @@ std::string ParserScale(graph::AttrInfo& attr,
return code_w.get_code_string();
}

// SaberScale
std::string ParserBatchNorm(graph::AttrInfo& attr,
std::string& code_name,
std::string& op_class_name,
std::string& node_name,
std::string& weights_ptr_name,
WeightsWritter& writter,
bool gen_param) {

// get batchnorm param
auto eps = get_attr<float>("epsilon", attr);
auto momentum = get_attr<float>("momentum", attr);
auto mean = get_attr<PBlock<float, X86>>("weight_1", attr);
auto mean_vec = mean.vector();
auto var = get_attr<PBlock<float, X86>>("weight_2", attr);
auto var_vec = var.vector();
auto scale_factor = get_attr<PBlock<float, X86>>("weight_3", attr);
auto scale_factor_vec = scale_factor.vector();

std::vector<float> scale;
std::vector<float> bias;
scale.resize(mean.count());
bias.resize(mean.count());
auto scale_val = scale_factor_vec[0] == 0 ? 0 : 1 / scale_factor_vec[0];

for (int i = 0; i < mean.count(); i++) {
scale[i] = 1.0f / std::sqrt(var_vec[i] * scale_val + eps);
bias[i] = - mean_vec[i] * scale_val / std::sqrt(var_vec[i] * scale_val + eps);
}

Shape sh1 = {1, 1, 1, scale.size()};
Shape sh2 = {1, 1, 1, bias.size()};
PBlock<float, X86> pscale(sh1);
PBlock<float, X86> pbias(sh2);
float* pscale_ptr = pscale.h_tensor().mutable_data();
for (int j = 0; j < scale.size(); ++j) {
pscale_ptr[j] = scale[j];
}
float* pbias_ptr = pbias.h_tensor().mutable_data();
for (int j = 0; j < bias.size(); ++j) {
pbias_ptr[j] = bias[j];
}

writter.register_weights(node_name, pscale);
LOG(INFO) << node_name << " write weights: " << pscale.count();

writter.register_weights(node_name, pbias);
LOG(INFO) << node_name << " write bias: " << pbias.count();

auto offset_info = writter.get_weights_by_name(node_name);

// gen cpp code
CodeWritter code_w;
if (gen_param) {
code_w.feed("%d %d %d %d %d\n",
offset_info.weights[0].offset,
offset_info.weights[1].offset,
1,
1,
1);
} else {
code_w.feed("ParamBase* %s_param = new ScaleParam(%s+%d, %s+%d, %s, %d, %d);\n",
node_name.c_str(),
weights_ptr_name.c_str(),
offset_info.weights[0].offset,
weights_ptr_name.c_str(),
offset_info.weights[1].offset,
"true",
1,
1);

code_w.feed(" %s_g_param.push_back(%s_param);\n", code_name.c_str(), node_name.c_str());
}
return code_w.get_code_string();
}

// SaberSoftmax
std::string ParserSoftmax(graph::AttrInfo& attr,
Expand Down Expand Up @@ -1923,6 +2003,7 @@ std::unordered_map<std::string, OpParser> OPERATION_MAP({
{"PriorBox", {"SaberPriorBox", ParserPriorBox} }, // done
{"Power", {"SaberPower", ParserPower} }, // done
{"Scale", {"SaberScale", ParserScale} }, // done
{"BatchNorm", {"SaberScale", ParserBatchNorm} }, // done
{"Slice", {"SaberSlice", ParserSlice} }, // done
{"Flatten", {"SaberFlatten", ParserFlatten}}, //done
{"Reshape", {"SaberReshape", ParserReshape}}, //done
Expand Down
5 changes: 4 additions & 1 deletion framework/operators/priorbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ Status PriorBoxHelper<Ttype, Dtype, Ptype>::InitParam() {
if (FIND_PARAMETER(fixed_size)) {
fixed_size_ = GET_PARAMETER(PTuple<float>, fixed_size);
}
// LOG(ERROR) << "fixed_size size " << fixed_size_.size();
PTuple<float> fixed_ratio_;
if (FIND_PARAMETER(fixed_ratio)) {
fixed_ratio_ = GET_PARAMETER(PTuple<float>, fixed_ratio);;
}
//LOG(ERROR) << "fixed_ratio size " << fixed_ratio_.size();
PTuple<float> density_;
if (FIND_PARAMETER(density)) {
auto density_ = GET_PARAMETER(PTuple<float>, density);
density_ = GET_PARAMETER(PTuple<float>, density);
}
//LOG(ERROR) << "density_ size " << density_.size();
//end
auto max_size_ = GET_PARAMETER(PTuple<float>, max_size);
auto as_ratio = GET_PARAMETER(PTuple<float>, aspect_ratio);
Expand Down
Loading