| 25 | return Status::OK(); }); |
| 26 | |
| 27 | class EMathOp : public OpKernel |
| 28 | { |
| 29 | public: |
| 30 | explicit EMathOp(OpKernelConstruction *context) : OpKernel(context) |
| 31 | { |
| 32 | OP_REQUIRES_OK(context, context->GetAttr("eid_low", &eid_low_)); |
| 33 | OP_REQUIRES_OK(context, context->GetAttr("eid_high", &eid_high_)); |
| 34 | OP_REQUIRES_OK(context, context->GetAttr("times", ×_)); |
| 35 | OP_REQUIRES_OK(context, context->GetAttr("num", &num_)); |
| 36 | lib = dlopen("/home/zhangyan/jhrsgx/privacy_test/privacy_tf/sgx_tf_ops/sgx.so", RTLD_LAZY); |
| 37 | OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!")); |
| 38 | } |
| 39 | void Compute(OpKernelContext *context) override |
| 40 | { |
| 41 | const Tensor &input = context->input(0); |
| 42 | auto input_flat = input.flat<float>(); |
| 43 | |
| 44 | const TensorShape &input_shape = input.shape(); |
| 45 | |
| 46 | Tensor *output = NULL; |
| 47 | OP_REQUIRES_OK(context, context->allocate_output(0, input_shape, &output)); |
| 48 | auto output_flat = output->flat<float>(); |
| 49 | int N = input_flat.size() / times_; |
| 50 | |
| 51 | unsigned long int eid_ = (eid_high_ << 32) + eid_low_; |
| 52 | typedef void (*function)(unsigned long int eid, float *input, float num, int N, float *output); |
| 53 | dlerror(); |
| 54 | function math_kernel = (function)dlsym(lib, "math"); |
| 55 | const char *dlsym_error = dlerror(); |
| 56 | OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of log failed: ", dlsym_error)); |
| 57 | math_kernel(eid_, (float *)input_flat.data(), num_, N, (float *)output_flat.data()); |
| 58 | }; |
| 59 | |
| 60 | private: |
| 61 | void *lib; |
| 62 | int64 eid_low_; |
| 63 | int64 eid_high_; |
| 64 | int64 times_; |
| 65 | float num_; |
| 66 | }; |
| 67 | REGISTER_KERNEL_BUILDER(Name("EMath").Device(DEVICE_CPU), EMathOp); |
nothing calls this directly
no outgoing calls
no test coverage detected