onnxruntime/java/src/main/native
Adam Pocock a8e776b78b
[java] Adds support for fp16 and bf16 tensors (#16703)
### Description
The Java API currently only supports fp16 output tensors which it
automatically casts to floats on the way out. This PR adds support for
creating fp16 and bf16 tensors (from `java.nio.Buffer` objects or as the
output of models, creation from Java short arrays is not supported),
along with efficient methods for casting `FloatBuffer` into
`ShortBuffer` filled with fp16 or bf16 values and vice versa.

The fp16 conversions use a trick to pull in the efficient conversion
methods added to Java 20, falling back to ports of the MLAS methods
otherwise. The Java 20 methods can be special cased by the C2 JIT
compiler to emit the single instruction on x86 and ARM which converts
fp32<->fp16, or the vectorized versions thereof, so they should be quite
a bit faster than the MLAS ported one.

### Motivation and Context
fp16 and bf16 are increasingly popular formats and we've had several
requests for this functionality. Fixes #7003.

cc @yuslepukhin  @cassiebreviu

---------

Co-authored-by: Scott McKay <Scott.McKay@microsoft.com>
2023-07-21 21:14:41 +10:00
..
ai_onnxruntime_OnnxMap.c [Java] JNI refactor for OrtJniUtil (#12516) 2022-09-08 17:04:42 -07:00
ai_onnxruntime_OnnxRuntime.c Adust GetVersionString() GetBuildInfoString() signatures and move them to OrtApi (#15921) 2023-05-13 13:45:07 -07:00
ai_onnxruntime_OnnxSequence.c [Java] Fix OnnxSequence semantics (#13012) 2022-09-28 15:53:30 -07:00
ai_onnxruntime_OnnxSparseTensor.c [java] Sparse tensor support (#10653) 2022-11-22 10:29:24 -08:00
ai_onnxruntime_OnnxTensor.c [java] Adds support for fp16 and bf16 tensors (#16703) 2023-07-21 21:14:41 +10:00
ai_onnxruntime_OrtAllocator.c
ai_onnxruntime_OrtEnvironment.c [java] Adds support for OrtEnvironment thread pools (#6406) 2021-01-27 13:25:22 -08:00
ai_onnxruntime_OrtEnvironment_ThreadingOptions.c [java] Adds support for OrtEnvironment thread pools (#6406) 2021-01-27 13:25:22 -08:00
ai_onnxruntime_OrtSession.c Use safe allocator for JNI code (#13999) 2023-03-08 11:40:55 -08:00
ai_onnxruntime_OrtSession_RunOptions.c [Java] Initial on device training support (#14027) 2023-03-08 10:01:08 -08:00
ai_onnxruntime_OrtSession_SessionOptions.c [java] Adding addExternalInitializers and addInitializer to OrtSession.SessionOptions (#16198) 2023-07-05 12:51:59 -07:00
ai_onnxruntime_OrtTrainingSession.c Removing C4090 warning suppression (#15994) 2023-05-18 10:08:05 -07:00
ai_onnxruntime_OrtTrainingSession_OrtCheckpointState.c [Java] CheckpointState AddProperty & GetProperty support (#15730) 2023-04-28 09:52:52 -07:00
ai_onnxruntime_providers_OrtCUDAProviderOptions.c [Java] Support configuring CUDA and TensorRT execution providers (#10697) 2022-03-30 14:26:51 -07:00
ai_onnxruntime_providers_OrtTensorRTProviderOptions.c [Java] Support configuring CUDA and TensorRT execution providers (#10697) 2022-03-30 14:26:51 -07:00
OrtJniUtil.c [java] Adds support for fp16 and bf16 tensors (#16703) 2023-07-21 21:14:41 +10:00
OrtJniUtil.h [java] Adds support for fp16 and bf16 tensors (#16703) 2023-07-21 21:14:41 +10:00