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

Method _HostConstantOp

tensorflow/core/kernels/host_constant_op.cc:27–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25namespace tensorflow {
26
27_HostConstantOp::_HostConstantOp(OpKernelConstruction* ctx)
28 : OpKernel(ctx), tensor_(ctx->output_type(0)) {
29 const TensorProto* proto = nullptr;
30 AllocatorAttributes alloc_attr;
31 alloc_attr.set_on_host(true);
32 OP_REQUIRES_OK(ctx, ctx->GetAttr("value", &proto));
33 OP_REQUIRES_OK(
34 ctx, ctx->device()->MakeTensorFromProto(*proto, alloc_attr, &tensor_));
35 OP_REQUIRES(
36 ctx, ctx->output_type(0) == tensor_.dtype(),
37 errors::InvalidArgument("Type mismatch between value (",
38 DataTypeString(tensor_.dtype()), ") and dtype (",
39 DataTypeString(ctx->output_type(0)), ")"));
40}
41
42void _HostConstantOp::Compute(OpKernelContext* ctx) {
43 ctx->set_output(0, tensor_);

Callers

nothing calls this directly

Calls 8

InvalidArgumentFunction · 0.85
set_on_hostMethod · 0.80
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