| 32 | .Output("output: float"); |
| 33 | |
| 34 | class ESortDeOp : public OpKernel |
| 35 | { |
| 36 | public: |
| 37 | explicit ESortDeOp(OpKernelConstruction *context) : OpKernel(context) |
| 38 | { |
| 39 | OP_REQUIRES_OK(context, context->GetAttr("eid_low", &eid_low_)); |
| 40 | OP_REQUIRES_OK(context, context->GetAttr("eid_high", &eid_high_)); |
| 41 | OP_REQUIRES_OK(context, context->GetAttr("times", ×_)); |
| 42 | lib = dlopen("/home/zhangyan/jhrsgx/privacy_test/privacy_tf/sgx_tf_ops/sgx.so", RTLD_LAZY); |
| 43 | OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!")); |
| 44 | } |
| 45 | void Compute(OpKernelContext *context) override |
| 46 | { |
| 47 | const Tensor &input = context->input(0); |
| 48 | auto input_flat = input.flat<float>(); |
| 49 | |
| 50 | const TensorShape &input_shape = input.shape(); |
| 51 | |
| 52 | Tensor *output = NULL; |
| 53 | OP_REQUIRES_OK(context, context->allocate_output(0, input_shape, &output)); |
| 54 | auto output_flat = output->flat<float>(); |
| 55 | int N = input_flat.size() / times_; |
| 56 | int M = input_shape.dim_size(0) / times_; |
| 57 | int C = input_shape.dim_size(1); |
| 58 | int L = input_shape.dim_size(2); |
| 59 | |
| 60 | unsigned long int eid_ = (eid_high_ << 32) + eid_low_; |
| 61 | typedef void (*function)(unsigned long int eid, float *input, int N, int M, int C, int L, float *output); |
| 62 | dlerror(); |
| 63 | function sort_de_kernel = (function)dlsym(lib, "sort_de"); |
| 64 | const char *dlsym_error = dlerror(); |
| 65 | OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of sort_de failed: ", dlsym_error)); |
| 66 | sort_de_kernel(eid_, (float *)input_flat.data(), N, M, C, L, (float *)output_flat.data()); |
| 67 | }; |
| 68 | |
| 69 | private: |
| 70 | void *lib; |
| 71 | int64 eid_low_; |
| 72 | int64 eid_high_; |
| 73 | int64 times_; |
| 74 | }; |
| 75 | REGISTER_KERNEL_BUILDER(Name("ESortDe").Device(DEVICE_CPU), ESortDeOp); |
| 76 | |
| 77 | class ESortDeGradOp : public OpKernel |
nothing calls this directly
no outgoing calls
no test coverage detected