| 70 | using BinaryOp<T>::BinaryOp; |
| 71 | |
| 72 | void Compute(OpKernelContext* context) override { |
| 73 | const Tensor& a = context->input(0); |
| 74 | const Tensor& b = context->input(1); |
| 75 | |
| 76 | if (!context->ValidateInputsAreSameShape(this)) { |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | Tensor* output = nullptr; |
| 81 | OP_REQUIRES_OK(context, context->forward_input_or_allocate_output( |
| 82 | {0, 1}, 0, a.shape(), &output)); |
| 83 | |
| 84 | // Dispatch to the descendant's Operate() function. |
| 85 | switch (a.dims()) { |
| 86 | #define NDIM_CASE(NDIMS) \ |
| 87 | case NDIMS: { \ |
| 88 | static_cast<CHILD*>(this)->template Operate<NDIMS>(context, a, b, output); \ |
| 89 | break; \ |
| 90 | } |
| 91 | |
| 92 | NDIM_CASE(0); |
| 93 | NDIM_CASE(1); |
| 94 | NDIM_CASE(2); |
| 95 | NDIM_CASE(3); |
| 96 | NDIM_CASE(4); |
| 97 | NDIM_CASE(5); |
| 98 | NDIM_CASE(6); |
| 99 | NDIM_CASE(7); |
| 100 | NDIM_CASE(8); |
| 101 | #undef NDIM_CASE |
| 102 | |
| 103 | default: |
| 104 | context->SetStatus(errors::InvalidArgument( |
| 105 | "We only handle up to Tensor::dims() up to 8, not ", a.dims())); |
| 106 | break; |
| 107 | } |
| 108 | } |
| 109 | }; |
| 110 | |
| 111 | } // namespace tensorflow |
nothing calls this directly
no test coverage detected