Skip to content

Commit ee2321d

Browse files
authored
Revert 15770 develop a6910f9 gelu mkl opt (#15872)
* Revert "Optimze Gelu with MKL Erf function (#15770)" This reverts commit 676995c. * test=develop
1 parent 8187072 commit ee2321d

5 files changed

Lines changed: 2 additions & 59 deletions

File tree

cmake/external/mklml.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ IF(WIN32)
3939
SET(MKLML_IOMP_LIB ${MKLML_LIB_DIR}/libiomp5md.lib)
4040
SET(MKLML_SHARED_LIB ${MKLML_LIB_DIR}/mklml.dll)
4141
SET(MKLML_SHARED_IOMP_LIB ${MKLML_LIB_DIR}/libiomp5md.dll)
42-
ELSE()
43-
#TODO(intel-huying):
44-
# Now enable Erf function in mklml library temporarily, it will be updated as offical version later.
45-
SET(MKLML_VER "VsErf_mklml_lnx_${TIME_VERSION}" CACHE STRING "" FORCE)
42+
ELSE()
43+
SET(MKLML_VER "mklml_lnx_${TIME_VERSION}" CACHE STRING "" FORCE)
4644
SET(MKLML_URL "http://paddlepaddledeps.cdn.bcebos.com/${MKLML_VER}.tgz" CACHE STRING "" FORCE)
4745
SET(MKLML_LIB ${MKLML_LIB_DIR}/libmklml_intel.so)
4846
SET(MKLML_IOMP_LIB ${MKLML_LIB_DIR}/libiomp5.so)

paddle/fluid/operators/activation_op.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ limitations under the License. */
1111

1212
#pragma once
1313
#include <glog/logging.h>
14-
#include <algorithm>
1514
#include <string>
1615
#include <unordered_set>
1716
#include <utility>
@@ -25,7 +24,6 @@ limitations under the License. */
2524
#include "paddle/fluid/framework/eigen.h"
2625
#include "paddle/fluid/framework/op_registry.h"
2726
#include "paddle/fluid/operators/detail/safe_ref.h"
28-
#include "paddle/fluid/operators/math/blas.h"
2927
#include "paddle/fluid/platform/float16.h"
3028

3129
#ifdef PADDLE_WITH_MKLDNN
@@ -303,28 +301,8 @@ template <typename T>
303301
struct GeluFunctor : public BaseActivationFunctor<T> {
304302
template <typename Device, typename X, typename Out>
305303
void operator()(Device d, X x, Out out) const {
306-
// Because the execute or device context can not be deliver here, it keep the
307-
// marco for NVCC.
308-
#if defined(PADDLE_WITH_MKLML) && !defined(_WIN32) && !defined(__APPLE__) && \
309-
!defined(__OSX__) && !defined(PADDLE_WITH_CUDA)
310-
auto x_data = x.data();
311-
auto out_data = out.data();
312-
int n = std::min(x.size(), out.size());
313-
314-
std::memset(out_data, 0, n * sizeof(T));
315-
math::CBlas<T>::AXPY(n, static_cast<T>(M_SQRT1_2), x_data, 1, out_data, 1);
316-
math::CBlas<T>::VMERF(n, out_data, out_data, VML_LA);
317-
for (int i = 0; i < n; i++) {
318-
out_data[i] += static_cast<T>(1);
319-
}
320-
math::CBlas<T>::VMUL(n, x_data, out_data, out_data);
321-
for (int i = 0; i < n; i++) {
322-
out_data[i] *= static_cast<T>(0.5);
323-
}
324-
#else
325304
auto temp = (x * static_cast<T>(M_SQRT1_2)).erf();
326305
out.device(d) = x * static_cast<T>(0.5) * (static_cast<T>(1) + temp);
327-
#endif
328306
}
329307
};
330308

paddle/fluid/operators/math/blas.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,6 @@ class Blas {
184184
template <typename T>
185185
void VINV(int n, const T* a, T* y) const;
186186

187-
template <typename T>
188-
void VMERF(int n, const T* a, T* y, int64_t mode) const;
189-
190187
private:
191188
const DeviceContext& context_;
192189
};
@@ -293,11 +290,6 @@ class BlasT : private Blas<DeviceContext> {
293290
Base()->template VINV<T>(args...);
294291
}
295292

296-
template <typename... ARGS>
297-
void VMERF(ARGS... args) const {
298-
Base()->template VMERF<T>(args...);
299-
}
300-
301293
private:
302294
const Blas<DeviceContext>* Base() const {
303295
return static_cast<const Blas<DeviceContext>*>(this);

paddle/fluid/operators/math/blas_impl.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,6 @@ struct CBlas<float> {
123123
static void VINV(ARGS... args) {
124124
platform::dynload::vsInv(args...);
125125
}
126-
127-
template <typename... ARGS>
128-
static void VMERF(ARGS... args) {
129-
platform::dynload::vmsErf(args...);
130-
}
131126
};
132127

133128
template <>
@@ -228,11 +223,6 @@ struct CBlas<double> {
228223
static void VINV(ARGS... args) {
229224
platform::dynload::vdInv(args...);
230225
}
231-
232-
template <typename... ARGS>
233-
static void VMERF(ARGS... args) {
234-
platform::dynload::vmdErf(args...);
235-
}
236226
};
237227

238228
#else
@@ -635,19 +625,6 @@ void Blas<DeviceContext>::VINV(int n, const T *a, T *y) const {
635625
#endif
636626
}
637627

638-
template <>
639-
template <typename T>
640-
void Blas<platform::CPUDeviceContext>::VMERF(int n, const T *a, T *y,
641-
int64_t mode) const {
642-
#ifdef PADDLE_WITH_MKLML
643-
CBlas<T>::VMERF(n, a, y, mode);
644-
#else
645-
for (int i = 0; i < n; ++i) {
646-
y[i] = std::erf(a[i]);
647-
}
648-
#endif
649-
}
650-
651628
} // namespace math
652629
} // namespace operators
653630
} // namespace paddle

paddle/fluid/platform/dynload/mklml.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ extern void* mklml_dso_handle;
8686
__macro(vdPowx); \
8787
__macro(vsInv); \
8888
__macro(vdInv); \
89-
__macro(vmsErf); \
90-
__macro(vmdErf); \
9189
__macro(MKL_Set_Num_Threads)
9290

9391
MKLML_ROUTINE_EACH(DECLARE_DYNAMIC_LOAD_MKLML_WRAP);

0 commit comments

Comments
 (0)