From a49660e9b83e34c56686dd04fd3995f2e164af40 Mon Sep 17 00:00:00 2001 From: Liu-xiandong Date: Mon, 22 Nov 2021 12:28:01 +0000 Subject: [PATCH] update after pten --- cmake/xpu2.cmake | 10 ++-- .../elementwise/elementwise_add_op.xpu | 10 ++-- .../elementwise/elementwise_add_op_kps.cc | 50 ------------------- paddle/pten/common/data_type.h | 12 +++-- 4 files changed, 18 insertions(+), 64 deletions(-) delete mode 100644 paddle/fluid/operators/elementwise/elementwise_add_op_kps.cc diff --git a/cmake/xpu2.cmake b/cmake/xpu2.cmake index 1d698aa82ab5b..85a7fce0ab171 100644 --- a/cmake/xpu2.cmake +++ b/cmake/xpu2.cmake @@ -95,7 +95,7 @@ macro(compile_kernel COMPILE_ARGS) #-Wno-error=constant-conversion -Wno-error=c++11-narrowing -Wno-error=shift-count-overflow set(XPU_CXX_INCLUDES -I/workspace/paddle/Paddle/build -I/workspace/paddle/Paddle/paddle/fluid/framework/io -I/workspace/paddle/Paddle/build/third_party/install/zlib/include -I/workspace/paddle/Paddle/build/third_party/install -I/workspace/paddle/Paddle/build/third_party/install/gflags/include -I/workspace/paddle/Paddle/build/third_party/install/glog/include -I/workspace/paddle/Paddle/build/third_party/boost/src/extern_boost -I/workspace/paddle/Paddle/build/third_party/eigen3/src/extern_eigen3 -I/workspace/paddle/Paddle/build/third_party/threadpool/src/extern_threadpool -I/workspace/paddle/Paddle/build/third_party/dlpack/src/extern_dlpack/include -I/workspace/paddle/Paddle/build/third_party/install/xxhash/include -I/workspace/paddle/Paddle/build/third_party/install/warpctc/include -I/workspace/paddle/Paddle/build/third_party/install/openblas/include -I/workspace/paddle/Paddle/build/third_party/install/protobuf/include -I/usr/include/python3.7m -I/usr/local/lib/python3.7/dist-packages/numpy/core/include -I/workspace/paddle/Paddle/build/third_party/pybind/src/extern_pybind/include -I/workspace/paddle/Paddle/build/third_party/install/gtest/include -I/workspace/paddle/Paddle/build/third_party/install/gloo/include -I/workspace/paddle/Paddle/build/third_party/install/xbyak/include -I/workspace/paddle/Paddle/build/third_party/install/xbyak/include/xbyak -I/workspace/paddle/Paddle/build/third_party/install/cryptopp/include -I/workspace/paddle/Paddle/build/third_party/pocketfft/src -I/workspace/paddle/Paddle) #set(XPU_CXX_FLAGS -Wno-error=deprecated-declarations -Wno-deprecated-declarations -std=c++14 -m64 -fPIC -fno-omit-frame-pointer -Werror -Wall -Wextra -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wno-unused-parameter -Wno-unused-function -Wno-error=literal-suffix -Wno-error=unused-local-typedefs -Wno-error=ignored-attributes -Wno-error=terminate -Wno-error=int-in-bool-context -Wimplicit-fallthrough=0 -Wno-error=maybe-uninitialized -Wno-format-truncation -Wno-error=cast-function-type -Wno-error=parentheses -Wno-error=catch-value -Wno-error=nonnull-compare -Wno-error=address -Wno-ignored-qualifiers -Wno-ignored-attributes -Wno-parentheses -mavx -O3 -DNDEBUG ) - set(XPU_CXX_FLAGS -Wno-error=constant-conversion -Wno-error=c++11-narrowing -Wno-error=shift-count-overflow -Wno-error=unused-local-typedef -Wno-error=deprecated-declarations -Wno-deprecated-declarations -std=c++14 -m64 -fPIC -fno-omit-frame-pointer -Werror -Wall -Wno-inconsistent-missing-override -Wextra -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wno-unused-parameter -Wno-unused-function -Wno-error=unused-local-typedefs -Wno-error=ignored-attributes -Wno-error=int-in-bool-context -Wno-error=parentheses -Wno-error=address -Wno-ignored-qualifiers -Wno-ignored-attributes -Wno-parentheses -O3 -DNDEBUG ) + set(XPU_CXX_FLAGS -Wno-error=pessimizing-move -Wno-error=constant-conversion -Wno-error=c++11-narrowing -Wno-error=shift-count-overflow -Wno-error=unused-local-typedef -Wno-error=deprecated-declarations -Wno-deprecated-declarations -std=c++14 -m64 -fPIC -fno-omit-frame-pointer -Wall -Wno-inconsistent-missing-override -Wextra -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wno-unused-parameter -Wno-unused-function -Wno-error=unused-local-typedefs -Wno-error=ignored-attributes -Wno-error=int-in-bool-context -Wno-error=parentheses -Wno-error=address -Wno-ignored-qualifiers -Wno-ignored-attributes -Wno-parentheses -O3 -DNDEBUG ) #set(XPU_CXX_FLAGS -Wno-error=deprecated-declarations -Wno-deprecated-declarations -std=c++14 -m64 -fPIC -fno-omit-frame-pointer -Werror -Wall -Wextra -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wno-unused-parameter -Wno-unused-function -Wno-error=literal-suffix -Wno-error=unused-local-typedefs -Wno-error=ignored-attributes -Wno-error=terminate -Wno-error=int-in-bool-context -Wimplicit-fallthrough=0 -Wno-error=maybe-uninitialized -Wno-format-truncation -Wno-error=cast-function-type -Wno-error=parentheses -Wno-error=catch-value -Wno-error=nonnull-compare -Wno-error=address -Wno-ignored-qualifiers -Wno-ignored-attributes -Wno-parentheses -O3 -DNDEBUG ) set(XPU_CXX_DEFINES -DHPPL_STUB_FUNC -DPADDLE_DISABLE_PROFILER -DPADDLE_DLL_EXPORT -DPADDLE_USE_OPENBLAS -DPADDLE_USE_PTHREAD_BARRIER -DPADDLE_USE_PTHREAD_SPINLOCK -DPADDLE_VERSION=0.0.0 -DPADDLE_VERSION_INTEGER=0 -DPADDLE_WITH_AVX -DPADDLE_WITH_CRYPTO -DPADDLE_WITH_POCKETFFT -DPADDLE_WITH_SSE3 -DPADDLE_WITH_TESTING -DPADDLE_WITH_XBYAK -DPADDLE_WITH_XPU2 -DXBYAK64 -DXBYAK_NO_OP_NAMES) @@ -105,8 +105,8 @@ macro(compile_kernel COMPILE_ARGS) COMMAND ${CMAKE_COMMAND} -E make_directory kernel_build COMMAND - # TODO(liuxiandong) xpu->kps -I${XTDK_DIR}/include -std=c++11 - ${XPU_CLANG} --sysroot=${CXX_DIR} -O2 -fno-builtin -g -mcpu=xpu2 -fPIC ${XPU_CXX_DEFINES} ${XPU_CXX_FLAGS} ${XPU_CXX_INCLUDES} + # TODO(liuxiandong) xpu->kps -I${XTDK_DIR}/include -std=c++11 + ${XPU_CLANG} --sysroot=${CXX_DIR} -O2 -fno-builtin -g -mcpu=xpu2 -fPIC ${XPU_CXX_DEFINES} ${XPU_CXX_FLAGS} ${XPU_CXX_INCLUDES} -I${XTDK_DIR}/include -I. -o kernel_build/${kernel_name}.bin.o.sec /workspace/paddle/Paddle/paddle/fluid/operators/elementwise/${kernel_name}.xpu --xpu-device-only -c -v COMMAND @@ -133,8 +133,8 @@ macro(compile_kernel COMPILE_ARGS) COMMAND ${CMAKE_COMMAND} -E make_directory kernel_build COMMAND - # TODO(liuxiandong) xpu->kps -I${XTDK_DIR}/include -std=c++11 - ${XPU_CLANG} --sysroot=${CXX_DIR} -O2 -fno-builtin -g -mcpu=xpu2 -fPIC ${XPU_CXX_DEFINES} ${XPU_CXX_FLAGS} ${XPU_CXX_INCLUDES} + # TODO(liuxiandong) xpu->kps -I${XTDK_DIR}/include -std=c++11 + ${XPU_CLANG} --sysroot=${CXX_DIR} -O2 -fno-builtin -g -mcpu=xpu2 -fPIC ${XPU_CXX_DEFINES} ${XPU_CXX_FLAGS} ${XPU_CXX_INCLUDES} -I${XTDK_DIR}/include -I. -o kernel_build/${kernel_name}.host.o /workspace/paddle/Paddle/paddle/fluid/operators/elementwise/${kernel_name}.xpu --xpu-host-only -c -v # COMMAND diff --git a/paddle/fluid/operators/elementwise/elementwise_add_op.xpu b/paddle/fluid/operators/elementwise/elementwise_add_op.xpu index 1f1577003940d..95989e8c4200a 100644 --- a/paddle/fluid/operators/elementwise/elementwise_add_op.xpu +++ b/paddle/fluid/operators/elementwise/elementwise_add_op.xpu @@ -33,15 +33,15 @@ limitations under the License. */ #include #include "paddle/fluid/platform/aligned_vector.h" #include "paddle/fluid/platform/function_traits.h" -#include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/framework/op_registry.h" //TODO #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/operators/elementwise/elementwise_add_op.h" #include "paddle/fluid/operators/elementwise/elementwise_op.h" -//#include "xpu/kernel/cluster_header.h" -//#include "xpu/kernel/debug.h" -//#include "xpu/kernel/math.h" -//#include +#include "xpu/kernel/cluster_header.h" +#include "xpu/kernel/debug.h" +#include "xpu/kernel/math.h" +#include namespace paddle { diff --git a/paddle/fluid/operators/elementwise/elementwise_add_op_kps.cc b/paddle/fluid/operators/elementwise/elementwise_add_op_kps.cc deleted file mode 100644 index 07755a77f4276..0000000000000 --- a/paddle/fluid/operators/elementwise/elementwise_add_op_kps.cc +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2020 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. */ - -#ifdef PADDLE_WITH_XPU2 -#include "paddle/fluid/operators/elementwise/elementwise_add_op.h" -#include -#include -#include "paddle/fluid/framework/data_type.h" -#include "paddle/fluid/framework/op_registry.h" - -namespace paddle { -namespace operators { - -template -class ElementwiseAddXPU2Kernel : public framework::OpKernel { - public: - void Compute(const framework::ExecutionContext& ctx) const override { - std::cout << "lxd_debug: XPU2 forward element_add !" << std::endl; - } -}; - -template -class ElementwiseAddGradXPU2Kernel : public ElemwiseGradKernel { - public: - void Compute(const framework::ExecutionContext& ctx) const override { - std::cout << "lxd_debug: XPU2 backward element_add !" << std::endl; - } -}; - -} // namespace operators -} // namespace paddle - -namespace ops = paddle::operators; - -REGISTER_OP_XPU2_KERNEL(elementwise_add, ops::ElementwiseAddXPU2Kernel); - -REGISTER_OP_XPU2_KERNEL(elementwise_add_grad, - ops::ElementwiseAddGradXPU2Kernel); -#endif diff --git a/paddle/pten/common/data_type.h b/paddle/pten/common/data_type.h index 1ddee0746d4d1..9e66fbe1ea85b 100644 --- a/paddle/pten/common/data_type.h +++ b/paddle/pten/common/data_type.h @@ -14,10 +14,14 @@ limitations under the License. */ #pragma once -#include "bfloat16.h" // NOLINT -#include "complex.h" // NOLINT -#include "float16.h" // NOLINT - +//#include "bfloat16.h" // NOLINT +//#include "complex.h" // NOLINT +//#include "float16.h" // NOLINT + +#include "paddle/fluid/platform/bfloat16.h" +#include "paddle/fluid/platform/complex.h" +#include "paddle/fluid/platform/enforce.h" +#include "paddle/fluid/platform/float16.h" #include "paddle/pten/api/ext/exception.h" namespace paddle {