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

Method Compute

tensorflow/core/kernels/parse_tensor_op.cc:34–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32 }
33
34 void Compute(OpKernelContext* ctx) override {
35 const Tensor& serialized = ctx->input(0);
36
37 OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(serialized.shape()),
38 errors::InvalidArgument(
39 "Expected `serialized` to be a scalar, got shape: ",
40 serialized.shape().DebugString()));
41
42 auto serialized_t = serialized.scalar<tstring>();
43
44 TensorProto proto;
45 OP_REQUIRES(ctx, ParseProtoUnlimited(&proto, serialized_t()),
46 errors::InvalidArgument(
47 "Could not parse `serialized` as TensorProto: '",
48 serialized_t(), "'"));
49
50 Tensor output;
51 OP_REQUIRES_OK(ctx, ctx->device()->MakeTensorFromProto(
52 proto, ctx->output_alloc_attr(0), &output));
53
54 OP_REQUIRES(
55 ctx, out_type_ == output.dtype(),
56 errors::InvalidArgument("Type mismatch between parsed tensor (",
57 DataTypeString(output.dtype()), ") and dtype (",
58 DataTypeString(out_type_), ")"));
59
60 ctx->set_output(0, output);
61 }
62
63 private:
64 DataType out_type_;

Callers

nothing calls this directly

Calls 12

InvalidArgumentFunction · 0.85
ParseProtoUnlimitedFunction · 0.85
output_alloc_attrMethod · 0.80
IsScalarFunction · 0.50
DataTypeStringFunction · 0.50
inputMethod · 0.45
shapeMethod · 0.45
DebugStringMethod · 0.45
MakeTensorFromProtoMethod · 0.45
deviceMethod · 0.45
dtypeMethod · 0.45
set_outputMethod · 0.45

Tested by

no test coverage detected