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

Function BitcastOp_Create

tensorflow/c/kernels/bitcast_op.cc:51–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49} BitcastOp;
50
51static void* BitcastOp_Create(TF_OpKernelConstruction* ctx) {
52 auto* kernel = new BitcastOp;
53
54 TF_Status* s = TF_NewStatus();
55 TF_OpKernelConstruction_GetAttrType(ctx, "T", &kernel->input_data_type, s);
56
57 if (TF_GetCode(s) == TF_OK) {
58 TF_OpKernelConstruction_GetAttrType(ctx, "type", &kernel->output_data_type,
59 s);
60 }
61
62 if (TF_GetCode(s) == TF_OK) {
63 kernel->in_size = TF_DataTypeSize(kernel->input_data_type);
64 kernel->out_size = TF_DataTypeSize(kernel->output_data_type);
65
66 size_t check_size = std::max(kernel->in_size, kernel->out_size) %
67 std::min(kernel->in_size, kernel->out_size);
68 if (check_size != 0) {
69 std::ostringstream err;
70 err << "cannot convert between datatype " << kernel->input_data_type
71 << " and " << kernel->output_data_type;
72 TF_SetStatus(s, TF_INVALID_ARGUMENT, err.str().c_str());
73 }
74 }
75
76 if (TF_GetCode(s) != TF_OK) {
77 TF_OpKernelConstruction_Failure(ctx, s);
78 delete kernel;
79 kernel = nullptr;
80 }
81
82 TF_DeleteStatus(s);
83 return kernel;
84}
85
86static void BitcastOp_Delete(void* kernel) {
87 delete static_cast<BitcastOp*>(kernel);

Callers

nothing calls this directly

Calls 9

TF_NewStatusFunction · 0.85
TF_GetCodeFunction · 0.85
TF_DataTypeSizeFunction · 0.85
TF_SetStatusFunction · 0.85
TF_DeleteStatusFunction · 0.85
c_strMethod · 0.80
maxFunction · 0.50
minFunction · 0.50

Tested by

no test coverage detected