| 85 | OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!")); |
| 86 | } |
| 87 | void Compute(OpKernelContext *context) override |
| 88 | { |
| 89 | |
| 90 | const Tensor &input = context->input(0); |
| 91 | auto input_flat = input.flat<float>(); |
| 92 | // check shapes of input |
| 93 | const TensorShape &input_shape = input.shape(); |
| 94 | TensorShape output_shape; |
| 95 | if (input_shape.dims() == 2) |
| 96 | { |
| 97 | output_shape.AddDim(times_ * input_shape.dim_size(0)); |
| 98 | output_shape.AddDim(input_shape.dim_size(1)); |
| 99 | } |
| 100 | else if (input_shape.dims() == 3) |
| 101 | { |
| 102 | output_shape.AddDim(times_ * input_shape.dim_size(0)); |
| 103 | output_shape.AddDim(input_shape.dim_size(1)); |
| 104 | output_shape.AddDim(input_shape.dim_size(2)); |
| 105 | } |
| 106 | else |
| 107 | { |
| 108 | output_shape.AddDim(times_ * input_shape.dim_size(0)); |
| 109 | output_shape.AddDim(input_shape.dim_size(1)); |
| 110 | output_shape.AddDim(input_shape.dim_size(2)); |
| 111 | output_shape.AddDim(input_shape.dim_size(3)); |
| 112 | } |
| 113 | // create output tensor |
| 114 | Tensor *output = NULL; |
| 115 | OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &output)); |
| 116 | auto output_flat = output->flat<float>(); |
| 117 | int N = input_flat.size(); |
| 118 | |
| 119 | unsigned long int eid_ = (eid_high_ << 32) + eid_low_; |
| 120 | typedef void (*function)(unsigned long int eid, float *x, int N, float *y); |
| 121 | dlerror(); |
| 122 | function encrypt_kernel = (function)dlsym(lib, "encrypt1"); |
| 123 | const char *dlsym_error = dlerror(); |
| 124 | |
| 125 | OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of encrypt1 failed: ", dlsym_error)); |
| 126 | encrypt_kernel(eid_, (float *)input_flat.data(), N, (float *)output_flat.data()); |
| 127 | }; |
| 128 | |
| 129 | private: |
| 130 | void *lib; |
nothing calls this directly
no outgoing calls
no test coverage detected