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

Method Compile

tensorflow/compiler/tf2xla/kernels/shape_op.cc:41–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39 }
40
41 void Compile(XlaOpKernelContext* ctx) override {
42 const TensorShape input_shape = ctx->InputShape(0);
43 std::vector<xla::XlaOp> operands;
44 const int rank = input_shape.dims();
45 if (rank != 0) {
46 for (int64 i = 0; i < rank; ++i) {
47 operands.push_back(xla::Broadcast(
48 xla::ConvertElementType(xla::GetDimensionSize(ctx->Input(0), i),
49 ctx->output_xla_type(0)),
50 {1}));
51 }
52
53 ctx->SetOutput(0, xla::ConcatInDim(ctx->builder(), operands, 0));
54 } else {
55 // Rank 0 won't have dynamic size dimension, use constant output.
56 Tensor shape_constant(out_dtype_, TensorShape({input_shape.dims()}));
57 OP_REQUIRES_OK(ctx, TensorShapeToConstant(input_shape, &shape_constant));
58 ctx->SetConstantOutput(0, shape_constant);
59 }
60 }
61
62 private:
63 DataType out_dtype_;

Callers

nothing calls this directly

Calls 14

BroadcastFunction · 0.85
GetDimensionSizeFunction · 0.85
ConcatInDimFunction · 0.85
TensorShapeToConstantFunction · 0.85
InputShapeMethod · 0.80
output_xla_typeMethod · 0.80
SetConstantOutputMethod · 0.80
ConvertElementTypeFunction · 0.50
TensorShapeClass · 0.50
dimsMethod · 0.45
push_backMethod · 0.45
InputMethod · 0.45

Tested by

no test coverage detected