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

Method Compute

en_ops/e_div.cc:127–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!"));
126 }
127 void Compute(OpKernelContext *context) override
128 {
129
130 const Tensor &grad = context->input(0);
131 const Tensor &input1 = context->input(1);
132 auto input1_flat = input1.flat<float>();
133
134 const Tensor &input2 = context->input(2);
135 auto input2_flat = input2.flat<float>();
136
137 auto grad_flat = grad.flat<float>();
138
139 const TensorShape &input1_shape = input1.shape();
140 const TensorShape &input2_shape = input2.shape();
141
142 int shape1[input1_shape.dims()];
143 for (int i = 0; i < input1_shape.dims(); i++)
144 {
145 shape1[i] = input1_shape.dim_size(i);
146 }
147
148 int shape2[input2_shape.dims()];
149 for (int i = 0; i < input2_shape.dims(); i++)
150 {
151 shape2[i] = input2_shape.dim_size(i);
152 }
153
154 Tensor *output1 = NULL;
155 OP_REQUIRES_OK(context, context->allocate_output(0, input1_shape, &output1));
156 auto output1_flat = output1->flat<float>();
157
158 Tensor *output2 = NULL;
159 OP_REQUIRES_OK(context, context->allocate_output(1, input2_shape, &output2));
160 auto output2_flat = output2->flat<float>();
161
162 int N1 = input1_flat.size() / times_;
163 int N2 = input2_flat.size() / times_;
164
165 unsigned long int eid_ = (eid_high_ << 32) + eid_low_;
166 typedef void (*function)(unsigned long int eid, float *input1, float *input2, float *grad, int N1, int N2, int *shape1, int *shape2, float *output1, float *output2);
167 dlerror();
168 function div_grad_kernel = (function)dlsym(lib, "divi_grad");
169 const char *dlsym_error = dlerror();
170 OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of dot_grad failed: ", dlsym_error));
171 div_grad_kernel(eid_, (float *)input1_flat.data(), (float *)input2_flat.data(), (float *)grad_flat.data(), N1, N2, (int *)shape1, (int *)shape2, (float *)output1_flat.data(), (float *)output2_flat.data());
172 };
173
174private:
175 void *lib;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected