| 63 | OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!")); |
| 64 | } |
| 65 | void Compute(OpKernelContext *context) override |
| 66 | { |
| 67 | // get the input tensor |
| 68 | const Tensor &input = context->input(0); |
| 69 | auto input_flat = input.flat<float>(); |
| 70 | // check shapes of input |
| 71 | const TensorShape &input_shape = input.shape(); |
| 72 | TensorShape output_shape; |
| 73 | output_shape.AddDim(10 * input_shape.dim_size(0)); |
| 74 | output_shape.AddDim(num_ * dim_); |
| 75 | // create output tensor |
| 76 | Tensor *output = NULL; |
| 77 | OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &output)); |
| 78 | auto output_flat = output->flat<float>(); |
| 79 | int M = input_shape.dim_size(0); |
| 80 | int C = input_shape.dim_size(1); |
| 81 | |
| 82 | unsigned long int eid_ = (eid_high_ << 32) + eid_low_; |
| 83 | typedef void (*function)(unsigned long int eid, float *x, float *y, int M, int C, int num, int dim); |
| 84 | dlerror(); |
| 85 | function embedding_ss_kernel = (function)dlsym(lib, "embedding_ss"); |
| 86 | const char *dlsym_error = dlerror(); |
| 87 | OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of embedding_ss failed: ", dlsym_error)); |
| 88 | |
| 89 | embedding_ss_kernel(eid_, (float *)input_flat.data(), (float *)output_flat.data(), M, C, num_, dim_); |
| 90 | }; |
| 91 | |
| 92 | private: |
| 93 | void *lib; |
nothing calls this directly
no outgoing calls
no test coverage detected