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

Method Compile

tensorflow/compiler/tf2xla/kernels/arg_op.cc:37–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35 }
36
37 void Compile(XlaOpKernelContext* ctx) override {
38 // If 'frame' is non-null, this is a function call inside an outer JIT
39 // compilation. Use the usual implementation of _Arg.
40 auto frame = ctx->call_frame();
41 if (frame != nullptr) {
42 Tensor val;
43 OP_REQUIRES_OK(ctx, frame->GetArg(index_, &val));
44 // Types that cannot be copied using memcpy (like DT_STRING) are wrapped
45 // in a DT_UINT8 and hence the type mismatches. Skip the test in such
46 // cases. See XlaOpKernelContext::SetOutputExpression for details.
47 if (DataTypeCanUseMemcpy(dtype_)) {
48 OP_REQUIRES(ctx, val.dtype() == dtype_,
49 errors::InvalidArgument(
50 "Type mismatch: actual ", DataTypeString(val.dtype()),
51 " vs. expect ", DataTypeString(dtype_)));
52 }
53 // Forwards the argument from the frame.
54 ctx->op_kernel_context()->set_output(0, val);
55 return;
56 }
57
58 const XlaExpression& arg = ctx->xla_context()->args()[index_];
59 OP_REQUIRES(ctx, arg.kind() != XlaExpression::Kind::kInvalid,
60 errors::InvalidArgument("Invalid/missing argument expression"));
61 if (ctx->expected_output_dtype(0) == DT_VARIANT) {
62 ctx->SetTensorListOutput(0, arg.handle());
63 } else {
64 ctx->SetOutputExpression(0, arg);
65 }
66 }
67
68 private:
69 int index_;

Callers

nothing calls this directly

Calls 15

DataTypeCanUseMemcpyFunction · 0.85
InvalidArgumentFunction · 0.85
op_kernel_contextMethod · 0.80
argsMethod · 0.80
xla_contextMethod · 0.80
SetTensorListOutputMethod · 0.80
SetOutputExpressionMethod · 0.80
DataTypeStringFunction · 0.50
call_frameMethod · 0.45
GetArgMethod · 0.45
dtypeMethod · 0.45
set_outputMethod · 0.45

Tested by

no test coverage detected