create a fp16(half) value directly

I failed to create a half precision value without conversion from float.
I think it is probably a dumb question. But is there a way to use half directly?
for example
half x = 10;
or using half inside a template function.

It is a device function, so used inside kernel only, but still requires conversion first.

It’s not clear if you mean for host or device code, but I think the answer is the same.

half is not a built-in type for the (C/C++) language AFAIK. It is effectively a defined, add-on class.

Therefore the only methods, operator overloads, and defined constructors for that class are the ones explicitly defined in the documentation (or you could parse cuda_fp16.h looking for undocumented stuff). This:

half x = 10;

requires that the half class have a (host or device-usable) defined copy constructor, I believe. AFAIK such does not exist (i.e. not provided as a built-in by CUDA.)

You could define your own, possibly. You may be interested in this:

http://stackoverflow.com/questions/32735292/can-anyone-provide-sample-code-demonstrating-the-use-of-16-bit-floating-point-in

and in particular the host side functions created by njuffa here:

https://devtalk.nvidia.com/default/topic/883897/cuda-programming-and-performance/error-when-trying-to-use-half-fp16-/?offset=11#4691963