Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom operator code generator script #6881

Closed

Conversation

sjperkins
Copy link
Contributor

This script uses jinja2 templates to generate the following:

  • C++ Header file that defines the operator class, templated on Device.
  • C++ Header file that defines the CPU implementation of the operator.
  • C++ Source file with Shape Function, REGISTER_OP and REGISTER_KERNEL_BUILDER constructs.
  • Cuda Header that defines the GPU implementation of the operator, including a CUDA kernel.
  • Cuda Source file with GPU REGISTER_KERNEL_BUILDER's for the operator.
  • python unit test case, which constructs random input data, and calls the operator.
  • Makefile for compiling the operator into a shared library, using g++ and nvcc.

Operator inputs, outputs, polymorphic type attributes, other attributes and documentation can be specified.

This script uses jinja2 templates to generate the following:
* C++ Header file that defines the operator class, templated on Device.
* C++ Header file that defines the CPU implementation of the operator.
* C++ Source file with Shape Function, REGISTER_OP and
  REGISTER_KERNEL_BUILDER constructs.
* Cuda Header that defines the GPU implementation of the operator,
  including a CUDA kernel.
* Cuda Source file with GPU REGISTER_KERNEL_BUILDER's for the operator.
* python unit test case, which constructs random input data, and calls
  the operator.
* Makefile for compiling the operator into a shared library, using g++
  and nvcc.

Operator inputs, outputs, polymorphic type attributes, other attributes
and documentation can be specified.
@tensorflow-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@sjperkins
Copy link
Contributor Author

sjperkins commented Jan 16, 2017

I felt the content in the README.md was too large to be included in the Adding a New Op howto, but it may be appropriate to add a link to this tool in that file.

@sjperkins
Copy link
Contributor Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@drpngx
Copy link
Contributor

drpngx commented Jan 16, 2017

Thanks! While it's nice, it'll take some effort to keep this in sync. I would suggest trying for contrib instead.

@vrv
Copy link

vrv commented Jan 16, 2017

Indeed, this is cool, but probably would be better as an external repo for now. GitHub doesn't provide great community tools for managing and supporting external code that isn't core to the codebase. Can this live on your own repo on GitHub for now?

@drpngx drpngx requested review from vrv and removed request for martinwicke January 16, 2017 18:41
@vrv vrv closed this Jan 20, 2017
@sjperkins
Copy link
Contributor Author

Apologies for not getting back sooner -- other commitments required my attention

I've packaged this up at https://github.com/sjperkins/tfopgen.

Its also available on pypi -- pip install tfopgen

@sjperkins sjperkins deleted the templated-operator-generation branch January 29, 2017 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants