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

Method Compute

en_ops/e_reduce_mean_zero.cc:94–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected