| 83 | OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!")); |
| 84 | } |
| 85 | void Compute(OpKernelContext *context) override |
| 86 | { |
| 87 | |
| 88 | const Tensor &grad = context->input(0); |
| 89 | const Tensor &input = context->input(1); |
| 90 | |
| 91 | auto grad_flat = grad.flat<float>(); |
| 92 | auto input_flat = input.flat<float>(); |
| 93 | |
| 94 | const TensorShape &input_shape = input.shape(); |
| 95 | |
| 96 | Tensor *output = NULL; |
| 97 | OP_REQUIRES_OK(context, context->allocate_output(0, input_shape, &output)); |
| 98 | auto output_flat = output->flat<float>(); |
| 99 | |
| 100 | const int N = input_flat.size() / times_; |
| 101 | |
| 102 | unsigned long int eid_ = (eid_high_ << 32) + eid_low_; |
| 103 | typedef void (*function)(unsigned long int eid, float *input, float *grad, int N, float *output); |
| 104 | dlerror(); |
| 105 | function softplus_grad_kernel = (function)dlsym(lib, "softplus_grad"); |
| 106 | const char *dlsym_error = dlerror(); |
| 107 | OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of softplus_grad failed: ", dlsym_error)); |
| 108 | softplus_grad_kernel(eid_, (float *)input_flat.data(), (float *)grad_flat.data(), N, (float *)output_flat.data()); |
| 109 | }; |
| 110 | |
| 111 | private: |
| 112 | void *lib; |
nothing calls this directly
no outgoing calls
no test coverage detected