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

Method Compute

tensorflow/core/kernels/cast_op.cc:95–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95void CastOpBase::Compute(OpKernelContext* ctx) {
96 const Tensor& inp = ctx->input(0);
97 if (work_ == nullptr) {
98 ctx->set_output(0, inp);
99 } else {
100 Tensor in;
101 if (external_src_dtype_ != src_dtype_) {
102 // If the type is a quantized type we need to do a bitcast since the
103 // src_dtype_ is different from external_src_type_.
104 OP_REQUIRES_OK(ctx, in.BitcastFrom(inp, src_dtype_, inp.shape()));
105 } else {
106 in = inp;
107 }
108 Tensor* out = nullptr;
109 OP_REQUIRES_OK(ctx, ctx->allocate_output(0, in.shape(), &out));
110 out->set_dtype(dst_dtype_);
111 work_(ctx, in, out, use_truncation_);
112 out->set_dtype(external_dst_dtype_);
113 }
114}
115
116Status CastOpBase::Unimplemented() {
117 return errors::Unimplemented("Cast ", DataTypeString(external_src_dtype_),

Callers

nothing calls this directly

Calls 6

BitcastFromMethod · 0.80
allocate_outputMethod · 0.80
inputMethod · 0.45
set_outputMethod · 0.45
shapeMethod · 0.45
set_dtypeMethod · 0.45

Tested by

no test coverage detected