MCPcopy Create free account
hub / github.com/3DAnimals/3DAnimals / test_lambda_ggx

Function test_lambda_ggx

model/render/renderutils/tests/test_bsdf.py:109–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

107 relative_loss("cosT:", cosT_ref.grad, cosT_cuda.grad)
108
109def test_lambda_ggx():
110 alphaSqr_cuda = torch.rand(1, RES, RES, 1, dtype=DTYPE, device='cuda', requires_grad=True)
111 alphaSqr_ref = alphaSqr_cuda.clone().detach().requires_grad_(True)
112 cosT_cuda = torch.rand(1, RES, RES, 1, dtype=DTYPE, device='cuda', requires_grad=True) * 3.0 - 1
113 cosT_cuda = cosT_cuda.clone().detach().requires_grad_(True)
114 cosT_ref = cosT_cuda.clone().detach().requires_grad_(True)
115 target = torch.rand(1, RES, RES, 1, dtype=DTYPE, device='cuda')
116
117 ref = ru._lambda_ggx(alphaSqr_ref, cosT_ref, use_python=True)
118 ref_loss = torch.nn.MSELoss()(ref, target)
119 ref_loss.backward()
120
121 cuda = ru._lambda_ggx(alphaSqr_cuda, cosT_cuda)
122 cuda_loss = torch.nn.MSELoss()(cuda, target)
123 cuda_loss.backward()
124
125 print("-------------------------------------------------------------")
126 print(" Lambda GGX")
127 print("-------------------------------------------------------------")
128 relative_loss("res:", ref, cuda)
129 relative_loss("alpha:", alphaSqr_ref.grad, alphaSqr_cuda.grad)
130 relative_loss("cosT:", cosT_ref.grad, cosT_cuda.grad)
131
132def test_masking_smith():
133 alphaSqr_cuda = torch.rand(1, RES, RES, 1, dtype=DTYPE, device='cuda', requires_grad=True)

Callers 1

test_bsdf.pyFile · 0.85

Calls 4

detachMethod · 0.80
relative_lossFunction · 0.70
cloneMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected