-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kernel hint design #6790
Kernel hint design #6790
Conversation
doc/design/kernel_hint_design.md
Outdated
const std::string kUseCUDNN = "use_cudnn"; | ||
const std::string kUseMKLDNN = "use_mkldnn"; | ||
|
||
KernelType GetExpectedKernelTyp() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
doc/design/kernel_hint_design.md
Outdated
LayoutType layout_; | ||
}; | ||
``` | ||
`place_` `data_type_` and `layout_` can come from the input tensor of the operator, `GetActualKernelType(inputs)` use inputs to infer the proper kernel key that fit the incoming data, user can not config it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users cannot configure it.
Actually, users can configure input data and influence the actual kernel type
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
doc/design/kernel_hint_design.md
Outdated
## Solution | ||
|
||
### potential choice | ||
1, Do nothing, let the user add the information they want to operator‘s attribute and get them inside `GetExpectedKernelType`, this can work right. But there is a little problem that users may define many kinds of hints for the same purpose, such as `force_cpu`, `use_cpu`, `CPU` for CPU kernel, and `use_cudnn`, `force_cudnn`, `cudnn_kernel` for use of CUDNN kernel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1,
--> 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
doc/design/kernel_hint_design.md
Outdated
## Solution | ||
|
||
### potential choice | ||
1, Do nothing, let the user add the information they want to operator‘s attribute and get them inside `GetExpectedKernelType`, this can work right. But there is a little problem that users may define many kinds of hints for the same purpose, such as `force_cpu`, `use_cpu`, `CPU` for CPU kernel, and `use_cudnn`, `force_cudnn`, `cudnn_kernel` for use of CUDNN kernel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can define some global constant for these attribute name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
doc/design/kernel_hint_design.md
Outdated
|
||
### final choice | ||
To provide enough flexibility while avoiding confusion definition, we can predefine some options, such as `force_cpu`, `use_cudnn`, `use_mkldnn` for a user to choose. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using string to represent force_cpu
, use_cudnn
, use_mkldnn
is not extendable. How to make an operator use CPU forcibly and use MKLDNN?
doc/design/kernel_hint_design.md
Outdated
const std::string kUseMKLDNN = "use_mkldnn"; | ||
|
||
KernelType GetExpectedKernelTyp() { | ||
// "kernel_hint" is a user defined attribute name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think kernel_hint
is a formal name. It is confusing for users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, use force_cpu as key and bool as value.
doc/design/kernel_hint_design.md
Outdated
|
||
KernelType GetExpectedKernelTyp() { | ||
// "kernel_hint" is a user defined attribute name | ||
if (Attr<std::string>("kernel_hint") == kForceCPU) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use Attr<bool>(kForceCPU)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically LGTM.
doc/design/kernel_hint_design.md
Outdated
const std::string kUseMKLDNN = "use_mkldnn"; | ||
|
||
KernelType GetExpectedKernelType() { | ||
if (Attr<bool>(kForceCPU)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a better Indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change tab to space
doc/design/kernel_hint_design.md
Outdated
FORCE_CPU = core.kForceCPU() | ||
|
||
def xx_layer(..., force_cpu=false): | ||
layer_helper = LayerHelper(...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need a better indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change tab to space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
No description provided.