Skip to content

How best to define input and output types in a function #52

Answered by sbrunk
hmf asked this question in Q&A
Discussion options

You must be logged in to vote

I was wondering if their is some rule to use when encoding the types. So my questions are:

1. When should we opt for the more specific types or the more general `DType`?

We want to be as specific as possible to avoid runtime errors, as many ops i.e. only support floating point inputs.

It's not always easy to find out though, as it is encoded in the C++ kernels. The existing softmax for instance is too generic but the updated one #51 (comment) only accepts floats.

One way to find out is to actually run the method with different input dtypes. If it fails, we get a nice stacktrace that often leads us to the kernel implementation where we can see dtype restrictions. SoftMaxKernel.cpp here.

W…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@hmf
Comment options

Answer selected by hmf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants