| 98 | explicit RankOp(OpKernelConstruction* ctx) : OpKernel(ctx) {} |
| 99 | |
| 100 | void Compute(OpKernelContext* ctx) override { |
| 101 | TensorShape shape; |
| 102 | OP_REQUIRES_OK(ctx, shape_op_helpers::GetShape(ctx, 0, &shape)); |
| 103 | const int rank = shape.dims(); |
| 104 | Tensor* out = nullptr; |
| 105 | OP_REQUIRES_OK(ctx, ctx->allocate_output(0, TensorShape({}), &out)); |
| 106 | out->scalar<int32>()() = rank; |
| 107 | } |
| 108 | |
| 109 | bool IsExpensive() override { return false; } |
| 110 | }; |
nothing calls this directly
no test coverage detected