(self, x, normalized_shape, eps=1e-5)
| 172 | return self._tensor_from_node(out.value) |
| 173 | |
| 174 | def layer_norm(self, x, normalized_shape, eps=1e-5): |
| 175 | x = self._ensure_tensor(x) |
| 176 | normalized_shape = tuple(int(v) for v in normalized_shape) |
| 177 | shape_arr = (ctypes.c_size_t * len(normalized_shape))(*normalized_shape) |
| 178 | out = cactus_node_t() |
| 179 | rc = _lib.cactus_graph_layer_norm( |
| 180 | self.h, |
| 181 | cactus_node_t(x.id), |
| 182 | shape_arr, |
| 183 | len(normalized_shape), |
| 184 | ctypes.c_float(float(eps)), |
| 185 | ctypes.byref(out), |
| 186 | ) |
| 187 | if rc != 0: |
| 188 | raise RuntimeError("graph_layer_norm failed") |
| 189 | return self._tensor_from_node(out.value) |
| 190 | |
| 191 | def softmax(self, x, axis=-1): |
| 192 | x = self._ensure_tensor(x) |
no test coverage detected