MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ValidateInputs

Function ValidateInputs

tensorflow/core/kernels/sparse_reduce_op.cc:107–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107Status 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
134struct SumOp {
135 template <typename T>

Callers 3

ComputeMethod · 0.70
ComputeMethod · 0.70
ComputeMethod · 0.70

Calls 6

InvalidArgumentFunction · 0.85
IsScalarFunction · 0.50
shapeMethod · 0.45
DebugStringMethod · 0.45
sizeMethod · 0.45
NumElementsMethod · 0.45

Tested by

no test coverage detected