MCPcopy Create free account
hub / github.com/OAID/Tengine / AbsvalOps

Class AbsvalOps

executor/operator/arm32/absval_float.cpp:45–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43const int default_prio = 300;
44
45struct AbsvalOps : public MTNodeOps
46{
47 AbsvalOps()
48 {
49 name_ = "arm_abs_fp32";
50 }
51 bool OnBind(Node* node)
52 {
53 inplace_t io_map;
54
55 io_map[0] = 0;
56
57 node->SetAttr(ATTR_INPLACE, io_map);
58 return true;
59 }
60
61 bool Prerun(Node* node)
62 {
63 return true;
64 }
65
66 bool Run(Node* node)
67 {
68 Tensor* input_tensor = node->GetInputTensor(0);
69 const TShape& shape = input_tensor->GetShape();
70
71 float* data = ( float* )get_tensor_mem(input_tensor);
72
73 int channel_num = shape.GetC();
74 int batch_number = shape.GetN();
75 int channel_size = shape.GetW() * shape.GetH();
76
77 for(int c = 0; c < channel_num * batch_number; c++)
78 {
79 for(int i = 0; i < (channel_size & -4); i += 4)
80 {
81 float32x4_t _p = vld1q_f32(data);
82 _p = vabsq_f32(_p);
83 vst1q_f32(data, _p);
84
85 data += 4;
86 }
87 for(int i = channel_size & ~3; i < channel_size; i++)
88 {
89 if (*data < 0)
90 *data = -*data;
91 data++;
92 }
93 }
94
95 /*
96 int elem_num = shape.GetSize();
97 for(int i = 0; i < (elem_num & -4); i += 4)
98 {
99 float32x4_t _p = vld1q_f32(data);
100 _p = vabsq_f32(_p);
101 vst1q_f32(data, _p);
102

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected