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

Method AllocateOutputTensor

tensorflow/core/kernels/mkl_slice_op.cc:485–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

483
484 private:
485 void AllocateOutputTensor(OpKernelContext* context,
486 const MklDnnShape& input_mkl_shape,
487 MEMORY_PRIMITIVE_DESC* output_pd,
488 const memory::dims& output_dims,
489 Tensor** output_tensor,
490 MklDnnShape* output_mkl_shape) {
491 DCHECK(output_tensor);
492 DCHECK(output_mkl_shape);
493
494 TensorShape output_tf_shape;
495
496 if (input_mkl_shape.IsMklTensor()) {
497 // Since input tensor is in OneDNN layout, output tensor will be in OneDNN
498 // layout.
499
500 // Allocate shape of OneDNN tensor.
501 output_mkl_shape->SetMklTensor(true);
502 output_mkl_shape->SetMklLayout(output_pd);
503 output_mkl_shape->SetElemType(MklDnnType<T>());
504 output_mkl_shape->SetTfLayout(input_mkl_shape.GetDimension(), output_dims,
505 input_mkl_shape.GetTfDataFormat());
506
507 output_tf_shape.AddDim(output_pd->get_size() / sizeof(T));
508 } else {
509 // If input is not in OneDNN layout, then output won't be in OneDNN layout.
510 output_mkl_shape->SetMklTensor(false);
511 output_tf_shape = MklDnnDimsToTFShape(output_dims);
512 }
513
514 AllocateOutputSetMklShape(context, 0, output_tensor, output_tf_shape,
515 *output_mkl_shape);
516 }
517};
518
519// OneDNN Slice registration

Callers

nothing calls this directly

Calls 11

MklDnnDimsToTFShapeFunction · 0.85
IsMklTensorMethod · 0.80
SetMklTensorMethod · 0.80
SetMklLayoutMethod · 0.80
SetElemTypeMethod · 0.80
SetTfLayoutMethod · 0.80
GetTfDataFormatMethod · 0.80
GetDimensionMethod · 0.45
AddDimMethod · 0.45
get_sizeMethod · 0.45

Tested by

no test coverage detected