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