api.h 2.4 KB
Newer Older
H
hanbuhe 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* 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. */

#pragma once

Z
zhangyang 已提交
17
#include "fpga/V2/driver/pe.h"
Z
zhangyang 已提交
18
#include "fpga/V2/fpga_common.h"
Z
zhangyang 已提交
19
#include "framework/tensor.h"
H
hanbuhe 已提交
20

Z
zhangyang 已提交
21
namespace paddle_mobile {
H
hanbuhe 已提交
22 23
namespace fpga {

H
hanbuhe 已提交
24 25 26 27
int open_device();
int close_device();
void* fpga_malloc(size_t size);
void fpga_free(void* ptr);
Z
zhangyang 已提交
28 29 30
void fpga_copy(void* dest, const void* src, size_t num);
int fpga_flush(void* address, size_t size);
int fpga_invalidate(void* address, size_t size);
31

Z
zhangyang 已提交
32 33 34 35 36
float filter_find_max(framework::Tensor* filter_tensor);
int get_aligned_channel_num(int channel_num);
int get_aligned_filter_num(framework::Tensor* filter_tensor);
int get_conv_output_channel(framework::Tensor* filter_tensor);

Z
zhangyang 已提交
37
void format_image(framework::Tensor* image_tensor);
Z
zhangyang 已提交
38 39 40
void format_fp16_ofm(framework::Tensor* ofm_tensor,
                     int aligned_channel);  // only allocate memory
void format_fp32_ofm(framework::Tensor* ofm_tensor, int aligned_channel);
41

Z
zhangyang 已提交
42 43
void format_filter(framework::Tensor* filter_tensor, float max_value,
                   int group_num);
Z
zhangyang 已提交
44
void format_fc_filter(framework::Tensor* filter_tensor, float max_value);
Z
zhangyang 已提交
45 46
void format_bias_scale_array(float** bias_scale_array, int filter_num,
                             int filter_channel);
Z
zhangyang 已提交
47
void format_concat_output(framework::Tensor* out, int height, int width,
Z
zhangyang 已提交
48 49 50 51 52
                          uint32_t out_channel);
int format_conv_data(framework::Tensor* filter_tensor,
                     framework::Tensor* ofm_tensor, float* bs_ptr, int group);
int format_fc_data(framework::Tensor* filter_tensor,
                   framework::Tensor* ofm_tensor, float* bs_ptr);
Z
zhangyang 已提交
53 54 55 56
void fill_split_arg(struct SplitConvArgs* arg, framework::Tensor* input,
                    framework::Tensor* out, framework::Tensor* filter,
                    bool relu_enabled, int group_num, int stride_h,
                    int stride_w, int padding_h, int padding_w, float* bs_ptr);
57

H
hanbuhe 已提交
58
}  // namespace fpga
Z
zhangyang 已提交
59
}  // namespace paddle_mobile