| 105 | } |
| 106 | |
| 107 | Status ValidateInputs(const Tensor *shape_t, const Tensor *reduction_axes_t) { |
| 108 | // indices and values are validated in SparseTensor ctor. |
| 109 | if (!TensorShapeUtils::IsVector(shape_t->shape())) { |
| 110 | return errors::InvalidArgument( |
| 111 | "Expected input_shape to be a vector; got shape: ", |
| 112 | shape_t->shape().DebugString()); |
| 113 | } |
| 114 | if (!TensorShapeUtils::IsScalar(reduction_axes_t->shape()) && |
| 115 | !TensorShapeUtils::IsVector(reduction_axes_t->shape())) { |
| 116 | return errors::InvalidArgument( |
| 117 | "Expected reduction_axes to be a scalar or a vector; got shape: ", |
| 118 | reduction_axes_t->shape().DebugString()); |
| 119 | } |
| 120 | |
| 121 | const auto reduction_axes_flat = reduction_axes_t->flat<int32>(); |
| 122 | for (int64 i = 0; i < reduction_axes_flat.size(); i++) { |
| 123 | int32 axis = reduction_axes_flat(i); |
| 124 | if (axis < -shape_t->NumElements() || axis >= shape_t->NumElements()) { |
| 125 | return errors::InvalidArgument("Invalid reduction dimension ", axis, |
| 126 | ", for input with ", |
| 127 | shape_t->NumElements(), " dimensions."); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | return Status::OK(); |
| 132 | } |
| 133 | |
| 134 | struct SumOp { |
| 135 | template <typename T> |
no test coverage detected