swift-apis
swift-apis copied to clipboard
Exposure of _ExecutionContext into public API
Currently I'm trying to implement custom CUDA kernel for S4TF. It seems mostly straightforward (given that C API contains TF_LibraryLoad and all other necessary stuff), but operation launching is what I'm struggling with. It is possible to create a new TFE_Context, but I would love my ops to share context with built-in ops.
Can ExectuionContext be exposed into public API? I know it may change with time, but as well can do things like _Raw, so maybe making it publicly available for development time will be useful for advanced experimenting.
Thanks!
_ExecutionContext
is already public:
import TensorFlow
print(_ExecutionContext.global.deviceNames)
// ["/job:localhost/replica:0/task:0/device:CPU:0", "/job:localhost/replica:0/task:0/device:XLA_CPU:0"]
It sounds like you'd like specific internal _ExecutionContext
members to be public. Could you please clarify which ones?
Making members public sounds pretty good to me since _ExecutionContext
is an underscored API.
Yes, initially I wanted to obtain a pointer to eagerContext
so that I could create my own ops in the same context and execute them. I still think it could be useful, but after a closer look I see that TFTensorOperation don't expect a context as an injection and instead use singletone context in initializer, so now I think maybe it is more reasonable to just make
func makeOp(_ name: String, _ nOutputs: Int) -> TFTensorOperation {
_ExecutionContext.makeOp(name, nOutputs)
}
a public function to enable users to create their own ops?
this is now partially addressed in #697