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

Method Compute

en_ops/decrypt.cc:150–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148 OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!"));
149 }
150 void Compute(OpKernelContext *context) override
151 {
152
153 // get the input tensor
154 const Tensor &input = context->input(0);
155 auto input_flat = input.flat<float>();
156 // check shapes of input
157 const TensorShape &input_shape = input.shape();
158 TensorShape output_shape;
159 if (input_shape.dims() == 2)
160 {
161 output_shape.AddDim(times_ * input_shape.dim_size(0));
162 output_shape.AddDim(input_shape.dim_size(1));
163 }
164 else if (input_shape.dims() == 3)
165 {
166 output_shape.AddDim(times_ * input_shape.dim_size(0));
167 output_shape.AddDim(input_shape.dim_size(1));
168 output_shape.AddDim(input_shape.dim_size(2));
169 }
170 else
171 {
172 output_shape.AddDim(times_ * input_shape.dim_size(0));
173 output_shape.AddDim(input_shape.dim_size(1));
174 output_shape.AddDim(input_shape.dim_size(2));
175 output_shape.AddDim(input_shape.dim_size(3));
176 }
177 // create output tensor
178 Tensor *output = NULL;
179 OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &output));
180 auto output_flat = output->flat<float>();
181 int N = input_flat.size();
182
183 unsigned long int eid_ = (eid_high_ << 32) + eid_low_;
184 typedef void (*function)(unsigned long int eid, float *x, int N, float *y);
185 dlerror();
186 function encrypt_kernel = (function)dlsym(lib, "encrypt1");
187 const char *dlsym_error = dlerror();
188 OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of encrypt1 failed: ", dlsym_error));
189 encrypt_kernel(eid_, (float *)input_flat.data(), N, (float *)output_flat.data());
190 };
191
192private:
193 void *lib;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected