Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/test_operations_hlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ def test_special_scalars_addcdiv_addcmul(self):
assert 'f32' in root_hlo
assert 'f64' not in root_hlo

def test_div_by_f64(self):
mod = torch.nn.MultiheadAttention(768, 12, batch_first=True)
mod.to(xm.xla_device())
a = torch.rand(1, 512, 768).to(xm.xla_device())
b, _ = mod(a, a, a, need_weights=False)
b.sum().backward()
hlo_text = torch_xla._XLAC._get_xla_tensors_text(
[p.grad for p in mod.parameters() if p.requires_grad])
assert 'f64' not in hlo_text


if __name__ == '__main__':
torch.set_default_tensor_type('torch.FloatTensor')
Expand Down