| 101 | public: |
| 102 | using OpKernel::OpKernel; |
| 103 | void Compute(OpKernelContext* context) override { |
| 104 | const Tensor* input; |
| 105 | OP_REQUIRES_OK(context, context->input("filename", &input)); |
| 106 | OP_REQUIRES(context, TensorShapeUtils::IsScalar(input->shape()), |
| 107 | errors::InvalidArgument( |
| 108 | "Input filename tensor must be scalar, but had shape: ", |
| 109 | input->shape().DebugString())); |
| 110 | |
| 111 | Tensor* output = nullptr; |
| 112 | OP_REQUIRES_OK(context, context->allocate_output("contents", |
| 113 | TensorShape({}), &output)); |
| 114 | OP_REQUIRES_OK(context, |
| 115 | ReadEntireFile(context->env(), input->scalar<string>()(), |
| 116 | &output->scalar<string>()())); |
| 117 | } |
| 118 | }; |
| 119 | |
| 120 | REGISTER_KERNEL_BUILDER(Name("ReadFile").Device(DEVICE_CPU), ReadFileOp); |
nothing calls this directly
no test coverage detected