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

Method Compile

tensorflow/compiler/tf2xla/kernels/empty_op.cc:39–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37 }
38
39 void Compile(XlaOpKernelContext* ctx) override {
40 // The output of this Op is a tensor of shape 'shape' with each
41 // element set to the default value of 'dtype'. If 'init' is false then
42 // the result values may be left undefined, though we don't do that here.
43 const TensorShape shape_shape = ctx->InputShape("shape");
44 OP_REQUIRES(
45 ctx, TensorShapeUtils::IsVector(shape_shape),
46 errors::InvalidArgument("shape must be a vector of int32, got shape ",
47 shape_shape.DebugString()));
48
49 std::vector<int64> shape;
50 OP_REQUIRES_OK(ctx, ctx->ConstantInputAsIntVector("shape", &shape));
51
52 auto default_value = xla::Zero(ctx->builder(), type_);
53 auto result = xla::Broadcast(default_value, shape);
54 ctx->SetOutput(0, result);
55 }
56
57 private:
58 DataType dtype_;

Callers

nothing calls this directly

Calls 8

InvalidArgumentFunction · 0.85
BroadcastFunction · 0.85
InputShapeMethod · 0.80
ZeroFunction · 0.50
DebugStringMethod · 0.45
builderMethod · 0.45
SetOutputMethod · 0.45

Tested by

no test coverage detected