Skip to content
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

how to add kernel hint #6780

Closed
jacquesqiao opened this issue Dec 20, 2017 · 2 comments
Closed

how to add kernel hint #6780

jacquesqiao opened this issue Dec 20, 2017 · 2 comments

Comments

@jacquesqiao
Copy link
Member

problem

user may have some personal preference to choose a certain kind of kernel for an operator, such as force_cpu to use a cpu kernel , use_cudnn to choose a cudnn kernel, use_mkldnn to choose an mkldnn kernel, we need to provide a way to enable the user to do this.

In the current design, we use KernelType

struct KernelType {
  Place place_;
  DataType data_type_;
  LayoutType layout_;
};

to determine the kernel, place_ data_type_ and layout_ are all come from the input of the operator. the user can not config it. GetActualKernelType is used to get this Kernel type, but the design also provides a virtual method GetExpectedKernelType, that user can overload and choose the KernelType they want to use.

so, we should send the information user defined in Python to GetExpectedKernelType to let the user use it.

The problem is, how should we define this information and how should we store it for GetExpectedKernelType to use?

solution

1, Do nothing, let the user add the information they want to operator‘s attribute and get them insideGetExpectedKernelType, this seems can work right. There is a little problem that users may define many kinds of hint 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.

2, pre-define all the needed option and use a single attr key such as kernel_hint for user, this may not be so flexible if the user wants to define some more kind of hint.

I think at least we can predefine some options, such as force_cpu, use_cudnn, use_mkldnn for a user to choose.

@luotao1
Copy link
Contributor

luotao1 commented Dec 20, 2017

What's the difference between the meaning of use_* and force_*?

@jacquesqiao
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants