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

Function TransposeOperand

tensorflow/core/kernels/einsum_op.cc:323–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321// transposing is not necessary.
322template <typename Device, typename T>
323Status TransposeOperand(OpKernelContext* ctx, const Tensor& input,
324 const std::vector<int>& permutation, Tensor* output) {
325 if (!ShouldTranspose(input.shape(), permutation)) {
326 return CopyFrom(input, input.shape(), output);
327 }
328 TensorShape transposed_shape;
329 for (int i = 0; i < input.dims(); ++i) {
330 transposed_shape.AddDim(input.dim_size(permutation[i]));
331 }
332 TF_RETURN_IF_ERROR(
333 ctx->allocate_temp(DataTypeToEnum<T>::value, transposed_shape, output));
334 const Device& device = ctx->eigen_device<Device>();
335 TF_RETURN_IF_ERROR(DoTranspose(device, input, permutation, output));
336 return Status::OK();
337}
338
339// If there are repeated labels in either the input or output, then this strides
340// the input (e.g. iii->i) or inflates it (e.g. i->iii), respectively.

Callers

nothing calls this directly

Calls 8

ShouldTransposeFunction · 0.85
CopyFromFunction · 0.85
DoTransposeFunction · 0.85
shapeMethod · 0.45
dimsMethod · 0.45
AddDimMethod · 0.45
dim_sizeMethod · 0.45
allocate_tempMethod · 0.45

Tested by

no test coverage detected