MCPcopy Create free account
hub / github.com/cactus-compute/cactus / layer_norm

Method layer_norm

python/src/graph.py:174–189  ·  view source on GitHub ↗
(self, x, normalized_shape, eps=1e-5)

Source from the content-addressed store, hash-verified

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)

Callers 1

layer_normMethod · 0.45

Calls 2

_ensure_tensorMethod · 0.95
_tensor_from_nodeMethod · 0.95

Tested by

no test coverage detected