| 47 | OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!")); |
| 48 | } |
| 49 | void Compute(OpKernelContext *context) override |
| 50 | { |
| 51 | const Tensor &input = context->input(0); |
| 52 | auto input_flat = input.flat<float>(); |
| 53 | |
| 54 | const Tensor &mu = context->input(1); |
| 55 | auto mu_flat = mu.flat<float>(); |
| 56 | |
| 57 | const Tensor &sigma = context->input(2); |
| 58 | auto sigma_flat = sigma.flat<float>(); |
| 59 | |
| 60 | const TensorShape &input_shape = input.shape(); |
| 61 | |
| 62 | Tensor *output = NULL; |
| 63 | OP_REQUIRES_OK(context, context->allocate_output(0, input_shape, &output)); |
| 64 | auto output_flat = output->flat<float>(); |
| 65 | int N = input_flat.size() / times_; |
| 66 | |
| 67 | unsigned long int eid_ = (eid_high_ << 32) + eid_low_; |
| 68 | typedef void (*function)(unsigned long int eid, float *input, float *mu, float *sigma, int N, float *output); |
| 69 | dlerror(); |
| 70 | function logprob_kernel = (function)dlsym(lib, "logprob"); |
| 71 | const char *dlsym_error = dlerror(); |
| 72 | OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of logprob failed: ", dlsym_error)); |
| 73 | logprob_kernel(eid_, (float *)input_flat.data(), (float *)mu_flat.data(), (float *)sigma_flat.data(), N, (float *)output_flat.data()); |
| 74 | }; |
| 75 | |
| 76 | private: |
| 77 | void *lib; |
nothing calls this directly
no outgoing calls
no test coverage detected