Skip to content

Commit

Permalink
Fix some typos (Intermedaite, deperecated, etc.) (#61720)
Browse files Browse the repository at this point in the history
  • Loading branch information
co63oc committed Feb 20, 2024
1 parent 664489d commit 43a2a60
Show file tree
Hide file tree
Showing 27 changed files with 55 additions and 55 deletions.
12 changes: 6 additions & 6 deletions paddle/fluid/operators/fused/fused_elemwise_activation_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ static void RunBinaryCompoundGradFunctors(
UnaryFunctor,
UnaryGradFunctor,
InPlace>;
using BinaryCompoundDIntermedaiteOutFunctor =
phi::funcs::BinaryCompoundGradDIntermedaiteOutFunctor<T,
using BinaryCompoundDIntermediateOutFunctor =
phi::funcs::BinaryCompoundGradDIntermediateOutFunctor<T,
BinaryGradFunctor,
UnaryFunctor>;

Expand All @@ -160,7 +160,7 @@ static void RunBinaryCompoundGradFunctors(
T,
BinaryCompoundDxFunctor,
BinaryCompoundDyFunctor,
BinaryCompoundDIntermedaiteOutFunctor,
BinaryCompoundDIntermediateOutFunctor,
true /*UseIntermediateOut*/,
false /*SameShapeOfIntermediateOutAndOut*/>(
ctx,
Expand All @@ -176,15 +176,15 @@ static void RunBinaryCompoundGradFunctors(
BinaryCompoundDxFunctor(binary_grad_functor, unary_functor),
BinaryCompoundDyFunctor(
binary_grad_functor, unary_functor, unary_grad_functor),
BinaryCompoundDIntermedaiteOutFunctor(binary_grad_functor,
BinaryCompoundDIntermediateOutFunctor(binary_grad_functor,
unary_functor));
} else {
FusedElemwiseAndActGradComputeEx<
DeviceContext,
T,
BinaryCompoundDxFunctor,
BinaryCompoundDyFunctor,
BinaryCompoundDIntermedaiteOutFunctor,
BinaryCompoundDIntermediateOutFunctor,
false /*UseIntermediateOut*/,
false /*SameShapeOfIntermediateOutAndOut*/>(
ctx,
Expand All @@ -200,7 +200,7 @@ static void RunBinaryCompoundGradFunctors(
BinaryCompoundDxFunctor(binary_grad_functor, unary_functor),
BinaryCompoundDyFunctor(
binary_grad_functor, unary_functor, unary_grad_functor),
BinaryCompoundDIntermedaiteOutFunctor(binary_grad_functor,
BinaryCompoundDIntermediateOutFunctor(binary_grad_functor,
unary_functor));
}
}
Expand Down
12 changes: 6 additions & 6 deletions paddle/phi/kernels/funcs/compound_functors.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ struct BinaryCompoundFunctor {

inline HOSTDEVICE T GetOut(T x, T y) { return func1_(x, func2_(y)); }

inline HOSTDEVICE T GetOutUseIntermediateOut(T x, T intermediat_out) {
return func1_(x, intermediat_out);
inline HOSTDEVICE T GetOutUseIntermediateOut(T x, T intermediate_out) {
return func1_(x, intermediate_out);
}

inline HOSTDEVICE T GetIntermediateOut(T x UNUSED, T y) { return func2_(y); }
Expand All @@ -47,8 +47,8 @@ struct UnaryCompoundFunctor {

inline HOSTDEVICE T GetOut(T x, T y) { return func1_(func2_(x, y)); }

inline HOSTDEVICE T GetOutUseIntermediateOut(T x UNUSED, T intermediat_out) {
return func1_(intermediat_out);
inline HOSTDEVICE T GetOutUseIntermediateOut(T x UNUSED, T intermediate_out) {
return func1_(intermediate_out);
}

inline HOSTDEVICE T GetIntermediateOut(T x, T y) { return func2_(x, y); }
Expand Down Expand Up @@ -209,8 +209,8 @@ struct UnaryCompoundGradDyFunctor {

// Z = BinaryFunctor(X, UnaryFunctor(Y))
template <typename T, typename DBinaryFun, typename UnaryFun>
struct BinaryCompoundGradDIntermedaiteOutFunctor {
BinaryCompoundGradDIntermedaiteOutFunctor(const DBinaryFun &d_binary_fun,
struct BinaryCompoundGradDIntermediateOutFunctor {
BinaryCompoundGradDIntermediateOutFunctor(const DBinaryFun &d_binary_fun,
const UnaryFun &unary_fun)
: d_binary_fun_(d_binary_fun), unary_fun_(unary_fun) {}

Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/funcs/elementwise_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RowwiseTransformIterator;
template <typename T, typename DeviceContext>
class MidWiseTransformIterator;

// NOTE(dzhwinter): ptrdiff_t in iterator is deperecated in c++17
// NOTE(dzhwinter): ptrdiff_t in iterator is deprecated in c++17
template <typename T>
class RowwiseTransformIterator<T, CPUContext>
: public std::iterator<std::random_access_iterator_tag,
Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/kernels/funcs/elementwise_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ struct RemainderFunctor<dtype::float16> {
const dtype::float16 b) const {
float b_float = static_cast<float>(b);
float res = fmod(static_cast<float>(a), b_float);
// Accoding to #PR26732: in dividen % divsor
// According to #PR26732: in dividen % divsor
// remainder shall have the same sign as divsor.
if ((res != 0.0f) && ((res < 0.0f) != (b_float < 0.0f))) res += b_float;
return static_cast<dtype::float16>(res);
Expand All @@ -584,7 +584,7 @@ struct RemainderFunctor<dtype::bfloat16> {
float b_float = static_cast<float>(b);
float res = fmod(static_cast<float>(a), b_float);

// Accoding to #PR26732: in dividen % divsor
// According to #PR26732: in dividen % divsor
// remainder shall have the same sign as divsor.
if ((res != 0.0f) && ((res < 0.0f) != (b_float < 0.0f))) res += b_float;
return static_cast<dtype::bfloat16>(res);
Expand Down
6 changes: 3 additions & 3 deletions paddle/phi/kernels/funcs/fft.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ struct FFTC2CFunctor<phi::CPUContext, Ti, To> {
// pocketfft requires std::vector<size_t>
std::vector<size_t> axes_(axes.size());
std::copy(axes.begin(), axes.end(), axes_.begin());
// compuet factor
// compute factor
size_t signal_numel = 1;
for (const auto axis : axes) {
signal_numel *= in_sizes[axis];
Expand Down Expand Up @@ -291,7 +291,7 @@ struct FFTR2CFunctor<phi::CPUContext, Ti, To> {
// pocketfft requires std::vector<size_t>
std::vector<size_t> axes_(axes.size());
std::copy(axes.begin(), axes.end(), axes_.begin());
// compuet normalization factor
// compute normalization factor
size_t signal_numel = 1;
for (const auto axis : axes) {
signal_numel *= in_sizes[axis];
Expand Down Expand Up @@ -348,7 +348,7 @@ struct FFTC2RFunctor<phi::CPUContext, Ti, To> {
// pocketfft requires std::vector<size_t>
std::vector<size_t> axes_(axes.size());
std::copy(axes.begin(), axes.end(), axes_.begin());
// compuet normalization factor
// compute normalization factor
size_t signal_numel = 1;
for (const auto axis : axes) {
signal_numel *= out_sizes[axis];
Expand Down
16 changes: 8 additions & 8 deletions paddle/phi/kernels/funcs/jit/README.en.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JIT Kernel

JIT(Just In Time) Kernel contains actually generated code and some other implemenations with the same logic.
JIT(Just In Time) Kernel contains actually generated code and some other implementations with the same logic.
Each implementation has its own condition to use, defined in `CanBeUsed`.
They are combined together to get the best performance of one single independent function.
They could be some very simple functions like vector multiply, or some complicated functions like LSTM.
Expand Down Expand Up @@ -34,7 +34,7 @@ PaddlePaddle/Paddle/paddle/phi/kernels/
└── ...
```

All basical definitions of jit kernels are addressed in `paddle/phi/kernels/funcs/jit` including these three key folders `refer`, `gen`, `more`. There is only one unique name for each kernel while may have seraval implementations with same functionality.
All basical definitions of jit kernels are addressed in `paddle/phi/kernels/funcs/jit` including these three key folders `refer`, `gen`, `more`. There is only one unique name for each kernel while may have several implementations with same functionality.

- `refer`: Each kernel must have one reference implementation on CPU, and it should only focus on the correctness and should not depends on any third-party libraries.
- `gen`: The code generated should be kept here. They should be designed focusing on the best performance, which depends on Xbyak.
Expand All @@ -44,7 +44,7 @@ All basical definitions of jit kernels are addressed in `paddle/phi/kernels/func

We present these methods to get the functions:
- `GetAllCandidateFuncs`. It can return all the implementations supported. All of the implementations can get the same result. You can do some runtime benchmark to choose which should actually be used.
- `GetDefaultBestFunc`. It only return one default function pointer, which is tuning offline with some genenal configures and attributes. This should cover most situations.
- `GetDefaultBestFunc`. It only return one default function pointer, which is tuning offline with some general configures and attributes. This should cover most situations.
- `KernelFuncs::Cache()`. It can get the default functions and save it for next time with the same attribute.
- `GetReferFunc`. It can only get the reference code in CPU, and all the others implementations have same logic with this reference code.

Expand Down Expand Up @@ -76,7 +76,7 @@ All kernels are included in `paddle/phi/kernels/funcs/jit/kernels.h`, which is a
## Solid Test

- Unit Test
All functions should be compared with the corresponding reference functions, including data tyep `float` and `double`.
All functions should be compared with the corresponding reference functions, including data type `float` and `double`.
- Benchmark
All functions should be tested, and make sure the `jit::GetDefaultBestFunc` function obtain the best performance with all attributes.

Expand All @@ -89,15 +89,15 @@ All kernels are included in `paddle/phi/kernels/funcs/jit/kernels.h`, which is a
3. Add reference function of `your_key`.
Note:
- this should be run on CPU and do not depend on any third-party.
- Add `USE_JITKERNEL_REFER(your_key)` in `refer/CmakeLists.txt` to make sure this code can be used.
4. Add unit test in `test.cc`, and verfiy at least `float` and `double`.
- Add `USE_JITKERNEL_REFER(your_key)` in `refer/CMakeLists.txt` to make sure this code can be used.
4. Add unit test in `test.cc`, and verify at least `float` and `double
Test more data type for some special functions if necessary, for example `int8`.
5. Add functions in `benchmark.cc` to test all function of same `KernelType`. Make sure `GetDefaultBestFunc` always get the best one.

## Optional

Add more implementations of `your_kery` for performance enhancement.
Add more implementations of `your_key` for performance enhancement.

1. Add functions based on generated code in `gen`. It should be derived from `JitCode` and should have correpsonding creator from `JitCodeCreator` which will be registered on the `your_key`.
1. Add functions based on generated code in `gen`. It should be derived from `JitCode` and should have corresponding creator from `JitCodeCreator` which will be registered on the `your_key`.
2. If new attribute type is added, you should specialize `JitCodeKey` of this type.
3. Add more functions in `more`,you can use any third party you wish, like mkl, mkldnn or intrinsic code to reach the best performance.
4 changes: 2 additions & 2 deletions paddle/phi/kernels/funcs/jit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PaddlePaddle/Paddle/paddle/phi/kernels/
基本类的定义都放在根目录下,根目录下包括gen,more和refer三个目录。每个目录下都是一种或者多种实现,每种kernel算子都需要有reference的实现,用作单元测试的基准,其他的实现都是可选的。
- gen: 代表使用jit生成的code,需要依赖xbyak库。该实现最关心的就是性能。
- refer: 代表reference的实现,每种kernel算子都需要有在CPU上的reference的实现,他主要关心的算法逻辑的正确性。
- more: 下面可以放入跟多实现,可以包括mkl,mkldnn,intrinsic,openblas等,也可以是自身已有的kernel组合。
- more: 下面可以放入更多实现,可以包括mkl,mkldnn,intrinsic,openblas等,也可以是自身已有的kernel组合。

## 动态获取

Expand Down Expand Up @@ -79,7 +79,7 @@ PaddlePaddle/Paddle/paddle/phi/kernels/
# 如何添加新的算子

1.`KernelType` 中添加 `your_key`
2. 实现Reference 的逻辑,这个是必须是在CPU上的实现,并且不能依赖任何第三方库。实现后在`refer/CmakeLists.txt`中添加`USE_JITKERNEL_REFER(your_key)`来使用该kernel。
2. 实现Reference 的逻辑,这个是必须是在CPU上的实现,并且不能依赖任何第三方库。实现后在`refer/CMakeLists.txt`中添加`USE_JITKERNEL_REFER(your_key)`来使用该kernel。
3. (optional) 实现更多的算法在`more`目录下,可以依赖mkl,intrinsic或者mkldnn等第三方库。
4. (optional) 实现基于Xbyak的生成code,在`gen`目下。 jitcode需要实现自己的`JitCodeCreator`,并注册在与refer相同的`KernelType`上。
5. 添加新的`KernelTuple`,需要与`KernelType`一一对应,是所有类型的一个打包,包括数据类型,属性的类型,以及返回的函数类型。可以参考`SeqPoolTuple`,新加的Attr类型需要特例化`JitCodeKey`方法。
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/funcs/jit/helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void pack_weights<float>(const float* src, float* dst, int n, int k) {
0,
phi::errors::InvalidArgument(
"Each element of groups should be larger than "
"0. However the element: %d doesn't satify.",
"0. However the element: %d doesn't satisfy.",
i));
});
int sum = std::accumulate(groups.begin(), groups.end(), 0);
Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/kernels/funcs/jit/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ std::vector<const Kernel*> GetAllCandidateKernels(
auto ref = GetReferKernel<KernelTuple>();
PADDLE_ENFORCE_NOT_NULL(
ref,
phi::errors::InvalidArgument("Get all candicate kernel in CPU failed. "
phi::errors::InvalidArgument("Get all candidate kernel in CPU failed. "
"The Refer Kernel can not be empty."));
res.emplace_back(ref);
return res;
Expand Down Expand Up @@ -188,7 +188,7 @@ typename KernelTuple::func_type GetDefaultBestFunc(
PADDLE_ENFORCE_GE(funcs.size(),
1UL,
phi::errors::InvalidArgument(
"The candicate jit kernel is at least one in CPU."));
"The candidate jit kernel is at least one in CPU."));
// Here could do some runtime benchmark of this attr and return the best one.
// But yet just get the first one as the default best one,
// which is searched in order and tuned by offline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void CRFDecoding(const int seq_len,
/* Calculate the offset of transition_weights.*/
int trans_offset = state_trans_base_idx * tag_num + j_offset;
for (int i = 0; i < tag_num; ++i) {
/* Initalize the content of alpha variable with related offset.*/
/* Initialize the content of alpha variable with related offset.*/
#ifdef __AVX512F__
__m512 alpha_content = _mm512_set1_ps(*(alpha + seq_offset + i));
/* Obtain the content of weights from un-aligned address.*/
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/funcs/matrix_bit_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace funcs {
* return the maximal code length
*
* SimpleCode operator()(size_t i)
* return the i-th code. Code class is descriebed below.
* return the i-th code. Code class is described below.
*
* SimpleCode class should support 3 functions:
*
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/funcs/matrix_solve.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static std::vector<int64_t> getNewDimsVec(const DDim& b_dims) {
true,
phi::errors::PreconditionNotMet(
"The size of tensor b must not be %d after getting new dims", 0));
// if b_dims_vec.size() == 1, just retun original vec
// if b_dims_vec.size() == 1, just return original vec
return b_dims_vec;
}

Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/funcs/selected_rows_functor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct SelectedRowsAdd<phi::CPUContext, T> {
in1_row_numel,
out_value->numel() / out_rows.size(),
phi::errors::InvalidArgument(
"The input and oupput width must be equal."
"The input and output width must be equal."
"But received input width = [%d], output width = [%d]",
in1_row_numel,
out_value->numel() / out_rows.size()));
Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/kernels/funcs/selected_rows_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ limitations under the License. */
namespace phi {
namespace funcs {

// SelectedRows + SelectedRows will simplely concat value and rows.
// SelectedRows + SelectedRows will simply concat value and rows.
// The real computation happens in dealing with LoDTensor.
template <typename DeviceContext, typename T>
struct SelectedRowsAdd {
Expand Down Expand Up @@ -77,7 +77,7 @@ struct SelectedRowsAddToTensor {
};

namespace scatter {
// functors for manuplating SelectedRows data
// functors for manipulating SelectedRows data
template <typename DeviceContext, typename T>
struct MergeAdd {
// unary functor, merge by adding duplicated rows in
Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/kernels/funcs/seq2col.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct Seq2ColFunctor {
a. Notion
- `i` stands for the flattened index of a bunch of frames.
- `src_idx` and `trg_idx` are the 1D indices of seqs and frames
respectivly.
respectively.
b. Sample idx
```cpp
Expand All @@ -58,7 +58,7 @@ struct Seq2ColFunctor {
n = i % (n_frames_ * frame_length_) % n_frames_;
```
d. Replace `sample_idx`, `f` and `n` in the following eqations:
d. Replace `sample_idx`, `f` and `n` in the following equations:
```cpp
src_idx = sample_idx * seq_length_ + n * hop_length_ + f;
trg_idx = sample_idx * n_frames_ * frame_length_ + f * n_frames_ + n;
Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/kernels/funcs/sparse/convolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ inline HOSTDEVICE bool Check(const IntT& x,
const int kdim,
const int xdim) {
const IntT lower = x - dilation * kx + pad;
const IntT uper = x + (kdim - kx - 1) * dilation - pad;
return (lower >= 0 && lower % stride == 0 && uper < xdim);
const IntT upper = x + (kdim - kx - 1) * dilation - pad;
return (lower >= 0 && lower % stride == 0 && upper < xdim);
}

// Check whether the current position(x, y, z) is legal:
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/funcs/unsqueeze.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ inline DDim GetUnsqueezeShape(const std::vector<int64_t> unsqz_dims,

for (int axis : unsqz_dims) {
int cur = axis < 0 ? axis + cur_output_rank + 1 : axis;
// Vaildity Check: the axis bound
// Validity Check: the axis bound
PADDLE_ENFORCE_GE(
cur,
0,
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/funcs/values_vectors_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ struct MatrixEighFunctor<CPUContext, T> {
ValueType *out_value = dev_ctx.template Alloc<ValueType>(eigen_values);

DenseTensor input_trans;
// lapack is a column-major storge, transpose make the input to
// lapack is a column-major storage, transpose make the input to
// have a continuous memory layout
input_trans = phi::TransposeLast2Dim<T>(dev_ctx, input);
T *input_vector = input_trans.data<T>();
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/funcs/vol2col.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class Col2VolFunctor<phi::CPUContext, T> {
input_width_tmp,
output_width,
phi::errors::InvalidArgument(
"input_width(%d) and output_width(%d) are mismatching.",
"input_width(%d) and output_width(%d) are mismatching.",
input_width_tmp,
output_width));
T* vol_data = vol->data<T>();
Expand Down
8 changes: 4 additions & 4 deletions paddle/phi/kernels/funcs/vol2col.cu
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ __global__ void vol2col(int num_kernels,
}

/*
* im = [input_channels,intpu_depth, input_height, input_width] for
* im = [input_channels,input_depth, input_height, input_width] for
* channels_first
* im = [input_depth, input_height, input_width, input_channels] for
* channels_last
Expand All @@ -112,7 +112,7 @@ void Vol2ColFunctor<DeviceContext, T>::operator()(
PADDLE_ENFORCE_EQ(vol.dims().size(),
4,
phi::errors::InvalidArgument(
"The dimension of vol should be 4, but received %d.",
"The dimension of vol should be 4, but received %d.",
vol.dims().size()));
PADDLE_ENFORCE_EQ(col->dims().size(),
7,
Expand Down Expand Up @@ -318,12 +318,12 @@ void Col2VolFunctor<DeviceContext, T>::operator()(
PADDLE_ENFORCE_EQ(vol->dims().size(),
4,
phi::errors::InvalidArgument(
"The dimension of vol should be 4, but received %d.",
"The dimension of vol should be 4, but received %d.",
vol->dims().size()));
PADDLE_ENFORCE_EQ(col.dims().size(),
7,
phi::errors::InvalidArgument(
"The dimension of col should be 7, but received %d.",
"The dimension of col should be 7, but received %d.",
col.dims().size()));

int input_channels =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def intlist2str(input):
return return_str


# Generate simt conv2d_depthwsie code.
# Generate simt conv2d_depthwise code.


def generate_conv2d_depthwise():
Expand Down
Loading

0 comments on commit 43a2a60

Please sign in to comment.