From f41959ccb2d9d4c722fe8fc3351401d53bcf4900 Mon Sep 17 00:00:00 2001 From: Manjunath Kudlur Date: Fri, 6 Nov 2015 16:27:58 -0800 Subject: TensorFlow: Initial commit of TensorFlow library. TensorFlow is an open source software library for numerical computation using data flow graphs. Base CL: 107276108 --- tensorflow/core/user_ops/fact.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tensorflow/core/user_ops/fact.cc (limited to 'tensorflow/core/user_ops') 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(); + + output() = "0! == 1"; + } +}; + +REGISTER_KERNEL_BUILDER(Name("Fact").Device(DEVICE_CPU), FactOp); -- cgit v1.2.3