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

Method Compute

en_ops/e_div.cc:63–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61 OP_REQUIRES(context, lib != NULL, errors::Unknown("Unable to load sgx.so!"));
62 }
63 void Compute(OpKernelContext *context) override
64 {
65 const Tensor &input1 = context->input(0);
66 auto input1_flat = input1.flat<float>();
67
68 const Tensor &input2 = context->input(1);
69 auto input2_flat = input2.flat<float>();
70
71 const TensorShape &input1_shape = input1.shape();
72 const TensorShape &input2_shape = input2.shape();
73
74 int shape1[input1_shape.dims()];
75 for (int i = 0; i < input1_shape.dims(); i++)
76 {
77 shape1[i] = input1_shape.dim_size(i);
78 }
79
80 int shape2[input2_shape.dims()];
81 for (int i = 0; i < input2_shape.dims(); i++)
82 {
83 shape2[i] = input2_shape.dim_size(i);
84 }
85
86 TensorShape output_shape;
87 for (int i = 0; i < input1_shape.dims(); i++)
88 {
89 int dim_tmp = shape1[i] > shape2[i] ? shape1[i] : shape2[i];
90 output_shape.AddDim(dim_tmp);
91 }
92
93 Tensor *output = NULL;
94 OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &output));
95 auto output_flat = output->flat<float>();
96 int N1 = input1_flat.size() / times_;
97 int N2 = input2_flat.size() / times_;
98
99 unsigned long int eid_ = (eid_high_ << 32) + eid_low_;
100 typedef void (*function)(unsigned long int eid, float *input1, float *input2, int N1, int N2, int *shape1, int *shape2, float *output);
101 dlerror();
102 function div_kernel = (function)dlsym(lib, "divi");
103 const char *dlsym_error = dlerror();
104 OP_REQUIRES(context, !dlsym_error, errors::Unknown("loading of dot failed: ", dlsym_error));
105 div_kernel(eid_, (float *)input1_flat.data(), (float *)input2_flat.data(), N1, N2, (int *)shape1, (int *)shape2, (float *)output_flat.data());
106 };
107
108private:
109 void *lib;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected