Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit 1c87177

Browse files
authored
Update 20190814-kernel-and-op-registration.md
1 parent 19ad326 commit 1c87177

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

rfcs/20190814-kernel-and-op-registration.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,28 @@ call ROCm's `hipLaunchKernelGGL` here instead. Its signature uses templates.
535535
Fortunately, AMD is planning to add an equivalent function that provides a C
536536
API. (see Appendix 2 for details)
537537
538+
### Getting Status when using device APIs
539+
540+
Kernel Device APIs described in this document rely on wrapping certain Eigen interfaces, such as `Eigen::StreamInterface` to provide a C API. Implementations of these interfaces might set an `OpKernelContext` status, which is not on the interface surface. Therefore, I propose that we add a new function that would update a given `TF_Status` with current `OpKernelContext` status:
541+
542+
```c++
543+
TF_CAPI_EXPORT extern void TF_OpKernelContext_UpdateStatus(TF_Status*);
544+
```
545+
546+
This would allow kernel implementations to return as soon as they see a failing status. For example:
547+
548+
```c++
549+
TF_EigenStream* eigen_stream = TF_GetEigenStream();
550+
... run computation using eigen_stream ...
551+
552+
TF_Status* context_status = TF_NewStatus();
553+
TF_OpKernelContext_UpdateStatus(context_status);
554+
if (TF_GetCode(context_status) != TF_OK) {
555+
TF_DeleteStatus(context_status);
556+
return;
557+
}
558+
```
559+
538560
## Appendix 1
539561
540562
Certain parts of our design involve kernel plugins calling a function in

0 commit comments

Comments
 (0)