deconv_bias_scale.cpp 1.6 KB
Newer Older
Z
zhangyang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */

#include "fpga/V1/deconv_bias_scale.h"
// #include "deconv_bias_scale.h"
#include "fpga/V1/bias_scale.h"
// #include "bias_scale.h"
#include <memory.h>

#include "fpga/V1/api.h"
// #include "fpga_api.h"
namespace paddle_mobile {
namespace fpga {
namespace deconv_bias_scale {

Z
zhangyang 已提交
27 28
void deconv_bias_scale_expand(float** bias_scale_array, int num,
                              int sub_conv_n) {
Z
zhangyang 已提交
29 30
  int sub_num = num * sub_conv_n;
  float* ptr_tmp = *bias_scale_array;
Z
zhangyang 已提交
31 32 33 34
  float* ptr_bias_scale_expand =
      (float*)fpga_malloc(sizeof(float) * sub_num * 2);
  int scale_base_offset = sub_num;
  for (int i = 0; i < sub_conv_n; ++i) {
Z
zhangyang 已提交
35
    int offset = num * i;
Z
zhangyang 已提交
36 37 38 39 40
    // copy bias
    fpga_copy(ptr_bias_scale_expand + offset, ptr_tmp, num * sizeof(float));
    // copy scale
    fpga_copy(ptr_bias_scale_expand + scale_base_offset + offset, ptr_tmp + num,
              num * sizeof(float));
Z
zhangyang 已提交
41 42 43 44 45
  }
  *bias_scale_array = ptr_bias_scale_expand;
  fpga_free(ptr_tmp);
}

Z
zhangyang 已提交
46
}  // namespace deconv_bias_scale
Z
zhangyang 已提交
47 48
}  // namespace fpga
}  // namespace paddle_mobile