Commit 5be2964e authored by Shucai Xiao's avatar Shucai Xiao
Browse files

fixed cppcheck error

parent fc03c706
......@@ -219,40 +219,39 @@ struct cpu_quant_convolution
argument compute(context&, shape output_shape, std::vector<argument> args) const
{
argument result{output_shape};
result.visit([&](auto output) {
visit_all(args[0], args[1])([&](auto input, auto weights) {
auto in = input.get_shape().lens();
auto in_h = in[2];
auto in_w = in[3];
auto wei = weights.get_shape().lens();
auto wei_n = wei[0];
auto wei_c = wei[1];
auto wei_h = wei[2];
auto wei_w = wei[3];
par_dfor(output_shape.lens()[0],
output_shape.lens()[1],
output_shape.lens()[2],
output_shape.lens()[3])(
[&](std::size_t o, std::size_t w, std::size_t i, std::size_t j) {
const int start_x = i * op.stride[0] - op.padding[0];
const int start_y = j * op.stride[1] - op.padding[1];
const int group_id = w / (wei_n / op.group);
float acc = 0;
dfor(wei_c, wei_h, wei_w)([&](std::size_t k, std::size_t x, std::size_t y) {
const int in_x = start_x + x;
const int in_y = start_y + y;
const int in_ch = group_id * wei_c + k;
if(in_x >= 0 && in_x < in_h && in_y >= 0 && in_y < in_w)
{
acc += input(o, in_ch, in_x, in_y) * weights(w, k, x, y);
}
});
output(o, w, i, j) = acc;
auto output = result.get<float>();
visit_all(args[0], args[1])([&](auto input, auto weights) {
auto in = input.get_shape().lens();
auto in_h = in[2];
auto in_w = in[3];
auto wei = weights.get_shape().lens();
auto wei_n = wei[0];
auto wei_c = wei[1];
auto wei_h = wei[2];
auto wei_w = wei[3];
par_dfor(output_shape.lens()[0],
output_shape.lens()[1],
output_shape.lens()[2],
output_shape.lens()[3])(
[&](std::size_t o, std::size_t w, std::size_t i, std::size_t j) {
const auto start_x = i * op.stride[0] - op.padding[0];
const auto start_y = j * op.stride[1] - op.padding[1];
const auto group_id = w / (wei_n / op.group);
float acc = 0;
dfor(wei_c, wei_h, wei_w)([&](std::size_t k, std::size_t x, std::size_t y) {
const auto in_x = start_x + x;
const auto in_y = start_y + y;
const auto in_ch = group_id * wei_c + k;
if(in_x >= 0 && in_x < in_h && in_y >= 0 && in_y < in_w)
{
acc += input(o, in_ch, in_x, in_y) * weights(w, k, x, y);
}
});
});
output(o, w, i, j) = acc;
});
});
return result;
......
......@@ -32,8 +32,8 @@ struct miopen_quant_gemm
}
private:
mutable argument arg_a;
mutable argument arg_b;
argument arg_a;
argument arg_b;
};
} // namespace gpu
......
......@@ -64,7 +64,8 @@ shape miopen_quant_gemm::compute_shape(const std::vector<shape>& inputs) const
{
if(arg_b.empty())
{
arg_b = allocate_gpu(inputs[1]);
auto *p_this = const_cast<miopen_quant_gemm*>(this);
p_this->arg_b = allocate_gpu(inputs[1]);
}
}
......@@ -72,7 +73,8 @@ shape miopen_quant_gemm::compute_shape(const std::vector<shape>& inputs) const
{
if(arg_a.empty())
{
arg_a = allocate_gpu(inputs[0]);
auto *p_this = const_cast<miopen_quant_gemm*>(this);
p_this->arg_a = allocate_gpu(inputs[0]);
}
}
......
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