1import torch 2 3 4""" 5tensor_factory_functions defines the list of torch functions that create tensors. 6The list is grabbed by searching thru native_functions.yaml by the following 7regular expression: 8 9 cat native_functions.yaml | grep 'func:' | grep -v "Tensor.*->" | grep "[-]>.*Tensor" 10 11It's possible that new tensor factory functions are added making this list stale. 12Use at your own risk or regenerate the list. 13""" 14tensor_factory_functions = ( 15 torch._cudnn_init_dropout_state, 16 torch.arange, 17 torch.bartlett_window, 18 torch.blackman_window, 19 torch._empty_affine_quantized, 20 torch.empty_strided, 21 torch.eye, 22 torch.full, 23 torch.from_file, 24 torch.hann_window, 25 torch.hamming_window, 26 torch.kaiser_window, 27 torch.linspace, 28 torch.logspace, 29 torch.ones, 30 torch.scalar_tensor, 31 torch.rand, 32 torch.randint, 33 torch.randn, 34 torch.randperm, 35 torch.range, 36 torch._efficientzerotensor, 37 torch.zeros, 38 torch.tril_indices, 39 torch.triu_indices, 40 # Note: the following functions match the regular expression search above but 41 # they are not available in the torch module. Comment out. 42 # torch._sparse_coo_tensor_with_dims, 43 # torch.fft_fftfreq, 44 # torch.fft_rfftfreq, 45) + ( 46 # torch.tensor is special since it's not in native_functions.yaml 47 # add it separately 48 torch.tensor, 49) 50