未验证 提交 a85592bc 编写于 作者: Z Zhong Hui 提交者: GitHub

fix cpplint error for the autmic max/min

fix cpplint error for the autmic max/min
上级 ecfdfc9c
...@@ -12,13 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ...@@ -12,13 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#include "paddle/fluid/operators/elementwise/elementwise_div_op.h" #include <algorithm>
#include "paddle/fluid/operators/gather.cu.h" #include "paddle/fluid/operators/gather.cu.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/operators/math/segment_pooling.h" #include "paddle/fluid/operators/math/segment_pooling.h"
#include "paddle/fluid/platform/cuda_primitives.h" #include "paddle/fluid/platform/cuda_primitives.h"
#include "paddle/fluid/platform/gpu_launch_param_config.h" #include "paddle/fluid/platform/gpu_launch_param_config.h"
#include "paddle/fluid/platform/macros.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -100,7 +99,7 @@ __global__ void SegmentOpsKernel(const Index* segment_ids, const T* input, ...@@ -100,7 +99,7 @@ __global__ void SegmentOpsKernel(const Index* segment_ids, const T* input,
CUDA_KERNEL_LOOP(stripe_index, h.total_stripe_count) { CUDA_KERNEL_LOOP(stripe_index, h.total_stripe_count) {
Index segment_offset, dim_index_base, actual_height; Index segment_offset, dim_index_base, actual_height;
Index inner_dim_size = h.inner_dim_size; Index inner_dim_size = h.inner_dim_size;
h.calculate(stripe_index, segment_offset, dim_index_base, actual_height); h.calculate(stripe_index, &segment_offset, &dim_index_base, &actual_height);
T minmax = pool.initial(); T minmax = pool.initial();
Index first_segment_id = segment_ids[dim_index_base]; Index first_segment_id = segment_ids[dim_index_base];
...@@ -154,7 +153,7 @@ __global__ void SegmentIndexGradKernel(const Index* segment_ids, const T* input, ...@@ -154,7 +153,7 @@ __global__ void SegmentIndexGradKernel(const Index* segment_ids, const T* input,
T* in_grad, Helper h) { T* in_grad, Helper h) {
CUDA_KERNEL_LOOP(stripe_index, h.total_stripe_count) { CUDA_KERNEL_LOOP(stripe_index, h.total_stripe_count) {
Index segment_offset, dim_index_base, actual_height; Index segment_offset, dim_index_base, actual_height;
h.calculate(stripe_index, segment_offset, dim_index_base, actual_height); h.calculate(stripe_index, &segment_offset, &dim_index_base, &actual_height);
for (Index j = 0; j < actual_height; j++) { for (Index j = 0; j < actual_height; j++) {
Index current_segment_id = segment_ids[dim_index_base + j]; Index current_segment_id = segment_ids[dim_index_base + j];
...@@ -217,11 +216,11 @@ class ArrangeHelper { ...@@ -217,11 +216,11 @@ class ArrangeHelper {
total_stripe_count = inner_dim_size * input_outer_dim_num_stripe; total_stripe_count = inner_dim_size * input_outer_dim_num_stripe;
} }
DEVICE inline void calculate(T stripe_index, T& segment_offset, DEVICE inline void calculate(T stripe_index, T* segment_offset,
T& dim_index_base, T& actual_height) { T* dim_index_base, T* actual_height) {
segment_offset = stripe_index % inner_dim_size; *segment_offset = stripe_index % inner_dim_size;
dim_index_base = stripe_index / inner_dim_size * DimTileSize; *dim_index_base = stripe_index / inner_dim_size * DimTileSize;
actual_height = min(DimTileSize, input_length_size - dim_index_base); *actual_height = min(DimTileSize, input_length_size - *dim_index_base);
} }
}; };
......
...@@ -137,12 +137,12 @@ USE_CUDA_ATOMIC(Max, unsigned int); ...@@ -137,12 +137,12 @@ USE_CUDA_ATOMIC(Max, unsigned int);
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 350 #if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 350
USE_CUDA_ATOMIC(Max, unsigned long long int); // NOLINT USE_CUDA_ATOMIC(Max, unsigned long long int); // NOLINT
#else #else
CUDA_ATOMIC_WRAPPER(Max, unsigned long long int) { CUDA_ATOMIC_WRAPPER(Max, unsigned long long int) { // NOLINT
if (*address >= val) { if (*address >= val) {
return; return;
} }
unsigned long long int old = *address, assumed; unsigned long long int old = *address, assumed; // NOLINT
do { do {
assumed = old; assumed = old;
...@@ -169,7 +169,7 @@ CUDA_ATOMIC_WRAPPER(Max, float) { ...@@ -169,7 +169,7 @@ CUDA_ATOMIC_WRAPPER(Max, float) {
return; return;
} }
int *const address_as_i = (int *)address; int *const address_as_i = reinterpret_cast<int *>(address);
int old = *address_as_i, assumed; int old = *address_as_i, assumed;
do { do {
...@@ -187,9 +187,9 @@ CUDA_ATOMIC_WRAPPER(Max, double) { ...@@ -187,9 +187,9 @@ CUDA_ATOMIC_WRAPPER(Max, double) {
return; return;
} }
unsigned long long int *const address_as_ull = unsigned long long int *const address_as_ull = // NOLINT
(unsigned long long int *)address; reinterpret_cast<unsigned long long int *>(address); // NOLINT
unsigned long long int old = *address_as_ull, assumed; unsigned long long int old = *address_as_ull, assumed; // NOLINT
do { do {
assumed = old; assumed = old;
...@@ -209,12 +209,12 @@ USE_CUDA_ATOMIC(Min, unsigned int); ...@@ -209,12 +209,12 @@ USE_CUDA_ATOMIC(Min, unsigned int);
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 350 #if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 350
USE_CUDA_ATOMIC(Min, unsigned long long int); // NOLINT USE_CUDA_ATOMIC(Min, unsigned long long int); // NOLINT
#else #else
CUDA_ATOMIC_WRAPPER(Min, unsigned long long int) { CUDA_ATOMIC_WRAPPER(Min, unsigned long long int) { // NOLINT
if (*address <= val) { if (*address <= val) {
return; return;
} }
unsigned long long int old = *address, assumed; unsigned long long int old = *address, assumed; // NOLINT
do { do {
assumed = old; assumed = old;
...@@ -241,7 +241,7 @@ CUDA_ATOMIC_WRAPPER(Min, float) { ...@@ -241,7 +241,7 @@ CUDA_ATOMIC_WRAPPER(Min, float) {
return; return;
} }
int *const address_as_i = (int *)address; int *const address_as_i = reinterpret_cast<int *>(address);
int old = *address_as_i, assumed; int old = *address_as_i, assumed;
do { do {
...@@ -259,9 +259,9 @@ CUDA_ATOMIC_WRAPPER(Min, double) { ...@@ -259,9 +259,9 @@ CUDA_ATOMIC_WRAPPER(Min, double) {
return; return;
} }
unsigned long long int *const address_as_ull = unsigned long long int *const address_as_ull = // NOLINT
(unsigned long long int *)address; reinterpret_cast<unsigned long long int *>(address); // NOLINT
unsigned long long int old = *address_as_ull, assumed; unsigned long long int old = *address_as_ull, assumed; // NOLINT
do { do {
assumed = old; assumed = old;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册