| 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_; |
nothing calls this directly
no test coverage detected