Commit 2426e157 authored by Shucai Xiao's avatar Shucai Xiao
Browse files

fixed cppcheck errors

parent 6f5895cf
...@@ -379,7 +379,7 @@ struct cpu_gemm ...@@ -379,7 +379,7 @@ struct cpu_gemm
if(out_lens == c_lens) if(out_lens == c_lens)
{ {
visit_all(result, c)([&](auto output, auto input) { visit_all(result, c)([&](auto output, auto input) {
std::memcpy(output.data(), input.data(), c.get_shape().bytes()); std::copy(input.begin(), input.end(), output.begin());
}); });
} }
// need broadcast // need broadcast
...@@ -397,7 +397,7 @@ struct cpu_gemm ...@@ -397,7 +397,7 @@ struct cpu_gemm
visit_all(result, c)([&](auto output, auto input) { visit_all(result, c)([&](auto output, auto input) {
for(std::size_t i = 0; i < m; i++) for(std::size_t i = 0; i < m; i++)
{ {
std::memcpy((output.data() + i * n), input.data(), c.get_shape().bytes()); std::copy(input.begin(), input.end(), output.begin() + i * n);
} }
}); });
} }
...@@ -428,7 +428,7 @@ struct cpu_gemm ...@@ -428,7 +428,7 @@ struct cpu_gemm
if(op.beta == 0.0f) if(op.beta == 0.0f)
{ {
result.visit( result.visit(
[&](auto output) { std::memset(output.data(), 0, output_shape.bytes()); }); [&](auto output) { std::fill(output.begin(), output.end(), 0); });
} }
else else
{ {
...@@ -445,11 +445,9 @@ struct cpu_gemm ...@@ -445,11 +445,9 @@ struct cpu_gemm
auto a_lens = args[0].get_shape().lens(); auto a_lens = args[0].get_shape().lens();
auto b_lens = args[1].get_shape().lens(); auto b_lens = args[1].get_shape().lens();
auto out_lens = output_shape.lens(); auto out_lens = output_shape.lens();
bool is_a_prepended = false;
shape::type_t t = output_shape.type(); shape::type_t t = output_shape.type();
if(a_lens.size() == 1) if(a_lens.size() == 1)
{ {
is_a_prepended = true;
a_lens.insert(a_lens.begin(), 1); a_lens.insert(a_lens.begin(), 1);
out_lens.push_back(1); out_lens.push_back(1);
if(out_lens.size() > 1) if(out_lens.size() > 1)
...@@ -458,10 +456,8 @@ struct cpu_gemm ...@@ -458,10 +456,8 @@ struct cpu_gemm
} }
} }
bool is_b_appended = false;
if(b_lens.size() == 1) if(b_lens.size() == 1)
{ {
is_b_appended = true;
b_lens.push_back(1); b_lens.push_back(1);
out_lens.push_back(1); out_lens.push_back(1);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment