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

Method ConstantOp

tensorflow/core/kernels/constant_op.cc:71–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69} // namespace
70
71ConstantOp::ConstantOp(OpKernelConstruction* ctx)
72 : OpKernel(ctx, StripTensorDataFromNodeDef(ctx)),
73 tensor_(ctx->output_type(0)) {
74 const TensorProto* proto = nullptr;
75 OP_REQUIRES_OK(ctx, ctx->GetAttr("value", &proto));
76 OP_REQUIRES_OK(ctx, ctx->device()->MakeTensorFromProto(
77 *proto, AllocatorAttributes(), &tensor_));
78 OP_REQUIRES(
79 ctx, ctx->output_type(0) == tensor_.dtype(),
80 errors::InvalidArgument("Type mismatch between value (",
81 DataTypeString(tensor_.dtype()), ") and dtype (",
82 DataTypeString(ctx->output_type(0)), ")"));
83}
84
85void ConstantOp::Compute(OpKernelContext* ctx) {
86 ctx->set_output(0, tensor_);

Callers

nothing calls this directly

Calls 9

AllocatorAttributesClass · 0.85
InvalidArgumentFunction · 0.85
DataTypeStringFunction · 0.50
output_typeMethod · 0.45
GetAttrMethod · 0.45
MakeTensorFromProtoMethod · 0.45
deviceMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected