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

Function TensorShapeFromTensor

tensorflow/core/kernels/list_kernels.cc:143–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143Status TensorShapeFromTensor(const Tensor& t, PartialTensorShape* out) {
144 if (t.shape() == TensorShape({})) {
145 if ((t.dtype() == DT_INT32 && t.scalar<int32>()() == -1) ||
146 (t.dtype() == DT_INT64 && t.scalar<int64>()() == -1)) {
147 *out = PartialTensorShape();
148 return Status::OK();
149 }
150 return errors::InvalidArgument(
151 "The only valid scalar shape tensor is the fully unknown shape "
152 "specified as -1.");
153 }
154 if (t.dtype() == DT_INT32) {
155 return PartialTensorShape::MakePartialShape(t.vec<int32>().data(),
156 t.NumElements(), out);
157 } else if (t.dtype() == DT_INT64) {
158 return PartialTensorShape::MakePartialShape(t.vec<int64>().data(),
159 t.NumElements(), out);
160 }
161 return errors::InvalidArgument(
162 "Expected an int32 or int64 shape tensor; found ",
163 DataTypeString(t.dtype()));
164}
165
166Status GetElementShapeFromInput(OpKernelContext* c,
167 const TensorList& tensor_list, int index,

Callers 7

GetElementShapeFromInputFunction · 0.85
ComputeMethod · 0.85
ComputeMethod · 0.85
ComputeMethod · 0.85
ComputeMethod · 0.85
ComputeMethod · 0.85
CalculateOutputSizeMethod · 0.85

Calls 8

PartialTensorShapeClass · 0.85
InvalidArgumentFunction · 0.85
TensorShapeClass · 0.50
DataTypeStringFunction · 0.50
shapeMethod · 0.45
dtypeMethod · 0.45
dataMethod · 0.45
NumElementsMethod · 0.45

Tested by

no test coverage detected