update jitkernel doc#16327
Conversation
test=develop
luotao1
left a comment
There was a problem hiding this comment.
@shanyi15 请帮忙review一下中英文文字
@tensor-tang 为了节省CI时间,可以在定稿后触发CI
paddle/fluid/operators/jit/README.md
Outdated
| ## 动态获取 | ||
|
|
||
| 提供一个`jit::Get`方法,根据kernel类别获取,每种实现都有自己的使用范围,根据范围动态和当前条件选择需要的kernel函数。 | ||
| - 提供`GetAllCandidateFuncs`方法,根据输入的kernel类别,获取满足要求的所有函数实现。所有实现保证结果一致,但是速度不一致,可以根据具体输入属性大小,runtime的测试得到当前最优实现,手动选择最优函数。 |
There was a problem hiding this comment.
- 结果是指精度在1e-7么?
- runtime的测试-》动态测试?
There was a problem hiding this comment.
结果是指精度在1e-7么?
精度是1e-5的。
runtime的测试-》动态测试?
OK
There was a problem hiding this comment.
"精度是1e-5的。",可以在README里说一下。
paddle/fluid/operators/jit/README.md
Outdated
|
|
||
| 提供一个`jit::Get`方法,根据kernel类别获取,每种实现都有自己的使用范围,根据范围动态和当前条件选择需要的kernel函数。 | ||
| - 提供`GetAllCandidateFuncs`方法,根据输入的kernel类别,获取满足要求的所有函数实现。所有实现保证结果一致,但是速度不一致,可以根据具体输入属性大小,runtime的测试得到当前最优实现,手动选择最优函数。 | ||
| - 提供`GetDefaultBestFunc`方法,返回一个默认最优的函数实现。该函数是经过我们离线根据一些通用配置,tuning之后的结果,能覆盖大多数情况下最优结果。 |
There was a problem hiding this comment.
“该函数是经过我们离线根据一些通用配置”,此句不通,“经过”和“根据”有两个动词
paddle/fluid/operators/jit/README.md
Outdated
| 提供一个`jit::Get`方法,根据kernel类别获取,每种实现都有自己的使用范围,根据范围动态和当前条件选择需要的kernel函数。 | ||
| - 提供`GetAllCandidateFuncs`方法,根据输入的kernel类别,获取满足要求的所有函数实现。所有实现保证结果一致,但是速度不一致,可以根据具体输入属性大小,runtime的测试得到当前最优实现,手动选择最优函数。 | ||
| - 提供`GetDefaultBestFunc`方法,返回一个默认最优的函数实现。该函数是经过我们离线根据一些通用配置,tuning之后的结果,能覆盖大多数情况下最优结果。 | ||
| - 提供`KernelFuncs::Cache()`方法,该方法会返回默认最优的函数,同时会缓存该函数指针,如果出现属性一致的情况下,直接返回上次的函数指针,如果不存在测根据属性新建。 |
paddle/fluid/operators/jit/README.md
Outdated
| - 提供`GetAllCandidateFuncs`方法,根据输入的kernel类别,获取满足要求的所有函数实现。所有实现保证结果一致,但是速度不一致,可以根据具体输入属性大小,runtime的测试得到当前最优实现,手动选择最优函数。 | ||
| - 提供`GetDefaultBestFunc`方法,返回一个默认最优的函数实现。该函数是经过我们离线根据一些通用配置,tuning之后的结果,能覆盖大多数情况下最优结果。 | ||
| - 提供`KernelFuncs::Cache()`方法,该方法会返回默认最优的函数,同时会缓存该函数指针,如果出现属性一致的情况下,直接返回上次的函数指针,如果不存在测根据属性新建。 | ||
| - 提供`GetReferFunc` 方法,返回该kernel的最原始的逻辑函数,与kernel的输入大小和属性没有任何关系,有且并只有一个,并且一定是在CPU上的实现,它表征了该kernel的原始逻辑,其他所有实现的逻辑与它保持一致。 |
There was a problem hiding this comment.
返回该kernel最原始的逻辑函数。该方法与kernel的输入大小和属性没有任何关系,有且并只有一个在CPU上的实现。该方法表征了kernel的原始逻辑,其他所有实现的逻辑与它保持一致。
paddle/fluid/operators/jit/README.md
Outdated
| - 在`test.cc`中添加unit test,至少需要测试`float`和`double`两种数据类型,如有必要需要支持额外的数据类型,比如`int8`的相关函数。 | ||
| - 在`benchmark.cc`中添加相应的性能对比,同一种kernel需要对比所有实现,并且确保`jit::Get`得到的实现一直是速度最快的。 | ||
| 1. 在`KernelType` 中添加 `your_key` . | ||
| 2. 实现Reference 的逻辑,这个是必须是在CPU上的实现,并且不能依赖任何第三方库。实现后在`refer/CmakeLists.txt`中添加`USE_JITKERNEL_REFER(your_key)`来使用该kernel. |
tensor-tang
left a comment
There was a problem hiding this comment.
OK thanks.
Done.
paddle/fluid/operators/jit/README.md
Outdated
| ## 动态获取 | ||
|
|
||
| 提供一个`jit::Get`方法,根据kernel类别获取,每种实现都有自己的使用范围,根据范围动态和当前条件选择需要的kernel函数。 | ||
| - 提供`GetAllCandidateFuncs`方法,根据输入的kernel类别,获取满足要求的所有函数实现。所有实现保证结果一致,但是速度不一致,可以根据具体输入属性大小,runtime的测试得到当前最优实现,手动选择最优函数。 |
There was a problem hiding this comment.
结果是指精度在1e-7么?
精度是1e-5的。
runtime的测试-》动态测试?
OK
paddle/fluid/operators/jit/README.md
Outdated
|
|
||
| 提供一个`jit::Get`方法,根据kernel类别获取,每种实现都有自己的使用范围,根据范围动态和当前条件选择需要的kernel函数。 | ||
| - 提供`GetAllCandidateFuncs`方法,根据输入的kernel类别,获取满足要求的所有函数实现。所有实现保证结果一致,但是速度不一致,可以根据具体输入属性大小,runtime的测试得到当前最优实现,手动选择最优函数。 | ||
| - 提供`GetDefaultBestFunc`方法,返回一个默认最优的函数实现。该函数是经过我们离线根据一些通用配置,tuning之后的结果,能覆盖大多数情况下最优结果。 |
paddle/fluid/operators/jit/README.md
Outdated
| 提供一个`jit::Get`方法,根据kernel类别获取,每种实现都有自己的使用范围,根据范围动态和当前条件选择需要的kernel函数。 | ||
| - 提供`GetAllCandidateFuncs`方法,根据输入的kernel类别,获取满足要求的所有函数实现。所有实现保证结果一致,但是速度不一致,可以根据具体输入属性大小,runtime的测试得到当前最优实现,手动选择最优函数。 | ||
| - 提供`GetDefaultBestFunc`方法,返回一个默认最优的函数实现。该函数是经过我们离线根据一些通用配置,tuning之后的结果,能覆盖大多数情况下最优结果。 | ||
| - 提供`KernelFuncs::Cache()`方法,该方法会返回默认最优的函数,同时会缓存该函数指针,如果出现属性一致的情况下,直接返回上次的函数指针,如果不存在测根据属性新建。 |
paddle/fluid/operators/jit/README.md
Outdated
| - 提供`GetAllCandidateFuncs`方法,根据输入的kernel类别,获取满足要求的所有函数实现。所有实现保证结果一致,但是速度不一致,可以根据具体输入属性大小,runtime的测试得到当前最优实现,手动选择最优函数。 | ||
| - 提供`GetDefaultBestFunc`方法,返回一个默认最优的函数实现。该函数是经过我们离线根据一些通用配置,tuning之后的结果,能覆盖大多数情况下最优结果。 | ||
| - 提供`KernelFuncs::Cache()`方法,该方法会返回默认最优的函数,同时会缓存该函数指针,如果出现属性一致的情况下,直接返回上次的函数指针,如果不存在测根据属性新建。 | ||
| - 提供`GetReferFunc` 方法,返回该kernel的最原始的逻辑函数,与kernel的输入大小和属性没有任何关系,有且并只有一个,并且一定是在CPU上的实现,它表征了该kernel的原始逻辑,其他所有实现的逻辑与它保持一致。 |
paddle/fluid/operators/jit/README.md
Outdated
| - 在`test.cc`中添加unit test,至少需要测试`float`和`double`两种数据类型,如有必要需要支持额外的数据类型,比如`int8`的相关函数。 | ||
| - 在`benchmark.cc`中添加相应的性能对比,同一种kernel需要对比所有实现,并且确保`jit::Get`得到的实现一直是速度最快的。 | ||
| 1. 在`KernelType` 中添加 `your_key` . | ||
| 2. 实现Reference 的逻辑,这个是必须是在CPU上的实现,并且不能依赖任何第三方库。实现后在`refer/CmakeLists.txt`中添加`USE_JITKERNEL_REFER(your_key)`来使用该kernel. |
shanyi15
left a comment
There was a problem hiding this comment.
please CHECK SPELL first
| @@ -1,7 +1,7 @@ | |||
| # 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 implemenations with the same logic. | ||
| Each implementations has its own condition to use, defined in `UseMe`. | ||
| Each implementations has its own condition to use, defined in `CanBeUsed`. |
There was a problem hiding this comment.
each 后面不应跟复数,另外请确定一下implementations 这个词的单复数是同样的写法吗
| All kernels are inlcuded in `paddle/fluid/operators/jit/kernels.h`, you can only include this one header to get all the registered kernels. | ||
| 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 defualt function pointer, which is tuning offline with some genenal configures and attributes. This should cover most situations. |
| 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 defualt function pointer, which is tuning offline with some genenal configures and attributes. This should cover most situations. | ||
| - `KernelFuncs::Cache()`. It can get the defualt functions and save it for next time with the same attribute. |
| } | ||
| ``` | ||
|
|
||
| All kernels are inlcuded in `paddle/fluid/operators/jit/kernels.h` which is automatically generated in compile time, you can only include this one header to get all the registered kernels. |
There was a problem hiding this comment.
All kernels are inlcuded in paddle/fluid/operators/jit/kernels.h 后面应跟逗号
|
|
||
| 1. Add `your_key` at `KernelType`. | ||
| 2. Add reference function of `your_key`. | ||
| 2. Add your new `KernelTuple` which must inlucde `your_key`. I should be a combination of the data type, attribute type and function type. You can refer `SeqPoolTuple`. |
|
|
||
| Add more implementations of `your_kery` for performance enhancement. | ||
|
|
||
| 1. Add functions based on generated code in `gen`. It should be derived from `JitCode` and should have corepsonding creator from `JitCodeCreator` which will be registered on the `your_key`. |
paddle/fluid/operators/jit/README.md
Outdated
| 提供一个`jit::Get`方法,根据kernel类别获取,每种实现都有自己的使用范围,根据范围动态和当前条件选择需要的kernel函数。 | ||
| - 提供`GetAllCandidateFuncs`方法,根据输入的kernel类别,获取满足要求的所有函数实现。所有实现保证结果一致,但是速度不一致,可以根据具体输入属性大小,动态测试得到当前最优实现,手动选择最优函数。 | ||
| - 提供`GetDefaultBestFunc`方法,返回一个默认最优的函数实现。该函数是根据一些通用配置离线tuning之后的结果,能覆盖大多数情况下最优结果。 | ||
| - 提供`KernelFuncs::Cache()`方法,该方法会返回默认最优的函数,同时会缓存该函数指针,如果出现属性一致的情况,直接返回上次的函数指针,如果不存在测根据属性新建。 |
|
python35 same of #16316 |
click here to review cn
click here to review en