diff options
author | Manjunath Kudlur <keveman@gmail.com> | 2015-11-06 16:27:58 -0800 |
---|---|---|
committer | Manjunath Kudlur <keveman@gmail.com> | 2015-11-06 16:27:58 -0800 |
commit | f41959ccb2d9d4c722fe8fc3351401d53bcf4900 (patch) | |
tree | ef0ca22cb2a5ac4bdec9d080d8e0788a53ed496d /tensorflow/core/user_ops |
TensorFlow: Initial commit of TensorFlow library.
TensorFlow is an open source software library for numerical computation
using data flow graphs.
Base CL: 107276108
Diffstat (limited to 'tensorflow/core/user_ops')
-rw-r--r-- | tensorflow/core/user_ops/fact.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tensorflow/core/user_ops/fact.cc b/tensorflow/core/user_ops/fact.cc new file mode 100644 index 0000000000..7b6932244d --- /dev/null +++ b/tensorflow/core/user_ops/fact.cc @@ -0,0 +1,29 @@ +// An example Op. + +#include "tensorflow/core/framework/op.h" +#include "tensorflow/core/framework/op_kernel.h" + +using namespace tensorflow; + +REGISTER_OP("Fact") + .Output("fact: string") + .Doc(R"doc( +Output a fact about factorials. +)doc"); + +class FactOp : public OpKernel { + public: + explicit FactOp(OpKernelConstruction* context) : OpKernel(context) {} + + void Compute(OpKernelContext* context) override { + // Output a scalar string. + Tensor* output_tensor = NULL; + OP_REQUIRES_OK(context, + context->allocate_output(0, TensorShape(), &output_tensor)); + auto output = output_tensor->template scalar<string>(); + + output() = "0! == 1"; + } +}; + +REGISTER_KERNEL_BUILDER(Name("Fact").Device(DEVICE_CPU), FactOp); |