community icon indicating copy to clipboard operation
community copied to clipboard

Add tutorial and sample code for TensorFlow plugin development

Open jzhoulon opened this issue 4 years ago • 15 comments

Add tutorial and code sample for TensorFlow plugin development

jzhoulon avatar Feb 01 '21 11:02 jzhoulon

@mihaimaruseac @penpornk can you review?

theadactyl avatar Feb 01 '21 19:02 theadactyl

@theadactyl Yes, I will review it soon.

penpornk avatar Feb 01 '21 19:02 penpornk

Hi,

I've been following the tutorial and it's pretty useful, but I have one question: what should be the name of the plugin package? In TensorFlow I see that it's explicitly looking for a python package named tensorflow_plugins, but wouldn't that mean that 2 plugins can't be used simultaneously? Is there a way to register a pluggable device with a different name?

Let me know if this isn't the right place to ask this question.

Thanks!

PatriceVignola avatar May 25 '21 08:05 PatriceVignola

Hi @PatriceVignola,

Yes, here is the right place to ask.

TensorFlow doesn't exactly look for a package named tensorflow_plugins, it's just going to look for shared libraries (.so files for linux) in a folder named tensorflow-plugins. That folder can have multiple shared libraries from multiple plugin packages, e.g., apu.so, bpu.so, dpu.so, etc.

I think the current pip-package generation script in this tutorial puts more than just the shared library file into the tensorflow-plugins folder when the package is installed. So it might need some adjustments.

penpornk avatar May 26 '21 01:05 penpornk

@PatriceVignola each package can have its own package name,the only requirement is the pluggable device library should be copied to tensorflow-plugins folder, I will update the tutoral example code. Thanks

jzhoulon avatar May 26 '21 01:05 jzhoulon

Thanks! That makes sense.

PatriceVignola avatar May 26 '21 02:05 PatriceVignola

@penpornk we have update the graph optimization C API part, including sample code. Thanks.

jzhoulon avatar May 28 '21 08:05 jzhoulon

What would be the best way to get the equivalent of libtensorflow_framework.so in Windows without building TensorFlow from source (if any)? It's not included as part of the python package and there doesn't seem to be Windows nightly builds for the C API library.

Thank you!

PatriceVignola avatar May 29 '21 04:05 PatriceVignola

@penpornk Have all your changes been addressed? If so, could you re-review?

ematejska avatar Dec 09 '21 16:12 ematejska

I have (partially) ported this sample code to Rust. Which way should I better post it? Could I publish that template in my repository or submit it to get included into this PR?

For now it only includes unsafe port of most plugin registration features except profiling and optimization.

dsseng avatar Jul 22 '22 18:07 dsseng

@sh7dm Thank you for your contribution! We will try to merge this PR soon. Then you can open a new PR to add new changes. How does this sound? :)

penpornk avatar Jul 22 '22 18:07 penpornk

Great! May I push stuff I have into an own repo at least for now (of course linking to this PR as the initial source)?

dsseng avatar Jul 22 '22 18:07 dsseng

Let it be here for now.

dsseng avatar Jul 23 '22 09:07 dsseng

I'm now working on extending my Rust port with stuff like device-bound kernels (accessing device from kernel).

dsseng avatar Jul 23 '22 12:07 dsseng

@penpornk Once you approve, we'll get this merged.

ematejska avatar Jul 25 '22 17:07 ematejska