MCPcopy Create free account
hub / github.com/apache/tvm / layer_norm

Method layer_norm

tests/python/relax/test_transform_fuse_ops.py:892–912  ·  view source on GitHub ↗
(A: T.Buffer((T.int64(1), T.int64(512), T.int64(64), T.int64(64)), "float32"), gamma: T.Buffer((T.int64(64), T.int64(64)), "float32"), beta: T.Buffer((T.int64(64), T.int64(64)), "float32"), T_layer_norm: T.Buffer((T.int64(1), T.int64(512), T.int64(64), T.int64(64)), "float32"))

Source from the content-addressed store, hash-verified

890
891 @T.prim_func(private=True, s_tir=True)
892 def layer_norm(A: T.Buffer((T.int64(1), T.int64(512), T.int64(64), T.int64(64)), "float32"), gamma: T.Buffer((T.int64(64), T.int64(64)), "float32"), beta: T.Buffer((T.int64(64), T.int64(64)), "float32"), T_layer_norm: T.Buffer((T.int64(1), T.int64(512), T.int64(64), T.int64(64)), "float32")):
893 rxplaceholder_red_temp_v0 = T.sblock_alloc_buffer([T.int64(64), T.int64(64)], dtype="float32")
894 rxplaceholder_red_temp_v1 = T.sblock_alloc_buffer([T.int64(64), T.int64(64)], dtype="float32")
895 for i0, i1, i2, i3 in T.grid(T.int64(1), T.int64(512), T.int64(64), T.int64(64)):
896 with T.sblock("rxplaceholder_red_temp"):
897 ax0, ax1, k2, k3 = T.axis.remap("SSRR", [i0, i1, i2, i3])
898 T.reads(A[ax0, ax1, k2, k3])
899 T.writes(rxplaceholder_red_temp_v0[ax0, ax1], rxplaceholder_red_temp_v1[ax0, ax1])
900 with T.init():
901 rxplaceholder_red_temp_v0[ax0, ax1] = T.float32(0)
902 rxplaceholder_red_temp_v1[ax0, ax1] = T.float32(0)
903 v_rxplaceholder_red_temp_v0: T.let[T.float32] = rxplaceholder_red_temp_v0[ax0, ax1] + A[ax0, ax1, k2, k3]
904 v_rxplaceholder_red_temp_v1: T.let[T.float32] = rxplaceholder_red_temp_v1[ax0, ax1] + A[ax0, ax1, k2, k3] * A[ax0, ax1, k2, k3]
905 rxplaceholder_red_temp_v0[ax0, ax1] = v_rxplaceholder_red_temp_v0
906 rxplaceholder_red_temp_v1[ax0, ax1] = v_rxplaceholder_red_temp_v1
907 for i0, i1, i2, i3 in T.grid(T.int64(1), T.int64(512), T.int64(64), T.int64(64)):
908 with T.sblock("T_layer_norm"):
909 ax0, ax1, ax2, ax3 = T.axis.remap("SSSS", [i0, i1, i2, i3])
910 T.reads(A[ax0, ax1, ax2, ax3], rxplaceholder_red_temp_v0[ax0, ax1], rxplaceholder_red_temp_v1[ax0, ax1], gamma[ax2, ax3], beta[ax2, ax3])
911 T.writes(T_layer_norm[ax0, ax1, ax2, ax3])
912 T_layer_norm[ax0, ax1, ax2, ax3] = (A[ax0, ax1, ax2, ax3] - rxplaceholder_red_temp_v0[ax0, ax1] * T.float32(0.05)) * T.rsqrt(rxplaceholder_red_temp_v1[ax0, ax1] * T.float32(0.05) - rxplaceholder_red_temp_v0[ax0, ax1] * T.float32(0.05) * (rxplaceholder_red_temp_v0[ax0, ax1] * T.float32(0.05)) + T.float32(1e-05), dtype="float32") * gamma[ax2, ax3] + beta[ax2, ax3]
913
914 @T.prim_func(private=True, s_tir=True)
915 def relu(A: T.Buffer((T.int64(1), T.int64(512), T.int64(64), T.int64(64)), "float32"), B: T.Buffer((T.int64(1), T.int64(512), T.int64(64), T.int64(64)), "float32")):

Callers 15

_layer_norm_implMethod · 0.45
layer_normFunction · 0.45
forwardMethod · 0.45
_impl_v17Method · 0.45
_impl_v1Method · 0.45
_impl_v1Method · 0.45
layer_normFunction · 0.45
layer_normFunction · 0.45
mainMethod · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
mainMethod · 0.45

Calls 2

remapMethod · 0.80
initMethod · 0.45

Tested by

no test coverage detected