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

Method Compute

en_ops/e_matadd.cc:92–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90 OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!"));
91 }
92 void Compute(OpKernelContext *context) override
93 {
94
95 const Tensor &grad = context->input(0);
96 const Tensor &input1 = context->input(1);
97 auto input1_flat = input1.flat<float>();
98
99 const Tensor &input2 = context->input(2);
100 auto input2_flat = input2.flat<float>();
101
102 auto grad_flat = grad.flat<float>();
103
104 const TensorShape &input1_shape = input1.shape();
105 const TensorShape &input2_shape = input2.shape();
106
107 Tensor *output1 = NULL;
108 OP_REQUIRES_OK(context, context->allocate_output(0, input1_shape, &output1));
109 auto output1_flat = output1->flat<float>();
110
111 Tensor *output2 = NULL;
112 OP_REQUIRES_OK(context, context->allocate_output(1, input2_shape, &output2));
113 auto output2_flat = output2->flat<float>();
114
115 int N = input1_flat.size() / times_;
116 int C = input2_flat.size();
117
118 unsigned long int eid_ = (eid_high_ << 32) + eid_low_;
119 typedef void (*function)(unsigned long int eid, float *input1, float *input2, float *grad, int N, int C, float *output1, float *output2);
120 dlerror();
121 function matadd_grad_kernel = (function)dlsym(lib, "matadd_grad");
122 const char *dlsym_error = dlerror();
123 OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of matadd_grad failed: ", dlsym_error));
124 matadd_grad_kernel(eid_, (float *)input1_flat.data(), (float *)input2_flat.data(), (float *)grad_flat.data(), N, C, (float *)output1_flat.data(), (float *)output2_flat.data());
125 };
126
127private:
128 void *lib;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected