fake_quantize_op.cu 2.5 KB
Newer Older
视言's avatar
视言 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* Copyright (c) 2016 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. */

15
#include "paddle/fluid/operators/fake_quantize_op.cu.h"
视言's avatar
视言 已提交
16 17
#include "paddle/fluid/operators/fake_quantize_op.h"

18 19
namespace ops = paddle::operators;
using CUDA = paddle::platform::CUDADeviceContext;
C
cc 已提交
20
using float16 = paddle::platform::float16;
21
REGISTER_OP_CUDA_KERNEL(fake_quantize_abs_max,
22 23
                        ops::FakeQuantizeAbsMaxKernel<CUDA, float>,
                        ops::FakeQuantizeAbsMaxKernel<CUDA, float16>);
24
REGISTER_OP_CUDA_KERNEL(fake_quantize_dequantize_abs_max,
C
cc 已提交
25 26
                        ops::FakeQuantizeDequantizeAbsMaxKernel<CUDA, float>,
                        ops::FakeQuantizeDequantizeAbsMaxKernel<CUDA, float16>);
27 28 29 30
REGISTER_OP_CUDA_KERNEL(
    fake_channel_wise_quantize_abs_max,
    ops::FakeChannelWiseQuantizeAbsMaxKernel<CUDA, float>,
    ops::FakeChannelWiseQuantizeAbsMaxKernel<CUDA, float16>);
31
REGISTER_OP_CUDA_KERNEL(fake_quantize_range_abs_max,
32 33
                        ops::FakeQuantizeRangeAbsMaxKernel<CUDA, float>,
                        ops::FakeQuantizeRangeAbsMaxKernel<CUDA, float16>);
34 35
REGISTER_OP_CUDA_KERNEL(
    fake_quantize_moving_average_abs_max,
36 37
    ops::FakeQuantizeMovingAverageAbsMaxKernel<CUDA, float>,
    ops::FakeQuantizeMovingAverageAbsMaxKernel<CUDA, float16>);
Z
Zhen Wang 已提交
38
REGISTER_OP_CUDA_KERNEL(moving_average_abs_max_scale,
C
cc 已提交
39 40
                        ops::MovingAverageAbsMaxScaleKernel<CUDA, float>,
                        ops::MovingAverageAbsMaxScaleKernel<CUDA, float16>);
41 42
REGISTER_OP_CUDA_KERNEL(
    fake_quantize_dequantize_moving_average_abs_max,
C
cc 已提交
43 44
    ops::FakeQuantizeDequantizeMovingAverageAbsMaxKernel<CUDA, float>,
    ops::FakeQuantizeDequantizeMovingAverageAbsMaxKernel<CUDA, float16>);
45
REGISTER_OP_CUDA_KERNEL(stright_throuth_estimator_grad,
C
cc 已提交
46 47
                        ops::StrightThroughEstimatorGradKernel<CUDA, float>,
                        ops::StrightThroughEstimatorGradKernel<CUDA, float16>);
H
huangxu96 已提交
48 49 50
REGISTER_OP_CUDA_KERNEL(
    fake_channel_wise_quantize_dequantize_abs_max,
    ops::FakeChannelWiseQuantizeDequantizeAbsMaxKernel<CUDA, float>);