PR #10485: [XLA:CPU][oneDNN] Scratchpad support to MatMul
PR #10485: [XLA:CPU][oneDNN] Scratchpad support to MatMul

Imported from GitHub PR https://github.com/openxla/xla/pull/10485

This PR enables user provided scratch memory to MatMul. It utilizes buffer assigner to allocate scratch buffers. The following is the HLO rewrites.

```
Input HLO:
result = result_shape custom-call(args), custom_call_target="__onednn$matmul", ...

Output HLO:
tuple = (result_shape, scratch_shape) custom-call(args), custom_call_target="__onednn$matmul", ...
result_from_tuple = result_shape get-tuple-element(tuple), index=0
```

Besides enabling scratch memory, this PR refactors the MatMul rewrites and kernel implementation in order to reuse common code. It also introduces the following template function so that similar features can be easily used for other oneDNN primitives.

```
template <typename PrimDesc>
std::unique_ptr<PrimDesc> CreateOneDnnPrimDesc(HloInstruction*);
```
Copybara import of the project:

--
830ace45111c7fa9d7b03ec2018e6c51d0052e81 by mdfaijul <md.faijul.amin@intel.com>:

Scratch support to matmul

--
a6e652633d7fc8eb65b76d1e18c18bd0629e7f47 by mdfaijul <md.faijul.amin@intel.com>:

Address review comments.

--
d6cb1f2e9618c6874dd28af13ba43c11bc7071b5 by mdfaijul <md.faijul.amin@intel.com>:

Use TF_ASSIGN_OR_RETURN

Merging this change closes #10485

FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/openxla/xla/pull/10485 from Intel-tensorflow:amin/matmul-scratch d6cb1f2e9618c6874dd28af13ba43c11bc7071b5
