MCPcopy Create free account
hub / github.com/conflow-dev/ConFlow / Compute

Method Compute

en_ops/e_emb_transfer.cc:95–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93 OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!"));
94 }
95 void Compute(OpKernelContext *context) override
96 {
97
98 const Tensor &grad = context->input(0);
99 auto grad_flat = grad.flat<float>();
100 const TensorShape &input_shape = grad.shape();
101
102 TensorShape output_shape;
103 output_shape.AddDim(input_shape.dim_size(0) / 10);
104 output_shape.AddDim(input_shape.dim_size(1) + 1);
105 Tensor *output = NULL;
106 OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &output));
107 auto output_flat = output->flat<float>();
108
109 int M = input_shape.dim_size(0) / 10;
110 int C = input_shape.dim_size(1);
111
112 unsigned long int eid_ = (eid_high_ << 32) + eid_low_;
113 typedef void (*function)(unsigned long int eid, float *grad, float *output, int M, int C);
114 dlerror();
115 function emb_transfer_grad_kernel = (function)dlsym(lib, "emb_transfer_grad");
116 const char *dlsym_error = dlerror();
117 OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of relu_grad failed: ", dlsym_error));
118 emb_transfer_grad_kernel(eid_, (float *)grad_flat.data(), (float *)output_flat.data(), M, C);
119 };
120
121private:
122 void *lib;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected