MCPcopy Create free account
hub / github.com/conflow-dev/ConFlow / Compute

Method Compute

en_ops/e_where_gequal.cc:111–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109 OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!"));
110 }
111 void Compute(OpKernelContext *context) override
112 {
113
114 const Tensor &grad = context->input(0);
115 auto grad_flat = grad.flat<float>();
116
117 const Tensor &input1 = context->input(1);
118 auto input1_flat = input1.flat<float>();
119
120 const Tensor &input2 = context->input(2);
121 auto input2_flat = input2.flat<float>();
122
123 const Tensor &cond1 = context->input(3);
124 auto cond1_flat = cond1.flat<float>();
125
126 const Tensor &cond2 = context->input(4);
127 auto cond2_flat = cond2.flat<float>();
128
129 const TensorShape &input1_shape = input1.shape();
130 const TensorShape &input2_shape = input2.shape();
131
132 Tensor *output1 = NULL;
133 OP_REQUIRES_OK(context, context->allocate_output(0, input1_shape, &output1));
134 auto output1_flat = output1->flat<float>();
135
136 Tensor *output2 = NULL;
137 OP_REQUIRES_OK(context, context->allocate_output(1, input2_shape, &output2));
138 auto output2_flat = output2->flat<float>();
139 int N = input1_flat.size() / times_;
140
141 int n1 = 1;
142 int n2 = 1;
143 if (cond1_flat.size() > 1)
144 {
145 n1 = cond1_flat.size() / times_;
146 }
147 if (cond2_flat.size() > 1)
148 {
149 n2 = cond2_flat.size() / times_;
150 }
151
152 unsigned long int eid_ = (eid_high_ << 32) + eid_low_;
153 typedef void (*function)(unsigned long int eid, float *grad, float *input1, float *input2, float *cond1, float *cond2, int N, int n1, int n2, float *output1, float *output2);
154 dlerror();
155 function where_gequal_grad_kernel = (function)dlsym(lib, "where_gequal_grad");
156 const char *dlsym_error = dlerror();
157 OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of where_gequal_grad failed: ", dlsym_error));
158 where_gequal_grad_kernel(eid_, (float *)grad_flat.data(), (float *)input1_flat.data(), (float *)input2_flat.data(), (float *)cond1_flat.data(), (float *)cond2_flat.data(), N, n1, n2, (float *)output1_flat.data(), (float *)output2_flat.data());
159 };
160
161private:
162 void *lib;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected