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

Method Compute

tensorflow/core/kernels/list_kernels.cc:283–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281 ~TensorListPushBack() override {}
282
283 void Compute(OpKernelContext* c) override {
284 const Tensor& input = c->input(1);
285 OP_REQUIRES(c, element_dtype_ == input.dtype(),
286 errors::InvalidArgument("Invalid data types; list elements ",
287 DataTypeString(element_dtype_),
288 " but tried to append ",
289 DataTypeString(input.dtype())));
290
291 const TensorList* l = nullptr;
292 OP_REQUIRES_OK(c, GetInputList(c, 0, &l));
293 OP_REQUIRES(c, l->element_shape.IsCompatibleWith(input.shape()),
294 errors::InvalidArgument(
295 "Tried to append a tensor with incompatible shape to a "
296 "list. Op element shape: ",
297 input.shape().DebugString(),
298 " list shape: ", l->element_shape.DebugString()));
299 OP_REQUIRES(c, element_dtype_ == l->element_dtype,
300 errors::InvalidArgument("Invalid data types; op elements ",
301 DataTypeString(element_dtype_),
302 " but list elements ",
303 DataTypeString(l->element_dtype)));
304
305 if (l->max_num_elements != -1) {
306 OP_REQUIRES(
307 c, l->tensors().size() < l->max_num_elements,
308 errors::InvalidArgument("Tried to push item into a full list",
309 " list size: ", l->tensors().size(),
310 " max_num_elements: ", l->max_num_elements));
311 }
312
313 TensorList* output_list = nullptr;
314 OP_REQUIRES_OK(c, ForwardInputOrCreateNewList(c, 0, 0, *l, &output_list));
315 output_list->tensors().push_back(input);
316 }
317
318 private:
319 DataType element_dtype_;

Callers

nothing calls this directly

Calls 12

InvalidArgumentFunction · 0.85
GetInputListFunction · 0.85
tensorsMethod · 0.80
DataTypeStringFunction · 0.50
inputMethod · 0.45
dtypeMethod · 0.45
IsCompatibleWithMethod · 0.45
shapeMethod · 0.45
DebugStringMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected