| 103 | OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!")); |
| 104 | } |
| 105 | void Compute(OpKernelContext *context) override |
| 106 | { |
| 107 | |
| 108 | const Tensor &grad = context->input(0); |
| 109 | const Tensor &input = context->input(1); |
| 110 | const Tensor &weight = context->input(2); |
| 111 | |
| 112 | auto grad_flat = grad.flat<float>(); |
| 113 | auto input_flat = input.flat<float>(); |
| 114 | auto weight_flat = weight.flat<float>(); |
| 115 | |
| 116 | const TensorShape &input_shape = input.shape(); |
| 117 | const TensorShape &weight_shape = weight.shape(); |
| 118 | |
| 119 | Tensor *output1 = NULL; |
| 120 | OP_REQUIRES_OK(context, context->allocate_output(0, input_shape, &output1)); |
| 121 | auto output1_flat = output1->flat<float>(); |
| 122 | |
| 123 | Tensor *output2 = NULL; |
| 124 | OP_REQUIRES_OK(context, context->allocate_output(1, weight_shape, &output2)); |
| 125 | auto output2_flat = output2->flat<float>(); |
| 126 | |
| 127 | int N = input_shape.dim_size(0) / times_; |
| 128 | int M = input_shape.dim_size(1); |
| 129 | int C = weight_shape.dim_size(1); |
| 130 | |
| 131 | unsigned long int eid_ = (eid_high_ << 32) + eid_low_; |
| 132 | typedef void (*function)(unsigned long int eid, float *input, float *grad, float *weight, int N, int M, int C, float *output1, float *output2); |
| 133 | dlerror(); |
| 134 | function matmul2d_grad_kernel = (function)dlsym(lib, "matmul2d_grad"); |
| 135 | const char *dlsym_error = dlerror(); |
| 136 | OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of matmul2d_grad failed: ", dlsym_error)); |
| 137 | matmul2d_grad_kernel(eid_, (float *)input_flat.data(), (float *)grad_flat.data(), (float *)weight_flat.data(), N, M, C, (float *)output1_flat.data(), (float *)output2_flat.data()); |
| 138 | }; |
| 139 | |
| 140 | private: |
| 141 | void *lib; |
nothing calls this directly
no outgoing calls
no test coverage detected