Add files using upload-large-folder tool
Browse files- LTA_openwebtext_dualt/logs/elfaligned_t5record_4gpu/lta_owt_t5record_len1024_elfaligned_dditelf_muon_logitnormal_m1p5_s0p8_none_floor0p0_zeroout_tf32_gbs512_4gpu_log10_20260516_012826.log +314 -0
- LTA_openwebtext_dualt/logs/owt_len1024_lognormal_sampler_trials/step7k_antisharpen_endpointonly_modelt_step_t_temp2_tau1_finalt1_n128.log +186 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/_core/__init__.py +4 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/_core/__init__.pyi +0 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/_core/_dtype_ctypes.py +6 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/_core/multiarray.py +6 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/_core/umath.py +6 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/__init__.py +194 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/__main__.py +5 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/_src_pyf.py +239 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/cfuncs.py +1536 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/common_rules.py +146 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/diagnose.py +154 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/f2py2e.py +768 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/f90mod_rules.py +264 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/func2subr.py +323 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/rules.py +1568 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/setup.cfg +3 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/symbolic.py +1517 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/logs/owt_t5_elftokenized_full_len1024_C1_to_1024_pow1_d768_l12_h12_gbs512_8gpu_50ep_lr3e4_elfopt_t5embed_unfixed_stateprobadd_selfcond_ce_fast_20260531_225829.log +875 -0
LTA_openwebtext_dualt/logs/elfaligned_t5record_4gpu/lta_owt_t5record_len1024_elfaligned_dditelf_muon_logitnormal_m1p5_s0p8_none_floor0p0_zeroout_tf32_gbs512_4gpu_log10_20260516_012826.log
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
NCCL version 2.25.1+cuda12.8
|
| 2 |
+
{
|
| 3 |
+
"device": "cuda:0",
|
| 4 |
+
"rank": 0,
|
| 5 |
+
"world_size": 4,
|
| 6 |
+
"samples": "record_pad_truncate:pad=0:add_eos=0:add_special=0:shuffle_buffer=10000",
|
| 7 |
+
"vocab_size": 32100,
|
| 8 |
+
"tokenizer_vocab_size": 32100,
|
| 9 |
+
"save_dir": "runs/lta_owt_t5record_len1024_elfaligned_dditelf_muon_logitnormal_m1p5_s0p8_none_floor0p0_zeroout_tf32_gbs512_4gpu_log10_20260516_012826",
|
| 10 |
+
"batch_size": 32,
|
| 11 |
+
"grad_accum": 4,
|
| 12 |
+
"effective_batch_size": 512,
|
| 13 |
+
"global_batch_size": 512,
|
| 14 |
+
"lr_schedule": "constant_warmup",
|
| 15 |
+
"optimizer": "muon",
|
| 16 |
+
"epochs": 5.0,
|
| 17 |
+
"steps_per_epoch": 15457,
|
| 18 |
+
"total_steps": 77285,
|
| 19 |
+
"warmup_steps": 7729,
|
| 20 |
+
"warmup_epochs": 0.5,
|
| 21 |
+
"min_lr": 0.0,
|
| 22 |
+
"weight_decay": 0.0,
|
| 23 |
+
"output_weight_decay": -1.0,
|
| 24 |
+
"adamw_param_groups": "nanogpt",
|
| 25 |
+
"adam_beta1": 0.9,
|
| 26 |
+
"adam_beta2": 0.999,
|
| 27 |
+
"adam_eps": 1e-08,
|
| 28 |
+
"muon_impl": "optax",
|
| 29 |
+
"muon_momentum": 0.95,
|
| 30 |
+
"muon_ns_steps": 5,
|
| 31 |
+
"muon_update_scale": 1.0,
|
| 32 |
+
"muon_nesterov": true,
|
| 33 |
+
"muon_width_scale": true,
|
| 34 |
+
"muon_grouping": "hidden_2d",
|
| 35 |
+
"muon_param_count": 84934656,
|
| 36 |
+
"muon_adam_param_count": 50212608,
|
| 37 |
+
"muon_param_names": [
|
| 38 |
+
"blocks.0.attn_qkv.weight",
|
| 39 |
+
"blocks.0.attn_out.weight",
|
| 40 |
+
"blocks.0.mlp.w12.weight",
|
| 41 |
+
"blocks.0.mlp.w3.weight",
|
| 42 |
+
"blocks.1.attn_qkv.weight",
|
| 43 |
+
"blocks.1.attn_out.weight",
|
| 44 |
+
"blocks.1.mlp.w12.weight",
|
| 45 |
+
"blocks.1.mlp.w3.weight",
|
| 46 |
+
"blocks.2.attn_qkv.weight",
|
| 47 |
+
"blocks.2.attn_out.weight",
|
| 48 |
+
"blocks.2.mlp.w12.weight",
|
| 49 |
+
"blocks.2.mlp.w3.weight",
|
| 50 |
+
"blocks.3.attn_qkv.weight",
|
| 51 |
+
"blocks.3.attn_out.weight",
|
| 52 |
+
"blocks.3.mlp.w12.weight",
|
| 53 |
+
"blocks.3.mlp.w3.weight",
|
| 54 |
+
"blocks.4.attn_qkv.weight",
|
| 55 |
+
"blocks.4.attn_out.weight",
|
| 56 |
+
"blocks.4.mlp.w12.weight",
|
| 57 |
+
"blocks.4.mlp.w3.weight",
|
| 58 |
+
"blocks.5.attn_qkv.weight",
|
| 59 |
+
"blocks.5.attn_out.weight",
|
| 60 |
+
"blocks.5.mlp.w12.weight",
|
| 61 |
+
"blocks.5.mlp.w3.weight",
|
| 62 |
+
"blocks.6.attn_qkv.weight",
|
| 63 |
+
"blocks.6.attn_out.weight",
|
| 64 |
+
"blocks.6.mlp.w12.weight",
|
| 65 |
+
"blocks.6.mlp.w3.weight",
|
| 66 |
+
"blocks.7.attn_qkv.weight",
|
| 67 |
+
"blocks.7.attn_out.weight",
|
| 68 |
+
"blocks.7.mlp.w12.weight",
|
| 69 |
+
"blocks.7.mlp.w3.weight",
|
| 70 |
+
"blocks.8.attn_qkv.weight",
|
| 71 |
+
"blocks.8.attn_out.weight",
|
| 72 |
+
"blocks.8.mlp.w12.weight",
|
| 73 |
+
"blocks.8.mlp.w3.weight",
|
| 74 |
+
"blocks.9.attn_qkv.weight",
|
| 75 |
+
"blocks.9.attn_out.weight",
|
| 76 |
+
"blocks.9.mlp.w12.weight",
|
| 77 |
+
"blocks.9.mlp.w3.weight",
|
| 78 |
+
"blocks.10.attn_qkv.weight",
|
| 79 |
+
"blocks.10.attn_out.weight",
|
| 80 |
+
"blocks.10.mlp.w12.weight",
|
| 81 |
+
"blocks.10.mlp.w3.weight",
|
| 82 |
+
"blocks.11.attn_qkv.weight",
|
| 83 |
+
"blocks.11.attn_out.weight",
|
| 84 |
+
"blocks.11.mlp.w12.weight",
|
| 85 |
+
"blocks.11.mlp.w3.weight"
|
| 86 |
+
],
|
| 87 |
+
"muon_adam_param_names": [
|
| 88 |
+
"time_tokens",
|
| 89 |
+
"vocab_embed.embedding",
|
| 90 |
+
"sigma_map.net.0.weight",
|
| 91 |
+
"sigma_map.net.0.bias",
|
| 92 |
+
"sigma_map.net.2.weight",
|
| 93 |
+
"sigma_map.net.2.bias",
|
| 94 |
+
"blocks.0.norm1.weight",
|
| 95 |
+
"blocks.0.attn_qkv.bias",
|
| 96 |
+
"blocks.0.attn_out.bias",
|
| 97 |
+
"blocks.0.q_norm.weight",
|
| 98 |
+
"blocks.0.k_norm.weight",
|
| 99 |
+
"blocks.0.norm2.weight",
|
| 100 |
+
"blocks.0.mlp.w12.bias",
|
| 101 |
+
"blocks.0.mlp.w3.bias",
|
| 102 |
+
"blocks.1.norm1.weight",
|
| 103 |
+
"blocks.1.attn_qkv.bias",
|
| 104 |
+
"blocks.1.attn_out.bias",
|
| 105 |
+
"blocks.1.q_norm.weight",
|
| 106 |
+
"blocks.1.k_norm.weight",
|
| 107 |
+
"blocks.1.norm2.weight",
|
| 108 |
+
"blocks.1.mlp.w12.bias",
|
| 109 |
+
"blocks.1.mlp.w3.bias",
|
| 110 |
+
"blocks.2.norm1.weight",
|
| 111 |
+
"blocks.2.attn_qkv.bias",
|
| 112 |
+
"blocks.2.attn_out.bias",
|
| 113 |
+
"blocks.2.q_norm.weight",
|
| 114 |
+
"blocks.2.k_norm.weight",
|
| 115 |
+
"blocks.2.norm2.weight",
|
| 116 |
+
"blocks.2.mlp.w12.bias",
|
| 117 |
+
"blocks.2.mlp.w3.bias",
|
| 118 |
+
"blocks.3.norm1.weight",
|
| 119 |
+
"blocks.3.attn_qkv.bias",
|
| 120 |
+
"blocks.3.attn_out.bias",
|
| 121 |
+
"blocks.3.q_norm.weight",
|
| 122 |
+
"blocks.3.k_norm.weight",
|
| 123 |
+
"blocks.3.norm2.weight",
|
| 124 |
+
"blocks.3.mlp.w12.bias",
|
| 125 |
+
"blocks.3.mlp.w3.bias",
|
| 126 |
+
"blocks.4.norm1.weight",
|
| 127 |
+
"blocks.4.attn_qkv.bias",
|
| 128 |
+
"blocks.4.attn_out.bias",
|
| 129 |
+
"blocks.4.q_norm.weight",
|
| 130 |
+
"blocks.4.k_norm.weight",
|
| 131 |
+
"blocks.4.norm2.weight",
|
| 132 |
+
"blocks.4.mlp.w12.bias",
|
| 133 |
+
"blocks.4.mlp.w3.bias",
|
| 134 |
+
"blocks.5.norm1.weight",
|
| 135 |
+
"blocks.5.attn_qkv.bias",
|
| 136 |
+
"blocks.5.attn_out.bias",
|
| 137 |
+
"blocks.5.q_norm.weight",
|
| 138 |
+
"blocks.5.k_norm.weight",
|
| 139 |
+
"blocks.5.norm2.weight",
|
| 140 |
+
"blocks.5.mlp.w12.bias",
|
| 141 |
+
"blocks.5.mlp.w3.bias",
|
| 142 |
+
"blocks.6.norm1.weight",
|
| 143 |
+
"blocks.6.attn_qkv.bias",
|
| 144 |
+
"blocks.6.attn_out.bias",
|
| 145 |
+
"blocks.6.q_norm.weight",
|
| 146 |
+
"blocks.6.k_norm.weight",
|
| 147 |
+
"blocks.6.norm2.weight",
|
| 148 |
+
"blocks.6.mlp.w12.bias",
|
| 149 |
+
"blocks.6.mlp.w3.bias",
|
| 150 |
+
"blocks.7.norm1.weight",
|
| 151 |
+
"blocks.7.attn_qkv.bias",
|
| 152 |
+
"blocks.7.attn_out.bias",
|
| 153 |
+
"blocks.7.q_norm.weight",
|
| 154 |
+
"blocks.7.k_norm.weight",
|
| 155 |
+
"blocks.7.norm2.weight",
|
| 156 |
+
"blocks.7.mlp.w12.bias",
|
| 157 |
+
"blocks.7.mlp.w3.bias",
|
| 158 |
+
"blocks.8.norm1.weight",
|
| 159 |
+
"blocks.8.attn_qkv.bias",
|
| 160 |
+
"blocks.8.attn_out.bias",
|
| 161 |
+
"blocks.8.q_norm.weight",
|
| 162 |
+
"blocks.8.k_norm.weight",
|
| 163 |
+
"blocks.8.norm2.weight",
|
| 164 |
+
"blocks.8.mlp.w12.bias",
|
| 165 |
+
"blocks.8.mlp.w3.bias",
|
| 166 |
+
"blocks.9.norm1.weight",
|
| 167 |
+
"blocks.9.attn_qkv.bias",
|
| 168 |
+
"blocks.9.attn_out.bias",
|
| 169 |
+
"blocks.9.q_norm.weight",
|
| 170 |
+
"blocks.9.k_norm.weight",
|
| 171 |
+
"blocks.9.norm2.weight",
|
| 172 |
+
"blocks.9.mlp.w12.bias",
|
| 173 |
+
"blocks.9.mlp.w3.bias",
|
| 174 |
+
"blocks.10.norm1.weight",
|
| 175 |
+
"blocks.10.attn_qkv.bias",
|
| 176 |
+
"blocks.10.attn_out.bias",
|
| 177 |
+
"blocks.10.q_norm.weight",
|
| 178 |
+
"blocks.10.k_norm.weight",
|
| 179 |
+
"blocks.10.norm2.weight",
|
| 180 |
+
"blocks.10.mlp.w12.bias",
|
| 181 |
+
"blocks.10.mlp.w3.bias",
|
| 182 |
+
"blocks.11.norm1.weight",
|
| 183 |
+
"blocks.11.attn_qkv.bias",
|
| 184 |
+
"blocks.11.attn_out.bias",
|
| 185 |
+
"blocks.11.q_norm.weight",
|
| 186 |
+
"blocks.11.k_norm.weight",
|
| 187 |
+
"blocks.11.norm2.weight",
|
| 188 |
+
"blocks.11.mlp.w12.bias",
|
| 189 |
+
"blocks.11.mlp.w3.bias",
|
| 190 |
+
"output_layer.norm_final.weight",
|
| 191 |
+
"output_layer.linear.weight"
|
| 192 |
+
],
|
| 193 |
+
"muon_effective_nesterov": true,
|
| 194 |
+
"muon_effective_width_scale": true,
|
| 195 |
+
"muon_effective_weight_decay": 0.0,
|
| 196 |
+
"muon_adam_fallback_nesterov": true,
|
| 197 |
+
"muon_adam_fallback_weight_decay": 0.0,
|
| 198 |
+
"ema_decay": 0.9999,
|
| 199 |
+
"ema_start_step": 0,
|
| 200 |
+
"model_type": "ddit_elf",
|
| 201 |
+
"elf_num_time_tokens": 4,
|
| 202 |
+
"elf_num_model_mode_tokens": 0,
|
| 203 |
+
"qk_norm": true,
|
| 204 |
+
"output_bias": false,
|
| 205 |
+
"output_init_std": 0.0,
|
| 206 |
+
"norm_type": "rmsnorm",
|
| 207 |
+
"t_sampling_mode": "logit_normal",
|
| 208 |
+
"t_sampling_power": 1.0,
|
| 209 |
+
"t_sampling_eps": 0.0001,
|
| 210 |
+
"t_sampling_logit_mean": -1.5,
|
| 211 |
+
"t_sampling_logit_std": 0.8,
|
| 212 |
+
"dual_t": true,
|
| 213 |
+
"corrupt_t_mode": "same",
|
| 214 |
+
"corrupt_min_t": 0.0,
|
| 215 |
+
"corrupt_max_t": 1.0,
|
| 216 |
+
"prefix_block_prob": 0.0,
|
| 217 |
+
"prefix_block_len": 128,
|
| 218 |
+
"mask_ratio_floor_schedule": "none",
|
| 219 |
+
"dirichlet_endpoint_mode": "categorical_dual_t",
|
| 220 |
+
"dirichlet_semantic_t_mode": "same",
|
| 221 |
+
"dirichlet_semantic_t_value": 0.0,
|
| 222 |
+
"dirichlet_semantic_t_curve": "linear",
|
| 223 |
+
"dirichlet_semantic_t_power": 1.0,
|
| 224 |
+
"endpoint_sequence_random_prob_alpha": 0.0,
|
| 225 |
+
"categorical_wrong_from_full_vocab": true,
|
| 226 |
+
"categorical_wrong_from_batch_valid_tokens": false,
|
| 227 |
+
"categorical_wrong_basin_token_ids": "",
|
| 228 |
+
"categorical_wrong_basin_prob": 0.0,
|
| 229 |
+
"categorical_wrong_unigram_prob": 0.0,
|
| 230 |
+
"categorical_wrong_uniform_prob": 0.0,
|
| 231 |
+
"categorical_wrong_corpus_unigram_path": "",
|
| 232 |
+
"categorical_wrong_corpus_unigram_alpha": 1.0,
|
| 233 |
+
"categorical_wrong_basin_shared_prob": 0.0,
|
| 234 |
+
"categorical_wrong_unigram_shared_prob": 0.0,
|
| 235 |
+
"mask_mixture_original_prob": 0.0,
|
| 236 |
+
"mask_mixture_lowk_prob": 0.0,
|
| 237 |
+
"mask_mixture_lowcorrupt_prob": 0.0,
|
| 238 |
+
"mask_mixture_block_prob": 0.0,
|
| 239 |
+
"mask_mixture_all_prob": 0.0,
|
| 240 |
+
"mask_mixture_lowk_clean_tokens": "1,2,4,8,16,32,64",
|
| 241 |
+
"mask_mixture_lowcorrupt_tokens": "1,2,4,8,16,32,64",
|
| 242 |
+
"mask_mixture_block_tokens": "64,128",
|
| 243 |
+
"simplex_bridge_sampler": "dirichlet",
|
| 244 |
+
"logistic_normal_sigma_min": 0.18,
|
| 245 |
+
"logistic_normal_sigma_max": 2.2,
|
| 246 |
+
"logistic_normal_tau_min": 0.65,
|
| 247 |
+
"logistic_normal_tau_max": 1.15,
|
| 248 |
+
"torch_compile": false,
|
| 249 |
+
"compile_mode": "max-autotune",
|
| 250 |
+
"state_format": "prob",
|
| 251 |
+
"target_loss": "hard_ce",
|
| 252 |
+
"meanflow_weight": 0.0,
|
| 253 |
+
"rollout_train_prob": 0.0,
|
| 254 |
+
"rollout_train_steps": 1,
|
| 255 |
+
"rollout_train_infer_steps": 64,
|
| 256 |
+
"rollout_train_temp": 1.45,
|
| 257 |
+
"rollout_train_max_gamma": 1.0,
|
| 258 |
+
"rollout_train_corrupt_only": true,
|
| 259 |
+
"rollout_train_samplewise": false,
|
| 260 |
+
"rollout_train_compute_always": false,
|
| 261 |
+
"bridge_noise_init": "logistic_normal",
|
| 262 |
+
"noise_sigma": -1.0,
|
| 263 |
+
"allow_tf32": true,
|
| 264 |
+
"activation_checkpointing": true,
|
| 265 |
+
"activation_checkpoint_interval": 1,
|
| 266 |
+
"activation_checkpoint_scope": "mlp",
|
| 267 |
+
"ddp_static_graph": false,
|
| 268 |
+
"ddp_gradient_as_bucket_view": true,
|
| 269 |
+
"blocking_data_transfer": false,
|
| 270 |
+
"dataloader_prefetch_factor": 4,
|
| 271 |
+
"full_train_stats": false,
|
| 272 |
+
"tokenized_hf": false,
|
| 273 |
+
"tokenized_pad_token": "pad",
|
| 274 |
+
"elf_conditional_hf": false,
|
| 275 |
+
"record_pad_truncate": true,
|
| 276 |
+
"record_add_eos": false,
|
| 277 |
+
"record_add_special_tokens": false,
|
| 278 |
+
"record_pad_token": "pad",
|
| 279 |
+
"record_shuffle_buffer": 10000,
|
| 280 |
+
"wrap": false,
|
| 281 |
+
"wrap_mode": "stream",
|
| 282 |
+
"wrap_record_buffer_size": 200,
|
| 283 |
+
"owt_cached_chunks": false,
|
| 284 |
+
"owt_chunk_cache_dir": "",
|
| 285 |
+
"owt_chunk_cache_rebuild": false,
|
| 286 |
+
"owt_chunk_cache_write_batch": 4096,
|
| 287 |
+
"owt_exact_repeat_per_chunk": 0,
|
| 288 |
+
"online_chunk_shuffle": false,
|
| 289 |
+
"online_chunk_shuffle_buffer": 10000,
|
| 290 |
+
"openwebtext_split": "train_minus_100k",
|
| 291 |
+
"detokenizer": "auto",
|
| 292 |
+
"resolved_detokenizer": null,
|
| 293 |
+
"num_workers": 8,
|
| 294 |
+
"latest_every": 1000,
|
| 295 |
+
"resume_path": ""
|
| 296 |
+
}
|
| 297 |
+
step=10 epoch=1/5 epoch_step=10/15457 micro_steps=40 elapsed=82.9s lr=2.846423e-06 loss=10.3751 loss_recon=10.3751 loss_meanflow=0.0000 mean_model_t=0.2104 mean_corrupt_t=0.2104 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0067 corrupt_frac=0.5492 acc_corrupt=0.0050 loss_corrupt=10.3751 wrong_frac=0.7897 init_acc_corrupt=0.1191 acc_corrupt_t_0p0_0p2=0.0040 corrupt_frac_t_0p0_0p2=0.5635 acc_corrupt_t_0p2_0p4=0.0057 corrupt_frac_t_0p2_0p4=0.3422 out_w_norm=0.0180 out_g_norm=0.7012 acc_corrupt_t_0p4_0p6=0.0091 corrupt_frac_t_0p4_0p6=0.0939 acc_corrupt_t_0p6_0p8=0.0005 corrupt_frac_t_0p6_0p8=0.0326 loss_all=10.3714 init_gold_top10=0.2049 init_gold_top100=0.4509
|
| 298 |
+
step=20 epoch=1/5 epoch_step=20/15457 micro_steps=80 elapsed=58.3s lr=5.434079e-06 loss=10.3646 loss_recon=10.3646 loss_meanflow=0.0000 mean_model_t=0.2067 mean_corrupt_t=0.2067 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0176 corrupt_frac=0.5599 acc_corrupt=0.0136 loss_corrupt=10.3646 wrong_frac=0.7932 init_acc_corrupt=0.1142 acc_corrupt_t_0p0_0p2=0.0109 corrupt_frac_t_0p0_0p2=0.5547 acc_corrupt_t_0p2_0p4=0.0161 corrupt_frac_t_0p2_0p4=0.3658 acc_corrupt_t_0p4_0p6=0.0202 corrupt_frac_t_0p4_0p6=0.0796 out_w_norm=0.1165 out_g_norm=0.8108 acc_corrupt_t_0p6_0p8=0.0251 corrupt_frac_t_0p6_0p8=0.0300 acc_corrupt_t_0p8_1p0=0.0461 corrupt_frac_t_0p8_1p0=0.0144 loss_all=10.3543 init_gold_top10=0.1608 init_gold_top100=0.4732
|
| 299 |
+
step=30 epoch=1/5 epoch_step=30/15457 micro_steps=120 elapsed=59.1s lr=8.021736e-06 loss=10.3356 loss_recon=10.3356 loss_meanflow=0.0000 mean_model_t=0.2106 mean_corrupt_t=0.2106 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0262 corrupt_frac=0.5559 acc_corrupt=0.0223 loss_corrupt=10.3356 wrong_frac=0.7916 init_acc_corrupt=0.1140 acc_corrupt_t_0p0_0p2=0.0196 corrupt_frac_t_0p0_0p2=0.5743 acc_corrupt_t_0p2_0p4=0.0252 corrupt_frac_t_0p2_0p4=0.3388 acc_corrupt_t_0p4_0p6=0.0279 corrupt_frac_t_0p4_0p6=0.0833 out_w_norm=0.3097 out_g_norm=1.0121 acc_corrupt_t_0p6_0p8=0.0338 corrupt_frac_t_0p6_0p8=0.0308 loss_all=10.3136 init_gold_top10=0.1666 init_gold_top100=0.4592
|
| 300 |
+
step=40 epoch=1/5 epoch_step=40/15457 micro_steps=160 elapsed=59.4s lr=1.060939e-05 loss=10.2804 loss_recon=10.2804 loss_meanflow=0.0000 mean_model_t=0.2059 mean_corrupt_t=0.2059 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0337 corrupt_frac=0.5464 acc_corrupt=0.0291 loss_corrupt=10.2804 wrong_frac=0.7954 init_acc_corrupt=0.1110 acc_corrupt_t_0p0_0p2=0.0267 corrupt_frac_t_0p0_0p2=0.5796 acc_corrupt_t_0p2_0p4=0.0316 corrupt_frac_t_0p2_0p4=0.3323 acc_corrupt_t_0p4_0p6=0.0360 corrupt_frac_t_0p4_0p6=0.0803 out_w_norm=0.5994 out_g_norm=1.2142 acc_corrupt_t_0p6_0p8=0.0358 corrupt_frac_t_0p6_0p8=0.0576 loss_all=10.2476 init_gold_top10=0.1957 init_gold_top100=0.4552
|
| 301 |
+
step=50 epoch=1/5 epoch_step=50/15457 micro_steps=200 elapsed=59.7s lr=1.319705e-05 loss=10.1962 loss_recon=10.1962 loss_meanflow=0.0000 mean_model_t=0.2069 mean_corrupt_t=0.2069 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0298 corrupt_frac=0.5491 acc_corrupt=0.0263 loss_corrupt=10.1962 wrong_frac=0.7932 init_acc_corrupt=0.1132 acc_corrupt_t_0p0_0p2=0.0255 corrupt_frac_t_0p0_0p2=0.5689 acc_corrupt_t_0p2_0p4=0.0268 corrupt_frac_t_0p2_0p4=0.3406 out_w_norm=0.9906 out_g_norm=1.3684 acc_corrupt_t_0p4_0p6=0.0297 corrupt_frac_t_0p4_0p6=0.0891 acc_corrupt_t_0p6_0p8=0.0271 corrupt_frac_t_0p6_0p8=0.0272 loss_all=10.1552 init_gold_top10=0.2206 init_gold_top100=0.4509
|
| 302 |
+
step=60 epoch=1/5 epoch_step=60/15457 micro_steps=240 elapsed=59.8s lr=1.578471e-05 loss=10.0900 loss_recon=10.0900 loss_meanflow=0.0000 mean_model_t=0.2029 mean_corrupt_t=0.2029 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0308 corrupt_frac=0.5452 acc_corrupt=0.0283 loss_corrupt=10.0900 wrong_frac=0.7988 init_acc_corrupt=0.1091 acc_corrupt_t_0p0_0p2=0.0272 corrupt_frac_t_0p0_0p2=0.5894 acc_corrupt_t_0p2_0p4=0.0288 corrupt_frac_t_0p2_0p4=0.3253 acc_corrupt_t_0p4_0p6=0.0337 corrupt_frac_t_0p4_0p6=0.0800 out_w_norm=1.4867 out_g_norm=1.4314 acc_corrupt_t_0p6_0p8=0.0343 corrupt_frac_t_0p6_0p8=0.0407 loss_all=10.0334 init_gold_top10=0.1659 init_gold_top100=0.4559
|
| 303 |
+
step=70 epoch=1/5 epoch_step=70/15457 micro_steps=280 elapsed=59.7s lr=1.837236e-05 loss=9.9604 loss_recon=9.9604 loss_meanflow=0.0000 mean_model_t=0.2105 mean_corrupt_t=0.2105 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0314 corrupt_frac=0.5514 acc_corrupt=0.0307 loss_corrupt=9.9604 wrong_frac=0.7883 init_acc_corrupt=0.1187 acc_corrupt_t_0p0_0p2=0.0304 corrupt_frac_t_0p0_0p2=0.5505 acc_corrupt_t_0p2_0p4=0.0310 corrupt_frac_t_0p2_0p4=0.3561 out_w_norm=2.0892 out_g_norm=1.4757 acc_corrupt_t_0p4_0p6=0.0315 corrupt_frac_t_0p4_0p6=0.0822 acc_corrupt_t_0p6_0p8=0.0345 corrupt_frac_t_0p6_0p8=0.0454 loss_all=9.9054 init_gold_top10=0.1834 init_gold_top100=0.4583
|
| 304 |
+
step=80 epoch=1/5 epoch_step=80/15457 micro_steps=320 elapsed=59.8s lr=2.096002e-05 loss=9.8077 loss_recon=9.8077 loss_meanflow=0.0000 mean_model_t=0.2098 mean_corrupt_t=0.2098 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0252 corrupt_frac=0.5554 acc_corrupt=0.0247 loss_corrupt=9.8077 wrong_frac=0.7907 init_acc_corrupt=0.1167 acc_corrupt_t_0p0_0p2=0.0242 corrupt_frac_t_0p0_0p2=0.5708 acc_corrupt_t_0p2_0p4=0.0257 corrupt_frac_t_0p2_0p4=0.3471 acc_corrupt_t_0p4_0p6=0.0244 corrupt_frac_t_0p4_0p6=0.0838 out_w_norm=2.7953 out_g_norm=1.5003 acc_corrupt_t_0p6_0p8=0.0209 corrupt_frac_t_0p6_0p8=0.0223 loss_all=9.7329 init_gold_top10=0.1639 init_gold_top100=0.4471
|
| 305 |
+
step=90 epoch=1/5 epoch_step=90/15457 micro_steps=360 elapsed=59.9s lr=2.354768e-05 loss=9.6373 loss_recon=9.6373 loss_meanflow=0.0000 mean_model_t=0.2147 mean_corrupt_t=0.2147 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0296 corrupt_frac=0.5415 acc_corrupt=0.0294 loss_corrupt=9.6373 wrong_frac=0.7831 init_acc_corrupt=0.1284 acc_corrupt_t_0p0_0p2=0.0294 corrupt_frac_t_0p0_0p2=0.5417 acc_corrupt_t_0p2_0p4=0.0298 corrupt_frac_t_0p2_0p4=0.3508 acc_corrupt_t_0p4_0p6=0.0288 corrupt_frac_t_0p4_0p6=0.1069 out_w_norm=3.5981 out_g_norm=1.5098 acc_corrupt_t_0p6_0p8=0.0230 corrupt_frac_t_0p6_0p8=0.0285 loss_all=9.5506 init_gold_top10=0.2271 init_gold_top100=0.4645
|
| 306 |
+
step=100 epoch=1/5 epoch_step=100/15457 micro_steps=400 elapsed=60.1s lr=2.613533e-05 loss=9.4540 loss_recon=9.4540 loss_meanflow=0.0000 mean_model_t=0.2131 mean_corrupt_t=0.2131 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0317 corrupt_frac=0.5573 acc_corrupt=0.0315 loss_corrupt=9.4540 wrong_frac=0.7873 init_acc_corrupt=0.1238 acc_corrupt_t_0p0_0p2=0.0308 corrupt_frac_t_0p0_0p2=0.5582 acc_corrupt_t_0p2_0p4=0.0320 corrupt_frac_t_0p2_0p4=0.3366 acc_corrupt_t_0p4_0p6=0.0342 corrupt_frac_t_0p4_0p6=0.0930 out_w_norm=4.4906 out_g_norm=1.5218 acc_corrupt_t_0p6_0p8=0.0300 corrupt_frac_t_0p6_0p8=0.0422 loss_all=9.3803 init_gold_top10=0.1560 init_gold_top100=0.4675
|
| 307 |
+
step=110 epoch=1/5 epoch_step=110/15457 micro_steps=440 elapsed=59.9s lr=2.872299e-05 loss=9.2567 loss_recon=9.2567 loss_meanflow=0.0000 mean_model_t=0.2037 mean_corrupt_t=0.2037 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0321 corrupt_frac=0.5506 acc_corrupt=0.0318 loss_corrupt=9.2567 wrong_frac=0.7989 init_acc_corrupt=0.1086 acc_corrupt_t_0p0_0p2=0.0316 corrupt_frac_t_0p0_0p2=0.6028 acc_corrupt_t_0p2_0p4=0.0317 corrupt_frac_t_0p2_0p4=0.3192 acc_corrupt_t_0p4_0p6=0.0331 corrupt_frac_t_0p4_0p6=0.0763 out_w_norm=5.4613 out_g_norm=1.5224 acc_corrupt_t_0p6_0p8=0.0348 corrupt_frac_t_0p6_0p8=0.0332 acc_corrupt_t_0p8_1p0=0.0345 corrupt_frac_t_0p8_1p0=0.0539 loss_all=9.2128 init_gold_top10=0.2641 init_gold_top100=0.4048
|
| 308 |
+
step=120 epoch=1/5 epoch_step=120/15457 micro_steps=480 elapsed=59.8s lr=3.131065e-05 loss=9.0491 loss_recon=9.0491 loss_meanflow=0.0000 mean_model_t=0.2123 mean_corrupt_t=0.2123 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0374 corrupt_frac=0.5576 acc_corrupt=0.0350 loss_corrupt=9.0491 wrong_frac=0.7869 init_acc_corrupt=0.1216 acc_corrupt_t_0p0_0p2=0.0346 corrupt_frac_t_0p0_0p2=0.5469 acc_corrupt_t_0p2_0p4=0.0352 corrupt_frac_t_0p2_0p4=0.3642 acc_corrupt_t_0p4_0p6=0.0348 corrupt_frac_t_0p4_0p6=0.0788 out_w_norm=6.4995 out_g_norm=1.5237 acc_corrupt_t_0p6_0p8=0.0447 corrupt_frac_t_0p6_0p8=0.0516 loss_all=8.9826 init_gold_top10=0.1500 init_gold_top100=0.4692
|
| 309 |
+
step=130 epoch=1/5 epoch_step=130/15457 micro_steps=520 elapsed=60.1s lr=3.389831e-05 loss=8.8358 loss_recon=8.8358 loss_meanflow=0.0000 mean_model_t=0.2087 mean_corrupt_t=0.2087 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0445 corrupt_frac=0.5479 acc_corrupt=0.0424 loss_corrupt=8.8358 wrong_frac=0.7932 init_acc_corrupt=0.1118 acc_corrupt_t_0p0_0p2=0.0418 corrupt_frac_t_0p0_0p2=0.5631 acc_corrupt_t_0p2_0p4=0.0426 corrupt_frac_t_0p2_0p4=0.3558 acc_corrupt_t_0p4_0p6=0.0453 corrupt_frac_t_0p4_0p6=0.0789 out_w_norm=7.5927 out_g_norm=1.5287 acc_corrupt_t_0p6_0p8=0.0400 corrupt_frac_t_0p6_0p8=0.0237 loss_all=8.7550 init_gold_top10=0.1693 init_gold_top100=0.4652
|
| 310 |
+
step=140 epoch=1/5 epoch_step=140/15457 micro_steps=560 elapsed=59.8s lr=3.648596e-05 loss=8.6275 loss_recon=8.6275 loss_meanflow=0.0000 mean_model_t=0.2114 mean_corrupt_t=0.2114 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0423 corrupt_frac=0.5500 acc_corrupt=0.0425 loss_corrupt=8.6275 wrong_frac=0.7878 init_acc_corrupt=0.1196 acc_corrupt_t_0p0_0p2=0.0432 corrupt_frac_t_0p0_0p2=0.5286 acc_corrupt_t_0p2_0p4=0.0415 corrupt_frac_t_0p2_0p4=0.3890 acc_corrupt_t_0p4_0p6=0.0430 corrupt_frac_t_0p4_0p6=0.0745 out_w_norm=8.7322 out_g_norm=1.5119 acc_corrupt_t_0p6_0p8=0.0455 corrupt_frac_t_0p6_0p8=0.0368 loss_all=8.5374 init_gold_top10=0.1540 init_gold_top100=0.4626
|
| 311 |
+
step=150 epoch=1/5 epoch_step=150/15457 micro_steps=600 elapsed=59.8s lr=3.907362e-05 loss=8.4065 loss_recon=8.4065 loss_meanflow=0.0000 mean_model_t=0.2073 mean_corrupt_t=0.2073 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0422 corrupt_frac=0.5433 acc_corrupt=0.0422 loss_corrupt=8.4065 wrong_frac=0.7948 init_acc_corrupt=0.1099 acc_corrupt_t_0p0_0p2=0.0427 corrupt_frac_t_0p0_0p2=0.5877 acc_corrupt_t_0p2_0p4=0.0414 corrupt_frac_t_0p2_0p4=0.3346 acc_corrupt_t_0p4_0p6=0.0420 corrupt_frac_t_0p4_0p6=0.0730 acc_corrupt_t_0p6_0p8=0.0331 corrupt_frac_t_0p6_0p8=0.0167 acc_corrupt_t_0p8_1p0=0.0485 corrupt_frac_t_0p8_1p0=0.0209 out_w_norm=9.9061 out_g_norm=1.4982 loss_all=8.3043 init_gold_top10=0.1943 init_gold_top100=0.4519
|
| 312 |
+
step=160 epoch=1/5 epoch_step=160/15457 micro_steps=640 elapsed=59.8s lr=4.166128e-05 loss=8.2023 loss_recon=8.2023 loss_meanflow=0.0000 mean_model_t=0.2147 mean_corrupt_t=0.2147 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0429 corrupt_frac=0.5405 acc_corrupt=0.0431 loss_corrupt=8.2023 wrong_frac=0.7852 init_acc_corrupt=0.1198 acc_corrupt_t_0p0_0p2=0.0431 corrupt_frac_t_0p0_0p2=0.5280 acc_corrupt_t_0p2_0p4=0.0435 corrupt_frac_t_0p2_0p4=0.3825 acc_corrupt_t_0p4_0p6=0.0409 corrupt_frac_t_0p4_0p6=0.0857 out_w_norm=11.1037 out_g_norm=1.4873 acc_corrupt_t_0p6_0p8=0.0413 corrupt_frac_t_0p6_0p8=0.0429 loss_all=8.1360 init_gold_top10=0.1755 init_gold_top100=0.4461
|
| 313 |
+
step=170 epoch=1/5 epoch_step=170/15457 micro_steps=680 elapsed=59.8s lr=4.424893e-05 loss=8.0012 loss_recon=8.0012 loss_meanflow=0.0000 mean_model_t=0.2117 mean_corrupt_t=0.2117 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0427 corrupt_frac=0.5484 acc_corrupt=0.0432 loss_corrupt=8.0012 wrong_frac=0.7896 init_acc_corrupt=0.1186 acc_corrupt_t_0p0_0p2=0.0425 corrupt_frac_t_0p0_0p2=0.5687 acc_corrupt_t_0p2_0p4=0.0433 corrupt_frac_t_0p2_0p4=0.3384 acc_corrupt_t_0p6_0p8=0.0439 corrupt_frac_t_0p6_0p8=0.0299 out_w_norm=12.3163 out_g_norm=1.4487 acc_corrupt_t_0p4_0p6=0.0471 corrupt_frac_t_0p4_0p6=0.0916 loss_all=7.8335 init_gold_top10=0.1526 init_gold_top100=0.4940
|
| 314 |
+
step=180 epoch=1/5 epoch_step=180/15457 micro_steps=720 elapsed=59.9s lr=4.683659e-05 loss=7.8349 loss_recon=7.8349 loss_meanflow=0.0000 mean_model_t=0.2047 mean_corrupt_t=0.2047 mean_loss_t_weight=1.0000 prior_center_loss_beta=0.0000 rollout_train_applied=0.0000 grad_enabled_before_rollout=1.0000 grad_enabled_after_rollout=1.0000 logits_requires_grad=1.0000 raw_loss_requires_grad=1.0000 acc_all=0.0428 corrupt_frac=0.5655 acc_corrupt=0.0425 loss_corrupt=7.8349 wrong_frac=0.7994 init_acc_corrupt=0.1058 acc_corrupt_t_0p0_0p2=0.0424 corrupt_frac_t_0p0_0p2=0.5883 acc_corrupt_t_0p2_0p4=0.0426 corrupt_frac_t_0p2_0p4=0.3398 acc_corrupt_t_0p4_0p6=0.0425 corrupt_frac_t_0p4_0p6=0.0739 out_w_norm=13.5342 out_g_norm=1.3832 acc_corrupt_t_0p6_0p8=0.0485 corrupt_frac_t_0p6_0p8=0.0194 loss_all=7.8063 init_gold_top10=0.1552 init_gold_top100=0.4545
|
LTA_openwebtext_dualt/logs/owt_len1024_lognormal_sampler_trials/step7k_antisharpen_endpointonly_modelt_step_t_temp2_tau1_finalt1_n128.log
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[load] runs/lta_owt_classic_fullvocab_bert_c1024_len1024_lognormalatoms_smax3.0_abspos0_d768_l12_h12_ff3072_lr3e-4_gbs512_2node8gpu_1m_save1k_t-20260523052744-twlvs/step_0007000.pt
|
| 2 |
+
[ckpt] step=7000
|
| 3 |
+
[sde] generated 1/128
|
| 4 |
+
[sde] generated 2/128
|
| 5 |
+
[sde] generated 3/128
|
| 6 |
+
[sde] generated 4/128
|
| 7 |
+
[sde] generated 5/128
|
| 8 |
+
[sde] generated 6/128
|
| 9 |
+
[sde] generated 7/128
|
| 10 |
+
[sde] generated 8/128
|
| 11 |
+
[sde] generated 9/128
|
| 12 |
+
[sde] generated 10/128
|
| 13 |
+
[sde] generated 11/128
|
| 14 |
+
[sde] generated 12/128
|
| 15 |
+
[sde] generated 13/128
|
| 16 |
+
[sde] generated 14/128
|
| 17 |
+
[sde] generated 15/128
|
| 18 |
+
[sde] generated 16/128
|
| 19 |
+
[sde] generated 17/128
|
| 20 |
+
[sde] generated 18/128
|
| 21 |
+
[sde] generated 19/128
|
| 22 |
+
[sde] generated 20/128
|
| 23 |
+
[sde] generated 21/128
|
| 24 |
+
[sde] generated 22/128
|
| 25 |
+
[sde] generated 23/128
|
| 26 |
+
[sde] generated 24/128
|
| 27 |
+
[sde] generated 25/128
|
| 28 |
+
[sde] generated 26/128
|
| 29 |
+
[sde] generated 27/128
|
| 30 |
+
[sde] generated 28/128
|
| 31 |
+
[sde] generated 29/128
|
| 32 |
+
[sde] generated 30/128
|
| 33 |
+
[sde] generated 31/128
|
| 34 |
+
[sde] generated 32/128
|
| 35 |
+
[sde] generated 33/128
|
| 36 |
+
[sde] generated 34/128
|
| 37 |
+
[sde] generated 35/128
|
| 38 |
+
[sde] generated 36/128
|
| 39 |
+
[sde] generated 37/128
|
| 40 |
+
[sde] generated 38/128
|
| 41 |
+
[sde] generated 39/128
|
| 42 |
+
[sde] generated 40/128
|
| 43 |
+
[sde] generated 41/128
|
| 44 |
+
[sde] generated 42/128
|
| 45 |
+
[sde] generated 43/128
|
| 46 |
+
[sde] generated 44/128
|
| 47 |
+
[sde] generated 45/128
|
| 48 |
+
[sde] generated 46/128
|
| 49 |
+
[sde] generated 47/128
|
| 50 |
+
[sde] generated 48/128
|
| 51 |
+
[sde] generated 49/128
|
| 52 |
+
[sde] generated 50/128
|
| 53 |
+
[sde] generated 51/128
|
| 54 |
+
[sde] generated 52/128
|
| 55 |
+
[sde] generated 53/128
|
| 56 |
+
[sde] generated 54/128
|
| 57 |
+
[sde] generated 55/128
|
| 58 |
+
[sde] generated 56/128
|
| 59 |
+
[sde] generated 57/128
|
| 60 |
+
[sde] generated 58/128
|
| 61 |
+
[sde] generated 59/128
|
| 62 |
+
[sde] generated 60/128
|
| 63 |
+
[sde] generated 61/128
|
| 64 |
+
[sde] generated 62/128
|
| 65 |
+
[sde] generated 63/128
|
| 66 |
+
[sde] generated 64/128
|
| 67 |
+
[sde] generated 65/128
|
| 68 |
+
[sde] generated 66/128
|
| 69 |
+
[sde] generated 67/128
|
| 70 |
+
[sde] generated 68/128
|
| 71 |
+
[sde] generated 69/128
|
| 72 |
+
[sde] generated 70/128
|
| 73 |
+
[sde] generated 71/128
|
| 74 |
+
[sde] generated 72/128
|
| 75 |
+
[sde] generated 73/128
|
| 76 |
+
[sde] generated 74/128
|
| 77 |
+
[sde] generated 75/128
|
| 78 |
+
[sde] generated 76/128
|
| 79 |
+
[sde] generated 77/128
|
| 80 |
+
[sde] generated 78/128
|
| 81 |
+
[sde] generated 79/128
|
| 82 |
+
[sde] generated 80/128
|
| 83 |
+
[sde] generated 81/128
|
| 84 |
+
[sde] generated 82/128
|
| 85 |
+
[sde] generated 83/128
|
| 86 |
+
[sde] generated 84/128
|
| 87 |
+
[sde] generated 85/128
|
| 88 |
+
[sde] generated 86/128
|
| 89 |
+
[sde] generated 87/128
|
| 90 |
+
[sde] generated 88/128
|
| 91 |
+
[sde] generated 89/128
|
| 92 |
+
[sde] generated 90/128
|
| 93 |
+
[sde] generated 91/128
|
| 94 |
+
[sde] generated 92/128
|
| 95 |
+
[sde] generated 93/128
|
| 96 |
+
[sde] generated 94/128
|
| 97 |
+
[sde] generated 95/128
|
| 98 |
+
[sde] generated 96/128
|
| 99 |
+
[sde] generated 97/128
|
| 100 |
+
[sde] generated 98/128
|
| 101 |
+
[sde] generated 99/128
|
| 102 |
+
[sde] generated 100/128
|
| 103 |
+
[sde] generated 101/128
|
| 104 |
+
[sde] generated 102/128
|
| 105 |
+
[sde] generated 103/128
|
| 106 |
+
[sde] generated 104/128
|
| 107 |
+
[sde] generated 105/128
|
| 108 |
+
[sde] generated 106/128
|
| 109 |
+
[sde] generated 107/128
|
| 110 |
+
[sde] generated 108/128
|
| 111 |
+
[sde] generated 109/128
|
| 112 |
+
[sde] generated 110/128
|
| 113 |
+
[sde] generated 111/128
|
| 114 |
+
[sde] generated 112/128
|
| 115 |
+
[sde] generated 113/128
|
| 116 |
+
[sde] generated 114/128
|
| 117 |
+
[sde] generated 115/128
|
| 118 |
+
[sde] generated 116/128
|
| 119 |
+
[sde] generated 117/128
|
| 120 |
+
[sde] generated 118/128
|
| 121 |
+
[sde] generated 119/128
|
| 122 |
+
[sde] generated 120/128
|
| 123 |
+
[sde] generated 121/128
|
| 124 |
+
[sde] generated 122/128
|
| 125 |
+
[sde] generated 123/128
|
| 126 |
+
[sde] generated 124/128
|
| 127 |
+
[sde] generated 125/128
|
| 128 |
+
[sde] generated 126/128
|
| 129 |
+
[sde] generated 127/128
|
| 130 |
+
[sde] generated 128/128
|
| 131 |
+
[score] loading scorer: /e2e-data/evad-tech-vla/wanghan58/models/flowtext_scorers/gpt2-large-standard
|
| 132 |
+
[summary] {
|
| 133 |
+
"type": "summary",
|
| 134 |
+
"checkpoint": "runs/lta_owt_classic_fullvocab_bert_c1024_len1024_lognormalatoms_smax3.0_abspos0_d768_l12_h12_ff3072_lr3e-4_gbs512_2node8gpu_1m_save1k_t-20260523052744-twlvs/step_0007000.pt",
|
| 135 |
+
"step": 7000,
|
| 136 |
+
"decode": {
|
| 137 |
+
"decode_rule": "logistic_normal_resample_sde",
|
| 138 |
+
"steps": 128,
|
| 139 |
+
"model_t_mode": "step_t",
|
| 140 |
+
"mean_mode": "endpoint_only",
|
| 141 |
+
"endpoint_floor": 0.0001,
|
| 142 |
+
"concentration_min": 1.0,
|
| 143 |
+
"concentration_max": 1024.0,
|
| 144 |
+
"endpoint_temp": 2.0,
|
| 145 |
+
"support_power": 1.0,
|
| 146 |
+
"semantic_power": 1.0,
|
| 147 |
+
"noise_init": "logistic_normal",
|
| 148 |
+
"noise_sigma": 3.0,
|
| 149 |
+
"noise_dirichlet_concentration": 1.0,
|
| 150 |
+
"sde_resample": "logistic_normal",
|
| 151 |
+
"logistic_normal_sigma_min": 0.18,
|
| 152 |
+
"logistic_normal_sigma_max": 3.0,
|
| 153 |
+
"logistic_normal_tau_min": 1.0,
|
| 154 |
+
"logistic_normal_tau_max": 1.0,
|
| 155 |
+
"final_from": "model_t1",
|
| 156 |
+
"n_samples": 128,
|
| 157 |
+
"seed": 20260522
|
| 158 |
+
},
|
| 159 |
+
"raw_genppl": {
|
| 160 |
+
"ppl": 1.0338466608355,
|
| 161 |
+
"nll_per_token": 0.03328646802482717,
|
| 162 |
+
"tokens": 130944,
|
| 163 |
+
"kept_samples": 128,
|
| 164 |
+
"total_samples": 128,
|
| 165 |
+
"empty_rate": 0.0,
|
| 166 |
+
"skipped_samples": 0
|
| 167 |
+
},
|
| 168 |
+
"stripped_genppl": {
|
| 169 |
+
"ppl": 1.0338466608355,
|
| 170 |
+
"nll_per_token": 0.03328646802482717,
|
| 171 |
+
"tokens": 130944,
|
| 172 |
+
"kept_samples": 128,
|
| 173 |
+
"total_samples": 128,
|
| 174 |
+
"empty_rate": 0.0,
|
| 175 |
+
"skipped_samples": 0
|
| 176 |
+
},
|
| 177 |
+
"diversity": {
|
| 178 |
+
"sample_entropy": 0.020021393598263906,
|
| 179 |
+
"unique_tokens": 5,
|
| 180 |
+
"token_count": 131072,
|
| 181 |
+
"distinct_1": 3.814697265625e-05,
|
| 182 |
+
"distinct_2": 9.927908113391985e-05,
|
| 183 |
+
"top_token_mass": 0.741607666015625
|
| 184 |
+
}
|
| 185 |
+
}
|
| 186 |
+
[done] docs/lta_samples/metrics_20260522/owt_len1024_lognormal_step7k_antisharpen_endpointonly_modelt_step_t_temp2_tau1_finalt1_n128/sde_steps128_samples128_scored.jsonl
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/_core/__init__.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
This private module only contains stubs for interoperability with
|
| 3 |
+
NumPy 2.0 pickled arrays. It may not be used by the end user.
|
| 4 |
+
"""
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/_core/__init__.pyi
ADDED
|
File without changes
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/_core/_dtype_ctypes.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from numpy.core import _dtype_ctypes
|
| 2 |
+
|
| 3 |
+
_globals = globals()
|
| 4 |
+
|
| 5 |
+
for item in _dtype_ctypes.__dir__():
|
| 6 |
+
_globals[item] = getattr(_dtype_ctypes, item)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/_core/multiarray.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from numpy.core import multiarray
|
| 2 |
+
|
| 3 |
+
_globals = globals()
|
| 4 |
+
|
| 5 |
+
for item in multiarray.__dir__():
|
| 6 |
+
_globals[item] = getattr(multiarray, item)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/_core/umath.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from numpy.core import umath
|
| 2 |
+
|
| 3 |
+
_globals = globals()
|
| 4 |
+
|
| 5 |
+
for item in umath.__dir__():
|
| 6 |
+
_globals[item] = getattr(umath, item)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/__init__.py
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Fortran to Python Interface Generator.
|
| 3 |
+
|
| 4 |
+
Copyright 1999 -- 2011 Pearu Peterson all rights reserved.
|
| 5 |
+
Copyright 2011 -- present NumPy Developers.
|
| 6 |
+
Permission to use, modify, and distribute this software is given under the terms
|
| 7 |
+
of the NumPy License.
|
| 8 |
+
|
| 9 |
+
NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
| 10 |
+
"""
|
| 11 |
+
__all__ = ['run_main', 'compile', 'get_include']
|
| 12 |
+
|
| 13 |
+
import sys
|
| 14 |
+
import subprocess
|
| 15 |
+
import os
|
| 16 |
+
import warnings
|
| 17 |
+
|
| 18 |
+
from numpy.exceptions import VisibleDeprecationWarning
|
| 19 |
+
from . import f2py2e
|
| 20 |
+
from . import diagnose
|
| 21 |
+
|
| 22 |
+
run_main = f2py2e.run_main
|
| 23 |
+
main = f2py2e.main
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def compile(source,
|
| 27 |
+
modulename='untitled',
|
| 28 |
+
extra_args='',
|
| 29 |
+
verbose=True,
|
| 30 |
+
source_fn=None,
|
| 31 |
+
extension='.f',
|
| 32 |
+
full_output=False
|
| 33 |
+
):
|
| 34 |
+
"""
|
| 35 |
+
Build extension module from a Fortran 77 source string with f2py.
|
| 36 |
+
|
| 37 |
+
Parameters
|
| 38 |
+
----------
|
| 39 |
+
source : str or bytes
|
| 40 |
+
Fortran source of module / subroutine to compile
|
| 41 |
+
|
| 42 |
+
.. versionchanged:: 1.16.0
|
| 43 |
+
Accept str as well as bytes
|
| 44 |
+
|
| 45 |
+
modulename : str, optional
|
| 46 |
+
The name of the compiled python module
|
| 47 |
+
extra_args : str or list, optional
|
| 48 |
+
Additional parameters passed to f2py
|
| 49 |
+
|
| 50 |
+
.. versionchanged:: 1.16.0
|
| 51 |
+
A list of args may also be provided.
|
| 52 |
+
|
| 53 |
+
verbose : bool, optional
|
| 54 |
+
Print f2py output to screen
|
| 55 |
+
source_fn : str, optional
|
| 56 |
+
Name of the file where the fortran source is written.
|
| 57 |
+
The default is to use a temporary file with the extension
|
| 58 |
+
provided by the ``extension`` parameter
|
| 59 |
+
extension : ``{'.f', '.f90'}``, optional
|
| 60 |
+
Filename extension if `source_fn` is not provided.
|
| 61 |
+
The extension tells which fortran standard is used.
|
| 62 |
+
The default is ``.f``, which implies F77 standard.
|
| 63 |
+
|
| 64 |
+
.. versionadded:: 1.11.0
|
| 65 |
+
|
| 66 |
+
full_output : bool, optional
|
| 67 |
+
If True, return a `subprocess.CompletedProcess` containing
|
| 68 |
+
the stdout and stderr of the compile process, instead of just
|
| 69 |
+
the status code.
|
| 70 |
+
|
| 71 |
+
.. versionadded:: 1.20.0
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
Returns
|
| 75 |
+
-------
|
| 76 |
+
result : int or `subprocess.CompletedProcess`
|
| 77 |
+
0 on success, or a `subprocess.CompletedProcess` if
|
| 78 |
+
``full_output=True``
|
| 79 |
+
|
| 80 |
+
Examples
|
| 81 |
+
--------
|
| 82 |
+
.. literalinclude:: ../../source/f2py/code/results/compile_session.dat
|
| 83 |
+
:language: python
|
| 84 |
+
|
| 85 |
+
"""
|
| 86 |
+
import tempfile
|
| 87 |
+
import shlex
|
| 88 |
+
|
| 89 |
+
if source_fn is None:
|
| 90 |
+
f, fname = tempfile.mkstemp(suffix=extension)
|
| 91 |
+
# f is a file descriptor so need to close it
|
| 92 |
+
# carefully -- not with .close() directly
|
| 93 |
+
os.close(f)
|
| 94 |
+
else:
|
| 95 |
+
fname = source_fn
|
| 96 |
+
|
| 97 |
+
if not isinstance(source, str):
|
| 98 |
+
source = str(source, 'utf-8')
|
| 99 |
+
try:
|
| 100 |
+
with open(fname, 'w') as f:
|
| 101 |
+
f.write(source)
|
| 102 |
+
|
| 103 |
+
args = ['-c', '-m', modulename, f.name]
|
| 104 |
+
|
| 105 |
+
if isinstance(extra_args, str):
|
| 106 |
+
is_posix = (os.name == 'posix')
|
| 107 |
+
extra_args = shlex.split(extra_args, posix=is_posix)
|
| 108 |
+
|
| 109 |
+
args.extend(extra_args)
|
| 110 |
+
|
| 111 |
+
c = [sys.executable,
|
| 112 |
+
'-c',
|
| 113 |
+
'import numpy.f2py as f2py2e;f2py2e.main()'] + args
|
| 114 |
+
try:
|
| 115 |
+
cp = subprocess.run(c, capture_output=True)
|
| 116 |
+
except OSError:
|
| 117 |
+
# preserve historic status code used by exec_command()
|
| 118 |
+
cp = subprocess.CompletedProcess(c, 127, stdout=b'', stderr=b'')
|
| 119 |
+
else:
|
| 120 |
+
if verbose:
|
| 121 |
+
print(cp.stdout.decode())
|
| 122 |
+
finally:
|
| 123 |
+
if source_fn is None:
|
| 124 |
+
os.remove(fname)
|
| 125 |
+
|
| 126 |
+
if full_output:
|
| 127 |
+
return cp
|
| 128 |
+
else:
|
| 129 |
+
return cp.returncode
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def get_include():
|
| 133 |
+
"""
|
| 134 |
+
Return the directory that contains the ``fortranobject.c`` and ``.h`` files.
|
| 135 |
+
|
| 136 |
+
.. note::
|
| 137 |
+
|
| 138 |
+
This function is not needed when building an extension with
|
| 139 |
+
`numpy.distutils` directly from ``.f`` and/or ``.pyf`` files
|
| 140 |
+
in one go.
|
| 141 |
+
|
| 142 |
+
Python extension modules built with f2py-generated code need to use
|
| 143 |
+
``fortranobject.c`` as a source file, and include the ``fortranobject.h``
|
| 144 |
+
header. This function can be used to obtain the directory containing
|
| 145 |
+
both of these files.
|
| 146 |
+
|
| 147 |
+
Returns
|
| 148 |
+
-------
|
| 149 |
+
include_path : str
|
| 150 |
+
Absolute path to the directory containing ``fortranobject.c`` and
|
| 151 |
+
``fortranobject.h``.
|
| 152 |
+
|
| 153 |
+
Notes
|
| 154 |
+
-----
|
| 155 |
+
.. versionadded:: 1.21.1
|
| 156 |
+
|
| 157 |
+
Unless the build system you are using has specific support for f2py,
|
| 158 |
+
building a Python extension using a ``.pyf`` signature file is a two-step
|
| 159 |
+
process. For a module ``mymod``:
|
| 160 |
+
|
| 161 |
+
* Step 1: run ``python -m numpy.f2py mymod.pyf --quiet``. This
|
| 162 |
+
generates ``_mymodmodule.c`` and (if needed)
|
| 163 |
+
``_fblas-f2pywrappers.f`` files next to ``mymod.pyf``.
|
| 164 |
+
* Step 2: build your Python extension module. This requires the
|
| 165 |
+
following source files:
|
| 166 |
+
|
| 167 |
+
* ``_mymodmodule.c``
|
| 168 |
+
* ``_mymod-f2pywrappers.f`` (if it was generated in Step 1)
|
| 169 |
+
* ``fortranobject.c``
|
| 170 |
+
|
| 171 |
+
See Also
|
| 172 |
+
--------
|
| 173 |
+
numpy.get_include : function that returns the numpy include directory
|
| 174 |
+
|
| 175 |
+
"""
|
| 176 |
+
return os.path.join(os.path.dirname(__file__), 'src')
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def __getattr__(attr):
|
| 180 |
+
|
| 181 |
+
# Avoid importing things that aren't needed for building
|
| 182 |
+
# which might import the main numpy module
|
| 183 |
+
if attr == "test":
|
| 184 |
+
from numpy._pytesttester import PytestTester
|
| 185 |
+
test = PytestTester(__name__)
|
| 186 |
+
return test
|
| 187 |
+
|
| 188 |
+
else:
|
| 189 |
+
raise AttributeError("module {!r} has no attribute "
|
| 190 |
+
"{!r}".format(__name__, attr))
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def __dir__():
|
| 194 |
+
return list(globals().keys() | {"test"})
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/__main__.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# See:
|
| 2 |
+
# https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e
|
| 3 |
+
from numpy.f2py.f2py2e import main
|
| 4 |
+
|
| 5 |
+
main()
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/_src_pyf.py
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
|
| 3 |
+
# START OF CODE VENDORED FROM `numpy.distutils.from_template`
|
| 4 |
+
#############################################################
|
| 5 |
+
"""
|
| 6 |
+
process_file(filename)
|
| 7 |
+
|
| 8 |
+
takes templated file .xxx.src and produces .xxx file where .xxx
|
| 9 |
+
is .pyf .f90 or .f using the following template rules:
|
| 10 |
+
|
| 11 |
+
'<..>' denotes a template.
|
| 12 |
+
|
| 13 |
+
All function and subroutine blocks in a source file with names that
|
| 14 |
+
contain '<..>' will be replicated according to the rules in '<..>'.
|
| 15 |
+
|
| 16 |
+
The number of comma-separated words in '<..>' will determine the number of
|
| 17 |
+
replicates.
|
| 18 |
+
|
| 19 |
+
'<..>' may have two different forms, named and short. For example,
|
| 20 |
+
|
| 21 |
+
named:
|
| 22 |
+
<p=d,s,z,c> where anywhere inside a block '<p>' will be replaced with
|
| 23 |
+
'd', 's', 'z', and 'c' for each replicate of the block.
|
| 24 |
+
|
| 25 |
+
<_c> is already defined: <_c=s,d,c,z>
|
| 26 |
+
<_t> is already defined: <_t=real,double precision,complex,double complex>
|
| 27 |
+
|
| 28 |
+
short:
|
| 29 |
+
<s,d,c,z>, a short form of the named, useful when no <p> appears inside
|
| 30 |
+
a block.
|
| 31 |
+
|
| 32 |
+
In general, '<..>' contains a comma separated list of arbitrary
|
| 33 |
+
expressions. If these expression must contain a comma|leftarrow|rightarrow,
|
| 34 |
+
then prepend the comma|leftarrow|rightarrow with a backslash.
|
| 35 |
+
|
| 36 |
+
If an expression matches '\\<index>' then it will be replaced
|
| 37 |
+
by <index>-th expression.
|
| 38 |
+
|
| 39 |
+
Note that all '<..>' forms in a block must have the same number of
|
| 40 |
+
comma-separated entries.
|
| 41 |
+
|
| 42 |
+
Predefined named template rules:
|
| 43 |
+
<prefix=s,d,c,z>
|
| 44 |
+
<ftype=real,double precision,complex,double complex>
|
| 45 |
+
<ftypereal=real,double precision,\\0,\\1>
|
| 46 |
+
<ctype=float,double,complex_float,complex_double>
|
| 47 |
+
<ctypereal=float,double,\\0,\\1>
|
| 48 |
+
"""
|
| 49 |
+
|
| 50 |
+
routine_start_re = re.compile(r'(\n|\A)(( (\$|\*))|)\s*(subroutine|function)\b', re.I)
|
| 51 |
+
routine_end_re = re.compile(r'\n\s*end\s*(subroutine|function)\b.*(\n|\Z)', re.I)
|
| 52 |
+
function_start_re = re.compile(r'\n (\$|\*)\s*function\b', re.I)
|
| 53 |
+
|
| 54 |
+
def parse_structure(astr):
|
| 55 |
+
""" Return a list of tuples for each function or subroutine each
|
| 56 |
+
tuple is the start and end of a subroutine or function to be
|
| 57 |
+
expanded.
|
| 58 |
+
"""
|
| 59 |
+
|
| 60 |
+
spanlist = []
|
| 61 |
+
ind = 0
|
| 62 |
+
while True:
|
| 63 |
+
m = routine_start_re.search(astr, ind)
|
| 64 |
+
if m is None:
|
| 65 |
+
break
|
| 66 |
+
start = m.start()
|
| 67 |
+
if function_start_re.match(astr, start, m.end()):
|
| 68 |
+
while True:
|
| 69 |
+
i = astr.rfind('\n', ind, start)
|
| 70 |
+
if i==-1:
|
| 71 |
+
break
|
| 72 |
+
start = i
|
| 73 |
+
if astr[i:i+7]!='\n $':
|
| 74 |
+
break
|
| 75 |
+
start += 1
|
| 76 |
+
m = routine_end_re.search(astr, m.end())
|
| 77 |
+
ind = end = m and m.end()-1 or len(astr)
|
| 78 |
+
spanlist.append((start, end))
|
| 79 |
+
return spanlist
|
| 80 |
+
|
| 81 |
+
template_re = re.compile(r"<\s*(\w[\w\d]*)\s*>")
|
| 82 |
+
named_re = re.compile(r"<\s*(\w[\w\d]*)\s*=\s*(.*?)\s*>")
|
| 83 |
+
list_re = re.compile(r"<\s*((.*?))\s*>")
|
| 84 |
+
|
| 85 |
+
def find_repl_patterns(astr):
|
| 86 |
+
reps = named_re.findall(astr)
|
| 87 |
+
names = {}
|
| 88 |
+
for rep in reps:
|
| 89 |
+
name = rep[0].strip() or unique_key(names)
|
| 90 |
+
repl = rep[1].replace(r'\,', '@comma@')
|
| 91 |
+
thelist = conv(repl)
|
| 92 |
+
names[name] = thelist
|
| 93 |
+
return names
|
| 94 |
+
|
| 95 |
+
def find_and_remove_repl_patterns(astr):
|
| 96 |
+
names = find_repl_patterns(astr)
|
| 97 |
+
astr = re.subn(named_re, '', astr)[0]
|
| 98 |
+
return astr, names
|
| 99 |
+
|
| 100 |
+
item_re = re.compile(r"\A\\(?P<index>\d+)\Z")
|
| 101 |
+
def conv(astr):
|
| 102 |
+
b = astr.split(',')
|
| 103 |
+
l = [x.strip() for x in b]
|
| 104 |
+
for i in range(len(l)):
|
| 105 |
+
m = item_re.match(l[i])
|
| 106 |
+
if m:
|
| 107 |
+
j = int(m.group('index'))
|
| 108 |
+
l[i] = l[j]
|
| 109 |
+
return ','.join(l)
|
| 110 |
+
|
| 111 |
+
def unique_key(adict):
|
| 112 |
+
""" Obtain a unique key given a dictionary."""
|
| 113 |
+
allkeys = list(adict.keys())
|
| 114 |
+
done = False
|
| 115 |
+
n = 1
|
| 116 |
+
while not done:
|
| 117 |
+
newkey = '__l%s' % (n)
|
| 118 |
+
if newkey in allkeys:
|
| 119 |
+
n += 1
|
| 120 |
+
else:
|
| 121 |
+
done = True
|
| 122 |
+
return newkey
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
template_name_re = re.compile(r'\A\s*(\w[\w\d]*)\s*\Z')
|
| 126 |
+
def expand_sub(substr, names):
|
| 127 |
+
substr = substr.replace(r'\>', '@rightarrow@')
|
| 128 |
+
substr = substr.replace(r'\<', '@leftarrow@')
|
| 129 |
+
lnames = find_repl_patterns(substr)
|
| 130 |
+
substr = named_re.sub(r"<\1>", substr) # get rid of definition templates
|
| 131 |
+
|
| 132 |
+
def listrepl(mobj):
|
| 133 |
+
thelist = conv(mobj.group(1).replace(r'\,', '@comma@'))
|
| 134 |
+
if template_name_re.match(thelist):
|
| 135 |
+
return "<%s>" % (thelist)
|
| 136 |
+
name = None
|
| 137 |
+
for key in lnames.keys(): # see if list is already in dictionary
|
| 138 |
+
if lnames[key] == thelist:
|
| 139 |
+
name = key
|
| 140 |
+
if name is None: # this list is not in the dictionary yet
|
| 141 |
+
name = unique_key(lnames)
|
| 142 |
+
lnames[name] = thelist
|
| 143 |
+
return "<%s>" % name
|
| 144 |
+
|
| 145 |
+
substr = list_re.sub(listrepl, substr) # convert all lists to named templates
|
| 146 |
+
# newnames are constructed as needed
|
| 147 |
+
|
| 148 |
+
numsubs = None
|
| 149 |
+
base_rule = None
|
| 150 |
+
rules = {}
|
| 151 |
+
for r in template_re.findall(substr):
|
| 152 |
+
if r not in rules:
|
| 153 |
+
thelist = lnames.get(r, names.get(r, None))
|
| 154 |
+
if thelist is None:
|
| 155 |
+
raise ValueError('No replicates found for <%s>' % (r))
|
| 156 |
+
if r not in names and not thelist.startswith('_'):
|
| 157 |
+
names[r] = thelist
|
| 158 |
+
rule = [i.replace('@comma@', ',') for i in thelist.split(',')]
|
| 159 |
+
num = len(rule)
|
| 160 |
+
|
| 161 |
+
if numsubs is None:
|
| 162 |
+
numsubs = num
|
| 163 |
+
rules[r] = rule
|
| 164 |
+
base_rule = r
|
| 165 |
+
elif num == numsubs:
|
| 166 |
+
rules[r] = rule
|
| 167 |
+
else:
|
| 168 |
+
print("Mismatch in number of replacements (base <{}={}>) "
|
| 169 |
+
"for <{}={}>. Ignoring.".format(base_rule, ','.join(rules[base_rule]), r, thelist))
|
| 170 |
+
if not rules:
|
| 171 |
+
return substr
|
| 172 |
+
|
| 173 |
+
def namerepl(mobj):
|
| 174 |
+
name = mobj.group(1)
|
| 175 |
+
return rules.get(name, (k+1)*[name])[k]
|
| 176 |
+
|
| 177 |
+
newstr = ''
|
| 178 |
+
for k in range(numsubs):
|
| 179 |
+
newstr += template_re.sub(namerepl, substr) + '\n\n'
|
| 180 |
+
|
| 181 |
+
newstr = newstr.replace('@rightarrow@', '>')
|
| 182 |
+
newstr = newstr.replace('@leftarrow@', '<')
|
| 183 |
+
return newstr
|
| 184 |
+
|
| 185 |
+
def process_str(allstr):
|
| 186 |
+
newstr = allstr
|
| 187 |
+
writestr = ''
|
| 188 |
+
|
| 189 |
+
struct = parse_structure(newstr)
|
| 190 |
+
|
| 191 |
+
oldend = 0
|
| 192 |
+
names = {}
|
| 193 |
+
names.update(_special_names)
|
| 194 |
+
for sub in struct:
|
| 195 |
+
cleanedstr, defs = find_and_remove_repl_patterns(newstr[oldend:sub[0]])
|
| 196 |
+
writestr += cleanedstr
|
| 197 |
+
names.update(defs)
|
| 198 |
+
writestr += expand_sub(newstr[sub[0]:sub[1]], names)
|
| 199 |
+
oldend = sub[1]
|
| 200 |
+
writestr += newstr[oldend:]
|
| 201 |
+
|
| 202 |
+
return writestr
|
| 203 |
+
|
| 204 |
+
include_src_re = re.compile(r"(\n|\A)\s*include\s*['\"](?P<name>[\w\d./\\]+\.src)['\"]", re.I)
|
| 205 |
+
|
| 206 |
+
def resolve_includes(source):
|
| 207 |
+
d = os.path.dirname(source)
|
| 208 |
+
with open(source) as fid:
|
| 209 |
+
lines = []
|
| 210 |
+
for line in fid:
|
| 211 |
+
m = include_src_re.match(line)
|
| 212 |
+
if m:
|
| 213 |
+
fn = m.group('name')
|
| 214 |
+
if not os.path.isabs(fn):
|
| 215 |
+
fn = os.path.join(d, fn)
|
| 216 |
+
if os.path.isfile(fn):
|
| 217 |
+
lines.extend(resolve_includes(fn))
|
| 218 |
+
else:
|
| 219 |
+
lines.append(line)
|
| 220 |
+
else:
|
| 221 |
+
lines.append(line)
|
| 222 |
+
return lines
|
| 223 |
+
|
| 224 |
+
def process_file(source):
|
| 225 |
+
lines = resolve_includes(source)
|
| 226 |
+
return process_str(''.join(lines))
|
| 227 |
+
|
| 228 |
+
_special_names = find_repl_patterns('''
|
| 229 |
+
<_c=s,d,c,z>
|
| 230 |
+
<_t=real,double precision,complex,double complex>
|
| 231 |
+
<prefix=s,d,c,z>
|
| 232 |
+
<ftype=real,double precision,complex,double complex>
|
| 233 |
+
<ctype=float,double,complex_float,complex_double>
|
| 234 |
+
<ftypereal=real,double precision,\\0,\\1>
|
| 235 |
+
<ctypereal=float,double,\\0,\\1>
|
| 236 |
+
''')
|
| 237 |
+
|
| 238 |
+
# END OF CODE VENDORED FROM `numpy.distutils.from_template`
|
| 239 |
+
###########################################################
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/cfuncs.py
ADDED
|
@@ -0,0 +1,1536 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
C declarations, CPP macros, and C functions for f2py2e.
|
| 4 |
+
Only required declarations/macros/functions will be used.
|
| 5 |
+
|
| 6 |
+
Copyright 1999 -- 2011 Pearu Peterson all rights reserved.
|
| 7 |
+
Copyright 2011 -- present NumPy Developers.
|
| 8 |
+
Permission to use, modify, and distribute this software is given under the
|
| 9 |
+
terms of the NumPy License.
|
| 10 |
+
|
| 11 |
+
NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
| 12 |
+
"""
|
| 13 |
+
import sys
|
| 14 |
+
import copy
|
| 15 |
+
|
| 16 |
+
from . import __version__
|
| 17 |
+
|
| 18 |
+
f2py_version = __version__.version
|
| 19 |
+
errmess = sys.stderr.write
|
| 20 |
+
|
| 21 |
+
##################### Definitions ##################
|
| 22 |
+
|
| 23 |
+
outneeds = {'includes0': [], 'includes': [], 'typedefs': [], 'typedefs_generated': [],
|
| 24 |
+
'userincludes': [],
|
| 25 |
+
'cppmacros': [], 'cfuncs': [], 'callbacks': [], 'f90modhooks': [],
|
| 26 |
+
'commonhooks': []}
|
| 27 |
+
needs = {}
|
| 28 |
+
includes0 = {'includes0': '/*need_includes0*/'}
|
| 29 |
+
includes = {'includes': '/*need_includes*/'}
|
| 30 |
+
userincludes = {'userincludes': '/*need_userincludes*/'}
|
| 31 |
+
typedefs = {'typedefs': '/*need_typedefs*/'}
|
| 32 |
+
typedefs_generated = {'typedefs_generated': '/*need_typedefs_generated*/'}
|
| 33 |
+
cppmacros = {'cppmacros': '/*need_cppmacros*/'}
|
| 34 |
+
cfuncs = {'cfuncs': '/*need_cfuncs*/'}
|
| 35 |
+
callbacks = {'callbacks': '/*need_callbacks*/'}
|
| 36 |
+
f90modhooks = {'f90modhooks': '/*need_f90modhooks*/',
|
| 37 |
+
'initf90modhooksstatic': '/*initf90modhooksstatic*/',
|
| 38 |
+
'initf90modhooksdynamic': '/*initf90modhooksdynamic*/',
|
| 39 |
+
}
|
| 40 |
+
commonhooks = {'commonhooks': '/*need_commonhooks*/',
|
| 41 |
+
'initcommonhooks': '/*need_initcommonhooks*/',
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
############ Includes ###################
|
| 45 |
+
|
| 46 |
+
includes0['math.h'] = '#include <math.h>'
|
| 47 |
+
includes0['string.h'] = '#include <string.h>'
|
| 48 |
+
includes0['setjmp.h'] = '#include <setjmp.h>'
|
| 49 |
+
|
| 50 |
+
includes['arrayobject.h'] = '''#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API
|
| 51 |
+
#include "arrayobject.h"'''
|
| 52 |
+
includes['npy_math.h'] = '#include "numpy/npy_math.h"'
|
| 53 |
+
|
| 54 |
+
includes['arrayobject.h'] = '#include "fortranobject.h"'
|
| 55 |
+
includes['stdarg.h'] = '#include <stdarg.h>'
|
| 56 |
+
|
| 57 |
+
############# Type definitions ###############
|
| 58 |
+
|
| 59 |
+
typedefs['unsigned_char'] = 'typedef unsigned char unsigned_char;'
|
| 60 |
+
typedefs['unsigned_short'] = 'typedef unsigned short unsigned_short;'
|
| 61 |
+
typedefs['unsigned_long'] = 'typedef unsigned long unsigned_long;'
|
| 62 |
+
typedefs['signed_char'] = 'typedef signed char signed_char;'
|
| 63 |
+
typedefs['long_long'] = """
|
| 64 |
+
#if defined(NPY_OS_WIN32)
|
| 65 |
+
typedef __int64 long_long;
|
| 66 |
+
#else
|
| 67 |
+
typedef long long long_long;
|
| 68 |
+
typedef unsigned long long unsigned_long_long;
|
| 69 |
+
#endif
|
| 70 |
+
"""
|
| 71 |
+
typedefs['unsigned_long_long'] = """
|
| 72 |
+
#if defined(NPY_OS_WIN32)
|
| 73 |
+
typedef __uint64 long_long;
|
| 74 |
+
#else
|
| 75 |
+
typedef unsigned long long unsigned_long_long;
|
| 76 |
+
#endif
|
| 77 |
+
"""
|
| 78 |
+
typedefs['long_double'] = """
|
| 79 |
+
#ifndef _LONG_DOUBLE
|
| 80 |
+
typedef long double long_double;
|
| 81 |
+
#endif
|
| 82 |
+
"""
|
| 83 |
+
typedefs[
|
| 84 |
+
'complex_long_double'] = 'typedef struct {long double r,i;} complex_long_double;'
|
| 85 |
+
typedefs['complex_float'] = 'typedef struct {float r,i;} complex_float;'
|
| 86 |
+
typedefs['complex_double'] = 'typedef struct {double r,i;} complex_double;'
|
| 87 |
+
typedefs['string'] = """typedef char * string;"""
|
| 88 |
+
typedefs['character'] = """typedef char character;"""
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
############### CPP macros ####################
|
| 92 |
+
cppmacros['CFUNCSMESS'] = """
|
| 93 |
+
#ifdef DEBUGCFUNCS
|
| 94 |
+
#define CFUNCSMESS(mess) fprintf(stderr,\"debug-capi:\"mess);
|
| 95 |
+
#define CFUNCSMESSPY(mess,obj) CFUNCSMESS(mess) \\
|
| 96 |
+
PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\\
|
| 97 |
+
fprintf(stderr,\"\\n\");
|
| 98 |
+
#else
|
| 99 |
+
#define CFUNCSMESS(mess)
|
| 100 |
+
#define CFUNCSMESSPY(mess,obj)
|
| 101 |
+
#endif
|
| 102 |
+
"""
|
| 103 |
+
cppmacros['F_FUNC'] = """
|
| 104 |
+
#if defined(PREPEND_FORTRAN)
|
| 105 |
+
#if defined(NO_APPEND_FORTRAN)
|
| 106 |
+
#if defined(UPPERCASE_FORTRAN)
|
| 107 |
+
#define F_FUNC(f,F) _##F
|
| 108 |
+
#else
|
| 109 |
+
#define F_FUNC(f,F) _##f
|
| 110 |
+
#endif
|
| 111 |
+
#else
|
| 112 |
+
#if defined(UPPERCASE_FORTRAN)
|
| 113 |
+
#define F_FUNC(f,F) _##F##_
|
| 114 |
+
#else
|
| 115 |
+
#define F_FUNC(f,F) _##f##_
|
| 116 |
+
#endif
|
| 117 |
+
#endif
|
| 118 |
+
#else
|
| 119 |
+
#if defined(NO_APPEND_FORTRAN)
|
| 120 |
+
#if defined(UPPERCASE_FORTRAN)
|
| 121 |
+
#define F_FUNC(f,F) F
|
| 122 |
+
#else
|
| 123 |
+
#define F_FUNC(f,F) f
|
| 124 |
+
#endif
|
| 125 |
+
#else
|
| 126 |
+
#if defined(UPPERCASE_FORTRAN)
|
| 127 |
+
#define F_FUNC(f,F) F##_
|
| 128 |
+
#else
|
| 129 |
+
#define F_FUNC(f,F) f##_
|
| 130 |
+
#endif
|
| 131 |
+
#endif
|
| 132 |
+
#endif
|
| 133 |
+
#if defined(UNDERSCORE_G77)
|
| 134 |
+
#define F_FUNC_US(f,F) F_FUNC(f##_,F##_)
|
| 135 |
+
#else
|
| 136 |
+
#define F_FUNC_US(f,F) F_FUNC(f,F)
|
| 137 |
+
#endif
|
| 138 |
+
"""
|
| 139 |
+
cppmacros['F_WRAPPEDFUNC'] = """
|
| 140 |
+
#if defined(PREPEND_FORTRAN)
|
| 141 |
+
#if defined(NO_APPEND_FORTRAN)
|
| 142 |
+
#if defined(UPPERCASE_FORTRAN)
|
| 143 |
+
#define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F
|
| 144 |
+
#else
|
| 145 |
+
#define F_WRAPPEDFUNC(f,F) _f2pywrap##f
|
| 146 |
+
#endif
|
| 147 |
+
#else
|
| 148 |
+
#if defined(UPPERCASE_FORTRAN)
|
| 149 |
+
#define F_WRAPPEDFUNC(f,F) _F2PYWRAP##F##_
|
| 150 |
+
#else
|
| 151 |
+
#define F_WRAPPEDFUNC(f,F) _f2pywrap##f##_
|
| 152 |
+
#endif
|
| 153 |
+
#endif
|
| 154 |
+
#else
|
| 155 |
+
#if defined(NO_APPEND_FORTRAN)
|
| 156 |
+
#if defined(UPPERCASE_FORTRAN)
|
| 157 |
+
#define F_WRAPPEDFUNC(f,F) F2PYWRAP##F
|
| 158 |
+
#else
|
| 159 |
+
#define F_WRAPPEDFUNC(f,F) f2pywrap##f
|
| 160 |
+
#endif
|
| 161 |
+
#else
|
| 162 |
+
#if defined(UPPERCASE_FORTRAN)
|
| 163 |
+
#define F_WRAPPEDFUNC(f,F) F2PYWRAP##F##_
|
| 164 |
+
#else
|
| 165 |
+
#define F_WRAPPEDFUNC(f,F) f2pywrap##f##_
|
| 166 |
+
#endif
|
| 167 |
+
#endif
|
| 168 |
+
#endif
|
| 169 |
+
#if defined(UNDERSCORE_G77)
|
| 170 |
+
#define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f##_,F##_)
|
| 171 |
+
#else
|
| 172 |
+
#define F_WRAPPEDFUNC_US(f,F) F_WRAPPEDFUNC(f,F)
|
| 173 |
+
#endif
|
| 174 |
+
"""
|
| 175 |
+
cppmacros['F_MODFUNC'] = """
|
| 176 |
+
#if defined(F90MOD2CCONV1) /*E.g. Compaq Fortran */
|
| 177 |
+
#if defined(NO_APPEND_FORTRAN)
|
| 178 |
+
#define F_MODFUNCNAME(m,f) $ ## m ## $ ## f
|
| 179 |
+
#else
|
| 180 |
+
#define F_MODFUNCNAME(m,f) $ ## m ## $ ## f ## _
|
| 181 |
+
#endif
|
| 182 |
+
#endif
|
| 183 |
+
|
| 184 |
+
#if defined(F90MOD2CCONV2) /*E.g. IBM XL Fortran, not tested though */
|
| 185 |
+
#if defined(NO_APPEND_FORTRAN)
|
| 186 |
+
#define F_MODFUNCNAME(m,f) __ ## m ## _MOD_ ## f
|
| 187 |
+
#else
|
| 188 |
+
#define F_MODFUNCNAME(m,f) __ ## m ## _MOD_ ## f ## _
|
| 189 |
+
#endif
|
| 190 |
+
#endif
|
| 191 |
+
|
| 192 |
+
#if defined(F90MOD2CCONV3) /*E.g. MIPSPro Compilers */
|
| 193 |
+
#if defined(NO_APPEND_FORTRAN)
|
| 194 |
+
#define F_MODFUNCNAME(m,f) f ## .in. ## m
|
| 195 |
+
#else
|
| 196 |
+
#define F_MODFUNCNAME(m,f) f ## .in. ## m ## _
|
| 197 |
+
#endif
|
| 198 |
+
#endif
|
| 199 |
+
/*
|
| 200 |
+
#if defined(UPPERCASE_FORTRAN)
|
| 201 |
+
#define F_MODFUNC(m,M,f,F) F_MODFUNCNAME(M,F)
|
| 202 |
+
#else
|
| 203 |
+
#define F_MODFUNC(m,M,f,F) F_MODFUNCNAME(m,f)
|
| 204 |
+
#endif
|
| 205 |
+
*/
|
| 206 |
+
|
| 207 |
+
#define F_MODFUNC(m,f) (*(f2pymodstruct##m##.##f))
|
| 208 |
+
"""
|
| 209 |
+
cppmacros['SWAPUNSAFE'] = """
|
| 210 |
+
#define SWAP(a,b) (size_t)(a) = ((size_t)(a) ^ (size_t)(b));\\
|
| 211 |
+
(size_t)(b) = ((size_t)(a) ^ (size_t)(b));\\
|
| 212 |
+
(size_t)(a) = ((size_t)(a) ^ (size_t)(b))
|
| 213 |
+
"""
|
| 214 |
+
cppmacros['SWAP'] = """
|
| 215 |
+
#define SWAP(a,b,t) {\\
|
| 216 |
+
t *c;\\
|
| 217 |
+
c = a;\\
|
| 218 |
+
a = b;\\
|
| 219 |
+
b = c;}
|
| 220 |
+
"""
|
| 221 |
+
# cppmacros['ISCONTIGUOUS']='#define ISCONTIGUOUS(m) (PyArray_FLAGS(m) &
|
| 222 |
+
# NPY_ARRAY_C_CONTIGUOUS)'
|
| 223 |
+
cppmacros['PRINTPYOBJERR'] = """
|
| 224 |
+
#define PRINTPYOBJERR(obj)\\
|
| 225 |
+
fprintf(stderr,\"#modulename#.error is related to \");\\
|
| 226 |
+
PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\\
|
| 227 |
+
fprintf(stderr,\"\\n\");
|
| 228 |
+
"""
|
| 229 |
+
cppmacros['MINMAX'] = """
|
| 230 |
+
#ifndef max
|
| 231 |
+
#define max(a,b) ((a > b) ? (a) : (b))
|
| 232 |
+
#endif
|
| 233 |
+
#ifndef min
|
| 234 |
+
#define min(a,b) ((a < b) ? (a) : (b))
|
| 235 |
+
#endif
|
| 236 |
+
#ifndef MAX
|
| 237 |
+
#define MAX(a,b) ((a > b) ? (a) : (b))
|
| 238 |
+
#endif
|
| 239 |
+
#ifndef MIN
|
| 240 |
+
#define MIN(a,b) ((a < b) ? (a) : (b))
|
| 241 |
+
#endif
|
| 242 |
+
"""
|
| 243 |
+
cppmacros['len..'] = """
|
| 244 |
+
/* See fortranobject.h for definitions. The macros here are provided for BC. */
|
| 245 |
+
#define rank f2py_rank
|
| 246 |
+
#define shape f2py_shape
|
| 247 |
+
#define fshape f2py_shape
|
| 248 |
+
#define len f2py_len
|
| 249 |
+
#define flen f2py_flen
|
| 250 |
+
#define slen f2py_slen
|
| 251 |
+
#define size f2py_size
|
| 252 |
+
"""
|
| 253 |
+
cppmacros['pyobj_from_char1'] = r"""
|
| 254 |
+
#define pyobj_from_char1(v) (PyLong_FromLong(v))
|
| 255 |
+
"""
|
| 256 |
+
cppmacros['pyobj_from_short1'] = r"""
|
| 257 |
+
#define pyobj_from_short1(v) (PyLong_FromLong(v))
|
| 258 |
+
"""
|
| 259 |
+
needs['pyobj_from_int1'] = ['signed_char']
|
| 260 |
+
cppmacros['pyobj_from_int1'] = r"""
|
| 261 |
+
#define pyobj_from_int1(v) (PyLong_FromLong(v))
|
| 262 |
+
"""
|
| 263 |
+
cppmacros['pyobj_from_long1'] = r"""
|
| 264 |
+
#define pyobj_from_long1(v) (PyLong_FromLong(v))
|
| 265 |
+
"""
|
| 266 |
+
needs['pyobj_from_long_long1'] = ['long_long']
|
| 267 |
+
cppmacros['pyobj_from_long_long1'] = """
|
| 268 |
+
#ifdef HAVE_LONG_LONG
|
| 269 |
+
#define pyobj_from_long_long1(v) (PyLong_FromLongLong(v))
|
| 270 |
+
#else
|
| 271 |
+
#warning HAVE_LONG_LONG is not available. Redefining pyobj_from_long_long.
|
| 272 |
+
#define pyobj_from_long_long1(v) (PyLong_FromLong(v))
|
| 273 |
+
#endif
|
| 274 |
+
"""
|
| 275 |
+
needs['pyobj_from_long_double1'] = ['long_double']
|
| 276 |
+
cppmacros['pyobj_from_long_double1'] = """
|
| 277 |
+
#define pyobj_from_long_double1(v) (PyFloat_FromDouble(v))"""
|
| 278 |
+
cppmacros['pyobj_from_double1'] = """
|
| 279 |
+
#define pyobj_from_double1(v) (PyFloat_FromDouble(v))"""
|
| 280 |
+
cppmacros['pyobj_from_float1'] = """
|
| 281 |
+
#define pyobj_from_float1(v) (PyFloat_FromDouble(v))"""
|
| 282 |
+
needs['pyobj_from_complex_long_double1'] = ['complex_long_double']
|
| 283 |
+
cppmacros['pyobj_from_complex_long_double1'] = """
|
| 284 |
+
#define pyobj_from_complex_long_double1(v) (PyComplex_FromDoubles(v.r,v.i))"""
|
| 285 |
+
needs['pyobj_from_complex_double1'] = ['complex_double']
|
| 286 |
+
cppmacros['pyobj_from_complex_double1'] = """
|
| 287 |
+
#define pyobj_from_complex_double1(v) (PyComplex_FromDoubles(v.r,v.i))"""
|
| 288 |
+
needs['pyobj_from_complex_float1'] = ['complex_float']
|
| 289 |
+
cppmacros['pyobj_from_complex_float1'] = """
|
| 290 |
+
#define pyobj_from_complex_float1(v) (PyComplex_FromDoubles(v.r,v.i))"""
|
| 291 |
+
needs['pyobj_from_string1'] = ['string']
|
| 292 |
+
cppmacros['pyobj_from_string1'] = """
|
| 293 |
+
#define pyobj_from_string1(v) (PyUnicode_FromString((char *)v))"""
|
| 294 |
+
needs['pyobj_from_string1size'] = ['string']
|
| 295 |
+
cppmacros['pyobj_from_string1size'] = """
|
| 296 |
+
#define pyobj_from_string1size(v,len) (PyUnicode_FromStringAndSize((char *)v, len))"""
|
| 297 |
+
needs['TRYPYARRAYTEMPLATE'] = ['PRINTPYOBJERR']
|
| 298 |
+
cppmacros['TRYPYARRAYTEMPLATE'] = """
|
| 299 |
+
/* New SciPy */
|
| 300 |
+
#define TRYPYARRAYTEMPLATECHAR case NPY_STRING: *(char *)(PyArray_DATA(arr))=*v; break;
|
| 301 |
+
#define TRYPYARRAYTEMPLATELONG case NPY_LONG: *(long *)(PyArray_DATA(arr))=*v; break;
|
| 302 |
+
#define TRYPYARRAYTEMPLATEOBJECT case NPY_OBJECT: PyArray_SETITEM(arr,PyArray_DATA(arr),pyobj_from_ ## ctype ## 1(*v)); break;
|
| 303 |
+
|
| 304 |
+
#define TRYPYARRAYTEMPLATE(ctype,typecode) \\
|
| 305 |
+
PyArrayObject *arr = NULL;\\
|
| 306 |
+
if (!obj) return -2;\\
|
| 307 |
+
if (!PyArray_Check(obj)) return -1;\\
|
| 308 |
+
if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,\"TRYPYARRAYTEMPLATE:\");PRINTPYOBJERR(obj);return 0;}\\
|
| 309 |
+
if (PyArray_DESCR(arr)->type==typecode) {*(ctype *)(PyArray_DATA(arr))=*v; return 1;}\\
|
| 310 |
+
switch (PyArray_TYPE(arr)) {\\
|
| 311 |
+
case NPY_DOUBLE: *(npy_double *)(PyArray_DATA(arr))=*v; break;\\
|
| 312 |
+
case NPY_INT: *(npy_int *)(PyArray_DATA(arr))=*v; break;\\
|
| 313 |
+
case NPY_LONG: *(npy_long *)(PyArray_DATA(arr))=*v; break;\\
|
| 314 |
+
case NPY_FLOAT: *(npy_float *)(PyArray_DATA(arr))=*v; break;\\
|
| 315 |
+
case NPY_CDOUBLE: *(npy_double *)(PyArray_DATA(arr))=*v; break;\\
|
| 316 |
+
case NPY_CFLOAT: *(npy_float *)(PyArray_DATA(arr))=*v; break;\\
|
| 317 |
+
case NPY_BOOL: *(npy_bool *)(PyArray_DATA(arr))=(*v!=0); break;\\
|
| 318 |
+
case NPY_UBYTE: *(npy_ubyte *)(PyArray_DATA(arr))=*v; break;\\
|
| 319 |
+
case NPY_BYTE: *(npy_byte *)(PyArray_DATA(arr))=*v; break;\\
|
| 320 |
+
case NPY_SHORT: *(npy_short *)(PyArray_DATA(arr))=*v; break;\\
|
| 321 |
+
case NPY_USHORT: *(npy_ushort *)(PyArray_DATA(arr))=*v; break;\\
|
| 322 |
+
case NPY_UINT: *(npy_uint *)(PyArray_DATA(arr))=*v; break;\\
|
| 323 |
+
case NPY_ULONG: *(npy_ulong *)(PyArray_DATA(arr))=*v; break;\\
|
| 324 |
+
case NPY_LONGLONG: *(npy_longlong *)(PyArray_DATA(arr))=*v; break;\\
|
| 325 |
+
case NPY_ULONGLONG: *(npy_ulonglong *)(PyArray_DATA(arr))=*v; break;\\
|
| 326 |
+
case NPY_LONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=*v; break;\\
|
| 327 |
+
case NPY_CLONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=*v; break;\\
|
| 328 |
+
case NPY_OBJECT: PyArray_SETITEM(arr, PyArray_DATA(arr), pyobj_from_ ## ctype ## 1(*v)); break;\\
|
| 329 |
+
default: return -2;\\
|
| 330 |
+
};\\
|
| 331 |
+
return 1
|
| 332 |
+
"""
|
| 333 |
+
|
| 334 |
+
needs['TRYCOMPLEXPYARRAYTEMPLATE'] = ['PRINTPYOBJERR']
|
| 335 |
+
cppmacros['TRYCOMPLEXPYARRAYTEMPLATE'] = """
|
| 336 |
+
#define TRYCOMPLEXPYARRAYTEMPLATEOBJECT case NPY_OBJECT: PyArray_SETITEM(arr, PyArray_DATA(arr), pyobj_from_complex_ ## ctype ## 1((*v))); break;
|
| 337 |
+
#define TRYCOMPLEXPYARRAYTEMPLATE(ctype,typecode)\\
|
| 338 |
+
PyArrayObject *arr = NULL;\\
|
| 339 |
+
if (!obj) return -2;\\
|
| 340 |
+
if (!PyArray_Check(obj)) return -1;\\
|
| 341 |
+
if (!(arr=(PyArrayObject *)obj)) {fprintf(stderr,\"TRYCOMPLEXPYARRAYTEMPLATE:\");PRINTPYOBJERR(obj);return 0;}\\
|
| 342 |
+
if (PyArray_DESCR(arr)->type==typecode) {\\
|
| 343 |
+
*(ctype *)(PyArray_DATA(arr))=(*v).r;\\
|
| 344 |
+
*(ctype *)(PyArray_DATA(arr)+sizeof(ctype))=(*v).i;\\
|
| 345 |
+
return 1;\\
|
| 346 |
+
}\\
|
| 347 |
+
switch (PyArray_TYPE(arr)) {\\
|
| 348 |
+
case NPY_CDOUBLE: *(npy_double *)(PyArray_DATA(arr))=(*v).r;\\
|
| 349 |
+
*(npy_double *)(PyArray_DATA(arr)+sizeof(npy_double))=(*v).i;\\
|
| 350 |
+
break;\\
|
| 351 |
+
case NPY_CFLOAT: *(npy_float *)(PyArray_DATA(arr))=(*v).r;\\
|
| 352 |
+
*(npy_float *)(PyArray_DATA(arr)+sizeof(npy_float))=(*v).i;\\
|
| 353 |
+
break;\\
|
| 354 |
+
case NPY_DOUBLE: *(npy_double *)(PyArray_DATA(arr))=(*v).r; break;\\
|
| 355 |
+
case NPY_LONG: *(npy_long *)(PyArray_DATA(arr))=(*v).r; break;\\
|
| 356 |
+
case NPY_FLOAT: *(npy_float *)(PyArray_DATA(arr))=(*v).r; break;\\
|
| 357 |
+
case NPY_INT: *(npy_int *)(PyArray_DATA(arr))=(*v).r; break;\\
|
| 358 |
+
case NPY_SHORT: *(npy_short *)(PyArray_DATA(arr))=(*v).r; break;\\
|
| 359 |
+
case NPY_UBYTE: *(npy_ubyte *)(PyArray_DATA(arr))=(*v).r; break;\\
|
| 360 |
+
case NPY_BYTE: *(npy_byte *)(PyArray_DATA(arr))=(*v).r; break;\\
|
| 361 |
+
case NPY_BOOL: *(npy_bool *)(PyArray_DATA(arr))=((*v).r!=0 && (*v).i!=0); break;\\
|
| 362 |
+
case NPY_USHORT: *(npy_ushort *)(PyArray_DATA(arr))=(*v).r; break;\\
|
| 363 |
+
case NPY_UINT: *(npy_uint *)(PyArray_DATA(arr))=(*v).r; break;\\
|
| 364 |
+
case NPY_ULONG: *(npy_ulong *)(PyArray_DATA(arr))=(*v).r; break;\\
|
| 365 |
+
case NPY_LONGLONG: *(npy_longlong *)(PyArray_DATA(arr))=(*v).r; break;\\
|
| 366 |
+
case NPY_ULONGLONG: *(npy_ulonglong *)(PyArray_DATA(arr))=(*v).r; break;\\
|
| 367 |
+
case NPY_LONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=(*v).r; break;\\
|
| 368 |
+
case NPY_CLONGDOUBLE: *(npy_longdouble *)(PyArray_DATA(arr))=(*v).r;\\
|
| 369 |
+
*(npy_longdouble *)(PyArray_DATA(arr)+sizeof(npy_longdouble))=(*v).i;\\
|
| 370 |
+
break;\\
|
| 371 |
+
case NPY_OBJECT: PyArray_SETITEM(arr, PyArray_DATA(arr), pyobj_from_complex_ ## ctype ## 1((*v))); break;\\
|
| 372 |
+
default: return -2;\\
|
| 373 |
+
};\\
|
| 374 |
+
return -1;
|
| 375 |
+
"""
|
| 376 |
+
# cppmacros['NUMFROMARROBJ']="""
|
| 377 |
+
# define NUMFROMARROBJ(typenum,ctype) \\
|
| 378 |
+
# if (PyArray_Check(obj)) arr = (PyArrayObject *)obj;\\
|
| 379 |
+
# else arr = (PyArrayObject *)PyArray_ContiguousFromObject(obj,typenum,0,0);\\
|
| 380 |
+
# if (arr) {\\
|
| 381 |
+
# if (PyArray_TYPE(arr)==NPY_OBJECT) {\\
|
| 382 |
+
# if (!ctype ## _from_pyobj(v,(PyArray_DESCR(arr)->getitem)(PyArray_DATA(arr)),\"\"))\\
|
| 383 |
+
# goto capi_fail;\\
|
| 384 |
+
# } else {\\
|
| 385 |
+
# (PyArray_DESCR(arr)->cast[typenum])(PyArray_DATA(arr),1,(char*)v,1,1);\\
|
| 386 |
+
# }\\
|
| 387 |
+
# if ((PyObject *)arr != obj) { Py_DECREF(arr); }\\
|
| 388 |
+
# return 1;\\
|
| 389 |
+
# }
|
| 390 |
+
# """
|
| 391 |
+
# XXX: Note that CNUMFROMARROBJ is identical with NUMFROMARROBJ
|
| 392 |
+
# cppmacros['CNUMFROMARROBJ']="""
|
| 393 |
+
# define CNUMFROMARROBJ(typenum,ctype) \\
|
| 394 |
+
# if (PyArray_Check(obj)) arr = (PyArrayObject *)obj;\\
|
| 395 |
+
# else arr = (PyArrayObject *)PyArray_ContiguousFromObject(obj,typenum,0,0);\\
|
| 396 |
+
# if (arr) {\\
|
| 397 |
+
# if (PyArray_TYPE(arr)==NPY_OBJECT) {\\
|
| 398 |
+
# if (!ctype ## _from_pyobj(v,(PyArray_DESCR(arr)->getitem)(PyArray_DATA(arr)),\"\"))\\
|
| 399 |
+
# goto capi_fail;\\
|
| 400 |
+
# } else {\\
|
| 401 |
+
# (PyArray_DESCR(arr)->cast[typenum])((void *)(PyArray_DATA(arr)),1,(void *)(v),1,1);\\
|
| 402 |
+
# }\\
|
| 403 |
+
# if ((PyObject *)arr != obj) { Py_DECREF(arr); }\\
|
| 404 |
+
# return 1;\\
|
| 405 |
+
# }
|
| 406 |
+
# """
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
needs['GETSTRFROMPYTUPLE'] = ['STRINGCOPYN', 'PRINTPYOBJERR']
|
| 410 |
+
cppmacros['GETSTRFROMPYTUPLE'] = """
|
| 411 |
+
#define GETSTRFROMPYTUPLE(tuple,index,str,len) {\\
|
| 412 |
+
PyObject *rv_cb_str = PyTuple_GetItem((tuple),(index));\\
|
| 413 |
+
if (rv_cb_str == NULL)\\
|
| 414 |
+
goto capi_fail;\\
|
| 415 |
+
if (PyBytes_Check(rv_cb_str)) {\\
|
| 416 |
+
str[len-1]='\\0';\\
|
| 417 |
+
STRINGCOPYN((str),PyBytes_AS_STRING((PyBytesObject*)rv_cb_str),(len));\\
|
| 418 |
+
} else {\\
|
| 419 |
+
PRINTPYOBJERR(rv_cb_str);\\
|
| 420 |
+
PyErr_SetString(#modulename#_error,\"string object expected\");\\
|
| 421 |
+
goto capi_fail;\\
|
| 422 |
+
}\\
|
| 423 |
+
}
|
| 424 |
+
"""
|
| 425 |
+
cppmacros['GETSCALARFROMPYTUPLE'] = """
|
| 426 |
+
#define GETSCALARFROMPYTUPLE(tuple,index,var,ctype,mess) {\\
|
| 427 |
+
if ((capi_tmp = PyTuple_GetItem((tuple),(index)))==NULL) goto capi_fail;\\
|
| 428 |
+
if (!(ctype ## _from_pyobj((var),capi_tmp,mess)))\\
|
| 429 |
+
goto capi_fail;\\
|
| 430 |
+
}
|
| 431 |
+
"""
|
| 432 |
+
|
| 433 |
+
cppmacros['FAILNULL'] = """\
|
| 434 |
+
#define FAILNULL(p) do { \\
|
| 435 |
+
if ((p) == NULL) { \\
|
| 436 |
+
PyErr_SetString(PyExc_MemoryError, "NULL pointer found"); \\
|
| 437 |
+
goto capi_fail; \\
|
| 438 |
+
} \\
|
| 439 |
+
} while (0)
|
| 440 |
+
"""
|
| 441 |
+
needs['MEMCOPY'] = ['string.h', 'FAILNULL']
|
| 442 |
+
cppmacros['MEMCOPY'] = """
|
| 443 |
+
#define MEMCOPY(to,from,n)\\
|
| 444 |
+
do { FAILNULL(to); FAILNULL(from); (void)memcpy(to,from,n); } while (0)
|
| 445 |
+
"""
|
| 446 |
+
cppmacros['STRINGMALLOC'] = """
|
| 447 |
+
#define STRINGMALLOC(str,len)\\
|
| 448 |
+
if ((str = (string)malloc(len+1)) == NULL) {\\
|
| 449 |
+
PyErr_SetString(PyExc_MemoryError, \"out of memory\");\\
|
| 450 |
+
goto capi_fail;\\
|
| 451 |
+
} else {\\
|
| 452 |
+
(str)[len] = '\\0';\\
|
| 453 |
+
}
|
| 454 |
+
"""
|
| 455 |
+
cppmacros['STRINGFREE'] = """
|
| 456 |
+
#define STRINGFREE(str) do {if (!(str == NULL)) free(str);} while (0)
|
| 457 |
+
"""
|
| 458 |
+
needs['STRINGPADN'] = ['string.h']
|
| 459 |
+
cppmacros['STRINGPADN'] = """
|
| 460 |
+
/*
|
| 461 |
+
STRINGPADN replaces null values with padding values from the right.
|
| 462 |
+
|
| 463 |
+
`to` must have size of at least N bytes.
|
| 464 |
+
|
| 465 |
+
If the `to[N-1]` has null value, then replace it and all the
|
| 466 |
+
preceding, nulls with the given padding.
|
| 467 |
+
|
| 468 |
+
STRINGPADN(to, N, PADDING, NULLVALUE) is an inverse operation.
|
| 469 |
+
*/
|
| 470 |
+
#define STRINGPADN(to, N, NULLVALUE, PADDING) \\
|
| 471 |
+
do { \\
|
| 472 |
+
int _m = (N); \\
|
| 473 |
+
char *_to = (to); \\
|
| 474 |
+
for (_m -= 1; _m >= 0 && _to[_m] == NULLVALUE; _m--) { \\
|
| 475 |
+
_to[_m] = PADDING; \\
|
| 476 |
+
} \\
|
| 477 |
+
} while (0)
|
| 478 |
+
"""
|
| 479 |
+
needs['STRINGCOPYN'] = ['string.h', 'FAILNULL']
|
| 480 |
+
cppmacros['STRINGCOPYN'] = """
|
| 481 |
+
/*
|
| 482 |
+
STRINGCOPYN copies N bytes.
|
| 483 |
+
|
| 484 |
+
`to` and `from` buffers must have sizes of at least N bytes.
|
| 485 |
+
*/
|
| 486 |
+
#define STRINGCOPYN(to,from,N) \\
|
| 487 |
+
do { \\
|
| 488 |
+
int _m = (N); \\
|
| 489 |
+
char *_to = (to); \\
|
| 490 |
+
char *_from = (from); \\
|
| 491 |
+
FAILNULL(_to); FAILNULL(_from); \\
|
| 492 |
+
(void)strncpy(_to, _from, _m); \\
|
| 493 |
+
} while (0)
|
| 494 |
+
"""
|
| 495 |
+
needs['STRINGCOPY'] = ['string.h', 'FAILNULL']
|
| 496 |
+
cppmacros['STRINGCOPY'] = """
|
| 497 |
+
#define STRINGCOPY(to,from)\\
|
| 498 |
+
do { FAILNULL(to); FAILNULL(from); (void)strcpy(to,from); } while (0)
|
| 499 |
+
"""
|
| 500 |
+
cppmacros['CHECKGENERIC'] = """
|
| 501 |
+
#define CHECKGENERIC(check,tcheck,name) \\
|
| 502 |
+
if (!(check)) {\\
|
| 503 |
+
PyErr_SetString(#modulename#_error,\"(\"tcheck\") failed for \"name);\\
|
| 504 |
+
/*goto capi_fail;*/\\
|
| 505 |
+
} else """
|
| 506 |
+
cppmacros['CHECKARRAY'] = """
|
| 507 |
+
#define CHECKARRAY(check,tcheck,name) \\
|
| 508 |
+
if (!(check)) {\\
|
| 509 |
+
PyErr_SetString(#modulename#_error,\"(\"tcheck\") failed for \"name);\\
|
| 510 |
+
/*goto capi_fail;*/\\
|
| 511 |
+
} else """
|
| 512 |
+
cppmacros['CHECKSTRING'] = """
|
| 513 |
+
#define CHECKSTRING(check,tcheck,name,show,var)\\
|
| 514 |
+
if (!(check)) {\\
|
| 515 |
+
char errstring[256];\\
|
| 516 |
+
sprintf(errstring, \"%s: \"show, \"(\"tcheck\") failed for \"name, slen(var), var);\\
|
| 517 |
+
PyErr_SetString(#modulename#_error, errstring);\\
|
| 518 |
+
/*goto capi_fail;*/\\
|
| 519 |
+
} else """
|
| 520 |
+
cppmacros['CHECKSCALAR'] = """
|
| 521 |
+
#define CHECKSCALAR(check,tcheck,name,show,var)\\
|
| 522 |
+
if (!(check)) {\\
|
| 523 |
+
char errstring[256];\\
|
| 524 |
+
sprintf(errstring, \"%s: \"show, \"(\"tcheck\") failed for \"name, var);\\
|
| 525 |
+
PyErr_SetString(#modulename#_error,errstring);\\
|
| 526 |
+
/*goto capi_fail;*/\\
|
| 527 |
+
} else """
|
| 528 |
+
# cppmacros['CHECKDIMS']="""
|
| 529 |
+
# define CHECKDIMS(dims,rank) \\
|
| 530 |
+
# for (int i=0;i<(rank);i++)\\
|
| 531 |
+
# if (dims[i]<0) {\\
|
| 532 |
+
# fprintf(stderr,\"Unspecified array argument requires a complete dimension specification.\\n\");\\
|
| 533 |
+
# goto capi_fail;\\
|
| 534 |
+
# }
|
| 535 |
+
# """
|
| 536 |
+
cppmacros[
|
| 537 |
+
'ARRSIZE'] = '#define ARRSIZE(dims,rank) (_PyArray_multiply_list(dims,rank))'
|
| 538 |
+
cppmacros['OLDPYNUM'] = """
|
| 539 |
+
#ifdef OLDPYNUM
|
| 540 |
+
#error You need to install NumPy version 0.13 or higher. See https://scipy.org/install.html
|
| 541 |
+
#endif
|
| 542 |
+
"""
|
| 543 |
+
cppmacros["F2PY_THREAD_LOCAL_DECL"] = """
|
| 544 |
+
#ifndef F2PY_THREAD_LOCAL_DECL
|
| 545 |
+
#if defined(_MSC_VER)
|
| 546 |
+
#define F2PY_THREAD_LOCAL_DECL __declspec(thread)
|
| 547 |
+
#elif defined(NPY_OS_MINGW)
|
| 548 |
+
#define F2PY_THREAD_LOCAL_DECL __thread
|
| 549 |
+
#elif defined(__STDC_VERSION__) \\
|
| 550 |
+
&& (__STDC_VERSION__ >= 201112L) \\
|
| 551 |
+
&& !defined(__STDC_NO_THREADS__) \\
|
| 552 |
+
&& (!defined(__GLIBC__) || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 12)) \\
|
| 553 |
+
&& !defined(NPY_OS_OPENBSD) && !defined(NPY_OS_HAIKU)
|
| 554 |
+
/* __STDC_NO_THREADS__ was first defined in a maintenance release of glibc 2.12,
|
| 555 |
+
see https://lists.gnu.org/archive/html/commit-hurd/2012-07/msg00180.html,
|
| 556 |
+
so `!defined(__STDC_NO_THREADS__)` may give false positive for the existence
|
| 557 |
+
of `threads.h` when using an older release of glibc 2.12
|
| 558 |
+
See gh-19437 for details on OpenBSD */
|
| 559 |
+
#include <threads.h>
|
| 560 |
+
#define F2PY_THREAD_LOCAL_DECL thread_local
|
| 561 |
+
#elif defined(__GNUC__) \\
|
| 562 |
+
&& (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 4)))
|
| 563 |
+
#define F2PY_THREAD_LOCAL_DECL __thread
|
| 564 |
+
#endif
|
| 565 |
+
#endif
|
| 566 |
+
"""
|
| 567 |
+
################# C functions ###############
|
| 568 |
+
|
| 569 |
+
cfuncs['calcarrindex'] = """
|
| 570 |
+
static int calcarrindex(int *i,PyArrayObject *arr) {
|
| 571 |
+
int k,ii = i[0];
|
| 572 |
+
for (k=1; k < PyArray_NDIM(arr); k++)
|
| 573 |
+
ii += (ii*(PyArray_DIM(arr,k) - 1)+i[k]); /* assuming contiguous arr */
|
| 574 |
+
return ii;
|
| 575 |
+
}"""
|
| 576 |
+
cfuncs['calcarrindextr'] = """
|
| 577 |
+
static int calcarrindextr(int *i,PyArrayObject *arr) {
|
| 578 |
+
int k,ii = i[PyArray_NDIM(arr)-1];
|
| 579 |
+
for (k=1; k < PyArray_NDIM(arr); k++)
|
| 580 |
+
ii += (ii*(PyArray_DIM(arr,PyArray_NDIM(arr)-k-1) - 1)+i[PyArray_NDIM(arr)-k-1]); /* assuming contiguous arr */
|
| 581 |
+
return ii;
|
| 582 |
+
}"""
|
| 583 |
+
cfuncs['forcomb'] = """
|
| 584 |
+
static struct { int nd;npy_intp *d;int *i,*i_tr,tr; } forcombcache;
|
| 585 |
+
static int initforcomb(npy_intp *dims,int nd,int tr) {
|
| 586 |
+
int k;
|
| 587 |
+
if (dims==NULL) return 0;
|
| 588 |
+
if (nd<0) return 0;
|
| 589 |
+
forcombcache.nd = nd;
|
| 590 |
+
forcombcache.d = dims;
|
| 591 |
+
forcombcache.tr = tr;
|
| 592 |
+
if ((forcombcache.i = (int *)malloc(sizeof(int)*nd))==NULL) return 0;
|
| 593 |
+
if ((forcombcache.i_tr = (int *)malloc(sizeof(int)*nd))==NULL) return 0;
|
| 594 |
+
for (k=1;k<nd;k++) {
|
| 595 |
+
forcombcache.i[k] = forcombcache.i_tr[nd-k-1] = 0;
|
| 596 |
+
}
|
| 597 |
+
forcombcache.i[0] = forcombcache.i_tr[nd-1] = -1;
|
| 598 |
+
return 1;
|
| 599 |
+
}
|
| 600 |
+
static int *nextforcomb(void) {
|
| 601 |
+
int j,*i,*i_tr,k;
|
| 602 |
+
int nd=forcombcache.nd;
|
| 603 |
+
if ((i=forcombcache.i) == NULL) return NULL;
|
| 604 |
+
if ((i_tr=forcombcache.i_tr) == NULL) return NULL;
|
| 605 |
+
if (forcombcache.d == NULL) return NULL;
|
| 606 |
+
i[0]++;
|
| 607 |
+
if (i[0]==forcombcache.d[0]) {
|
| 608 |
+
j=1;
|
| 609 |
+
while ((j<nd) && (i[j]==forcombcache.d[j]-1)) j++;
|
| 610 |
+
if (j==nd) {
|
| 611 |
+
free(i);
|
| 612 |
+
free(i_tr);
|
| 613 |
+
return NULL;
|
| 614 |
+
}
|
| 615 |
+
for (k=0;k<j;k++) i[k] = i_tr[nd-k-1] = 0;
|
| 616 |
+
i[j]++;
|
| 617 |
+
i_tr[nd-j-1]++;
|
| 618 |
+
} else
|
| 619 |
+
i_tr[nd-1]++;
|
| 620 |
+
if (forcombcache.tr) return i_tr;
|
| 621 |
+
return i;
|
| 622 |
+
}"""
|
| 623 |
+
needs['try_pyarr_from_string'] = ['STRINGCOPYN', 'PRINTPYOBJERR', 'string']
|
| 624 |
+
cfuncs['try_pyarr_from_string'] = """
|
| 625 |
+
/*
|
| 626 |
+
try_pyarr_from_string copies str[:len(obj)] to the data of an `ndarray`.
|
| 627 |
+
|
| 628 |
+
If obj is an `ndarray`, it is assumed to be contiguous.
|
| 629 |
+
|
| 630 |
+
If the specified len==-1, str must be null-terminated.
|
| 631 |
+
*/
|
| 632 |
+
static int try_pyarr_from_string(PyObject *obj,
|
| 633 |
+
const string str, const int len) {
|
| 634 |
+
#ifdef DEBUGCFUNCS
|
| 635 |
+
fprintf(stderr, "try_pyarr_from_string(str='%s', len=%d, obj=%p)\\n",
|
| 636 |
+
(char*)str,len, obj);
|
| 637 |
+
#endif
|
| 638 |
+
if (!obj) return -2; /* Object missing */
|
| 639 |
+
if (obj == Py_None) return -1; /* None */
|
| 640 |
+
if (!PyArray_Check(obj)) goto capi_fail; /* not an ndarray */
|
| 641 |
+
if (PyArray_Check(obj)) {
|
| 642 |
+
PyArrayObject *arr = (PyArrayObject *)obj;
|
| 643 |
+
assert(ISCONTIGUOUS(arr));
|
| 644 |
+
string buf = PyArray_DATA(arr);
|
| 645 |
+
npy_intp n = len;
|
| 646 |
+
if (n == -1) {
|
| 647 |
+
/* Assuming null-terminated str. */
|
| 648 |
+
n = strlen(str);
|
| 649 |
+
}
|
| 650 |
+
if (n > PyArray_NBYTES(arr)) {
|
| 651 |
+
n = PyArray_NBYTES(arr);
|
| 652 |
+
}
|
| 653 |
+
STRINGCOPYN(buf, str, n);
|
| 654 |
+
return 1;
|
| 655 |
+
}
|
| 656 |
+
capi_fail:
|
| 657 |
+
PRINTPYOBJERR(obj);
|
| 658 |
+
PyErr_SetString(#modulename#_error, \"try_pyarr_from_string failed\");
|
| 659 |
+
return 0;
|
| 660 |
+
}
|
| 661 |
+
"""
|
| 662 |
+
needs['string_from_pyobj'] = ['string', 'STRINGMALLOC', 'STRINGCOPYN']
|
| 663 |
+
cfuncs['string_from_pyobj'] = """
|
| 664 |
+
/*
|
| 665 |
+
Create a new string buffer `str` of at most length `len` from a
|
| 666 |
+
Python string-like object `obj`.
|
| 667 |
+
|
| 668 |
+
The string buffer has given size (len) or the size of inistr when len==-1.
|
| 669 |
+
|
| 670 |
+
The string buffer is padded with blanks: in Fortran, trailing blanks
|
| 671 |
+
are insignificant contrary to C nulls.
|
| 672 |
+
*/
|
| 673 |
+
static int
|
| 674 |
+
string_from_pyobj(string *str, int *len, const string inistr, PyObject *obj,
|
| 675 |
+
const char *errmess)
|
| 676 |
+
{
|
| 677 |
+
PyObject *tmp = NULL;
|
| 678 |
+
string buf = NULL;
|
| 679 |
+
npy_intp n = -1;
|
| 680 |
+
#ifdef DEBUGCFUNCS
|
| 681 |
+
fprintf(stderr,\"string_from_pyobj(str='%s',len=%d,inistr='%s',obj=%p)\\n\",
|
| 682 |
+
(char*)str, *len, (char *)inistr, obj);
|
| 683 |
+
#endif
|
| 684 |
+
if (obj == Py_None) {
|
| 685 |
+
n = strlen(inistr);
|
| 686 |
+
buf = inistr;
|
| 687 |
+
}
|
| 688 |
+
else if (PyArray_Check(obj)) {
|
| 689 |
+
PyArrayObject *arr = (PyArrayObject *)obj;
|
| 690 |
+
if (!ISCONTIGUOUS(arr)) {
|
| 691 |
+
PyErr_SetString(PyExc_ValueError,
|
| 692 |
+
\"array object is non-contiguous.\");
|
| 693 |
+
goto capi_fail;
|
| 694 |
+
}
|
| 695 |
+
n = PyArray_NBYTES(arr);
|
| 696 |
+
buf = PyArray_DATA(arr);
|
| 697 |
+
n = strnlen(buf, n);
|
| 698 |
+
}
|
| 699 |
+
else {
|
| 700 |
+
if (PyBytes_Check(obj)) {
|
| 701 |
+
tmp = obj;
|
| 702 |
+
Py_INCREF(tmp);
|
| 703 |
+
}
|
| 704 |
+
else if (PyUnicode_Check(obj)) {
|
| 705 |
+
tmp = PyUnicode_AsASCIIString(obj);
|
| 706 |
+
}
|
| 707 |
+
else {
|
| 708 |
+
PyObject *tmp2;
|
| 709 |
+
tmp2 = PyObject_Str(obj);
|
| 710 |
+
if (tmp2) {
|
| 711 |
+
tmp = PyUnicode_AsASCIIString(tmp2);
|
| 712 |
+
Py_DECREF(tmp2);
|
| 713 |
+
}
|
| 714 |
+
else {
|
| 715 |
+
tmp = NULL;
|
| 716 |
+
}
|
| 717 |
+
}
|
| 718 |
+
if (tmp == NULL) goto capi_fail;
|
| 719 |
+
n = PyBytes_GET_SIZE(tmp);
|
| 720 |
+
buf = PyBytes_AS_STRING(tmp);
|
| 721 |
+
}
|
| 722 |
+
if (*len == -1) {
|
| 723 |
+
/* TODO: change the type of `len` so that we can remove this */
|
| 724 |
+
if (n > NPY_MAX_INT) {
|
| 725 |
+
PyErr_SetString(PyExc_OverflowError,
|
| 726 |
+
"object too large for a 32-bit int");
|
| 727 |
+
goto capi_fail;
|
| 728 |
+
}
|
| 729 |
+
*len = n;
|
| 730 |
+
}
|
| 731 |
+
else if (*len < n) {
|
| 732 |
+
/* discard the last (len-n) bytes of input buf */
|
| 733 |
+
n = *len;
|
| 734 |
+
}
|
| 735 |
+
if (n < 0 || *len < 0 || buf == NULL) {
|
| 736 |
+
goto capi_fail;
|
| 737 |
+
}
|
| 738 |
+
STRINGMALLOC(*str, *len); // *str is allocated with size (*len + 1)
|
| 739 |
+
if (n < *len) {
|
| 740 |
+
/*
|
| 741 |
+
Pad fixed-width string with nulls. The caller will replace
|
| 742 |
+
nulls with blanks when the corresponding argument is not
|
| 743 |
+
intent(c).
|
| 744 |
+
*/
|
| 745 |
+
memset(*str + n, '\\0', *len - n);
|
| 746 |
+
}
|
| 747 |
+
STRINGCOPYN(*str, buf, n);
|
| 748 |
+
Py_XDECREF(tmp);
|
| 749 |
+
return 1;
|
| 750 |
+
capi_fail:
|
| 751 |
+
Py_XDECREF(tmp);
|
| 752 |
+
{
|
| 753 |
+
PyObject* err = PyErr_Occurred();
|
| 754 |
+
if (err == NULL) {
|
| 755 |
+
err = #modulename#_error;
|
| 756 |
+
}
|
| 757 |
+
PyErr_SetString(err, errmess);
|
| 758 |
+
}
|
| 759 |
+
return 0;
|
| 760 |
+
}
|
| 761 |
+
"""
|
| 762 |
+
|
| 763 |
+
cfuncs['character_from_pyobj'] = """
|
| 764 |
+
static int
|
| 765 |
+
character_from_pyobj(character* v, PyObject *obj, const char *errmess) {
|
| 766 |
+
if (PyBytes_Check(obj)) {
|
| 767 |
+
/* empty bytes has trailing null, so dereferencing is always safe */
|
| 768 |
+
*v = PyBytes_AS_STRING(obj)[0];
|
| 769 |
+
return 1;
|
| 770 |
+
} else if (PyUnicode_Check(obj)) {
|
| 771 |
+
PyObject* tmp = PyUnicode_AsASCIIString(obj);
|
| 772 |
+
if (tmp != NULL) {
|
| 773 |
+
*v = PyBytes_AS_STRING(tmp)[0];
|
| 774 |
+
Py_DECREF(tmp);
|
| 775 |
+
return 1;
|
| 776 |
+
}
|
| 777 |
+
} else if (PyArray_Check(obj)) {
|
| 778 |
+
PyArrayObject* arr = (PyArrayObject*)obj;
|
| 779 |
+
if (F2PY_ARRAY_IS_CHARACTER_COMPATIBLE(arr)) {
|
| 780 |
+
*v = PyArray_BYTES(arr)[0];
|
| 781 |
+
return 1;
|
| 782 |
+
} else if (F2PY_IS_UNICODE_ARRAY(arr)) {
|
| 783 |
+
// TODO: update when numpy will support 1-byte and
|
| 784 |
+
// 2-byte unicode dtypes
|
| 785 |
+
PyObject* tmp = PyUnicode_FromKindAndData(
|
| 786 |
+
PyUnicode_4BYTE_KIND,
|
| 787 |
+
PyArray_BYTES(arr),
|
| 788 |
+
(PyArray_NBYTES(arr)>0?1:0));
|
| 789 |
+
if (tmp != NULL) {
|
| 790 |
+
if (character_from_pyobj(v, tmp, errmess)) {
|
| 791 |
+
Py_DECREF(tmp);
|
| 792 |
+
return 1;
|
| 793 |
+
}
|
| 794 |
+
Py_DECREF(tmp);
|
| 795 |
+
}
|
| 796 |
+
}
|
| 797 |
+
} else if (PySequence_Check(obj)) {
|
| 798 |
+
PyObject* tmp = PySequence_GetItem(obj,0);
|
| 799 |
+
if (tmp != NULL) {
|
| 800 |
+
if (character_from_pyobj(v, tmp, errmess)) {
|
| 801 |
+
Py_DECREF(tmp);
|
| 802 |
+
return 1;
|
| 803 |
+
}
|
| 804 |
+
Py_DECREF(tmp);
|
| 805 |
+
}
|
| 806 |
+
}
|
| 807 |
+
{
|
| 808 |
+
/* TODO: This error (and most other) error handling needs cleaning. */
|
| 809 |
+
char mess[F2PY_MESSAGE_BUFFER_SIZE];
|
| 810 |
+
strcpy(mess, errmess);
|
| 811 |
+
PyObject* err = PyErr_Occurred();
|
| 812 |
+
if (err == NULL) {
|
| 813 |
+
err = PyExc_TypeError;
|
| 814 |
+
Py_INCREF(err);
|
| 815 |
+
}
|
| 816 |
+
else {
|
| 817 |
+
Py_INCREF(err);
|
| 818 |
+
PyErr_Clear();
|
| 819 |
+
}
|
| 820 |
+
sprintf(mess + strlen(mess),
|
| 821 |
+
" -- expected str|bytes|sequence-of-str-or-bytes, got ");
|
| 822 |
+
f2py_describe(obj, mess + strlen(mess));
|
| 823 |
+
PyErr_SetString(err, mess);
|
| 824 |
+
Py_DECREF(err);
|
| 825 |
+
}
|
| 826 |
+
return 0;
|
| 827 |
+
}
|
| 828 |
+
"""
|
| 829 |
+
|
| 830 |
+
# TODO: These should be dynamically generated, too many mapped to int things,
|
| 831 |
+
# see note in _isocbind.py
|
| 832 |
+
needs['char_from_pyobj'] = ['int_from_pyobj']
|
| 833 |
+
cfuncs['char_from_pyobj'] = """
|
| 834 |
+
static int
|
| 835 |
+
char_from_pyobj(char* v, PyObject *obj, const char *errmess) {
|
| 836 |
+
int i = 0;
|
| 837 |
+
if (int_from_pyobj(&i, obj, errmess)) {
|
| 838 |
+
*v = (char)i;
|
| 839 |
+
return 1;
|
| 840 |
+
}
|
| 841 |
+
return 0;
|
| 842 |
+
}
|
| 843 |
+
"""
|
| 844 |
+
|
| 845 |
+
|
| 846 |
+
needs['signed_char_from_pyobj'] = ['int_from_pyobj', 'signed_char']
|
| 847 |
+
cfuncs['signed_char_from_pyobj'] = """
|
| 848 |
+
static int
|
| 849 |
+
signed_char_from_pyobj(signed_char* v, PyObject *obj, const char *errmess) {
|
| 850 |
+
int i = 0;
|
| 851 |
+
if (int_from_pyobj(&i, obj, errmess)) {
|
| 852 |
+
*v = (signed_char)i;
|
| 853 |
+
return 1;
|
| 854 |
+
}
|
| 855 |
+
return 0;
|
| 856 |
+
}
|
| 857 |
+
"""
|
| 858 |
+
|
| 859 |
+
|
| 860 |
+
needs['short_from_pyobj'] = ['int_from_pyobj']
|
| 861 |
+
cfuncs['short_from_pyobj'] = """
|
| 862 |
+
static int
|
| 863 |
+
short_from_pyobj(short* v, PyObject *obj, const char *errmess) {
|
| 864 |
+
int i = 0;
|
| 865 |
+
if (int_from_pyobj(&i, obj, errmess)) {
|
| 866 |
+
*v = (short)i;
|
| 867 |
+
return 1;
|
| 868 |
+
}
|
| 869 |
+
return 0;
|
| 870 |
+
}
|
| 871 |
+
"""
|
| 872 |
+
|
| 873 |
+
|
| 874 |
+
cfuncs['int_from_pyobj'] = """
|
| 875 |
+
static int
|
| 876 |
+
int_from_pyobj(int* v, PyObject *obj, const char *errmess)
|
| 877 |
+
{
|
| 878 |
+
PyObject* tmp = NULL;
|
| 879 |
+
|
| 880 |
+
if (PyLong_Check(obj)) {
|
| 881 |
+
*v = Npy__PyLong_AsInt(obj);
|
| 882 |
+
return !(*v == -1 && PyErr_Occurred());
|
| 883 |
+
}
|
| 884 |
+
|
| 885 |
+
tmp = PyNumber_Long(obj);
|
| 886 |
+
if (tmp) {
|
| 887 |
+
*v = Npy__PyLong_AsInt(tmp);
|
| 888 |
+
Py_DECREF(tmp);
|
| 889 |
+
return !(*v == -1 && PyErr_Occurred());
|
| 890 |
+
}
|
| 891 |
+
|
| 892 |
+
if (PyComplex_Check(obj)) {
|
| 893 |
+
PyErr_Clear();
|
| 894 |
+
tmp = PyObject_GetAttrString(obj,\"real\");
|
| 895 |
+
}
|
| 896 |
+
else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) {
|
| 897 |
+
/*pass*/;
|
| 898 |
+
}
|
| 899 |
+
else if (PySequence_Check(obj)) {
|
| 900 |
+
PyErr_Clear();
|
| 901 |
+
tmp = PySequence_GetItem(obj, 0);
|
| 902 |
+
}
|
| 903 |
+
|
| 904 |
+
if (tmp) {
|
| 905 |
+
if (int_from_pyobj(v, tmp, errmess)) {
|
| 906 |
+
Py_DECREF(tmp);
|
| 907 |
+
return 1;
|
| 908 |
+
}
|
| 909 |
+
Py_DECREF(tmp);
|
| 910 |
+
}
|
| 911 |
+
|
| 912 |
+
{
|
| 913 |
+
PyObject* err = PyErr_Occurred();
|
| 914 |
+
if (err == NULL) {
|
| 915 |
+
err = #modulename#_error;
|
| 916 |
+
}
|
| 917 |
+
PyErr_SetString(err, errmess);
|
| 918 |
+
}
|
| 919 |
+
return 0;
|
| 920 |
+
}
|
| 921 |
+
"""
|
| 922 |
+
|
| 923 |
+
|
| 924 |
+
cfuncs['long_from_pyobj'] = """
|
| 925 |
+
static int
|
| 926 |
+
long_from_pyobj(long* v, PyObject *obj, const char *errmess) {
|
| 927 |
+
PyObject* tmp = NULL;
|
| 928 |
+
|
| 929 |
+
if (PyLong_Check(obj)) {
|
| 930 |
+
*v = PyLong_AsLong(obj);
|
| 931 |
+
return !(*v == -1 && PyErr_Occurred());
|
| 932 |
+
}
|
| 933 |
+
|
| 934 |
+
tmp = PyNumber_Long(obj);
|
| 935 |
+
if (tmp) {
|
| 936 |
+
*v = PyLong_AsLong(tmp);
|
| 937 |
+
Py_DECREF(tmp);
|
| 938 |
+
return !(*v == -1 && PyErr_Occurred());
|
| 939 |
+
}
|
| 940 |
+
|
| 941 |
+
if (PyComplex_Check(obj)) {
|
| 942 |
+
PyErr_Clear();
|
| 943 |
+
tmp = PyObject_GetAttrString(obj,\"real\");
|
| 944 |
+
}
|
| 945 |
+
else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) {
|
| 946 |
+
/*pass*/;
|
| 947 |
+
}
|
| 948 |
+
else if (PySequence_Check(obj)) {
|
| 949 |
+
PyErr_Clear();
|
| 950 |
+
tmp = PySequence_GetItem(obj, 0);
|
| 951 |
+
}
|
| 952 |
+
|
| 953 |
+
if (tmp) {
|
| 954 |
+
if (long_from_pyobj(v, tmp, errmess)) {
|
| 955 |
+
Py_DECREF(tmp);
|
| 956 |
+
return 1;
|
| 957 |
+
}
|
| 958 |
+
Py_DECREF(tmp);
|
| 959 |
+
}
|
| 960 |
+
{
|
| 961 |
+
PyObject* err = PyErr_Occurred();
|
| 962 |
+
if (err == NULL) {
|
| 963 |
+
err = #modulename#_error;
|
| 964 |
+
}
|
| 965 |
+
PyErr_SetString(err, errmess);
|
| 966 |
+
}
|
| 967 |
+
return 0;
|
| 968 |
+
}
|
| 969 |
+
"""
|
| 970 |
+
|
| 971 |
+
|
| 972 |
+
needs['long_long_from_pyobj'] = ['long_long']
|
| 973 |
+
cfuncs['long_long_from_pyobj'] = """
|
| 974 |
+
static int
|
| 975 |
+
long_long_from_pyobj(long_long* v, PyObject *obj, const char *errmess)
|
| 976 |
+
{
|
| 977 |
+
PyObject* tmp = NULL;
|
| 978 |
+
|
| 979 |
+
if (PyLong_Check(obj)) {
|
| 980 |
+
*v = PyLong_AsLongLong(obj);
|
| 981 |
+
return !(*v == -1 && PyErr_Occurred());
|
| 982 |
+
}
|
| 983 |
+
|
| 984 |
+
tmp = PyNumber_Long(obj);
|
| 985 |
+
if (tmp) {
|
| 986 |
+
*v = PyLong_AsLongLong(tmp);
|
| 987 |
+
Py_DECREF(tmp);
|
| 988 |
+
return !(*v == -1 && PyErr_Occurred());
|
| 989 |
+
}
|
| 990 |
+
|
| 991 |
+
if (PyComplex_Check(obj)) {
|
| 992 |
+
PyErr_Clear();
|
| 993 |
+
tmp = PyObject_GetAttrString(obj,\"real\");
|
| 994 |
+
}
|
| 995 |
+
else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) {
|
| 996 |
+
/*pass*/;
|
| 997 |
+
}
|
| 998 |
+
else if (PySequence_Check(obj)) {
|
| 999 |
+
PyErr_Clear();
|
| 1000 |
+
tmp = PySequence_GetItem(obj, 0);
|
| 1001 |
+
}
|
| 1002 |
+
|
| 1003 |
+
if (tmp) {
|
| 1004 |
+
if (long_long_from_pyobj(v, tmp, errmess)) {
|
| 1005 |
+
Py_DECREF(tmp);
|
| 1006 |
+
return 1;
|
| 1007 |
+
}
|
| 1008 |
+
Py_DECREF(tmp);
|
| 1009 |
+
}
|
| 1010 |
+
{
|
| 1011 |
+
PyObject* err = PyErr_Occurred();
|
| 1012 |
+
if (err == NULL) {
|
| 1013 |
+
err = #modulename#_error;
|
| 1014 |
+
}
|
| 1015 |
+
PyErr_SetString(err,errmess);
|
| 1016 |
+
}
|
| 1017 |
+
return 0;
|
| 1018 |
+
}
|
| 1019 |
+
"""
|
| 1020 |
+
|
| 1021 |
+
|
| 1022 |
+
needs['long_double_from_pyobj'] = ['double_from_pyobj', 'long_double']
|
| 1023 |
+
cfuncs['long_double_from_pyobj'] = """
|
| 1024 |
+
static int
|
| 1025 |
+
long_double_from_pyobj(long_double* v, PyObject *obj, const char *errmess)
|
| 1026 |
+
{
|
| 1027 |
+
double d=0;
|
| 1028 |
+
if (PyArray_CheckScalar(obj)){
|
| 1029 |
+
if PyArray_IsScalar(obj, LongDouble) {
|
| 1030 |
+
PyArray_ScalarAsCtype(obj, v);
|
| 1031 |
+
return 1;
|
| 1032 |
+
}
|
| 1033 |
+
else if (PyArray_Check(obj) && PyArray_TYPE(obj) == NPY_LONGDOUBLE) {
|
| 1034 |
+
(*v) = *((npy_longdouble *)PyArray_DATA(obj));
|
| 1035 |
+
return 1;
|
| 1036 |
+
}
|
| 1037 |
+
}
|
| 1038 |
+
if (double_from_pyobj(&d, obj, errmess)) {
|
| 1039 |
+
*v = (long_double)d;
|
| 1040 |
+
return 1;
|
| 1041 |
+
}
|
| 1042 |
+
return 0;
|
| 1043 |
+
}
|
| 1044 |
+
"""
|
| 1045 |
+
|
| 1046 |
+
|
| 1047 |
+
cfuncs['double_from_pyobj'] = """
|
| 1048 |
+
static int
|
| 1049 |
+
double_from_pyobj(double* v, PyObject *obj, const char *errmess)
|
| 1050 |
+
{
|
| 1051 |
+
PyObject* tmp = NULL;
|
| 1052 |
+
if (PyFloat_Check(obj)) {
|
| 1053 |
+
*v = PyFloat_AsDouble(obj);
|
| 1054 |
+
return !(*v == -1.0 && PyErr_Occurred());
|
| 1055 |
+
}
|
| 1056 |
+
|
| 1057 |
+
tmp = PyNumber_Float(obj);
|
| 1058 |
+
if (tmp) {
|
| 1059 |
+
*v = PyFloat_AsDouble(tmp);
|
| 1060 |
+
Py_DECREF(tmp);
|
| 1061 |
+
return !(*v == -1.0 && PyErr_Occurred());
|
| 1062 |
+
}
|
| 1063 |
+
|
| 1064 |
+
if (PyComplex_Check(obj)) {
|
| 1065 |
+
PyErr_Clear();
|
| 1066 |
+
tmp = PyObject_GetAttrString(obj,\"real\");
|
| 1067 |
+
}
|
| 1068 |
+
else if (PyBytes_Check(obj) || PyUnicode_Check(obj)) {
|
| 1069 |
+
/*pass*/;
|
| 1070 |
+
}
|
| 1071 |
+
else if (PySequence_Check(obj)) {
|
| 1072 |
+
PyErr_Clear();
|
| 1073 |
+
tmp = PySequence_GetItem(obj, 0);
|
| 1074 |
+
}
|
| 1075 |
+
|
| 1076 |
+
if (tmp) {
|
| 1077 |
+
if (double_from_pyobj(v,tmp,errmess)) {Py_DECREF(tmp); return 1;}
|
| 1078 |
+
Py_DECREF(tmp);
|
| 1079 |
+
}
|
| 1080 |
+
{
|
| 1081 |
+
PyObject* err = PyErr_Occurred();
|
| 1082 |
+
if (err==NULL) err = #modulename#_error;
|
| 1083 |
+
PyErr_SetString(err,errmess);
|
| 1084 |
+
}
|
| 1085 |
+
return 0;
|
| 1086 |
+
}
|
| 1087 |
+
"""
|
| 1088 |
+
|
| 1089 |
+
|
| 1090 |
+
needs['float_from_pyobj'] = ['double_from_pyobj']
|
| 1091 |
+
cfuncs['float_from_pyobj'] = """
|
| 1092 |
+
static int
|
| 1093 |
+
float_from_pyobj(float* v, PyObject *obj, const char *errmess)
|
| 1094 |
+
{
|
| 1095 |
+
double d=0.0;
|
| 1096 |
+
if (double_from_pyobj(&d,obj,errmess)) {
|
| 1097 |
+
*v = (float)d;
|
| 1098 |
+
return 1;
|
| 1099 |
+
}
|
| 1100 |
+
return 0;
|
| 1101 |
+
}
|
| 1102 |
+
"""
|
| 1103 |
+
|
| 1104 |
+
|
| 1105 |
+
needs['complex_long_double_from_pyobj'] = ['complex_long_double', 'long_double',
|
| 1106 |
+
'complex_double_from_pyobj', 'npy_math.h']
|
| 1107 |
+
cfuncs['complex_long_double_from_pyobj'] = """
|
| 1108 |
+
static int
|
| 1109 |
+
complex_long_double_from_pyobj(complex_long_double* v, PyObject *obj, const char *errmess)
|
| 1110 |
+
{
|
| 1111 |
+
complex_double cd = {0.0,0.0};
|
| 1112 |
+
if (PyArray_CheckScalar(obj)){
|
| 1113 |
+
if PyArray_IsScalar(obj, CLongDouble) {
|
| 1114 |
+
PyArray_ScalarAsCtype(obj, v);
|
| 1115 |
+
return 1;
|
| 1116 |
+
}
|
| 1117 |
+
else if (PyArray_Check(obj) && PyArray_TYPE(obj)==NPY_CLONGDOUBLE) {
|
| 1118 |
+
(*v).r = npy_creall(*(((npy_clongdouble *)PyArray_DATA(obj))));
|
| 1119 |
+
(*v).i = npy_cimagl(*(((npy_clongdouble *)PyArray_DATA(obj))));
|
| 1120 |
+
return 1;
|
| 1121 |
+
}
|
| 1122 |
+
}
|
| 1123 |
+
if (complex_double_from_pyobj(&cd,obj,errmess)) {
|
| 1124 |
+
(*v).r = (long_double)cd.r;
|
| 1125 |
+
(*v).i = (long_double)cd.i;
|
| 1126 |
+
return 1;
|
| 1127 |
+
}
|
| 1128 |
+
return 0;
|
| 1129 |
+
}
|
| 1130 |
+
"""
|
| 1131 |
+
|
| 1132 |
+
|
| 1133 |
+
needs['complex_double_from_pyobj'] = ['complex_double', 'npy_math.h']
|
| 1134 |
+
cfuncs['complex_double_from_pyobj'] = """
|
| 1135 |
+
static int
|
| 1136 |
+
complex_double_from_pyobj(complex_double* v, PyObject *obj, const char *errmess) {
|
| 1137 |
+
Py_complex c;
|
| 1138 |
+
if (PyComplex_Check(obj)) {
|
| 1139 |
+
c = PyComplex_AsCComplex(obj);
|
| 1140 |
+
(*v).r = c.real;
|
| 1141 |
+
(*v).i = c.imag;
|
| 1142 |
+
return 1;
|
| 1143 |
+
}
|
| 1144 |
+
if (PyArray_IsScalar(obj, ComplexFloating)) {
|
| 1145 |
+
if (PyArray_IsScalar(obj, CFloat)) {
|
| 1146 |
+
npy_cfloat new;
|
| 1147 |
+
PyArray_ScalarAsCtype(obj, &new);
|
| 1148 |
+
(*v).r = (double)npy_crealf(new);
|
| 1149 |
+
(*v).i = (double)npy_cimagf(new);
|
| 1150 |
+
}
|
| 1151 |
+
else if (PyArray_IsScalar(obj, CLongDouble)) {
|
| 1152 |
+
npy_clongdouble new;
|
| 1153 |
+
PyArray_ScalarAsCtype(obj, &new);
|
| 1154 |
+
(*v).r = (double)npy_creall(new);
|
| 1155 |
+
(*v).i = (double)npy_cimagl(new);
|
| 1156 |
+
}
|
| 1157 |
+
else { /* if (PyArray_IsScalar(obj, CDouble)) */
|
| 1158 |
+
PyArray_ScalarAsCtype(obj, v);
|
| 1159 |
+
}
|
| 1160 |
+
return 1;
|
| 1161 |
+
}
|
| 1162 |
+
if (PyArray_CheckScalar(obj)) { /* 0-dim array or still array scalar */
|
| 1163 |
+
PyArrayObject *arr;
|
| 1164 |
+
if (PyArray_Check(obj)) {
|
| 1165 |
+
arr = (PyArrayObject *)PyArray_Cast((PyArrayObject *)obj, NPY_CDOUBLE);
|
| 1166 |
+
}
|
| 1167 |
+
else {
|
| 1168 |
+
arr = (PyArrayObject *)PyArray_FromScalar(obj, PyArray_DescrFromType(NPY_CDOUBLE));
|
| 1169 |
+
}
|
| 1170 |
+
if (arr == NULL) {
|
| 1171 |
+
return 0;
|
| 1172 |
+
}
|
| 1173 |
+
(*v).r = npy_creal(*(((npy_cdouble *)PyArray_DATA(arr))));
|
| 1174 |
+
(*v).i = npy_cimag(*(((npy_cdouble *)PyArray_DATA(arr))));
|
| 1175 |
+
Py_DECREF(arr);
|
| 1176 |
+
return 1;
|
| 1177 |
+
}
|
| 1178 |
+
/* Python does not provide PyNumber_Complex function :-( */
|
| 1179 |
+
(*v).i = 0.0;
|
| 1180 |
+
if (PyFloat_Check(obj)) {
|
| 1181 |
+
(*v).r = PyFloat_AsDouble(obj);
|
| 1182 |
+
return !((*v).r == -1.0 && PyErr_Occurred());
|
| 1183 |
+
}
|
| 1184 |
+
if (PyLong_Check(obj)) {
|
| 1185 |
+
(*v).r = PyLong_AsDouble(obj);
|
| 1186 |
+
return !((*v).r == -1.0 && PyErr_Occurred());
|
| 1187 |
+
}
|
| 1188 |
+
if (PySequence_Check(obj) && !(PyBytes_Check(obj) || PyUnicode_Check(obj))) {
|
| 1189 |
+
PyObject *tmp = PySequence_GetItem(obj,0);
|
| 1190 |
+
if (tmp) {
|
| 1191 |
+
if (complex_double_from_pyobj(v,tmp,errmess)) {
|
| 1192 |
+
Py_DECREF(tmp);
|
| 1193 |
+
return 1;
|
| 1194 |
+
}
|
| 1195 |
+
Py_DECREF(tmp);
|
| 1196 |
+
}
|
| 1197 |
+
}
|
| 1198 |
+
{
|
| 1199 |
+
PyObject* err = PyErr_Occurred();
|
| 1200 |
+
if (err==NULL)
|
| 1201 |
+
err = PyExc_TypeError;
|
| 1202 |
+
PyErr_SetString(err,errmess);
|
| 1203 |
+
}
|
| 1204 |
+
return 0;
|
| 1205 |
+
}
|
| 1206 |
+
"""
|
| 1207 |
+
|
| 1208 |
+
|
| 1209 |
+
needs['complex_float_from_pyobj'] = [
|
| 1210 |
+
'complex_float', 'complex_double_from_pyobj']
|
| 1211 |
+
cfuncs['complex_float_from_pyobj'] = """
|
| 1212 |
+
static int
|
| 1213 |
+
complex_float_from_pyobj(complex_float* v,PyObject *obj,const char *errmess)
|
| 1214 |
+
{
|
| 1215 |
+
complex_double cd={0.0,0.0};
|
| 1216 |
+
if (complex_double_from_pyobj(&cd,obj,errmess)) {
|
| 1217 |
+
(*v).r = (float)cd.r;
|
| 1218 |
+
(*v).i = (float)cd.i;
|
| 1219 |
+
return 1;
|
| 1220 |
+
}
|
| 1221 |
+
return 0;
|
| 1222 |
+
}
|
| 1223 |
+
"""
|
| 1224 |
+
|
| 1225 |
+
|
| 1226 |
+
cfuncs['try_pyarr_from_character'] = """
|
| 1227 |
+
static int try_pyarr_from_character(PyObject* obj, character* v) {
|
| 1228 |
+
PyArrayObject *arr = (PyArrayObject*)obj;
|
| 1229 |
+
if (!obj) return -2;
|
| 1230 |
+
if (PyArray_Check(obj)) {
|
| 1231 |
+
if (F2PY_ARRAY_IS_CHARACTER_COMPATIBLE(arr)) {
|
| 1232 |
+
*(character *)(PyArray_DATA(arr)) = *v;
|
| 1233 |
+
return 1;
|
| 1234 |
+
}
|
| 1235 |
+
}
|
| 1236 |
+
{
|
| 1237 |
+
char mess[F2PY_MESSAGE_BUFFER_SIZE];
|
| 1238 |
+
PyObject* err = PyErr_Occurred();
|
| 1239 |
+
if (err == NULL) {
|
| 1240 |
+
err = PyExc_ValueError;
|
| 1241 |
+
strcpy(mess, "try_pyarr_from_character failed"
|
| 1242 |
+
" -- expected bytes array-scalar|array, got ");
|
| 1243 |
+
f2py_describe(obj, mess + strlen(mess));
|
| 1244 |
+
PyErr_SetString(err, mess);
|
| 1245 |
+
}
|
| 1246 |
+
}
|
| 1247 |
+
return 0;
|
| 1248 |
+
}
|
| 1249 |
+
"""
|
| 1250 |
+
|
| 1251 |
+
needs['try_pyarr_from_char'] = ['pyobj_from_char1', 'TRYPYARRAYTEMPLATE']
|
| 1252 |
+
cfuncs[
|
| 1253 |
+
'try_pyarr_from_char'] = 'static int try_pyarr_from_char(PyObject* obj,char* v) {\n TRYPYARRAYTEMPLATE(char,\'c\');\n}\n'
|
| 1254 |
+
needs['try_pyarr_from_signed_char'] = ['TRYPYARRAYTEMPLATE', 'unsigned_char']
|
| 1255 |
+
cfuncs[
|
| 1256 |
+
'try_pyarr_from_unsigned_char'] = 'static int try_pyarr_from_unsigned_char(PyObject* obj,unsigned_char* v) {\n TRYPYARRAYTEMPLATE(unsigned_char,\'b\');\n}\n'
|
| 1257 |
+
needs['try_pyarr_from_signed_char'] = ['TRYPYARRAYTEMPLATE', 'signed_char']
|
| 1258 |
+
cfuncs[
|
| 1259 |
+
'try_pyarr_from_signed_char'] = 'static int try_pyarr_from_signed_char(PyObject* obj,signed_char* v) {\n TRYPYARRAYTEMPLATE(signed_char,\'1\');\n}\n'
|
| 1260 |
+
needs['try_pyarr_from_short'] = ['pyobj_from_short1', 'TRYPYARRAYTEMPLATE']
|
| 1261 |
+
cfuncs[
|
| 1262 |
+
'try_pyarr_from_short'] = 'static int try_pyarr_from_short(PyObject* obj,short* v) {\n TRYPYARRAYTEMPLATE(short,\'s\');\n}\n'
|
| 1263 |
+
needs['try_pyarr_from_int'] = ['pyobj_from_int1', 'TRYPYARRAYTEMPLATE']
|
| 1264 |
+
cfuncs[
|
| 1265 |
+
'try_pyarr_from_int'] = 'static int try_pyarr_from_int(PyObject* obj,int* v) {\n TRYPYARRAYTEMPLATE(int,\'i\');\n}\n'
|
| 1266 |
+
needs['try_pyarr_from_long'] = ['pyobj_from_long1', 'TRYPYARRAYTEMPLATE']
|
| 1267 |
+
cfuncs[
|
| 1268 |
+
'try_pyarr_from_long'] = 'static int try_pyarr_from_long(PyObject* obj,long* v) {\n TRYPYARRAYTEMPLATE(long,\'l\');\n}\n'
|
| 1269 |
+
needs['try_pyarr_from_long_long'] = [
|
| 1270 |
+
'pyobj_from_long_long1', 'TRYPYARRAYTEMPLATE', 'long_long']
|
| 1271 |
+
cfuncs[
|
| 1272 |
+
'try_pyarr_from_long_long'] = 'static int try_pyarr_from_long_long(PyObject* obj,long_long* v) {\n TRYPYARRAYTEMPLATE(long_long,\'L\');\n}\n'
|
| 1273 |
+
needs['try_pyarr_from_float'] = ['pyobj_from_float1', 'TRYPYARRAYTEMPLATE']
|
| 1274 |
+
cfuncs[
|
| 1275 |
+
'try_pyarr_from_float'] = 'static int try_pyarr_from_float(PyObject* obj,float* v) {\n TRYPYARRAYTEMPLATE(float,\'f\');\n}\n'
|
| 1276 |
+
needs['try_pyarr_from_double'] = ['pyobj_from_double1', 'TRYPYARRAYTEMPLATE']
|
| 1277 |
+
cfuncs[
|
| 1278 |
+
'try_pyarr_from_double'] = 'static int try_pyarr_from_double(PyObject* obj,double* v) {\n TRYPYARRAYTEMPLATE(double,\'d\');\n}\n'
|
| 1279 |
+
needs['try_pyarr_from_complex_float'] = [
|
| 1280 |
+
'pyobj_from_complex_float1', 'TRYCOMPLEXPYARRAYTEMPLATE', 'complex_float']
|
| 1281 |
+
cfuncs[
|
| 1282 |
+
'try_pyarr_from_complex_float'] = 'static int try_pyarr_from_complex_float(PyObject* obj,complex_float* v) {\n TRYCOMPLEXPYARRAYTEMPLATE(float,\'F\');\n}\n'
|
| 1283 |
+
needs['try_pyarr_from_complex_double'] = [
|
| 1284 |
+
'pyobj_from_complex_double1', 'TRYCOMPLEXPYARRAYTEMPLATE', 'complex_double']
|
| 1285 |
+
cfuncs[
|
| 1286 |
+
'try_pyarr_from_complex_double'] = 'static int try_pyarr_from_complex_double(PyObject* obj,complex_double* v) {\n TRYCOMPLEXPYARRAYTEMPLATE(double,\'D\');\n}\n'
|
| 1287 |
+
|
| 1288 |
+
|
| 1289 |
+
needs['create_cb_arglist'] = ['CFUNCSMESS', 'PRINTPYOBJERR', 'MINMAX']
|
| 1290 |
+
# create the list of arguments to be used when calling back to python
|
| 1291 |
+
cfuncs['create_cb_arglist'] = """
|
| 1292 |
+
static int
|
| 1293 |
+
create_cb_arglist(PyObject* fun, PyTupleObject* xa , const int maxnofargs,
|
| 1294 |
+
const int nofoptargs, int *nofargs, PyTupleObject **args,
|
| 1295 |
+
const char *errmess)
|
| 1296 |
+
{
|
| 1297 |
+
PyObject *tmp = NULL;
|
| 1298 |
+
PyObject *tmp_fun = NULL;
|
| 1299 |
+
Py_ssize_t tot, opt, ext, siz, i, di = 0;
|
| 1300 |
+
CFUNCSMESS(\"create_cb_arglist\\n\");
|
| 1301 |
+
tot=opt=ext=siz=0;
|
| 1302 |
+
/* Get the total number of arguments */
|
| 1303 |
+
if (PyFunction_Check(fun)) {
|
| 1304 |
+
tmp_fun = fun;
|
| 1305 |
+
Py_INCREF(tmp_fun);
|
| 1306 |
+
}
|
| 1307 |
+
else {
|
| 1308 |
+
di = 1;
|
| 1309 |
+
if (PyObject_HasAttrString(fun,\"im_func\")) {
|
| 1310 |
+
tmp_fun = PyObject_GetAttrString(fun,\"im_func\");
|
| 1311 |
+
}
|
| 1312 |
+
else if (PyObject_HasAttrString(fun,\"__call__\")) {
|
| 1313 |
+
tmp = PyObject_GetAttrString(fun,\"__call__\");
|
| 1314 |
+
if (PyObject_HasAttrString(tmp,\"im_func\"))
|
| 1315 |
+
tmp_fun = PyObject_GetAttrString(tmp,\"im_func\");
|
| 1316 |
+
else {
|
| 1317 |
+
tmp_fun = fun; /* built-in function */
|
| 1318 |
+
Py_INCREF(tmp_fun);
|
| 1319 |
+
tot = maxnofargs;
|
| 1320 |
+
if (PyCFunction_Check(fun)) {
|
| 1321 |
+
/* In case the function has a co_argcount (like on PyPy) */
|
| 1322 |
+
di = 0;
|
| 1323 |
+
}
|
| 1324 |
+
if (xa != NULL)
|
| 1325 |
+
tot += PyTuple_Size((PyObject *)xa);
|
| 1326 |
+
}
|
| 1327 |
+
Py_XDECREF(tmp);
|
| 1328 |
+
}
|
| 1329 |
+
else if (PyFortran_Check(fun) || PyFortran_Check1(fun)) {
|
| 1330 |
+
tot = maxnofargs;
|
| 1331 |
+
if (xa != NULL)
|
| 1332 |
+
tot += PyTuple_Size((PyObject *)xa);
|
| 1333 |
+
tmp_fun = fun;
|
| 1334 |
+
Py_INCREF(tmp_fun);
|
| 1335 |
+
}
|
| 1336 |
+
else if (F2PyCapsule_Check(fun)) {
|
| 1337 |
+
tot = maxnofargs;
|
| 1338 |
+
if (xa != NULL)
|
| 1339 |
+
ext = PyTuple_Size((PyObject *)xa);
|
| 1340 |
+
if(ext>0) {
|
| 1341 |
+
fprintf(stderr,\"extra arguments tuple cannot be used with PyCapsule call-back\\n\");
|
| 1342 |
+
goto capi_fail;
|
| 1343 |
+
}
|
| 1344 |
+
tmp_fun = fun;
|
| 1345 |
+
Py_INCREF(tmp_fun);
|
| 1346 |
+
}
|
| 1347 |
+
}
|
| 1348 |
+
|
| 1349 |
+
if (tmp_fun == NULL) {
|
| 1350 |
+
fprintf(stderr,
|
| 1351 |
+
\"Call-back argument must be function|instance|instance.__call__|f2py-function \"
|
| 1352 |
+
\"but got %s.\\n\",
|
| 1353 |
+
((fun == NULL) ? \"NULL\" : Py_TYPE(fun)->tp_name));
|
| 1354 |
+
goto capi_fail;
|
| 1355 |
+
}
|
| 1356 |
+
|
| 1357 |
+
if (PyObject_HasAttrString(tmp_fun,\"__code__\")) {
|
| 1358 |
+
if (PyObject_HasAttrString(tmp = PyObject_GetAttrString(tmp_fun,\"__code__\"),\"co_argcount\")) {
|
| 1359 |
+
PyObject *tmp_argcount = PyObject_GetAttrString(tmp,\"co_argcount\");
|
| 1360 |
+
Py_DECREF(tmp);
|
| 1361 |
+
if (tmp_argcount == NULL) {
|
| 1362 |
+
goto capi_fail;
|
| 1363 |
+
}
|
| 1364 |
+
tot = PyLong_AsSsize_t(tmp_argcount) - di;
|
| 1365 |
+
Py_DECREF(tmp_argcount);
|
| 1366 |
+
}
|
| 1367 |
+
}
|
| 1368 |
+
/* Get the number of optional arguments */
|
| 1369 |
+
if (PyObject_HasAttrString(tmp_fun,\"__defaults__\")) {
|
| 1370 |
+
if (PyTuple_Check(tmp = PyObject_GetAttrString(tmp_fun,\"__defaults__\")))
|
| 1371 |
+
opt = PyTuple_Size(tmp);
|
| 1372 |
+
Py_XDECREF(tmp);
|
| 1373 |
+
}
|
| 1374 |
+
/* Get the number of extra arguments */
|
| 1375 |
+
if (xa != NULL)
|
| 1376 |
+
ext = PyTuple_Size((PyObject *)xa);
|
| 1377 |
+
/* Calculate the size of call-backs argument list */
|
| 1378 |
+
siz = MIN(maxnofargs+ext,tot);
|
| 1379 |
+
*nofargs = MAX(0,siz-ext);
|
| 1380 |
+
|
| 1381 |
+
#ifdef DEBUGCFUNCS
|
| 1382 |
+
fprintf(stderr,
|
| 1383 |
+
\"debug-capi:create_cb_arglist:maxnofargs(-nofoptargs),\"
|
| 1384 |
+
\"tot,opt,ext,siz,nofargs = %d(-%d), %zd, %zd, %zd, %zd, %d\\n\",
|
| 1385 |
+
maxnofargs, nofoptargs, tot, opt, ext, siz, *nofargs);
|
| 1386 |
+
#endif
|
| 1387 |
+
|
| 1388 |
+
if (siz < tot-opt) {
|
| 1389 |
+
fprintf(stderr,
|
| 1390 |
+
\"create_cb_arglist: Failed to build argument list \"
|
| 1391 |
+
\"(siz) with enough arguments (tot-opt) required by \"
|
| 1392 |
+
\"user-supplied function (siz,tot,opt=%zd, %zd, %zd).\\n\",
|
| 1393 |
+
siz, tot, opt);
|
| 1394 |
+
goto capi_fail;
|
| 1395 |
+
}
|
| 1396 |
+
|
| 1397 |
+
/* Initialize argument list */
|
| 1398 |
+
*args = (PyTupleObject *)PyTuple_New(siz);
|
| 1399 |
+
for (i=0;i<*nofargs;i++) {
|
| 1400 |
+
Py_INCREF(Py_None);
|
| 1401 |
+
PyTuple_SET_ITEM((PyObject *)(*args),i,Py_None);
|
| 1402 |
+
}
|
| 1403 |
+
if (xa != NULL)
|
| 1404 |
+
for (i=(*nofargs);i<siz;i++) {
|
| 1405 |
+
tmp = PyTuple_GetItem((PyObject *)xa,i-(*nofargs));
|
| 1406 |
+
Py_INCREF(tmp);
|
| 1407 |
+
PyTuple_SET_ITEM(*args,i,tmp);
|
| 1408 |
+
}
|
| 1409 |
+
CFUNCSMESS(\"create_cb_arglist-end\\n\");
|
| 1410 |
+
Py_DECREF(tmp_fun);
|
| 1411 |
+
return 1;
|
| 1412 |
+
|
| 1413 |
+
capi_fail:
|
| 1414 |
+
if (PyErr_Occurred() == NULL)
|
| 1415 |
+
PyErr_SetString(#modulename#_error, errmess);
|
| 1416 |
+
Py_XDECREF(tmp_fun);
|
| 1417 |
+
return 0;
|
| 1418 |
+
}
|
| 1419 |
+
"""
|
| 1420 |
+
|
| 1421 |
+
|
| 1422 |
+
def buildcfuncs():
|
| 1423 |
+
from .capi_maps import c2capi_map
|
| 1424 |
+
for k in c2capi_map.keys():
|
| 1425 |
+
m = 'pyarr_from_p_%s1' % k
|
| 1426 |
+
cppmacros[
|
| 1427 |
+
m] = '#define %s(v) (PyArray_SimpleNewFromData(0,NULL,%s,(char *)v))' % (m, c2capi_map[k])
|
| 1428 |
+
k = 'string'
|
| 1429 |
+
m = 'pyarr_from_p_%s1' % k
|
| 1430 |
+
# NPY_CHAR compatibility, NPY_STRING with itemsize 1
|
| 1431 |
+
cppmacros[
|
| 1432 |
+
m] = '#define %s(v,dims) (PyArray_New(&PyArray_Type, 1, dims, NPY_STRING, NULL, v, 1, NPY_ARRAY_CARRAY, NULL))' % (m)
|
| 1433 |
+
|
| 1434 |
+
|
| 1435 |
+
############ Auxiliary functions for sorting needs ###################
|
| 1436 |
+
|
| 1437 |
+
def append_needs(need, flag=1):
|
| 1438 |
+
# This function modifies the contents of the global `outneeds` dict.
|
| 1439 |
+
if isinstance(need, list):
|
| 1440 |
+
for n in need:
|
| 1441 |
+
append_needs(n, flag)
|
| 1442 |
+
elif isinstance(need, str):
|
| 1443 |
+
if not need:
|
| 1444 |
+
return
|
| 1445 |
+
if need in includes0:
|
| 1446 |
+
n = 'includes0'
|
| 1447 |
+
elif need in includes:
|
| 1448 |
+
n = 'includes'
|
| 1449 |
+
elif need in typedefs:
|
| 1450 |
+
n = 'typedefs'
|
| 1451 |
+
elif need in typedefs_generated:
|
| 1452 |
+
n = 'typedefs_generated'
|
| 1453 |
+
elif need in cppmacros:
|
| 1454 |
+
n = 'cppmacros'
|
| 1455 |
+
elif need in cfuncs:
|
| 1456 |
+
n = 'cfuncs'
|
| 1457 |
+
elif need in callbacks:
|
| 1458 |
+
n = 'callbacks'
|
| 1459 |
+
elif need in f90modhooks:
|
| 1460 |
+
n = 'f90modhooks'
|
| 1461 |
+
elif need in commonhooks:
|
| 1462 |
+
n = 'commonhooks'
|
| 1463 |
+
else:
|
| 1464 |
+
errmess('append_needs: unknown need %s\n' % (repr(need)))
|
| 1465 |
+
return
|
| 1466 |
+
if need in outneeds[n]:
|
| 1467 |
+
return
|
| 1468 |
+
if flag:
|
| 1469 |
+
tmp = {}
|
| 1470 |
+
if need in needs:
|
| 1471 |
+
for nn in needs[need]:
|
| 1472 |
+
t = append_needs(nn, 0)
|
| 1473 |
+
if isinstance(t, dict):
|
| 1474 |
+
for nnn in t.keys():
|
| 1475 |
+
if nnn in tmp:
|
| 1476 |
+
tmp[nnn] = tmp[nnn] + t[nnn]
|
| 1477 |
+
else:
|
| 1478 |
+
tmp[nnn] = t[nnn]
|
| 1479 |
+
for nn in tmp.keys():
|
| 1480 |
+
for nnn in tmp[nn]:
|
| 1481 |
+
if nnn not in outneeds[nn]:
|
| 1482 |
+
outneeds[nn] = [nnn] + outneeds[nn]
|
| 1483 |
+
outneeds[n].append(need)
|
| 1484 |
+
else:
|
| 1485 |
+
tmp = {}
|
| 1486 |
+
if need in needs:
|
| 1487 |
+
for nn in needs[need]:
|
| 1488 |
+
t = append_needs(nn, flag)
|
| 1489 |
+
if isinstance(t, dict):
|
| 1490 |
+
for nnn in t.keys():
|
| 1491 |
+
if nnn in tmp:
|
| 1492 |
+
tmp[nnn] = t[nnn] + tmp[nnn]
|
| 1493 |
+
else:
|
| 1494 |
+
tmp[nnn] = t[nnn]
|
| 1495 |
+
if n not in tmp:
|
| 1496 |
+
tmp[n] = []
|
| 1497 |
+
tmp[n].append(need)
|
| 1498 |
+
return tmp
|
| 1499 |
+
else:
|
| 1500 |
+
errmess('append_needs: expected list or string but got :%s\n' %
|
| 1501 |
+
(repr(need)))
|
| 1502 |
+
|
| 1503 |
+
|
| 1504 |
+
def get_needs():
|
| 1505 |
+
# This function modifies the contents of the global `outneeds` dict.
|
| 1506 |
+
res = {}
|
| 1507 |
+
for n in outneeds.keys():
|
| 1508 |
+
out = []
|
| 1509 |
+
saveout = copy.copy(outneeds[n])
|
| 1510 |
+
while len(outneeds[n]) > 0:
|
| 1511 |
+
if outneeds[n][0] not in needs:
|
| 1512 |
+
out.append(outneeds[n][0])
|
| 1513 |
+
del outneeds[n][0]
|
| 1514 |
+
else:
|
| 1515 |
+
flag = 0
|
| 1516 |
+
for k in outneeds[n][1:]:
|
| 1517 |
+
if k in needs[outneeds[n][0]]:
|
| 1518 |
+
flag = 1
|
| 1519 |
+
break
|
| 1520 |
+
if flag:
|
| 1521 |
+
outneeds[n] = outneeds[n][1:] + [outneeds[n][0]]
|
| 1522 |
+
else:
|
| 1523 |
+
out.append(outneeds[n][0])
|
| 1524 |
+
del outneeds[n][0]
|
| 1525 |
+
if saveout and (0 not in map(lambda x, y: x == y, saveout, outneeds[n])) \
|
| 1526 |
+
and outneeds[n] != []:
|
| 1527 |
+
print(n, saveout)
|
| 1528 |
+
errmess(
|
| 1529 |
+
'get_needs: no progress in sorting needs, probably circular dependence, skipping.\n')
|
| 1530 |
+
out = out + saveout
|
| 1531 |
+
break
|
| 1532 |
+
saveout = copy.copy(outneeds[n])
|
| 1533 |
+
if out == []:
|
| 1534 |
+
out = [n]
|
| 1535 |
+
res[n] = out
|
| 1536 |
+
return res
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/common_rules.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Build common block mechanism for f2py2e.
|
| 3 |
+
|
| 4 |
+
Copyright 1999 -- 2011 Pearu Peterson all rights reserved.
|
| 5 |
+
Copyright 2011 -- present NumPy Developers.
|
| 6 |
+
Permission to use, modify, and distribute this software is given under the
|
| 7 |
+
terms of the NumPy License
|
| 8 |
+
|
| 9 |
+
NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
| 10 |
+
"""
|
| 11 |
+
from . import __version__
|
| 12 |
+
f2py_version = __version__.version
|
| 13 |
+
|
| 14 |
+
from .auxfuncs import (
|
| 15 |
+
hasbody, hascommon, hasnote, isintent_hide, outmess, getuseblocks
|
| 16 |
+
)
|
| 17 |
+
from . import capi_maps
|
| 18 |
+
from . import func2subr
|
| 19 |
+
from .crackfortran import rmbadname
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def findcommonblocks(block, top=1):
|
| 23 |
+
ret = []
|
| 24 |
+
if hascommon(block):
|
| 25 |
+
for key, value in block['common'].items():
|
| 26 |
+
vars_ = {v: block['vars'][v] for v in value}
|
| 27 |
+
ret.append((key, value, vars_))
|
| 28 |
+
elif hasbody(block):
|
| 29 |
+
for b in block['body']:
|
| 30 |
+
ret = ret + findcommonblocks(b, 0)
|
| 31 |
+
if top:
|
| 32 |
+
tret = []
|
| 33 |
+
names = []
|
| 34 |
+
for t in ret:
|
| 35 |
+
if t[0] not in names:
|
| 36 |
+
names.append(t[0])
|
| 37 |
+
tret.append(t)
|
| 38 |
+
return tret
|
| 39 |
+
return ret
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def buildhooks(m):
|
| 43 |
+
ret = {'commonhooks': [], 'initcommonhooks': [],
|
| 44 |
+
'docs': ['"COMMON blocks:\\n"']}
|
| 45 |
+
fwrap = ['']
|
| 46 |
+
|
| 47 |
+
def fadd(line, s=fwrap):
|
| 48 |
+
s[0] = '%s\n %s' % (s[0], line)
|
| 49 |
+
chooks = ['']
|
| 50 |
+
|
| 51 |
+
def cadd(line, s=chooks):
|
| 52 |
+
s[0] = '%s\n%s' % (s[0], line)
|
| 53 |
+
ihooks = ['']
|
| 54 |
+
|
| 55 |
+
def iadd(line, s=ihooks):
|
| 56 |
+
s[0] = '%s\n%s' % (s[0], line)
|
| 57 |
+
doc = ['']
|
| 58 |
+
|
| 59 |
+
def dadd(line, s=doc):
|
| 60 |
+
s[0] = '%s\n%s' % (s[0], line)
|
| 61 |
+
for (name, vnames, vars) in findcommonblocks(m):
|
| 62 |
+
lower_name = name.lower()
|
| 63 |
+
hnames, inames = [], []
|
| 64 |
+
for n in vnames:
|
| 65 |
+
if isintent_hide(vars[n]):
|
| 66 |
+
hnames.append(n)
|
| 67 |
+
else:
|
| 68 |
+
inames.append(n)
|
| 69 |
+
if hnames:
|
| 70 |
+
outmess('\t\tConstructing COMMON block support for "%s"...\n\t\t %s\n\t\t Hidden: %s\n' % (
|
| 71 |
+
name, ','.join(inames), ','.join(hnames)))
|
| 72 |
+
else:
|
| 73 |
+
outmess('\t\tConstructing COMMON block support for "%s"...\n\t\t %s\n' % (
|
| 74 |
+
name, ','.join(inames)))
|
| 75 |
+
fadd('subroutine f2pyinit%s(setupfunc)' % name)
|
| 76 |
+
for usename in getuseblocks(m):
|
| 77 |
+
fadd(f'use {usename}')
|
| 78 |
+
fadd('external setupfunc')
|
| 79 |
+
for n in vnames:
|
| 80 |
+
fadd(func2subr.var2fixfortran(vars, n))
|
| 81 |
+
if name == '_BLNK_':
|
| 82 |
+
fadd('common %s' % (','.join(vnames)))
|
| 83 |
+
else:
|
| 84 |
+
fadd('common /%s/ %s' % (name, ','.join(vnames)))
|
| 85 |
+
fadd('call setupfunc(%s)' % (','.join(inames)))
|
| 86 |
+
fadd('end\n')
|
| 87 |
+
cadd('static FortranDataDef f2py_%s_def[] = {' % (name))
|
| 88 |
+
idims = []
|
| 89 |
+
for n in inames:
|
| 90 |
+
ct = capi_maps.getctype(vars[n])
|
| 91 |
+
elsize = capi_maps.get_elsize(vars[n])
|
| 92 |
+
at = capi_maps.c2capi_map[ct]
|
| 93 |
+
dm = capi_maps.getarrdims(n, vars[n])
|
| 94 |
+
if dm['dims']:
|
| 95 |
+
idims.append('(%s)' % (dm['dims']))
|
| 96 |
+
else:
|
| 97 |
+
idims.append('')
|
| 98 |
+
dms = dm['dims'].strip()
|
| 99 |
+
if not dms:
|
| 100 |
+
dms = '-1'
|
| 101 |
+
cadd('\t{\"%s\",%s,{{%s}},%s, %s},'
|
| 102 |
+
% (n, dm['rank'], dms, at, elsize))
|
| 103 |
+
cadd('\t{NULL}\n};')
|
| 104 |
+
inames1 = rmbadname(inames)
|
| 105 |
+
inames1_tps = ','.join(['char *' + s for s in inames1])
|
| 106 |
+
cadd('static void f2py_setup_%s(%s) {' % (name, inames1_tps))
|
| 107 |
+
cadd('\tint i_f2py=0;')
|
| 108 |
+
for n in inames1:
|
| 109 |
+
cadd('\tf2py_%s_def[i_f2py++].data = %s;' % (name, n))
|
| 110 |
+
cadd('}')
|
| 111 |
+
if '_' in lower_name:
|
| 112 |
+
F_FUNC = 'F_FUNC_US'
|
| 113 |
+
else:
|
| 114 |
+
F_FUNC = 'F_FUNC'
|
| 115 |
+
cadd('extern void %s(f2pyinit%s,F2PYINIT%s)(void(*)(%s));'
|
| 116 |
+
% (F_FUNC, lower_name, name.upper(),
|
| 117 |
+
','.join(['char*'] * len(inames1))))
|
| 118 |
+
cadd('static void f2py_init_%s(void) {' % name)
|
| 119 |
+
cadd('\t%s(f2pyinit%s,F2PYINIT%s)(f2py_setup_%s);'
|
| 120 |
+
% (F_FUNC, lower_name, name.upper(), name))
|
| 121 |
+
cadd('}\n')
|
| 122 |
+
iadd('\ttmp = PyFortranObject_New(f2py_%s_def,f2py_init_%s);' % (name, name))
|
| 123 |
+
iadd('\tif (tmp == NULL) return NULL;')
|
| 124 |
+
iadd('\tif (F2PyDict_SetItemString(d, \"%s\", tmp) == -1) return NULL;'
|
| 125 |
+
% name)
|
| 126 |
+
iadd('\tPy_DECREF(tmp);')
|
| 127 |
+
tname = name.replace('_', '\\_')
|
| 128 |
+
dadd('\\subsection{Common block \\texttt{%s}}\n' % (tname))
|
| 129 |
+
dadd('\\begin{description}')
|
| 130 |
+
for n in inames:
|
| 131 |
+
dadd('\\item[]{{}\\verb@%s@{}}' %
|
| 132 |
+
(capi_maps.getarrdocsign(n, vars[n])))
|
| 133 |
+
if hasnote(vars[n]):
|
| 134 |
+
note = vars[n]['note']
|
| 135 |
+
if isinstance(note, list):
|
| 136 |
+
note = '\n'.join(note)
|
| 137 |
+
dadd('--- %s' % (note))
|
| 138 |
+
dadd('\\end{description}')
|
| 139 |
+
ret['docs'].append(
|
| 140 |
+
'"\t/%s/ %s\\n"' % (name, ','.join(map(lambda v, d: v + d, inames, idims))))
|
| 141 |
+
ret['commonhooks'] = chooks
|
| 142 |
+
ret['initcommonhooks'] = ihooks
|
| 143 |
+
ret['latexdoc'] = doc[0]
|
| 144 |
+
if len(ret['docs']) <= 1:
|
| 145 |
+
ret['docs'] = ''
|
| 146 |
+
return ret, fwrap[0]
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/diagnose.py
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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wd()
|
| 15 |
+
os.chdir(tempfile.gettempdir())
|
| 16 |
+
print('------')
|
| 17 |
+
print('os.name=%r' % (os.name))
|
| 18 |
+
print('------')
|
| 19 |
+
print('sys.platform=%r' % (sys.platform))
|
| 20 |
+
print('------')
|
| 21 |
+
print('sys.version:')
|
| 22 |
+
print(sys.version)
|
| 23 |
+
print('------')
|
| 24 |
+
print('sys.prefix:')
|
| 25 |
+
print(sys.prefix)
|
| 26 |
+
print('------')
|
| 27 |
+
print('sys.path=%r' % (':'.join(sys.path)))
|
| 28 |
+
print('------')
|
| 29 |
+
|
| 30 |
+
try:
|
| 31 |
+
import numpy
|
| 32 |
+
has_newnumpy = 1
|
| 33 |
+
except ImportError as e:
|
| 34 |
+
print('Failed to import new numpy:', e)
|
| 35 |
+
has_newnumpy = 0
|
| 36 |
+
|
| 37 |
+
try:
|
| 38 |
+
from numpy.f2py import f2py2e
|
| 39 |
+
has_f2py2e = 1
|
| 40 |
+
except ImportError as e:
|
| 41 |
+
print('Failed to import f2py2e:', e)
|
| 42 |
+
has_f2py2e = 0
|
| 43 |
+
|
| 44 |
+
try:
|
| 45 |
+
import numpy.distutils
|
| 46 |
+
has_numpy_distutils = 2
|
| 47 |
+
except ImportError:
|
| 48 |
+
try:
|
| 49 |
+
import numpy_distutils
|
| 50 |
+
has_numpy_distutils = 1
|
| 51 |
+
except ImportError as e:
|
| 52 |
+
print('Failed to import numpy_distutils:', e)
|
| 53 |
+
has_numpy_distutils = 0
|
| 54 |
+
|
| 55 |
+
if has_newnumpy:
|
| 56 |
+
try:
|
| 57 |
+
print('Found new numpy version %r in %s' %
|
| 58 |
+
(numpy.__version__, numpy.__file__))
|
| 59 |
+
except Exception as msg:
|
| 60 |
+
print('error:', msg)
|
| 61 |
+
print('------')
|
| 62 |
+
|
| 63 |
+
if has_f2py2e:
|
| 64 |
+
try:
|
| 65 |
+
print('Found f2py2e version %r in %s' %
|
| 66 |
+
(f2py2e.__version__.version, f2py2e.__file__))
|
| 67 |
+
except Exception as msg:
|
| 68 |
+
print('error:', msg)
|
| 69 |
+
print('------')
|
| 70 |
+
|
| 71 |
+
if has_numpy_distutils:
|
| 72 |
+
try:
|
| 73 |
+
if has_numpy_distutils == 2:
|
| 74 |
+
print('Found numpy.distutils version %r in %r' % (
|
| 75 |
+
numpy.distutils.__version__,
|
| 76 |
+
numpy.distutils.__file__))
|
| 77 |
+
else:
|
| 78 |
+
print('Found numpy_distutils version %r in %r' % (
|
| 79 |
+
numpy_distutils.numpy_distutils_version.numpy_distutils_version,
|
| 80 |
+
numpy_distutils.__file__))
|
| 81 |
+
print('------')
|
| 82 |
+
except Exception as msg:
|
| 83 |
+
print('error:', msg)
|
| 84 |
+
print('------')
|
| 85 |
+
try:
|
| 86 |
+
if has_numpy_distutils == 1:
|
| 87 |
+
print(
|
| 88 |
+
'Importing numpy_distutils.command.build_flib ...', end=' ')
|
| 89 |
+
import numpy_distutils.command.build_flib as build_flib
|
| 90 |
+
print('ok')
|
| 91 |
+
print('------')
|
| 92 |
+
try:
|
| 93 |
+
print(
|
| 94 |
+
'Checking availability of supported Fortran compilers:')
|
| 95 |
+
for compiler_class in build_flib.all_compilers:
|
| 96 |
+
compiler_class(verbose=1).is_available()
|
| 97 |
+
print('------')
|
| 98 |
+
except Exception as msg:
|
| 99 |
+
print('error:', msg)
|
| 100 |
+
print('------')
|
| 101 |
+
except Exception as msg:
|
| 102 |
+
print(
|
| 103 |
+
'error:', msg, '(ignore it, build_flib is obsolute for numpy.distutils 0.2.2 and up)')
|
| 104 |
+
print('------')
|
| 105 |
+
try:
|
| 106 |
+
if has_numpy_distutils == 2:
|
| 107 |
+
print('Importing numpy.distutils.fcompiler ...', end=' ')
|
| 108 |
+
import numpy.distutils.fcompiler as fcompiler
|
| 109 |
+
else:
|
| 110 |
+
print('Importing numpy_distutils.fcompiler ...', end=' ')
|
| 111 |
+
import numpy_distutils.fcompiler as fcompiler
|
| 112 |
+
print('ok')
|
| 113 |
+
print('------')
|
| 114 |
+
try:
|
| 115 |
+
print('Checking availability of supported Fortran compilers:')
|
| 116 |
+
fcompiler.show_fcompilers()
|
| 117 |
+
print('------')
|
| 118 |
+
except Exception as msg:
|
| 119 |
+
print('error:', msg)
|
| 120 |
+
print('------')
|
| 121 |
+
except Exception as msg:
|
| 122 |
+
print('error:', msg)
|
| 123 |
+
print('------')
|
| 124 |
+
try:
|
| 125 |
+
if has_numpy_distutils == 2:
|
| 126 |
+
print('Importing numpy.distutils.cpuinfo ...', end=' ')
|
| 127 |
+
from numpy.distutils.cpuinfo import cpuinfo
|
| 128 |
+
print('ok')
|
| 129 |
+
print('------')
|
| 130 |
+
else:
|
| 131 |
+
try:
|
| 132 |
+
print(
|
| 133 |
+
'Importing numpy_distutils.command.cpuinfo ...', end=' ')
|
| 134 |
+
from numpy_distutils.command.cpuinfo import cpuinfo
|
| 135 |
+
print('ok')
|
| 136 |
+
print('------')
|
| 137 |
+
except Exception as msg:
|
| 138 |
+
print('error:', msg, '(ignore it)')
|
| 139 |
+
print('Importing numpy_distutils.cpuinfo ...', end=' ')
|
| 140 |
+
from numpy_distutils.cpuinfo import cpuinfo
|
| 141 |
+
print('ok')
|
| 142 |
+
print('------')
|
| 143 |
+
cpu = cpuinfo()
|
| 144 |
+
print('CPU information:', end=' ')
|
| 145 |
+
for name in dir(cpuinfo):
|
| 146 |
+
if name[0] == '_' and name[1] != '_' and getattr(cpu, name[1:])():
|
| 147 |
+
print(name[1:], end=' ')
|
| 148 |
+
print('------')
|
| 149 |
+
except Exception as msg:
|
| 150 |
+
print('error:', msg)
|
| 151 |
+
print('------')
|
| 152 |
+
os.chdir(_path)
|
| 153 |
+
if __name__ == "__main__":
|
| 154 |
+
run()
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/f2py2e.py
ADDED
|
@@ -0,0 +1,768 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
|
| 4 |
+
f2py2e - Fortran to Python C/API generator. 2nd Edition.
|
| 5 |
+
See __usage__ below.
|
| 6 |
+
|
| 7 |
+
Copyright 1999 -- 2011 Pearu Peterson all rights reserved.
|
| 8 |
+
Copyright 2011 -- present NumPy Developers.
|
| 9 |
+
Permission to use, modify, and distribute this software is given under the
|
| 10 |
+
terms of the NumPy License.
|
| 11 |
+
|
| 12 |
+
NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
| 13 |
+
"""
|
| 14 |
+
import sys
|
| 15 |
+
import os
|
| 16 |
+
import pprint
|
| 17 |
+
import re
|
| 18 |
+
from pathlib import Path
|
| 19 |
+
from itertools import dropwhile
|
| 20 |
+
import argparse
|
| 21 |
+
import copy
|
| 22 |
+
|
| 23 |
+
from . import crackfortran
|
| 24 |
+
from . import rules
|
| 25 |
+
from . import cb_rules
|
| 26 |
+
from . import auxfuncs
|
| 27 |
+
from . import cfuncs
|
| 28 |
+
from . import f90mod_rules
|
| 29 |
+
from . import __version__
|
| 30 |
+
from . import capi_maps
|
| 31 |
+
from numpy.f2py._backends import f2py_build_generator
|
| 32 |
+
|
| 33 |
+
f2py_version = __version__.version
|
| 34 |
+
numpy_version = __version__.version
|
| 35 |
+
errmess = sys.stderr.write
|
| 36 |
+
# outmess=sys.stdout.write
|
| 37 |
+
show = pprint.pprint
|
| 38 |
+
outmess = auxfuncs.outmess
|
| 39 |
+
MESON_ONLY_VER = (sys.version_info >= (3, 12))
|
| 40 |
+
|
| 41 |
+
__usage__ =\
|
| 42 |
+
f"""Usage:
|
| 43 |
+
|
| 44 |
+
1) To construct extension module sources:
|
| 45 |
+
|
| 46 |
+
f2py [<options>] <fortran files> [[[only:]||[skip:]] \\
|
| 47 |
+
<fortran functions> ] \\
|
| 48 |
+
[: <fortran files> ...]
|
| 49 |
+
|
| 50 |
+
2) To compile fortran files and build extension modules:
|
| 51 |
+
|
| 52 |
+
f2py -c [<options>, <build_flib options>, <extra options>] <fortran files>
|
| 53 |
+
|
| 54 |
+
3) To generate signature files:
|
| 55 |
+
|
| 56 |
+
f2py -h <filename.pyf> ...< same options as in (1) >
|
| 57 |
+
|
| 58 |
+
Description: This program generates a Python C/API file (<modulename>module.c)
|
| 59 |
+
that contains wrappers for given fortran functions so that they
|
| 60 |
+
can be called from Python. With the -c option the corresponding
|
| 61 |
+
extension modules are built.
|
| 62 |
+
|
| 63 |
+
Options:
|
| 64 |
+
|
| 65 |
+
-h <filename> Write signatures of the fortran routines to file <filename>
|
| 66 |
+
and exit. You can then edit <filename> and use it instead
|
| 67 |
+
of <fortran files>. If <filename>==stdout then the
|
| 68 |
+
signatures are printed to stdout.
|
| 69 |
+
<fortran functions> Names of fortran routines for which Python C/API
|
| 70 |
+
functions will be generated. Default is all that are found
|
| 71 |
+
in <fortran files>.
|
| 72 |
+
<fortran files> Paths to fortran/signature files that will be scanned for
|
| 73 |
+
<fortran functions> in order to determine their signatures.
|
| 74 |
+
skip: Ignore fortran functions that follow until `:'.
|
| 75 |
+
only: Use only fortran functions that follow until `:'.
|
| 76 |
+
: Get back to <fortran files> mode.
|
| 77 |
+
|
| 78 |
+
-m <modulename> Name of the module; f2py generates a Python/C API
|
| 79 |
+
file <modulename>module.c or extension module <modulename>.
|
| 80 |
+
Default is 'untitled'.
|
| 81 |
+
|
| 82 |
+
'-include<header>' Writes additional headers in the C wrapper, can be passed
|
| 83 |
+
multiple times, generates #include <header> each time.
|
| 84 |
+
|
| 85 |
+
--[no-]lower Do [not] lower the cases in <fortran files>. By default,
|
| 86 |
+
--lower is assumed with -h key, and --no-lower without -h key.
|
| 87 |
+
|
| 88 |
+
--build-dir <dirname> All f2py generated files are created in <dirname>.
|
| 89 |
+
Default is tempfile.mkdtemp().
|
| 90 |
+
|
| 91 |
+
--overwrite-signature Overwrite existing signature file.
|
| 92 |
+
|
| 93 |
+
--[no-]latex-doc Create (or not) <modulename>module.tex.
|
| 94 |
+
Default is --no-latex-doc.
|
| 95 |
+
--short-latex Create 'incomplete' LaTeX document (without commands
|
| 96 |
+
\\documentclass, \\tableofcontents, and \\begin{{document}},
|
| 97 |
+
\\end{{document}}).
|
| 98 |
+
|
| 99 |
+
--[no-]rest-doc Create (or not) <modulename>module.rst.
|
| 100 |
+
Default is --no-rest-doc.
|
| 101 |
+
|
| 102 |
+
--debug-capi Create C/API code that reports the state of the wrappers
|
| 103 |
+
during runtime. Useful for debugging.
|
| 104 |
+
|
| 105 |
+
--[no-]wrap-functions Create Fortran subroutine wrappers to Fortran 77
|
| 106 |
+
functions. --wrap-functions is default because it ensures
|
| 107 |
+
maximum portability/compiler independence.
|
| 108 |
+
|
| 109 |
+
--include-paths <path1>:<path2>:... Search include files from the given
|
| 110 |
+
directories.
|
| 111 |
+
|
| 112 |
+
--help-link [..] List system resources found by system_info.py. See also
|
| 113 |
+
--link-<resource> switch below. [..] is optional list
|
| 114 |
+
of resources names. E.g. try 'f2py --help-link lapack_opt'.
|
| 115 |
+
|
| 116 |
+
--f2cmap <filename> Load Fortran-to-Python KIND specification from the given
|
| 117 |
+
file. Default: .f2py_f2cmap in current directory.
|
| 118 |
+
|
| 119 |
+
--quiet Run quietly.
|
| 120 |
+
--verbose Run with extra verbosity.
|
| 121 |
+
--skip-empty-wrappers Only generate wrapper files when needed.
|
| 122 |
+
-v Print f2py version ID and exit.
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
build backend options (only effective with -c)
|
| 126 |
+
[NO_MESON] is used to indicate an option not meant to be used
|
| 127 |
+
with the meson backend or above Python 3.12:
|
| 128 |
+
|
| 129 |
+
--fcompiler= Specify Fortran compiler type by vendor [NO_MESON]
|
| 130 |
+
--compiler= Specify distutils C compiler type [NO_MESON]
|
| 131 |
+
|
| 132 |
+
--help-fcompiler List available Fortran compilers and exit [NO_MESON]
|
| 133 |
+
--f77exec= Specify the path to F77 compiler [NO_MESON]
|
| 134 |
+
--f90exec= Specify the path to F90 compiler [NO_MESON]
|
| 135 |
+
--f77flags= Specify F77 compiler flags
|
| 136 |
+
--f90flags= Specify F90 compiler flags
|
| 137 |
+
--opt= Specify optimization flags [NO_MESON]
|
| 138 |
+
--arch= Specify architecture specific optimization flags [NO_MESON]
|
| 139 |
+
--noopt Compile without optimization [NO_MESON]
|
| 140 |
+
--noarch Compile without arch-dependent optimization [NO_MESON]
|
| 141 |
+
--debug Compile with debugging information
|
| 142 |
+
|
| 143 |
+
--dep <dependency>
|
| 144 |
+
Specify a meson dependency for the module. This may
|
| 145 |
+
be passed multiple times for multiple dependencies.
|
| 146 |
+
Dependencies are stored in a list for further processing.
|
| 147 |
+
|
| 148 |
+
Example: --dep lapack --dep scalapack
|
| 149 |
+
This will identify "lapack" and "scalapack" as dependencies
|
| 150 |
+
and remove them from argv, leaving a dependencies list
|
| 151 |
+
containing ["lapack", "scalapack"].
|
| 152 |
+
|
| 153 |
+
--backend <backend_type>
|
| 154 |
+
Specify the build backend for the compilation process.
|
| 155 |
+
The supported backends are 'meson' and 'distutils'.
|
| 156 |
+
If not specified, defaults to 'distutils'. On
|
| 157 |
+
Python 3.12 or higher, the default is 'meson'.
|
| 158 |
+
|
| 159 |
+
Extra options (only effective with -c):
|
| 160 |
+
|
| 161 |
+
--link-<resource> Link extension module with <resource> as defined
|
| 162 |
+
by numpy.distutils/system_info.py. E.g. to link
|
| 163 |
+
with optimized LAPACK libraries (vecLib on MacOSX,
|
| 164 |
+
ATLAS elsewhere), use --link-lapack_opt.
|
| 165 |
+
See also --help-link switch. [NO_MESON]
|
| 166 |
+
|
| 167 |
+
-L/path/to/lib/ -l<libname>
|
| 168 |
+
-D<define> -U<name>
|
| 169 |
+
-I/path/to/include/
|
| 170 |
+
<filename>.o <filename>.so <filename>.a
|
| 171 |
+
|
| 172 |
+
Using the following macros may be required with non-gcc Fortran
|
| 173 |
+
compilers:
|
| 174 |
+
-DPREPEND_FORTRAN -DNO_APPEND_FORTRAN -DUPPERCASE_FORTRAN
|
| 175 |
+
-DUNDERSCORE_G77
|
| 176 |
+
|
| 177 |
+
When using -DF2PY_REPORT_ATEXIT, a performance report of F2PY
|
| 178 |
+
interface is printed out at exit (platforms: Linux).
|
| 179 |
+
|
| 180 |
+
When using -DF2PY_REPORT_ON_ARRAY_COPY=<int>, a message is
|
| 181 |
+
sent to stderr whenever F2PY interface makes a copy of an
|
| 182 |
+
array. Integer <int> sets the threshold for array sizes when
|
| 183 |
+
a message should be shown.
|
| 184 |
+
|
| 185 |
+
Version: {f2py_version}
|
| 186 |
+
numpy Version: {numpy_version}
|
| 187 |
+
License: NumPy license (see LICENSE.txt in the NumPy source code)
|
| 188 |
+
Copyright 1999 -- 2011 Pearu Peterson all rights reserved.
|
| 189 |
+
Copyright 2011 -- present NumPy Developers.
|
| 190 |
+
https://numpy.org/doc/stable/f2py/index.html\n"""
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
def scaninputline(inputline):
|
| 194 |
+
files, skipfuncs, onlyfuncs, debug = [], [], [], []
|
| 195 |
+
f, f2, f3, f5, f6, f8, f9, f10 = 1, 0, 0, 0, 0, 0, 0, 0
|
| 196 |
+
verbose = 1
|
| 197 |
+
emptygen = True
|
| 198 |
+
dolc = -1
|
| 199 |
+
dolatexdoc = 0
|
| 200 |
+
dorestdoc = 0
|
| 201 |
+
wrapfuncs = 1
|
| 202 |
+
buildpath = '.'
|
| 203 |
+
include_paths, inputline = get_includes(inputline)
|
| 204 |
+
signsfile, modulename = None, None
|
| 205 |
+
options = {'buildpath': buildpath,
|
| 206 |
+
'coutput': None,
|
| 207 |
+
'f2py_wrapper_output': None}
|
| 208 |
+
for l in inputline:
|
| 209 |
+
if l == '':
|
| 210 |
+
pass
|
| 211 |
+
elif l == 'only:':
|
| 212 |
+
f = 0
|
| 213 |
+
elif l == 'skip:':
|
| 214 |
+
f = -1
|
| 215 |
+
elif l == ':':
|
| 216 |
+
f = 1
|
| 217 |
+
elif l[:8] == '--debug-':
|
| 218 |
+
debug.append(l[8:])
|
| 219 |
+
elif l == '--lower':
|
| 220 |
+
dolc = 1
|
| 221 |
+
elif l == '--build-dir':
|
| 222 |
+
f6 = 1
|
| 223 |
+
elif l == '--no-lower':
|
| 224 |
+
dolc = 0
|
| 225 |
+
elif l == '--quiet':
|
| 226 |
+
verbose = 0
|
| 227 |
+
elif l == '--verbose':
|
| 228 |
+
verbose += 1
|
| 229 |
+
elif l == '--latex-doc':
|
| 230 |
+
dolatexdoc = 1
|
| 231 |
+
elif l == '--no-latex-doc':
|
| 232 |
+
dolatexdoc = 0
|
| 233 |
+
elif l == '--rest-doc':
|
| 234 |
+
dorestdoc = 1
|
| 235 |
+
elif l == '--no-rest-doc':
|
| 236 |
+
dorestdoc = 0
|
| 237 |
+
elif l == '--wrap-functions':
|
| 238 |
+
wrapfuncs = 1
|
| 239 |
+
elif l == '--no-wrap-functions':
|
| 240 |
+
wrapfuncs = 0
|
| 241 |
+
elif l == '--short-latex':
|
| 242 |
+
options['shortlatex'] = 1
|
| 243 |
+
elif l == '--coutput':
|
| 244 |
+
f8 = 1
|
| 245 |
+
elif l == '--f2py-wrapper-output':
|
| 246 |
+
f9 = 1
|
| 247 |
+
elif l == '--f2cmap':
|
| 248 |
+
f10 = 1
|
| 249 |
+
elif l == '--overwrite-signature':
|
| 250 |
+
options['h-overwrite'] = 1
|
| 251 |
+
elif l == '-h':
|
| 252 |
+
f2 = 1
|
| 253 |
+
elif l == '-m':
|
| 254 |
+
f3 = 1
|
| 255 |
+
elif l[:2] == '-v':
|
| 256 |
+
print(f2py_version)
|
| 257 |
+
sys.exit()
|
| 258 |
+
elif l == '--show-compilers':
|
| 259 |
+
f5 = 1
|
| 260 |
+
elif l[:8] == '-include':
|
| 261 |
+
cfuncs.outneeds['userincludes'].append(l[9:-1])
|
| 262 |
+
cfuncs.userincludes[l[9:-1]] = '#include ' + l[8:]
|
| 263 |
+
elif l == '--skip-empty-wrappers':
|
| 264 |
+
emptygen = False
|
| 265 |
+
elif l[0] == '-':
|
| 266 |
+
errmess('Unknown option %s\n' % repr(l))
|
| 267 |
+
sys.exit()
|
| 268 |
+
elif f2:
|
| 269 |
+
f2 = 0
|
| 270 |
+
signsfile = l
|
| 271 |
+
elif f3:
|
| 272 |
+
f3 = 0
|
| 273 |
+
modulename = l
|
| 274 |
+
elif f6:
|
| 275 |
+
f6 = 0
|
| 276 |
+
buildpath = l
|
| 277 |
+
elif f8:
|
| 278 |
+
f8 = 0
|
| 279 |
+
options["coutput"] = l
|
| 280 |
+
elif f9:
|
| 281 |
+
f9 = 0
|
| 282 |
+
options["f2py_wrapper_output"] = l
|
| 283 |
+
elif f10:
|
| 284 |
+
f10 = 0
|
| 285 |
+
options["f2cmap_file"] = l
|
| 286 |
+
elif f == 1:
|
| 287 |
+
try:
|
| 288 |
+
with open(l):
|
| 289 |
+
pass
|
| 290 |
+
files.append(l)
|
| 291 |
+
except OSError as detail:
|
| 292 |
+
errmess(f'OSError: {detail!s}. Skipping file "{l!s}".\n')
|
| 293 |
+
elif f == -1:
|
| 294 |
+
skipfuncs.append(l)
|
| 295 |
+
elif f == 0:
|
| 296 |
+
onlyfuncs.append(l)
|
| 297 |
+
if not f5 and not files and not modulename:
|
| 298 |
+
print(__usage__)
|
| 299 |
+
sys.exit()
|
| 300 |
+
if not os.path.isdir(buildpath):
|
| 301 |
+
if not verbose:
|
| 302 |
+
outmess('Creating build directory %s\n' % (buildpath))
|
| 303 |
+
os.mkdir(buildpath)
|
| 304 |
+
if signsfile:
|
| 305 |
+
signsfile = os.path.join(buildpath, signsfile)
|
| 306 |
+
if signsfile and os.path.isfile(signsfile) and 'h-overwrite' not in options:
|
| 307 |
+
errmess(
|
| 308 |
+
'Signature file "%s" exists!!! Use --overwrite-signature to overwrite.\n' % (signsfile))
|
| 309 |
+
sys.exit()
|
| 310 |
+
|
| 311 |
+
options['emptygen'] = emptygen
|
| 312 |
+
options['debug'] = debug
|
| 313 |
+
options['verbose'] = verbose
|
| 314 |
+
if dolc == -1 and not signsfile:
|
| 315 |
+
options['do-lower'] = 0
|
| 316 |
+
else:
|
| 317 |
+
options['do-lower'] = dolc
|
| 318 |
+
if modulename:
|
| 319 |
+
options['module'] = modulename
|
| 320 |
+
if signsfile:
|
| 321 |
+
options['signsfile'] = signsfile
|
| 322 |
+
if onlyfuncs:
|
| 323 |
+
options['onlyfuncs'] = onlyfuncs
|
| 324 |
+
if skipfuncs:
|
| 325 |
+
options['skipfuncs'] = skipfuncs
|
| 326 |
+
options['dolatexdoc'] = dolatexdoc
|
| 327 |
+
options['dorestdoc'] = dorestdoc
|
| 328 |
+
options['wrapfuncs'] = wrapfuncs
|
| 329 |
+
options['buildpath'] = buildpath
|
| 330 |
+
options['include_paths'] = include_paths
|
| 331 |
+
options.setdefault('f2cmap_file', None)
|
| 332 |
+
return files, options
|
| 333 |
+
|
| 334 |
+
|
| 335 |
+
def callcrackfortran(files, options):
|
| 336 |
+
rules.options = options
|
| 337 |
+
crackfortran.debug = options['debug']
|
| 338 |
+
crackfortran.verbose = options['verbose']
|
| 339 |
+
if 'module' in options:
|
| 340 |
+
crackfortran.f77modulename = options['module']
|
| 341 |
+
if 'skipfuncs' in options:
|
| 342 |
+
crackfortran.skipfuncs = options['skipfuncs']
|
| 343 |
+
if 'onlyfuncs' in options:
|
| 344 |
+
crackfortran.onlyfuncs = options['onlyfuncs']
|
| 345 |
+
crackfortran.include_paths[:] = options['include_paths']
|
| 346 |
+
crackfortran.dolowercase = options['do-lower']
|
| 347 |
+
postlist = crackfortran.crackfortran(files)
|
| 348 |
+
if 'signsfile' in options:
|
| 349 |
+
outmess('Saving signatures to file "%s"\n' % (options['signsfile']))
|
| 350 |
+
pyf = crackfortran.crack2fortran(postlist)
|
| 351 |
+
if options['signsfile'][-6:] == 'stdout':
|
| 352 |
+
sys.stdout.write(pyf)
|
| 353 |
+
else:
|
| 354 |
+
with open(options['signsfile'], 'w') as f:
|
| 355 |
+
f.write(pyf)
|
| 356 |
+
if options["coutput"] is None:
|
| 357 |
+
for mod in postlist:
|
| 358 |
+
mod["coutput"] = "%smodule.c" % mod["name"]
|
| 359 |
+
else:
|
| 360 |
+
for mod in postlist:
|
| 361 |
+
mod["coutput"] = options["coutput"]
|
| 362 |
+
if options["f2py_wrapper_output"] is None:
|
| 363 |
+
for mod in postlist:
|
| 364 |
+
mod["f2py_wrapper_output"] = "%s-f2pywrappers.f" % mod["name"]
|
| 365 |
+
else:
|
| 366 |
+
for mod in postlist:
|
| 367 |
+
mod["f2py_wrapper_output"] = options["f2py_wrapper_output"]
|
| 368 |
+
return postlist
|
| 369 |
+
|
| 370 |
+
|
| 371 |
+
def buildmodules(lst):
|
| 372 |
+
cfuncs.buildcfuncs()
|
| 373 |
+
outmess('Building modules...\n')
|
| 374 |
+
modules, mnames, isusedby = [], [], {}
|
| 375 |
+
for item in lst:
|
| 376 |
+
if '__user__' in item['name']:
|
| 377 |
+
cb_rules.buildcallbacks(item)
|
| 378 |
+
else:
|
| 379 |
+
if 'use' in item:
|
| 380 |
+
for u in item['use'].keys():
|
| 381 |
+
if u not in isusedby:
|
| 382 |
+
isusedby[u] = []
|
| 383 |
+
isusedby[u].append(item['name'])
|
| 384 |
+
modules.append(item)
|
| 385 |
+
mnames.append(item['name'])
|
| 386 |
+
ret = {}
|
| 387 |
+
for module, name in zip(modules, mnames):
|
| 388 |
+
if name in isusedby:
|
| 389 |
+
outmess('\tSkipping module "%s" which is used by %s.\n' % (
|
| 390 |
+
name, ','.join('"%s"' % s for s in isusedby[name])))
|
| 391 |
+
else:
|
| 392 |
+
um = []
|
| 393 |
+
if 'use' in module:
|
| 394 |
+
for u in module['use'].keys():
|
| 395 |
+
if u in isusedby and u in mnames:
|
| 396 |
+
um.append(modules[mnames.index(u)])
|
| 397 |
+
else:
|
| 398 |
+
outmess(
|
| 399 |
+
f'\tModule "{name}" uses nonexisting "{u}" '
|
| 400 |
+
'which will be ignored.\n')
|
| 401 |
+
ret[name] = {}
|
| 402 |
+
dict_append(ret[name], rules.buildmodule(module, um))
|
| 403 |
+
return ret
|
| 404 |
+
|
| 405 |
+
|
| 406 |
+
def dict_append(d_out, d_in):
|
| 407 |
+
for (k, v) in d_in.items():
|
| 408 |
+
if k not in d_out:
|
| 409 |
+
d_out[k] = []
|
| 410 |
+
if isinstance(v, list):
|
| 411 |
+
d_out[k] = d_out[k] + v
|
| 412 |
+
else:
|
| 413 |
+
d_out[k].append(v)
|
| 414 |
+
|
| 415 |
+
|
| 416 |
+
def run_main(comline_list):
|
| 417 |
+
"""
|
| 418 |
+
Equivalent to running::
|
| 419 |
+
|
| 420 |
+
f2py <args>
|
| 421 |
+
|
| 422 |
+
where ``<args>=string.join(<list>,' ')``, but in Python. Unless
|
| 423 |
+
``-h`` is used, this function returns a dictionary containing
|
| 424 |
+
information on generated modules and their dependencies on source
|
| 425 |
+
files.
|
| 426 |
+
|
| 427 |
+
You cannot build extension modules with this function, that is,
|
| 428 |
+
using ``-c`` is not allowed. Use the ``compile`` command instead.
|
| 429 |
+
|
| 430 |
+
Examples
|
| 431 |
+
--------
|
| 432 |
+
The command ``f2py -m scalar scalar.f`` can be executed from Python as
|
| 433 |
+
follows.
|
| 434 |
+
|
| 435 |
+
.. literalinclude:: ../../source/f2py/code/results/run_main_session.dat
|
| 436 |
+
:language: python
|
| 437 |
+
|
| 438 |
+
"""
|
| 439 |
+
crackfortran.reset_global_f2py_vars()
|
| 440 |
+
f2pydir = os.path.dirname(os.path.abspath(cfuncs.__file__))
|
| 441 |
+
fobjhsrc = os.path.join(f2pydir, 'src', 'fortranobject.h')
|
| 442 |
+
fobjcsrc = os.path.join(f2pydir, 'src', 'fortranobject.c')
|
| 443 |
+
# gh-22819 -- begin
|
| 444 |
+
parser = make_f2py_compile_parser()
|
| 445 |
+
args, comline_list = parser.parse_known_args(comline_list)
|
| 446 |
+
pyf_files, _ = filter_files("", "[.]pyf([.]src|)", comline_list)
|
| 447 |
+
# Checks that no existing modulename is defined in a pyf file
|
| 448 |
+
# TODO: Remove all this when scaninputline is replaced
|
| 449 |
+
if args.module_name:
|
| 450 |
+
if "-h" in comline_list:
|
| 451 |
+
modname = (
|
| 452 |
+
args.module_name
|
| 453 |
+
) # Directly use from args when -h is present
|
| 454 |
+
else:
|
| 455 |
+
modname = validate_modulename(
|
| 456 |
+
pyf_files, args.module_name
|
| 457 |
+
) # Validate modname when -h is not present
|
| 458 |
+
comline_list += ['-m', modname] # needed for the rest of scaninputline
|
| 459 |
+
# gh-22819 -- end
|
| 460 |
+
files, options = scaninputline(comline_list)
|
| 461 |
+
auxfuncs.options = options
|
| 462 |
+
capi_maps.load_f2cmap_file(options['f2cmap_file'])
|
| 463 |
+
postlist = callcrackfortran(files, options)
|
| 464 |
+
isusedby = {}
|
| 465 |
+
for plist in postlist:
|
| 466 |
+
if 'use' in plist:
|
| 467 |
+
for u in plist['use'].keys():
|
| 468 |
+
if u not in isusedby:
|
| 469 |
+
isusedby[u] = []
|
| 470 |
+
isusedby[u].append(plist['name'])
|
| 471 |
+
for plist in postlist:
|
| 472 |
+
if plist['block'] == 'python module' and '__user__' in plist['name']:
|
| 473 |
+
if plist['name'] in isusedby:
|
| 474 |
+
# if not quiet:
|
| 475 |
+
outmess(
|
| 476 |
+
f'Skipping Makefile build for module "{plist["name"]}" '
|
| 477 |
+
'which is used by {}\n'.format(
|
| 478 |
+
','.join(f'"{s}"' for s in isusedby[plist['name']])))
|
| 479 |
+
if 'signsfile' in options:
|
| 480 |
+
if options['verbose'] > 1:
|
| 481 |
+
outmess(
|
| 482 |
+
'Stopping. Edit the signature file and then run f2py on the signature file: ')
|
| 483 |
+
outmess('%s %s\n' %
|
| 484 |
+
(os.path.basename(sys.argv[0]), options['signsfile']))
|
| 485 |
+
return
|
| 486 |
+
for plist in postlist:
|
| 487 |
+
if plist['block'] != 'python module':
|
| 488 |
+
if 'python module' not in options:
|
| 489 |
+
errmess(
|
| 490 |
+
'Tip: If your original code is Fortran source then you must use -m option.\n')
|
| 491 |
+
raise TypeError('All blocks must be python module blocks but got %s' % (
|
| 492 |
+
repr(plist['block'])))
|
| 493 |
+
auxfuncs.debugoptions = options['debug']
|
| 494 |
+
f90mod_rules.options = options
|
| 495 |
+
auxfuncs.wrapfuncs = options['wrapfuncs']
|
| 496 |
+
|
| 497 |
+
ret = buildmodules(postlist)
|
| 498 |
+
|
| 499 |
+
for mn in ret.keys():
|
| 500 |
+
dict_append(ret[mn], {'csrc': fobjcsrc, 'h': fobjhsrc})
|
| 501 |
+
return ret
|
| 502 |
+
|
| 503 |
+
|
| 504 |
+
def filter_files(prefix, suffix, files, remove_prefix=None):
|
| 505 |
+
"""
|
| 506 |
+
Filter files by prefix and suffix.
|
| 507 |
+
"""
|
| 508 |
+
filtered, rest = [], []
|
| 509 |
+
match = re.compile(prefix + r'.*' + suffix + r'\Z').match
|
| 510 |
+
if remove_prefix:
|
| 511 |
+
ind = len(prefix)
|
| 512 |
+
else:
|
| 513 |
+
ind = 0
|
| 514 |
+
for file in [x.strip() for x in files]:
|
| 515 |
+
if match(file):
|
| 516 |
+
filtered.append(file[ind:])
|
| 517 |
+
else:
|
| 518 |
+
rest.append(file)
|
| 519 |
+
return filtered, rest
|
| 520 |
+
|
| 521 |
+
|
| 522 |
+
def get_prefix(module):
|
| 523 |
+
p = os.path.dirname(os.path.dirname(module.__file__))
|
| 524 |
+
return p
|
| 525 |
+
|
| 526 |
+
|
| 527 |
+
class CombineIncludePaths(argparse.Action):
|
| 528 |
+
def __call__(self, parser, namespace, values, option_string=None):
|
| 529 |
+
include_paths_set = set(getattr(namespace, 'include_paths', []) or [])
|
| 530 |
+
if option_string == "--include_paths":
|
| 531 |
+
outmess("Use --include-paths or -I instead of --include_paths which will be removed")
|
| 532 |
+
if option_string == "--include-paths" or option_string == "--include_paths":
|
| 533 |
+
include_paths_set.update(values.split(':'))
|
| 534 |
+
else:
|
| 535 |
+
include_paths_set.add(values)
|
| 536 |
+
setattr(namespace, 'include_paths', list(include_paths_set))
|
| 537 |
+
|
| 538 |
+
def include_parser():
|
| 539 |
+
parser = argparse.ArgumentParser(add_help=False)
|
| 540 |
+
parser.add_argument("-I", dest="include_paths", action=CombineIncludePaths)
|
| 541 |
+
parser.add_argument("--include-paths", dest="include_paths", action=CombineIncludePaths)
|
| 542 |
+
parser.add_argument("--include_paths", dest="include_paths", action=CombineIncludePaths)
|
| 543 |
+
return parser
|
| 544 |
+
|
| 545 |
+
def get_includes(iline):
|
| 546 |
+
iline = (' '.join(iline)).split()
|
| 547 |
+
parser = include_parser()
|
| 548 |
+
args, remain = parser.parse_known_args(iline)
|
| 549 |
+
ipaths = args.include_paths
|
| 550 |
+
if args.include_paths is None:
|
| 551 |
+
ipaths = []
|
| 552 |
+
return ipaths, remain
|
| 553 |
+
|
| 554 |
+
def make_f2py_compile_parser():
|
| 555 |
+
parser = argparse.ArgumentParser(add_help=False)
|
| 556 |
+
parser.add_argument("--dep", action="append", dest="dependencies")
|
| 557 |
+
parser.add_argument("--backend", choices=['meson', 'distutils'], default='distutils')
|
| 558 |
+
parser.add_argument("-m", dest="module_name")
|
| 559 |
+
return parser
|
| 560 |
+
|
| 561 |
+
def preparse_sysargv():
|
| 562 |
+
# To keep backwards bug compatibility, newer flags are handled by argparse,
|
| 563 |
+
# and `sys.argv` is passed to the rest of `f2py` as is.
|
| 564 |
+
parser = make_f2py_compile_parser()
|
| 565 |
+
|
| 566 |
+
args, remaining_argv = parser.parse_known_args()
|
| 567 |
+
sys.argv = [sys.argv[0]] + remaining_argv
|
| 568 |
+
|
| 569 |
+
backend_key = args.backend
|
| 570 |
+
if MESON_ONLY_VER and backend_key == 'distutils':
|
| 571 |
+
outmess("Cannot use distutils backend with Python>=3.12,"
|
| 572 |
+
" using meson backend instead.\n")
|
| 573 |
+
backend_key = "meson"
|
| 574 |
+
|
| 575 |
+
return {
|
| 576 |
+
"dependencies": args.dependencies or [],
|
| 577 |
+
"backend": backend_key,
|
| 578 |
+
"modulename": args.module_name,
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
def run_compile():
|
| 582 |
+
"""
|
| 583 |
+
Do it all in one call!
|
| 584 |
+
"""
|
| 585 |
+
import tempfile
|
| 586 |
+
|
| 587 |
+
# Collect dependency flags, preprocess sys.argv
|
| 588 |
+
argy = preparse_sysargv()
|
| 589 |
+
modulename = argy["modulename"]
|
| 590 |
+
if modulename is None:
|
| 591 |
+
modulename = 'untitled'
|
| 592 |
+
dependencies = argy["dependencies"]
|
| 593 |
+
backend_key = argy["backend"]
|
| 594 |
+
build_backend = f2py_build_generator(backend_key)
|
| 595 |
+
|
| 596 |
+
i = sys.argv.index('-c')
|
| 597 |
+
del sys.argv[i]
|
| 598 |
+
|
| 599 |
+
remove_build_dir = 0
|
| 600 |
+
try:
|
| 601 |
+
i = sys.argv.index('--build-dir')
|
| 602 |
+
except ValueError:
|
| 603 |
+
i = None
|
| 604 |
+
if i is not None:
|
| 605 |
+
build_dir = sys.argv[i + 1]
|
| 606 |
+
del sys.argv[i + 1]
|
| 607 |
+
del sys.argv[i]
|
| 608 |
+
else:
|
| 609 |
+
remove_build_dir = 1
|
| 610 |
+
build_dir = tempfile.mkdtemp()
|
| 611 |
+
|
| 612 |
+
_reg1 = re.compile(r'--link-')
|
| 613 |
+
sysinfo_flags = [_m for _m in sys.argv[1:] if _reg1.match(_m)]
|
| 614 |
+
sys.argv = [_m for _m in sys.argv if _m not in sysinfo_flags]
|
| 615 |
+
if sysinfo_flags:
|
| 616 |
+
sysinfo_flags = [f[7:] for f in sysinfo_flags]
|
| 617 |
+
|
| 618 |
+
_reg2 = re.compile(
|
| 619 |
+
r'--((no-|)(wrap-functions|lower)|debug-capi|quiet|skip-empty-wrappers)|-include')
|
| 620 |
+
f2py_flags = [_m for _m in sys.argv[1:] if _reg2.match(_m)]
|
| 621 |
+
sys.argv = [_m for _m in sys.argv if _m not in f2py_flags]
|
| 622 |
+
f2py_flags2 = []
|
| 623 |
+
fl = 0
|
| 624 |
+
for a in sys.argv[1:]:
|
| 625 |
+
if a in ['only:', 'skip:']:
|
| 626 |
+
fl = 1
|
| 627 |
+
elif a == ':':
|
| 628 |
+
fl = 0
|
| 629 |
+
if fl or a == ':':
|
| 630 |
+
f2py_flags2.append(a)
|
| 631 |
+
if f2py_flags2 and f2py_flags2[-1] != ':':
|
| 632 |
+
f2py_flags2.append(':')
|
| 633 |
+
f2py_flags.extend(f2py_flags2)
|
| 634 |
+
sys.argv = [_m for _m in sys.argv if _m not in f2py_flags2]
|
| 635 |
+
_reg3 = re.compile(
|
| 636 |
+
r'--((f(90)?compiler(-exec|)|compiler)=|help-compiler)')
|
| 637 |
+
flib_flags = [_m for _m in sys.argv[1:] if _reg3.match(_m)]
|
| 638 |
+
sys.argv = [_m for _m in sys.argv if _m not in flib_flags]
|
| 639 |
+
_reg4 = re.compile(
|
| 640 |
+
r'--((f(77|90)(flags|exec)|opt|arch)=|(debug|noopt|noarch|help-fcompiler))')
|
| 641 |
+
fc_flags = [_m for _m in sys.argv[1:] if _reg4.match(_m)]
|
| 642 |
+
sys.argv = [_m for _m in sys.argv if _m not in fc_flags]
|
| 643 |
+
|
| 644 |
+
del_list = []
|
| 645 |
+
for s in flib_flags:
|
| 646 |
+
v = '--fcompiler='
|
| 647 |
+
if s[:len(v)] == v:
|
| 648 |
+
if MESON_ONLY_VER or backend_key == 'meson':
|
| 649 |
+
outmess(
|
| 650 |
+
"--fcompiler cannot be used with meson,"
|
| 651 |
+
"set compiler with the FC environment variable\n"
|
| 652 |
+
)
|
| 653 |
+
else:
|
| 654 |
+
from numpy.distutils import fcompiler
|
| 655 |
+
fcompiler.load_all_fcompiler_classes()
|
| 656 |
+
allowed_keys = list(fcompiler.fcompiler_class.keys())
|
| 657 |
+
nv = ov = s[len(v):].lower()
|
| 658 |
+
if ov not in allowed_keys:
|
| 659 |
+
vmap = {} # XXX
|
| 660 |
+
try:
|
| 661 |
+
nv = vmap[ov]
|
| 662 |
+
except KeyError:
|
| 663 |
+
if ov not in vmap.values():
|
| 664 |
+
print('Unknown vendor: "%s"' % (s[len(v):]))
|
| 665 |
+
nv = ov
|
| 666 |
+
i = flib_flags.index(s)
|
| 667 |
+
flib_flags[i] = '--fcompiler=' + nv
|
| 668 |
+
continue
|
| 669 |
+
for s in del_list:
|
| 670 |
+
i = flib_flags.index(s)
|
| 671 |
+
del flib_flags[i]
|
| 672 |
+
assert len(flib_flags) <= 2, repr(flib_flags)
|
| 673 |
+
|
| 674 |
+
_reg5 = re.compile(r'--(verbose)')
|
| 675 |
+
setup_flags = [_m for _m in sys.argv[1:] if _reg5.match(_m)]
|
| 676 |
+
sys.argv = [_m for _m in sys.argv if _m not in setup_flags]
|
| 677 |
+
|
| 678 |
+
if '--quiet' in f2py_flags:
|
| 679 |
+
setup_flags.append('--quiet')
|
| 680 |
+
|
| 681 |
+
# Ugly filter to remove everything but sources
|
| 682 |
+
sources = sys.argv[1:]
|
| 683 |
+
f2cmapopt = '--f2cmap'
|
| 684 |
+
if f2cmapopt in sys.argv:
|
| 685 |
+
i = sys.argv.index(f2cmapopt)
|
| 686 |
+
f2py_flags.extend(sys.argv[i:i + 2])
|
| 687 |
+
del sys.argv[i + 1], sys.argv[i]
|
| 688 |
+
sources = sys.argv[1:]
|
| 689 |
+
|
| 690 |
+
pyf_files, _sources = filter_files("", "[.]pyf([.]src|)", sources)
|
| 691 |
+
sources = pyf_files + _sources
|
| 692 |
+
modulename = validate_modulename(pyf_files, modulename)
|
| 693 |
+
extra_objects, sources = filter_files('', '[.](o|a|so|dylib)', sources)
|
| 694 |
+
library_dirs, sources = filter_files('-L', '', sources, remove_prefix=1)
|
| 695 |
+
libraries, sources = filter_files('-l', '', sources, remove_prefix=1)
|
| 696 |
+
undef_macros, sources = filter_files('-U', '', sources, remove_prefix=1)
|
| 697 |
+
define_macros, sources = filter_files('-D', '', sources, remove_prefix=1)
|
| 698 |
+
for i in range(len(define_macros)):
|
| 699 |
+
name_value = define_macros[i].split('=', 1)
|
| 700 |
+
if len(name_value) == 1:
|
| 701 |
+
name_value.append(None)
|
| 702 |
+
if len(name_value) == 2:
|
| 703 |
+
define_macros[i] = tuple(name_value)
|
| 704 |
+
else:
|
| 705 |
+
print('Invalid use of -D:', name_value)
|
| 706 |
+
|
| 707 |
+
# Construct wrappers / signatures / things
|
| 708 |
+
if backend_key == 'meson':
|
| 709 |
+
if not pyf_files:
|
| 710 |
+
outmess('Using meson backend\nWill pass --lower to f2py\nSee https://numpy.org/doc/stable/f2py/buildtools/meson.html\n')
|
| 711 |
+
f2py_flags.append('--lower')
|
| 712 |
+
run_main(f" {' '.join(f2py_flags)} -m {modulename} {' '.join(sources)}".split())
|
| 713 |
+
else:
|
| 714 |
+
run_main(f" {' '.join(f2py_flags)} {' '.join(pyf_files)}".split())
|
| 715 |
+
|
| 716 |
+
# Order matters here, includes are needed for run_main above
|
| 717 |
+
include_dirs, sources = get_includes(sources)
|
| 718 |
+
# Now use the builder
|
| 719 |
+
builder = build_backend(
|
| 720 |
+
modulename,
|
| 721 |
+
sources,
|
| 722 |
+
extra_objects,
|
| 723 |
+
build_dir,
|
| 724 |
+
include_dirs,
|
| 725 |
+
library_dirs,
|
| 726 |
+
libraries,
|
| 727 |
+
define_macros,
|
| 728 |
+
undef_macros,
|
| 729 |
+
f2py_flags,
|
| 730 |
+
sysinfo_flags,
|
| 731 |
+
fc_flags,
|
| 732 |
+
flib_flags,
|
| 733 |
+
setup_flags,
|
| 734 |
+
remove_build_dir,
|
| 735 |
+
{"dependencies": dependencies},
|
| 736 |
+
)
|
| 737 |
+
|
| 738 |
+
builder.compile()
|
| 739 |
+
|
| 740 |
+
|
| 741 |
+
def validate_modulename(pyf_files, modulename='untitled'):
|
| 742 |
+
if len(pyf_files) > 1:
|
| 743 |
+
raise ValueError("Only one .pyf file per call")
|
| 744 |
+
if pyf_files:
|
| 745 |
+
pyff = pyf_files[0]
|
| 746 |
+
pyf_modname = auxfuncs.get_f2py_modulename(pyff)
|
| 747 |
+
if modulename != pyf_modname:
|
| 748 |
+
outmess(
|
| 749 |
+
f"Ignoring -m {modulename}.\n"
|
| 750 |
+
f"{pyff} defines {pyf_modname} to be the modulename.\n"
|
| 751 |
+
)
|
| 752 |
+
modulename = pyf_modname
|
| 753 |
+
return modulename
|
| 754 |
+
|
| 755 |
+
def main():
|
| 756 |
+
if '--help-link' in sys.argv[1:]:
|
| 757 |
+
sys.argv.remove('--help-link')
|
| 758 |
+
if MESON_ONLY_VER:
|
| 759 |
+
outmess("Use --dep for meson builds\n")
|
| 760 |
+
else:
|
| 761 |
+
from numpy.distutils.system_info import show_all
|
| 762 |
+
show_all()
|
| 763 |
+
return
|
| 764 |
+
|
| 765 |
+
if '-c' in sys.argv[1:]:
|
| 766 |
+
run_compile()
|
| 767 |
+
else:
|
| 768 |
+
run_main(sys.argv[1:])
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/f90mod_rules.py
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Build F90 module support for f2py2e.
|
| 3 |
+
|
| 4 |
+
Copyright 1999 -- 2011 Pearu Peterson all rights reserved.
|
| 5 |
+
Copyright 2011 -- present NumPy Developers.
|
| 6 |
+
Permission to use, modify, and distribute this software is given under the
|
| 7 |
+
terms of the NumPy License.
|
| 8 |
+
|
| 9 |
+
NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
| 10 |
+
"""
|
| 11 |
+
__version__ = "$Revision: 1.27 $"[10:-1]
|
| 12 |
+
|
| 13 |
+
f2py_version = 'See `f2py -v`'
|
| 14 |
+
|
| 15 |
+
import numpy as np
|
| 16 |
+
|
| 17 |
+
from . import capi_maps
|
| 18 |
+
from . import func2subr
|
| 19 |
+
from .crackfortran import undo_rmbadname, undo_rmbadname1
|
| 20 |
+
|
| 21 |
+
# The environment provided by auxfuncs.py is needed for some calls to eval.
|
| 22 |
+
# As the needed functions cannot be determined by static inspection of the
|
| 23 |
+
# code, it is safest to use import * pending a major refactoring of f2py.
|
| 24 |
+
from .auxfuncs import *
|
| 25 |
+
|
| 26 |
+
options = {}
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def findf90modules(m):
|
| 30 |
+
if ismodule(m):
|
| 31 |
+
return [m]
|
| 32 |
+
if not hasbody(m):
|
| 33 |
+
return []
|
| 34 |
+
ret = []
|
| 35 |
+
for b in m['body']:
|
| 36 |
+
if ismodule(b):
|
| 37 |
+
ret.append(b)
|
| 38 |
+
else:
|
| 39 |
+
ret = ret + findf90modules(b)
|
| 40 |
+
return ret
|
| 41 |
+
|
| 42 |
+
fgetdims1 = """\
|
| 43 |
+
external f2pysetdata
|
| 44 |
+
logical ns
|
| 45 |
+
integer r,i
|
| 46 |
+
integer(%d) s(*)
|
| 47 |
+
ns = .FALSE.
|
| 48 |
+
if (allocated(d)) then
|
| 49 |
+
do i=1,r
|
| 50 |
+
if ((size(d,i).ne.s(i)).and.(s(i).ge.0)) then
|
| 51 |
+
ns = .TRUE.
|
| 52 |
+
end if
|
| 53 |
+
end do
|
| 54 |
+
if (ns) then
|
| 55 |
+
deallocate(d)
|
| 56 |
+
end if
|
| 57 |
+
end if
|
| 58 |
+
if ((.not.allocated(d)).and.(s(1).ge.1)) then""" % np.intp().itemsize
|
| 59 |
+
|
| 60 |
+
fgetdims2 = """\
|
| 61 |
+
end if
|
| 62 |
+
if (allocated(d)) then
|
| 63 |
+
do i=1,r
|
| 64 |
+
s(i) = size(d,i)
|
| 65 |
+
end do
|
| 66 |
+
end if
|
| 67 |
+
flag = 1
|
| 68 |
+
call f2pysetdata(d,allocated(d))"""
|
| 69 |
+
|
| 70 |
+
fgetdims2_sa = """\
|
| 71 |
+
end if
|
| 72 |
+
if (allocated(d)) then
|
| 73 |
+
do i=1,r
|
| 74 |
+
s(i) = size(d,i)
|
| 75 |
+
end do
|
| 76 |
+
!s(r) must be equal to len(d(1))
|
| 77 |
+
end if
|
| 78 |
+
flag = 2
|
| 79 |
+
call f2pysetdata(d,allocated(d))"""
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def buildhooks(pymod):
|
| 83 |
+
from . import rules
|
| 84 |
+
ret = {'f90modhooks': [], 'initf90modhooks': [], 'body': [],
|
| 85 |
+
'need': ['F_FUNC', 'arrayobject.h'],
|
| 86 |
+
'separatorsfor': {'includes0': '\n', 'includes': '\n'},
|
| 87 |
+
'docs': ['"Fortran 90/95 modules:\\n"'],
|
| 88 |
+
'latexdoc': []}
|
| 89 |
+
fhooks = ['']
|
| 90 |
+
|
| 91 |
+
def fadd(line, s=fhooks):
|
| 92 |
+
s[0] = '%s\n %s' % (s[0], line)
|
| 93 |
+
doc = ['']
|
| 94 |
+
|
| 95 |
+
def dadd(line, s=doc):
|
| 96 |
+
s[0] = '%s\n%s' % (s[0], line)
|
| 97 |
+
|
| 98 |
+
usenames = getuseblocks(pymod)
|
| 99 |
+
for m in findf90modules(pymod):
|
| 100 |
+
sargs, fargs, efargs, modobjs, notvars, onlyvars = [], [], [], [], [
|
| 101 |
+
m['name']], []
|
| 102 |
+
sargsp = []
|
| 103 |
+
ifargs = []
|
| 104 |
+
mfargs = []
|
| 105 |
+
if hasbody(m):
|
| 106 |
+
for b in m['body']:
|
| 107 |
+
notvars.append(b['name'])
|
| 108 |
+
for n in m['vars'].keys():
|
| 109 |
+
var = m['vars'][n]
|
| 110 |
+
if (n not in notvars) and (not l_or(isintent_hide, isprivate)(var)):
|
| 111 |
+
onlyvars.append(n)
|
| 112 |
+
mfargs.append(n)
|
| 113 |
+
outmess('\t\tConstructing F90 module support for "%s"...\n' %
|
| 114 |
+
(m['name']))
|
| 115 |
+
if m['name'] in usenames and not onlyvars:
|
| 116 |
+
outmess(f"\t\t\tSkipping {m['name']} since it is in 'use'...\n")
|
| 117 |
+
continue
|
| 118 |
+
if onlyvars:
|
| 119 |
+
outmess('\t\t Variables: %s\n' % (' '.join(onlyvars)))
|
| 120 |
+
chooks = ['']
|
| 121 |
+
|
| 122 |
+
def cadd(line, s=chooks):
|
| 123 |
+
s[0] = '%s\n%s' % (s[0], line)
|
| 124 |
+
ihooks = ['']
|
| 125 |
+
|
| 126 |
+
def iadd(line, s=ihooks):
|
| 127 |
+
s[0] = '%s\n%s' % (s[0], line)
|
| 128 |
+
|
| 129 |
+
vrd = capi_maps.modsign2map(m)
|
| 130 |
+
cadd('static FortranDataDef f2py_%s_def[] = {' % (m['name']))
|
| 131 |
+
dadd('\\subsection{Fortran 90/95 module \\texttt{%s}}\n' % (m['name']))
|
| 132 |
+
if hasnote(m):
|
| 133 |
+
note = m['note']
|
| 134 |
+
if isinstance(note, list):
|
| 135 |
+
note = '\n'.join(note)
|
| 136 |
+
dadd(note)
|
| 137 |
+
if onlyvars:
|
| 138 |
+
dadd('\\begin{description}')
|
| 139 |
+
for n in onlyvars:
|
| 140 |
+
var = m['vars'][n]
|
| 141 |
+
modobjs.append(n)
|
| 142 |
+
ct = capi_maps.getctype(var)
|
| 143 |
+
at = capi_maps.c2capi_map[ct]
|
| 144 |
+
dm = capi_maps.getarrdims(n, var)
|
| 145 |
+
dms = dm['dims'].replace('*', '-1').strip()
|
| 146 |
+
dms = dms.replace(':', '-1').strip()
|
| 147 |
+
if not dms:
|
| 148 |
+
dms = '-1'
|
| 149 |
+
use_fgetdims2 = fgetdims2
|
| 150 |
+
cadd('\t{"%s",%s,{{%s}},%s, %s},' %
|
| 151 |
+
(undo_rmbadname1(n), dm['rank'], dms, at,
|
| 152 |
+
capi_maps.get_elsize(var)))
|
| 153 |
+
dadd('\\item[]{{}\\verb@%s@{}}' %
|
| 154 |
+
(capi_maps.getarrdocsign(n, var)))
|
| 155 |
+
if hasnote(var):
|
| 156 |
+
note = var['note']
|
| 157 |
+
if isinstance(note, list):
|
| 158 |
+
note = '\n'.join(note)
|
| 159 |
+
dadd('--- %s' % (note))
|
| 160 |
+
if isallocatable(var):
|
| 161 |
+
fargs.append('f2py_%s_getdims_%s' % (m['name'], n))
|
| 162 |
+
efargs.append(fargs[-1])
|
| 163 |
+
sargs.append(
|
| 164 |
+
'void (*%s)(int*,npy_intp*,void(*)(char*,npy_intp*),int*)' % (n))
|
| 165 |
+
sargsp.append('void (*)(int*,npy_intp*,void(*)(char*,npy_intp*),int*)')
|
| 166 |
+
iadd('\tf2py_%s_def[i_f2py++].func = %s;' % (m['name'], n))
|
| 167 |
+
fadd('subroutine %s(r,s,f2pysetdata,flag)' % (fargs[-1]))
|
| 168 |
+
fadd('use %s, only: d => %s\n' %
|
| 169 |
+
(m['name'], undo_rmbadname1(n)))
|
| 170 |
+
fadd('integer flag\n')
|
| 171 |
+
fhooks[0] = fhooks[0] + fgetdims1
|
| 172 |
+
dms = range(1, int(dm['rank']) + 1)
|
| 173 |
+
fadd(' allocate(d(%s))\n' %
|
| 174 |
+
(','.join(['s(%s)' % i for i in dms])))
|
| 175 |
+
fhooks[0] = fhooks[0] + use_fgetdims2
|
| 176 |
+
fadd('end subroutine %s' % (fargs[-1]))
|
| 177 |
+
else:
|
| 178 |
+
fargs.append(n)
|
| 179 |
+
sargs.append('char *%s' % (n))
|
| 180 |
+
sargsp.append('char*')
|
| 181 |
+
iadd('\tf2py_%s_def[i_f2py++].data = %s;' % (m['name'], n))
|
| 182 |
+
if onlyvars:
|
| 183 |
+
dadd('\\end{description}')
|
| 184 |
+
if hasbody(m):
|
| 185 |
+
for b in m['body']:
|
| 186 |
+
if not isroutine(b):
|
| 187 |
+
outmess("f90mod_rules.buildhooks:"
|
| 188 |
+
f" skipping {b['block']} {b['name']}\n")
|
| 189 |
+
continue
|
| 190 |
+
modobjs.append('%s()' % (b['name']))
|
| 191 |
+
b['modulename'] = m['name']
|
| 192 |
+
api, wrap = rules.buildapi(b)
|
| 193 |
+
if isfunction(b):
|
| 194 |
+
fhooks[0] = fhooks[0] + wrap
|
| 195 |
+
fargs.append('f2pywrap_%s_%s' % (m['name'], b['name']))
|
| 196 |
+
ifargs.append(func2subr.createfuncwrapper(b, signature=1))
|
| 197 |
+
else:
|
| 198 |
+
if wrap:
|
| 199 |
+
fhooks[0] = fhooks[0] + wrap
|
| 200 |
+
fargs.append('f2pywrap_%s_%s' % (m['name'], b['name']))
|
| 201 |
+
ifargs.append(
|
| 202 |
+
func2subr.createsubrwrapper(b, signature=1))
|
| 203 |
+
else:
|
| 204 |
+
fargs.append(b['name'])
|
| 205 |
+
mfargs.append(fargs[-1])
|
| 206 |
+
api['externroutines'] = []
|
| 207 |
+
ar = applyrules(api, vrd)
|
| 208 |
+
ar['docs'] = []
|
| 209 |
+
ar['docshort'] = []
|
| 210 |
+
ret = dictappend(ret, ar)
|
| 211 |
+
cadd(('\t{"%s",-1,{{-1}},0,0,NULL,(void *)'
|
| 212 |
+
'f2py_rout_#modulename#_%s_%s,'
|
| 213 |
+
'doc_f2py_rout_#modulename#_%s_%s},')
|
| 214 |
+
% (b['name'], m['name'], b['name'], m['name'], b['name']))
|
| 215 |
+
sargs.append('char *%s' % (b['name']))
|
| 216 |
+
sargsp.append('char *')
|
| 217 |
+
iadd('\tf2py_%s_def[i_f2py++].data = %s;' %
|
| 218 |
+
(m['name'], b['name']))
|
| 219 |
+
cadd('\t{NULL}\n};\n')
|
| 220 |
+
iadd('}')
|
| 221 |
+
ihooks[0] = 'static void f2py_setup_%s(%s) {\n\tint i_f2py=0;%s' % (
|
| 222 |
+
m['name'], ','.join(sargs), ihooks[0])
|
| 223 |
+
if '_' in m['name']:
|
| 224 |
+
F_FUNC = 'F_FUNC_US'
|
| 225 |
+
else:
|
| 226 |
+
F_FUNC = 'F_FUNC'
|
| 227 |
+
iadd('extern void %s(f2pyinit%s,F2PYINIT%s)(void (*)(%s));'
|
| 228 |
+
% (F_FUNC, m['name'], m['name'].upper(), ','.join(sargsp)))
|
| 229 |
+
iadd('static void f2py_init_%s(void) {' % (m['name']))
|
| 230 |
+
iadd('\t%s(f2pyinit%s,F2PYINIT%s)(f2py_setup_%s);'
|
| 231 |
+
% (F_FUNC, m['name'], m['name'].upper(), m['name']))
|
| 232 |
+
iadd('}\n')
|
| 233 |
+
ret['f90modhooks'] = ret['f90modhooks'] + chooks + ihooks
|
| 234 |
+
ret['initf90modhooks'] = ['\tPyDict_SetItemString(d, "%s", PyFortranObject_New(f2py_%s_def,f2py_init_%s));' % (
|
| 235 |
+
m['name'], m['name'], m['name'])] + ret['initf90modhooks']
|
| 236 |
+
fadd('')
|
| 237 |
+
fadd('subroutine f2pyinit%s(f2pysetupfunc)' % (m['name']))
|
| 238 |
+
if mfargs:
|
| 239 |
+
for a in undo_rmbadname(mfargs):
|
| 240 |
+
fadd('use %s, only : %s' % (m['name'], a))
|
| 241 |
+
if ifargs:
|
| 242 |
+
fadd(' '.join(['interface'] + ifargs))
|
| 243 |
+
fadd('end interface')
|
| 244 |
+
fadd('external f2pysetupfunc')
|
| 245 |
+
if efargs:
|
| 246 |
+
for a in undo_rmbadname(efargs):
|
| 247 |
+
fadd('external %s' % (a))
|
| 248 |
+
fadd('call f2pysetupfunc(%s)' % (','.join(undo_rmbadname(fargs))))
|
| 249 |
+
fadd('end subroutine f2pyinit%s\n' % (m['name']))
|
| 250 |
+
|
| 251 |
+
dadd('\n'.join(ret['latexdoc']).replace(
|
| 252 |
+
r'\subsection{', r'\subsubsection{'))
|
| 253 |
+
|
| 254 |
+
ret['latexdoc'] = []
|
| 255 |
+
ret['docs'].append('"\t%s --- %s"' % (m['name'],
|
| 256 |
+
','.join(undo_rmbadname(modobjs))))
|
| 257 |
+
|
| 258 |
+
ret['routine_defs'] = ''
|
| 259 |
+
ret['doc'] = []
|
| 260 |
+
ret['docshort'] = []
|
| 261 |
+
ret['latexdoc'] = doc[0]
|
| 262 |
+
if len(ret['docs']) <= 1:
|
| 263 |
+
ret['docs'] = ''
|
| 264 |
+
return ret, fhooks[0]
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/func2subr.py
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
|
| 3 |
+
Rules for building C/API module with f2py2e.
|
| 4 |
+
|
| 5 |
+
Copyright 1999 -- 2011 Pearu Peterson all rights reserved.
|
| 6 |
+
Copyright 2011 -- present NumPy Developers.
|
| 7 |
+
Permission to use, modify, and distribute this software is given under the
|
| 8 |
+
terms of the NumPy License.
|
| 9 |
+
|
| 10 |
+
NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
| 11 |
+
"""
|
| 12 |
+
import copy
|
| 13 |
+
|
| 14 |
+
from .auxfuncs import (
|
| 15 |
+
getfortranname, isexternal, isfunction, isfunction_wrap, isintent_in,
|
| 16 |
+
isintent_out, islogicalfunction, ismoduleroutine, isscalar,
|
| 17 |
+
issubroutine, issubroutine_wrap, outmess, show
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
from ._isocbind import isoc_kindmap
|
| 21 |
+
|
| 22 |
+
def var2fixfortran(vars, a, fa=None, f90mode=None):
|
| 23 |
+
if fa is None:
|
| 24 |
+
fa = a
|
| 25 |
+
if a not in vars:
|
| 26 |
+
show(vars)
|
| 27 |
+
outmess('var2fixfortran: No definition for argument "%s".\n' % a)
|
| 28 |
+
return ''
|
| 29 |
+
if 'typespec' not in vars[a]:
|
| 30 |
+
show(vars[a])
|
| 31 |
+
outmess('var2fixfortran: No typespec for argument "%s".\n' % a)
|
| 32 |
+
return ''
|
| 33 |
+
vardef = vars[a]['typespec']
|
| 34 |
+
if vardef == 'type' and 'typename' in vars[a]:
|
| 35 |
+
vardef = '%s(%s)' % (vardef, vars[a]['typename'])
|
| 36 |
+
selector = {}
|
| 37 |
+
lk = ''
|
| 38 |
+
if 'kindselector' in vars[a]:
|
| 39 |
+
selector = vars[a]['kindselector']
|
| 40 |
+
lk = 'kind'
|
| 41 |
+
elif 'charselector' in vars[a]:
|
| 42 |
+
selector = vars[a]['charselector']
|
| 43 |
+
lk = 'len'
|
| 44 |
+
if '*' in selector:
|
| 45 |
+
if f90mode:
|
| 46 |
+
if selector['*'] in ['*', ':', '(*)']:
|
| 47 |
+
vardef = '%s(len=*)' % (vardef)
|
| 48 |
+
else:
|
| 49 |
+
vardef = '%s(%s=%s)' % (vardef, lk, selector['*'])
|
| 50 |
+
else:
|
| 51 |
+
if selector['*'] in ['*', ':']:
|
| 52 |
+
vardef = '%s*(%s)' % (vardef, selector['*'])
|
| 53 |
+
else:
|
| 54 |
+
vardef = '%s*%s' % (vardef, selector['*'])
|
| 55 |
+
else:
|
| 56 |
+
if 'len' in selector:
|
| 57 |
+
vardef = '%s(len=%s' % (vardef, selector['len'])
|
| 58 |
+
if 'kind' in selector:
|
| 59 |
+
vardef = '%s,kind=%s)' % (vardef, selector['kind'])
|
| 60 |
+
else:
|
| 61 |
+
vardef = '%s)' % (vardef)
|
| 62 |
+
elif 'kind' in selector:
|
| 63 |
+
vardef = '%s(kind=%s)' % (vardef, selector['kind'])
|
| 64 |
+
|
| 65 |
+
vardef = '%s %s' % (vardef, fa)
|
| 66 |
+
if 'dimension' in vars[a]:
|
| 67 |
+
vardef = '%s(%s)' % (vardef, ','.join(vars[a]['dimension']))
|
| 68 |
+
return vardef
|
| 69 |
+
|
| 70 |
+
def useiso_c_binding(rout):
|
| 71 |
+
useisoc = False
|
| 72 |
+
for key, value in rout['vars'].items():
|
| 73 |
+
kind_value = value.get('kindselector', {}).get('kind')
|
| 74 |
+
if kind_value in isoc_kindmap:
|
| 75 |
+
return True
|
| 76 |
+
return useisoc
|
| 77 |
+
|
| 78 |
+
def createfuncwrapper(rout, signature=0):
|
| 79 |
+
assert isfunction(rout)
|
| 80 |
+
|
| 81 |
+
extra_args = []
|
| 82 |
+
vars = rout['vars']
|
| 83 |
+
for a in rout['args']:
|
| 84 |
+
v = rout['vars'][a]
|
| 85 |
+
for i, d in enumerate(v.get('dimension', [])):
|
| 86 |
+
if d == ':':
|
| 87 |
+
dn = 'f2py_%s_d%s' % (a, i)
|
| 88 |
+
dv = dict(typespec='integer', intent=['hide'])
|
| 89 |
+
dv['='] = 'shape(%s, %s)' % (a, i)
|
| 90 |
+
extra_args.append(dn)
|
| 91 |
+
vars[dn] = dv
|
| 92 |
+
v['dimension'][i] = dn
|
| 93 |
+
rout['args'].extend(extra_args)
|
| 94 |
+
need_interface = bool(extra_args)
|
| 95 |
+
|
| 96 |
+
ret = ['']
|
| 97 |
+
|
| 98 |
+
def add(line, ret=ret):
|
| 99 |
+
ret[0] = '%s\n %s' % (ret[0], line)
|
| 100 |
+
name = rout['name']
|
| 101 |
+
fortranname = getfortranname(rout)
|
| 102 |
+
f90mode = ismoduleroutine(rout)
|
| 103 |
+
newname = '%sf2pywrap' % (name)
|
| 104 |
+
|
| 105 |
+
if newname not in vars:
|
| 106 |
+
vars[newname] = vars[name]
|
| 107 |
+
args = [newname] + rout['args'][1:]
|
| 108 |
+
else:
|
| 109 |
+
args = [newname] + rout['args']
|
| 110 |
+
|
| 111 |
+
l_tmpl = var2fixfortran(vars, name, '@@@NAME@@@', f90mode)
|
| 112 |
+
if l_tmpl[:13] == 'character*(*)':
|
| 113 |
+
if f90mode:
|
| 114 |
+
l_tmpl = 'character(len=10)' + l_tmpl[13:]
|
| 115 |
+
else:
|
| 116 |
+
l_tmpl = 'character*10' + l_tmpl[13:]
|
| 117 |
+
charselect = vars[name]['charselector']
|
| 118 |
+
if charselect.get('*', '') == '(*)':
|
| 119 |
+
charselect['*'] = '10'
|
| 120 |
+
|
| 121 |
+
l1 = l_tmpl.replace('@@@NAME@@@', newname)
|
| 122 |
+
rl = None
|
| 123 |
+
|
| 124 |
+
useisoc = useiso_c_binding(rout)
|
| 125 |
+
sargs = ', '.join(args)
|
| 126 |
+
if f90mode:
|
| 127 |
+
# gh-23598 fix warning
|
| 128 |
+
# Essentially, this gets called again with modules where the name of the
|
| 129 |
+
# function is added to the arguments, which is not required, and removed
|
| 130 |
+
sargs = sargs.replace(f"{name}, ", '')
|
| 131 |
+
args = [arg for arg in args if arg != name]
|
| 132 |
+
rout['args'] = args
|
| 133 |
+
add('subroutine f2pywrap_%s_%s (%s)' %
|
| 134 |
+
(rout['modulename'], name, sargs))
|
| 135 |
+
if not signature:
|
| 136 |
+
add('use %s, only : %s' % (rout['modulename'], fortranname))
|
| 137 |
+
if useisoc:
|
| 138 |
+
add('use iso_c_binding')
|
| 139 |
+
else:
|
| 140 |
+
add('subroutine f2pywrap%s (%s)' % (name, sargs))
|
| 141 |
+
if useisoc:
|
| 142 |
+
add('use iso_c_binding')
|
| 143 |
+
if not need_interface:
|
| 144 |
+
add('external %s' % (fortranname))
|
| 145 |
+
rl = l_tmpl.replace('@@@NAME@@@', '') + ' ' + fortranname
|
| 146 |
+
|
| 147 |
+
if need_interface:
|
| 148 |
+
for line in rout['saved_interface'].split('\n'):
|
| 149 |
+
if line.lstrip().startswith('use ') and '__user__' not in line:
|
| 150 |
+
add(line)
|
| 151 |
+
|
| 152 |
+
args = args[1:]
|
| 153 |
+
dumped_args = []
|
| 154 |
+
for a in args:
|
| 155 |
+
if isexternal(vars[a]):
|
| 156 |
+
add('external %s' % (a))
|
| 157 |
+
dumped_args.append(a)
|
| 158 |
+
for a in args:
|
| 159 |
+
if a in dumped_args:
|
| 160 |
+
continue
|
| 161 |
+
if isscalar(vars[a]):
|
| 162 |
+
add(var2fixfortran(vars, a, f90mode=f90mode))
|
| 163 |
+
dumped_args.append(a)
|
| 164 |
+
for a in args:
|
| 165 |
+
if a in dumped_args:
|
| 166 |
+
continue
|
| 167 |
+
if isintent_in(vars[a]):
|
| 168 |
+
add(var2fixfortran(vars, a, f90mode=f90mode))
|
| 169 |
+
dumped_args.append(a)
|
| 170 |
+
for a in args:
|
| 171 |
+
if a in dumped_args:
|
| 172 |
+
continue
|
| 173 |
+
add(var2fixfortran(vars, a, f90mode=f90mode))
|
| 174 |
+
|
| 175 |
+
add(l1)
|
| 176 |
+
if rl is not None:
|
| 177 |
+
add(rl)
|
| 178 |
+
|
| 179 |
+
if need_interface:
|
| 180 |
+
if f90mode:
|
| 181 |
+
# f90 module already defines needed interface
|
| 182 |
+
pass
|
| 183 |
+
else:
|
| 184 |
+
add('interface')
|
| 185 |
+
add(rout['saved_interface'].lstrip())
|
| 186 |
+
add('end interface')
|
| 187 |
+
|
| 188 |
+
sargs = ', '.join([a for a in args if a not in extra_args])
|
| 189 |
+
|
| 190 |
+
if not signature:
|
| 191 |
+
if islogicalfunction(rout):
|
| 192 |
+
add('%s = .not.(.not.%s(%s))' % (newname, fortranname, sargs))
|
| 193 |
+
else:
|
| 194 |
+
add('%s = %s(%s)' % (newname, fortranname, sargs))
|
| 195 |
+
if f90mode:
|
| 196 |
+
add('end subroutine f2pywrap_%s_%s' % (rout['modulename'], name))
|
| 197 |
+
else:
|
| 198 |
+
add('end')
|
| 199 |
+
return ret[0]
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
def createsubrwrapper(rout, signature=0):
|
| 203 |
+
assert issubroutine(rout)
|
| 204 |
+
|
| 205 |
+
extra_args = []
|
| 206 |
+
vars = rout['vars']
|
| 207 |
+
for a in rout['args']:
|
| 208 |
+
v = rout['vars'][a]
|
| 209 |
+
for i, d in enumerate(v.get('dimension', [])):
|
| 210 |
+
if d == ':':
|
| 211 |
+
dn = 'f2py_%s_d%s' % (a, i)
|
| 212 |
+
dv = dict(typespec='integer', intent=['hide'])
|
| 213 |
+
dv['='] = 'shape(%s, %s)' % (a, i)
|
| 214 |
+
extra_args.append(dn)
|
| 215 |
+
vars[dn] = dv
|
| 216 |
+
v['dimension'][i] = dn
|
| 217 |
+
rout['args'].extend(extra_args)
|
| 218 |
+
need_interface = bool(extra_args)
|
| 219 |
+
|
| 220 |
+
ret = ['']
|
| 221 |
+
|
| 222 |
+
def add(line, ret=ret):
|
| 223 |
+
ret[0] = '%s\n %s' % (ret[0], line)
|
| 224 |
+
name = rout['name']
|
| 225 |
+
fortranname = getfortranname(rout)
|
| 226 |
+
f90mode = ismoduleroutine(rout)
|
| 227 |
+
|
| 228 |
+
args = rout['args']
|
| 229 |
+
|
| 230 |
+
useisoc = useiso_c_binding(rout)
|
| 231 |
+
sargs = ', '.join(args)
|
| 232 |
+
if f90mode:
|
| 233 |
+
add('subroutine f2pywrap_%s_%s (%s)' %
|
| 234 |
+
(rout['modulename'], name, sargs))
|
| 235 |
+
if useisoc:
|
| 236 |
+
add('use iso_c_binding')
|
| 237 |
+
if not signature:
|
| 238 |
+
add('use %s, only : %s' % (rout['modulename'], fortranname))
|
| 239 |
+
else:
|
| 240 |
+
add('subroutine f2pywrap%s (%s)' % (name, sargs))
|
| 241 |
+
if useisoc:
|
| 242 |
+
add('use iso_c_binding')
|
| 243 |
+
if not need_interface:
|
| 244 |
+
add('external %s' % (fortranname))
|
| 245 |
+
|
| 246 |
+
if need_interface:
|
| 247 |
+
for line in rout['saved_interface'].split('\n'):
|
| 248 |
+
if line.lstrip().startswith('use ') and '__user__' not in line:
|
| 249 |
+
add(line)
|
| 250 |
+
|
| 251 |
+
dumped_args = []
|
| 252 |
+
for a in args:
|
| 253 |
+
if isexternal(vars[a]):
|
| 254 |
+
add('external %s' % (a))
|
| 255 |
+
dumped_args.append(a)
|
| 256 |
+
for a in args:
|
| 257 |
+
if a in dumped_args:
|
| 258 |
+
continue
|
| 259 |
+
if isscalar(vars[a]):
|
| 260 |
+
add(var2fixfortran(vars, a, f90mode=f90mode))
|
| 261 |
+
dumped_args.append(a)
|
| 262 |
+
for a in args:
|
| 263 |
+
if a in dumped_args:
|
| 264 |
+
continue
|
| 265 |
+
add(var2fixfortran(vars, a, f90mode=f90mode))
|
| 266 |
+
|
| 267 |
+
if need_interface:
|
| 268 |
+
if f90mode:
|
| 269 |
+
# f90 module already defines needed interface
|
| 270 |
+
pass
|
| 271 |
+
else:
|
| 272 |
+
add('interface')
|
| 273 |
+
for line in rout['saved_interface'].split('\n'):
|
| 274 |
+
if line.lstrip().startswith('use ') and '__user__' in line:
|
| 275 |
+
continue
|
| 276 |
+
add(line)
|
| 277 |
+
add('end interface')
|
| 278 |
+
|
| 279 |
+
sargs = ', '.join([a for a in args if a not in extra_args])
|
| 280 |
+
|
| 281 |
+
if not signature:
|
| 282 |
+
add('call %s(%s)' % (fortranname, sargs))
|
| 283 |
+
if f90mode:
|
| 284 |
+
add('end subroutine f2pywrap_%s_%s' % (rout['modulename'], name))
|
| 285 |
+
else:
|
| 286 |
+
add('end')
|
| 287 |
+
return ret[0]
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
def assubr(rout):
|
| 291 |
+
if isfunction_wrap(rout):
|
| 292 |
+
fortranname = getfortranname(rout)
|
| 293 |
+
name = rout['name']
|
| 294 |
+
outmess('\t\tCreating wrapper for Fortran function "%s"("%s")...\n' % (
|
| 295 |
+
name, fortranname))
|
| 296 |
+
rout = copy.copy(rout)
|
| 297 |
+
fname = name
|
| 298 |
+
rname = fname
|
| 299 |
+
if 'result' in rout:
|
| 300 |
+
rname = rout['result']
|
| 301 |
+
rout['vars'][fname] = rout['vars'][rname]
|
| 302 |
+
fvar = rout['vars'][fname]
|
| 303 |
+
if not isintent_out(fvar):
|
| 304 |
+
if 'intent' not in fvar:
|
| 305 |
+
fvar['intent'] = []
|
| 306 |
+
fvar['intent'].append('out')
|
| 307 |
+
flag = 1
|
| 308 |
+
for i in fvar['intent']:
|
| 309 |
+
if i.startswith('out='):
|
| 310 |
+
flag = 0
|
| 311 |
+
break
|
| 312 |
+
if flag:
|
| 313 |
+
fvar['intent'].append('out=%s' % (rname))
|
| 314 |
+
rout['args'][:] = [fname] + rout['args']
|
| 315 |
+
return rout, createfuncwrapper(rout)
|
| 316 |
+
if issubroutine_wrap(rout):
|
| 317 |
+
fortranname = getfortranname(rout)
|
| 318 |
+
name = rout['name']
|
| 319 |
+
outmess('\t\tCreating wrapper for Fortran subroutine "%s"("%s")...\n'
|
| 320 |
+
% (name, fortranname))
|
| 321 |
+
rout = copy.copy(rout)
|
| 322 |
+
return rout, createsubrwrapper(rout)
|
| 323 |
+
return rout, ''
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/rules.py
ADDED
|
@@ -0,0 +1,1568 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
|
| 4 |
+
Rules for building C/API module with f2py2e.
|
| 5 |
+
|
| 6 |
+
Here is a skeleton of a new wrapper function (13Dec2001):
|
| 7 |
+
|
| 8 |
+
wrapper_function(args)
|
| 9 |
+
declarations
|
| 10 |
+
get_python_arguments, say, `a' and `b'
|
| 11 |
+
|
| 12 |
+
get_a_from_python
|
| 13 |
+
if (successful) {
|
| 14 |
+
|
| 15 |
+
get_b_from_python
|
| 16 |
+
if (successful) {
|
| 17 |
+
|
| 18 |
+
callfortran
|
| 19 |
+
if (successful) {
|
| 20 |
+
|
| 21 |
+
put_a_to_python
|
| 22 |
+
if (successful) {
|
| 23 |
+
|
| 24 |
+
put_b_to_python
|
| 25 |
+
if (successful) {
|
| 26 |
+
|
| 27 |
+
buildvalue = ...
|
| 28 |
+
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
}
|
| 36 |
+
cleanup_b
|
| 37 |
+
|
| 38 |
+
}
|
| 39 |
+
cleanup_a
|
| 40 |
+
|
| 41 |
+
return buildvalue
|
| 42 |
+
|
| 43 |
+
Copyright 1999 -- 2011 Pearu Peterson all rights reserved.
|
| 44 |
+
Copyright 2011 -- present NumPy Developers.
|
| 45 |
+
Permission to use, modify, and distribute this software is given under the
|
| 46 |
+
terms of the NumPy License.
|
| 47 |
+
|
| 48 |
+
NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
| 49 |
+
"""
|
| 50 |
+
import os, sys
|
| 51 |
+
import time
|
| 52 |
+
import copy
|
| 53 |
+
from pathlib import Path
|
| 54 |
+
|
| 55 |
+
# __version__.version is now the same as the NumPy version
|
| 56 |
+
from . import __version__
|
| 57 |
+
|
| 58 |
+
from .auxfuncs import (
|
| 59 |
+
applyrules, debugcapi, dictappend, errmess, gentitle, getargs2,
|
| 60 |
+
hascallstatement, hasexternals, hasinitvalue, hasnote,
|
| 61 |
+
hasresultnote, isarray, isarrayofstrings, ischaracter,
|
| 62 |
+
ischaracterarray, ischaracter_or_characterarray, iscomplex,
|
| 63 |
+
iscomplexarray, iscomplexfunction, iscomplexfunction_warn,
|
| 64 |
+
isdummyroutine, isexternal, isfunction, isfunction_wrap, isint1,
|
| 65 |
+
isint1array, isintent_aux, isintent_c, isintent_callback,
|
| 66 |
+
isintent_copy, isintent_hide, isintent_inout, isintent_nothide,
|
| 67 |
+
isintent_out, isintent_overwrite, islogical, islong_complex,
|
| 68 |
+
islong_double, islong_doublefunction, islong_long,
|
| 69 |
+
islong_longfunction, ismoduleroutine, isoptional, isrequired,
|
| 70 |
+
isscalar, issigned_long_longarray, isstring, isstringarray,
|
| 71 |
+
isstringfunction, issubroutine, isattr_value,
|
| 72 |
+
issubroutine_wrap, isthreadsafe, isunsigned, isunsigned_char,
|
| 73 |
+
isunsigned_chararray, isunsigned_long_long,
|
| 74 |
+
isunsigned_long_longarray, isunsigned_short, isunsigned_shortarray,
|
| 75 |
+
l_and, l_not, l_or, outmess, replace, stripcomma, requiresf90wrapper
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
from . import capi_maps
|
| 79 |
+
from . import cfuncs
|
| 80 |
+
from . import common_rules
|
| 81 |
+
from . import use_rules
|
| 82 |
+
from . import f90mod_rules
|
| 83 |
+
from . import func2subr
|
| 84 |
+
|
| 85 |
+
f2py_version = __version__.version
|
| 86 |
+
numpy_version = __version__.version
|
| 87 |
+
|
| 88 |
+
options = {}
|
| 89 |
+
sepdict = {}
|
| 90 |
+
# for k in ['need_cfuncs']: sepdict[k]=','
|
| 91 |
+
for k in ['decl',
|
| 92 |
+
'frompyobj',
|
| 93 |
+
'cleanupfrompyobj',
|
| 94 |
+
'topyarr', 'method',
|
| 95 |
+
'pyobjfrom', 'closepyobjfrom',
|
| 96 |
+
'freemem',
|
| 97 |
+
'userincludes',
|
| 98 |
+
'includes0', 'includes', 'typedefs', 'typedefs_generated',
|
| 99 |
+
'cppmacros', 'cfuncs', 'callbacks',
|
| 100 |
+
'latexdoc',
|
| 101 |
+
'restdoc',
|
| 102 |
+
'routine_defs', 'externroutines',
|
| 103 |
+
'initf2pywraphooks',
|
| 104 |
+
'commonhooks', 'initcommonhooks',
|
| 105 |
+
'f90modhooks', 'initf90modhooks']:
|
| 106 |
+
sepdict[k] = '\n'
|
| 107 |
+
|
| 108 |
+
#################### Rules for C/API module #################
|
| 109 |
+
|
| 110 |
+
generationtime = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
|
| 111 |
+
module_rules = {
|
| 112 |
+
'modulebody': """\
|
| 113 |
+
/* File: #modulename#module.c
|
| 114 |
+
* This file is auto-generated with f2py (version:#f2py_version#).
|
| 115 |
+
* f2py is a Fortran to Python Interface Generator (FPIG), Second Edition,
|
| 116 |
+
* written by Pearu Peterson <pearu@cens.ioc.ee>.
|
| 117 |
+
* Generation date: """ + time.asctime(time.gmtime(generationtime)) + """
|
| 118 |
+
* Do not edit this file directly unless you know what you are doing!!!
|
| 119 |
+
*/
|
| 120 |
+
|
| 121 |
+
#ifdef __cplusplus
|
| 122 |
+
extern \"C\" {
|
| 123 |
+
#endif
|
| 124 |
+
|
| 125 |
+
#ifndef PY_SSIZE_T_CLEAN
|
| 126 |
+
#define PY_SSIZE_T_CLEAN
|
| 127 |
+
#endif /* PY_SSIZE_T_CLEAN */
|
| 128 |
+
|
| 129 |
+
/* Unconditionally included */
|
| 130 |
+
#include <Python.h>
|
| 131 |
+
#include <numpy/npy_os.h>
|
| 132 |
+
|
| 133 |
+
""" + gentitle("See f2py2e/cfuncs.py: includes") + """
|
| 134 |
+
#includes#
|
| 135 |
+
#includes0#
|
| 136 |
+
|
| 137 |
+
""" + gentitle("See f2py2e/rules.py: mod_rules['modulebody']") + """
|
| 138 |
+
static PyObject *#modulename#_error;
|
| 139 |
+
static PyObject *#modulename#_module;
|
| 140 |
+
|
| 141 |
+
""" + gentitle("See f2py2e/cfuncs.py: typedefs") + """
|
| 142 |
+
#typedefs#
|
| 143 |
+
|
| 144 |
+
""" + gentitle("See f2py2e/cfuncs.py: typedefs_generated") + """
|
| 145 |
+
#typedefs_generated#
|
| 146 |
+
|
| 147 |
+
""" + gentitle("See f2py2e/cfuncs.py: cppmacros") + """
|
| 148 |
+
#cppmacros#
|
| 149 |
+
|
| 150 |
+
""" + gentitle("See f2py2e/cfuncs.py: cfuncs") + """
|
| 151 |
+
#cfuncs#
|
| 152 |
+
|
| 153 |
+
""" + gentitle("See f2py2e/cfuncs.py: userincludes") + """
|
| 154 |
+
#userincludes#
|
| 155 |
+
|
| 156 |
+
""" + gentitle("See f2py2e/capi_rules.py: usercode") + """
|
| 157 |
+
#usercode#
|
| 158 |
+
|
| 159 |
+
/* See f2py2e/rules.py */
|
| 160 |
+
#externroutines#
|
| 161 |
+
|
| 162 |
+
""" + gentitle("See f2py2e/capi_rules.py: usercode1") + """
|
| 163 |
+
#usercode1#
|
| 164 |
+
|
| 165 |
+
""" + gentitle("See f2py2e/cb_rules.py: buildcallback") + """
|
| 166 |
+
#callbacks#
|
| 167 |
+
|
| 168 |
+
""" + gentitle("See f2py2e/rules.py: buildapi") + """
|
| 169 |
+
#body#
|
| 170 |
+
|
| 171 |
+
""" + gentitle("See f2py2e/f90mod_rules.py: buildhooks") + """
|
| 172 |
+
#f90modhooks#
|
| 173 |
+
|
| 174 |
+
""" + gentitle("See f2py2e/rules.py: module_rules['modulebody']") + """
|
| 175 |
+
|
| 176 |
+
""" + gentitle("See f2py2e/common_rules.py: buildhooks") + """
|
| 177 |
+
#commonhooks#
|
| 178 |
+
|
| 179 |
+
""" + gentitle("See f2py2e/rules.py") + """
|
| 180 |
+
|
| 181 |
+
static FortranDataDef f2py_routine_defs[] = {
|
| 182 |
+
#routine_defs#
|
| 183 |
+
{NULL}
|
| 184 |
+
};
|
| 185 |
+
|
| 186 |
+
static PyMethodDef f2py_module_methods[] = {
|
| 187 |
+
#pymethoddef#
|
| 188 |
+
{NULL,NULL}
|
| 189 |
+
};
|
| 190 |
+
|
| 191 |
+
static struct PyModuleDef moduledef = {
|
| 192 |
+
PyModuleDef_HEAD_INIT,
|
| 193 |
+
"#modulename#",
|
| 194 |
+
NULL,
|
| 195 |
+
-1,
|
| 196 |
+
f2py_module_methods,
|
| 197 |
+
NULL,
|
| 198 |
+
NULL,
|
| 199 |
+
NULL,
|
| 200 |
+
NULL
|
| 201 |
+
};
|
| 202 |
+
|
| 203 |
+
PyMODINIT_FUNC PyInit_#modulename#(void) {
|
| 204 |
+
int i;
|
| 205 |
+
PyObject *m,*d, *s, *tmp;
|
| 206 |
+
m = #modulename#_module = PyModule_Create(&moduledef);
|
| 207 |
+
Py_SET_TYPE(&PyFortran_Type, &PyType_Type);
|
| 208 |
+
import_array();
|
| 209 |
+
if (PyErr_Occurred())
|
| 210 |
+
{PyErr_SetString(PyExc_ImportError, \"can't initialize module #modulename# (failed to import numpy)\"); return m;}
|
| 211 |
+
d = PyModule_GetDict(m);
|
| 212 |
+
s = PyUnicode_FromString(\"#f2py_version#\");
|
| 213 |
+
PyDict_SetItemString(d, \"__version__\", s);
|
| 214 |
+
Py_DECREF(s);
|
| 215 |
+
s = PyUnicode_FromString(
|
| 216 |
+
\"This module '#modulename#' is auto-generated with f2py (version:#f2py_version#).\\nFunctions:\\n\"\n#docs#\".\");
|
| 217 |
+
PyDict_SetItemString(d, \"__doc__\", s);
|
| 218 |
+
Py_DECREF(s);
|
| 219 |
+
s = PyUnicode_FromString(\"""" + numpy_version + """\");
|
| 220 |
+
PyDict_SetItemString(d, \"__f2py_numpy_version__\", s);
|
| 221 |
+
Py_DECREF(s);
|
| 222 |
+
#modulename#_error = PyErr_NewException (\"#modulename#.error\", NULL, NULL);
|
| 223 |
+
/*
|
| 224 |
+
* Store the error object inside the dict, so that it could get deallocated.
|
| 225 |
+
* (in practice, this is a module, so it likely will not and cannot.)
|
| 226 |
+
*/
|
| 227 |
+
PyDict_SetItemString(d, \"_#modulename#_error\", #modulename#_error);
|
| 228 |
+
Py_DECREF(#modulename#_error);
|
| 229 |
+
for(i=0;f2py_routine_defs[i].name!=NULL;i++) {
|
| 230 |
+
tmp = PyFortranObject_NewAsAttr(&f2py_routine_defs[i]);
|
| 231 |
+
PyDict_SetItemString(d, f2py_routine_defs[i].name, tmp);
|
| 232 |
+
Py_DECREF(tmp);
|
| 233 |
+
}
|
| 234 |
+
#initf2pywraphooks#
|
| 235 |
+
#initf90modhooks#
|
| 236 |
+
#initcommonhooks#
|
| 237 |
+
#interface_usercode#
|
| 238 |
+
|
| 239 |
+
#ifdef F2PY_REPORT_ATEXIT
|
| 240 |
+
if (! PyErr_Occurred())
|
| 241 |
+
on_exit(f2py_report_on_exit,(void*)\"#modulename#\");
|
| 242 |
+
#endif
|
| 243 |
+
return m;
|
| 244 |
+
}
|
| 245 |
+
#ifdef __cplusplus
|
| 246 |
+
}
|
| 247 |
+
#endif
|
| 248 |
+
""",
|
| 249 |
+
'separatorsfor': {'latexdoc': '\n\n',
|
| 250 |
+
'restdoc': '\n\n'},
|
| 251 |
+
'latexdoc': ['\\section{Module \\texttt{#texmodulename#}}\n',
|
| 252 |
+
'#modnote#\n',
|
| 253 |
+
'#latexdoc#'],
|
| 254 |
+
'restdoc': ['Module #modulename#\n' + '=' * 80,
|
| 255 |
+
'\n#restdoc#']
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
defmod_rules = [
|
| 259 |
+
{'body': '/*eof body*/',
|
| 260 |
+
'method': '/*eof method*/',
|
| 261 |
+
'externroutines': '/*eof externroutines*/',
|
| 262 |
+
'routine_defs': '/*eof routine_defs*/',
|
| 263 |
+
'initf90modhooks': '/*eof initf90modhooks*/',
|
| 264 |
+
'initf2pywraphooks': '/*eof initf2pywraphooks*/',
|
| 265 |
+
'initcommonhooks': '/*eof initcommonhooks*/',
|
| 266 |
+
'latexdoc': '',
|
| 267 |
+
'restdoc': '',
|
| 268 |
+
'modnote': {hasnote: '#note#', l_not(hasnote): ''},
|
| 269 |
+
}
|
| 270 |
+
]
|
| 271 |
+
|
| 272 |
+
routine_rules = {
|
| 273 |
+
'separatorsfor': sepdict,
|
| 274 |
+
'body': """
|
| 275 |
+
#begintitle#
|
| 276 |
+
static char doc_#apiname#[] = \"\\\n#docreturn##name#(#docsignatureshort#)\\n\\nWrapper for ``#name#``.\\\n\\n#docstrsigns#\";
|
| 277 |
+
/* #declfortranroutine# */
|
| 278 |
+
static PyObject *#apiname#(const PyObject *capi_self,
|
| 279 |
+
PyObject *capi_args,
|
| 280 |
+
PyObject *capi_keywds,
|
| 281 |
+
#functype# (*f2py_func)(#callprotoargument#)) {
|
| 282 |
+
PyObject * volatile capi_buildvalue = NULL;
|
| 283 |
+
volatile int f2py_success = 1;
|
| 284 |
+
#decl#
|
| 285 |
+
static char *capi_kwlist[] = {#kwlist##kwlistopt##kwlistxa#NULL};
|
| 286 |
+
#usercode#
|
| 287 |
+
#routdebugenter#
|
| 288 |
+
#ifdef F2PY_REPORT_ATEXIT
|
| 289 |
+
f2py_start_clock();
|
| 290 |
+
#endif
|
| 291 |
+
if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\\
|
| 292 |
+
\"#argformat#|#keyformat##xaformat#:#pyname#\",\\
|
| 293 |
+
capi_kwlist#args_capi##keys_capi##keys_xa#))\n return NULL;
|
| 294 |
+
#frompyobj#
|
| 295 |
+
/*end of frompyobj*/
|
| 296 |
+
#ifdef F2PY_REPORT_ATEXIT
|
| 297 |
+
f2py_start_call_clock();
|
| 298 |
+
#endif
|
| 299 |
+
#callfortranroutine#
|
| 300 |
+
if (PyErr_Occurred())
|
| 301 |
+
f2py_success = 0;
|
| 302 |
+
#ifdef F2PY_REPORT_ATEXIT
|
| 303 |
+
f2py_stop_call_clock();
|
| 304 |
+
#endif
|
| 305 |
+
/*end of callfortranroutine*/
|
| 306 |
+
if (f2py_success) {
|
| 307 |
+
#pyobjfrom#
|
| 308 |
+
/*end of pyobjfrom*/
|
| 309 |
+
CFUNCSMESS(\"Building return value.\\n\");
|
| 310 |
+
capi_buildvalue = Py_BuildValue(\"#returnformat#\"#return#);
|
| 311 |
+
/*closepyobjfrom*/
|
| 312 |
+
#closepyobjfrom#
|
| 313 |
+
} /*if (f2py_success) after callfortranroutine*/
|
| 314 |
+
/*cleanupfrompyobj*/
|
| 315 |
+
#cleanupfrompyobj#
|
| 316 |
+
if (capi_buildvalue == NULL) {
|
| 317 |
+
#routdebugfailure#
|
| 318 |
+
} else {
|
| 319 |
+
#routdebugleave#
|
| 320 |
+
}
|
| 321 |
+
CFUNCSMESS(\"Freeing memory.\\n\");
|
| 322 |
+
#freemem#
|
| 323 |
+
#ifdef F2PY_REPORT_ATEXIT
|
| 324 |
+
f2py_stop_clock();
|
| 325 |
+
#endif
|
| 326 |
+
return capi_buildvalue;
|
| 327 |
+
}
|
| 328 |
+
#endtitle#
|
| 329 |
+
""",
|
| 330 |
+
'routine_defs': '#routine_def#',
|
| 331 |
+
'initf2pywraphooks': '#initf2pywraphook#',
|
| 332 |
+
'externroutines': '#declfortranroutine#',
|
| 333 |
+
'doc': '#docreturn##name#(#docsignature#)',
|
| 334 |
+
'docshort': '#docreturn##name#(#docsignatureshort#)',
|
| 335 |
+
'docs': '" #docreturn##name#(#docsignature#)\\n"\n',
|
| 336 |
+
'need': ['arrayobject.h', 'CFUNCSMESS', 'MINMAX'],
|
| 337 |
+
'cppmacros': {debugcapi: '#define DEBUGCFUNCS'},
|
| 338 |
+
'latexdoc': ['\\subsection{Wrapper function \\texttt{#texname#}}\n',
|
| 339 |
+
"""
|
| 340 |
+
\\noindent{{}\\verb@#docreturn##name#@{}}\\texttt{(#latexdocsignatureshort#)}
|
| 341 |
+
#routnote#
|
| 342 |
+
|
| 343 |
+
#latexdocstrsigns#
|
| 344 |
+
"""],
|
| 345 |
+
'restdoc': ['Wrapped function ``#name#``\n' + '-' * 80,
|
| 346 |
+
|
| 347 |
+
]
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
################## Rules for C/API function ##############
|
| 351 |
+
|
| 352 |
+
rout_rules = [
|
| 353 |
+
{ # Init
|
| 354 |
+
'separatorsfor': {'callfortranroutine': '\n', 'routdebugenter': '\n', 'decl': '\n',
|
| 355 |
+
'routdebugleave': '\n', 'routdebugfailure': '\n',
|
| 356 |
+
'setjmpbuf': ' || ',
|
| 357 |
+
'docstrreq': '\n', 'docstropt': '\n', 'docstrout': '\n',
|
| 358 |
+
'docstrcbs': '\n', 'docstrsigns': '\\n"\n"',
|
| 359 |
+
'latexdocstrsigns': '\n',
|
| 360 |
+
'latexdocstrreq': '\n', 'latexdocstropt': '\n',
|
| 361 |
+
'latexdocstrout': '\n', 'latexdocstrcbs': '\n',
|
| 362 |
+
},
|
| 363 |
+
'kwlist': '', 'kwlistopt': '', 'callfortran': '', 'callfortranappend': '',
|
| 364 |
+
'docsign': '', 'docsignopt': '', 'decl': '/*decl*/',
|
| 365 |
+
'freemem': '/*freemem*/',
|
| 366 |
+
'docsignshort': '', 'docsignoptshort': '',
|
| 367 |
+
'docstrsigns': '', 'latexdocstrsigns': '',
|
| 368 |
+
'docstrreq': '\\nParameters\\n----------',
|
| 369 |
+
'docstropt': '\\nOther Parameters\\n----------------',
|
| 370 |
+
'docstrout': '\\nReturns\\n-------',
|
| 371 |
+
'docstrcbs': '\\nNotes\\n-----\\nCall-back functions::\\n',
|
| 372 |
+
'latexdocstrreq': '\\noindent Required arguments:',
|
| 373 |
+
'latexdocstropt': '\\noindent Optional arguments:',
|
| 374 |
+
'latexdocstrout': '\\noindent Return objects:',
|
| 375 |
+
'latexdocstrcbs': '\\noindent Call-back functions:',
|
| 376 |
+
'args_capi': '', 'keys_capi': '', 'functype': '',
|
| 377 |
+
'frompyobj': '/*frompyobj*/',
|
| 378 |
+
# this list will be reversed
|
| 379 |
+
'cleanupfrompyobj': ['/*end of cleanupfrompyobj*/'],
|
| 380 |
+
'pyobjfrom': '/*pyobjfrom*/',
|
| 381 |
+
# this list will be reversed
|
| 382 |
+
'closepyobjfrom': ['/*end of closepyobjfrom*/'],
|
| 383 |
+
'topyarr': '/*topyarr*/', 'routdebugleave': '/*routdebugleave*/',
|
| 384 |
+
'routdebugenter': '/*routdebugenter*/',
|
| 385 |
+
'routdebugfailure': '/*routdebugfailure*/',
|
| 386 |
+
'callfortranroutine': '/*callfortranroutine*/',
|
| 387 |
+
'argformat': '', 'keyformat': '', 'need_cfuncs': '',
|
| 388 |
+
'docreturn': '', 'return': '', 'returnformat': '', 'rformat': '',
|
| 389 |
+
'kwlistxa': '', 'keys_xa': '', 'xaformat': '', 'docsignxa': '', 'docsignxashort': '',
|
| 390 |
+
'initf2pywraphook': '',
|
| 391 |
+
'routnote': {hasnote: '--- #note#', l_not(hasnote): ''},
|
| 392 |
+
}, {
|
| 393 |
+
'apiname': 'f2py_rout_#modulename#_#name#',
|
| 394 |
+
'pyname': '#modulename#.#name#',
|
| 395 |
+
'decl': '',
|
| 396 |
+
'_check': l_not(ismoduleroutine)
|
| 397 |
+
}, {
|
| 398 |
+
'apiname': 'f2py_rout_#modulename#_#f90modulename#_#name#',
|
| 399 |
+
'pyname': '#modulename#.#f90modulename#.#name#',
|
| 400 |
+
'decl': '',
|
| 401 |
+
'_check': ismoduleroutine
|
| 402 |
+
}, { # Subroutine
|
| 403 |
+
'functype': 'void',
|
| 404 |
+
'declfortranroutine': {l_and(l_not(l_or(ismoduleroutine, isintent_c)), l_not(isdummyroutine)): 'extern void #F_FUNC#(#fortranname#,#FORTRANNAME#)(#callprotoargument#);',
|
| 405 |
+
l_and(l_not(ismoduleroutine), isintent_c, l_not(isdummyroutine)): 'extern void #fortranname#(#callprotoargument#);',
|
| 406 |
+
ismoduleroutine: '',
|
| 407 |
+
isdummyroutine: ''
|
| 408 |
+
},
|
| 409 |
+
'routine_def': {
|
| 410 |
+
l_not(l_or(ismoduleroutine, isintent_c, isdummyroutine)):
|
| 411 |
+
' {\"#name#\",-1,{{-1}},0,0,(char *)'
|
| 412 |
+
' #F_FUNC#(#fortranname#,#FORTRANNAME#),'
|
| 413 |
+
' (f2py_init_func)#apiname#,doc_#apiname#},',
|
| 414 |
+
l_and(l_not(ismoduleroutine), isintent_c, l_not(isdummyroutine)):
|
| 415 |
+
' {\"#name#\",-1,{{-1}},0,0,(char *)#fortranname#,'
|
| 416 |
+
' (f2py_init_func)#apiname#,doc_#apiname#},',
|
| 417 |
+
l_and(l_not(ismoduleroutine), isdummyroutine):
|
| 418 |
+
' {\"#name#\",-1,{{-1}},0,0,NULL,'
|
| 419 |
+
' (f2py_init_func)#apiname#,doc_#apiname#},',
|
| 420 |
+
},
|
| 421 |
+
'need': {l_and(l_not(l_or(ismoduleroutine, isintent_c)), l_not(isdummyroutine)): 'F_FUNC'},
|
| 422 |
+
'callfortranroutine': [
|
| 423 |
+
{debugcapi: [
|
| 424 |
+
""" fprintf(stderr,\"debug-capi:Fortran subroutine `#fortranname#(#callfortran#)\'\\n\");"""]},
|
| 425 |
+
{hasexternals: """\
|
| 426 |
+
if (#setjmpbuf#) {
|
| 427 |
+
f2py_success = 0;
|
| 428 |
+
} else {"""},
|
| 429 |
+
{isthreadsafe: ' Py_BEGIN_ALLOW_THREADS'},
|
| 430 |
+
{hascallstatement: ''' #callstatement#;
|
| 431 |
+
/*(*f2py_func)(#callfortran#);*/'''},
|
| 432 |
+
{l_not(l_or(hascallstatement, isdummyroutine))
|
| 433 |
+
: ' (*f2py_func)(#callfortran#);'},
|
| 434 |
+
{isthreadsafe: ' Py_END_ALLOW_THREADS'},
|
| 435 |
+
{hasexternals: """ }"""}
|
| 436 |
+
],
|
| 437 |
+
'_check': l_and(issubroutine, l_not(issubroutine_wrap)),
|
| 438 |
+
}, { # Wrapped function
|
| 439 |
+
'functype': 'void',
|
| 440 |
+
'declfortranroutine': {l_not(l_or(ismoduleroutine, isdummyroutine)): 'extern void #F_WRAPPEDFUNC#(#name_lower#,#NAME#)(#callprotoargument#);',
|
| 441 |
+
isdummyroutine: '',
|
| 442 |
+
},
|
| 443 |
+
|
| 444 |
+
'routine_def': {
|
| 445 |
+
l_not(l_or(ismoduleroutine, isdummyroutine)):
|
| 446 |
+
' {\"#name#\",-1,{{-1}},0,0,(char *)'
|
| 447 |
+
' #F_WRAPPEDFUNC#(#name_lower#,#NAME#),'
|
| 448 |
+
' (f2py_init_func)#apiname#,doc_#apiname#},',
|
| 449 |
+
isdummyroutine:
|
| 450 |
+
' {\"#name#\",-1,{{-1}},0,0,NULL,'
|
| 451 |
+
' (f2py_init_func)#apiname#,doc_#apiname#},',
|
| 452 |
+
},
|
| 453 |
+
'initf2pywraphook': {l_not(l_or(ismoduleroutine, isdummyroutine)): '''
|
| 454 |
+
{
|
| 455 |
+
extern #ctype# #F_FUNC#(#name_lower#,#NAME#)(void);
|
| 456 |
+
PyObject* o = PyDict_GetItemString(d,"#name#");
|
| 457 |
+
tmp = F2PyCapsule_FromVoidPtr((void*)#F_FUNC#(#name_lower#,#NAME#),NULL);
|
| 458 |
+
PyObject_SetAttrString(o,"_cpointer", tmp);
|
| 459 |
+
Py_DECREF(tmp);
|
| 460 |
+
s = PyUnicode_FromString("#name#");
|
| 461 |
+
PyObject_SetAttrString(o,"__name__", s);
|
| 462 |
+
Py_DECREF(s);
|
| 463 |
+
}
|
| 464 |
+
'''},
|
| 465 |
+
'need': {l_not(l_or(ismoduleroutine, isdummyroutine)): ['F_WRAPPEDFUNC', 'F_FUNC']},
|
| 466 |
+
'callfortranroutine': [
|
| 467 |
+
{debugcapi: [
|
| 468 |
+
""" fprintf(stderr,\"debug-capi:Fortran subroutine `f2pywrap#name_lower#(#callfortran#)\'\\n\");"""]},
|
| 469 |
+
{hasexternals: """\
|
| 470 |
+
if (#setjmpbuf#) {
|
| 471 |
+
f2py_success = 0;
|
| 472 |
+
} else {"""},
|
| 473 |
+
{isthreadsafe: ' Py_BEGIN_ALLOW_THREADS'},
|
| 474 |
+
{l_not(l_or(hascallstatement, isdummyroutine))
|
| 475 |
+
: ' (*f2py_func)(#callfortran#);'},
|
| 476 |
+
{hascallstatement:
|
| 477 |
+
' #callstatement#;\n /*(*f2py_func)(#callfortran#);*/'},
|
| 478 |
+
{isthreadsafe: ' Py_END_ALLOW_THREADS'},
|
| 479 |
+
{hasexternals: ' }'}
|
| 480 |
+
],
|
| 481 |
+
'_check': isfunction_wrap,
|
| 482 |
+
}, { # Wrapped subroutine
|
| 483 |
+
'functype': 'void',
|
| 484 |
+
'declfortranroutine': {l_not(l_or(ismoduleroutine, isdummyroutine)): 'extern void #F_WRAPPEDFUNC#(#name_lower#,#NAME#)(#callprotoargument#);',
|
| 485 |
+
isdummyroutine: '',
|
| 486 |
+
},
|
| 487 |
+
|
| 488 |
+
'routine_def': {
|
| 489 |
+
l_not(l_or(ismoduleroutine, isdummyroutine)):
|
| 490 |
+
' {\"#name#\",-1,{{-1}},0,0,(char *)'
|
| 491 |
+
' #F_WRAPPEDFUNC#(#name_lower#,#NAME#),'
|
| 492 |
+
' (f2py_init_func)#apiname#,doc_#apiname#},',
|
| 493 |
+
isdummyroutine:
|
| 494 |
+
' {\"#name#\",-1,{{-1}},0,0,NULL,'
|
| 495 |
+
' (f2py_init_func)#apiname#,doc_#apiname#},',
|
| 496 |
+
},
|
| 497 |
+
'initf2pywraphook': {l_not(l_or(ismoduleroutine, isdummyroutine)): '''
|
| 498 |
+
{
|
| 499 |
+
extern void #F_FUNC#(#name_lower#,#NAME#)(void);
|
| 500 |
+
PyObject* o = PyDict_GetItemString(d,"#name#");
|
| 501 |
+
tmp = F2PyCapsule_FromVoidPtr((void*)#F_FUNC#(#name_lower#,#NAME#),NULL);
|
| 502 |
+
PyObject_SetAttrString(o,"_cpointer", tmp);
|
| 503 |
+
Py_DECREF(tmp);
|
| 504 |
+
s = PyUnicode_FromString("#name#");
|
| 505 |
+
PyObject_SetAttrString(o,"__name__", s);
|
| 506 |
+
Py_DECREF(s);
|
| 507 |
+
}
|
| 508 |
+
'''},
|
| 509 |
+
'need': {l_not(l_or(ismoduleroutine, isdummyroutine)): ['F_WRAPPEDFUNC', 'F_FUNC']},
|
| 510 |
+
'callfortranroutine': [
|
| 511 |
+
{debugcapi: [
|
| 512 |
+
""" fprintf(stderr,\"debug-capi:Fortran subroutine `f2pywrap#name_lower#(#callfortran#)\'\\n\");"""]},
|
| 513 |
+
{hasexternals: """\
|
| 514 |
+
if (#setjmpbuf#) {
|
| 515 |
+
f2py_success = 0;
|
| 516 |
+
} else {"""},
|
| 517 |
+
{isthreadsafe: ' Py_BEGIN_ALLOW_THREADS'},
|
| 518 |
+
{l_not(l_or(hascallstatement, isdummyroutine))
|
| 519 |
+
: ' (*f2py_func)(#callfortran#);'},
|
| 520 |
+
{hascallstatement:
|
| 521 |
+
' #callstatement#;\n /*(*f2py_func)(#callfortran#);*/'},
|
| 522 |
+
{isthreadsafe: ' Py_END_ALLOW_THREADS'},
|
| 523 |
+
{hasexternals: ' }'}
|
| 524 |
+
],
|
| 525 |
+
'_check': issubroutine_wrap,
|
| 526 |
+
}, { # Function
|
| 527 |
+
'functype': '#ctype#',
|
| 528 |
+
'docreturn': {l_not(isintent_hide): '#rname#,'},
|
| 529 |
+
'docstrout': '#pydocsignout#',
|
| 530 |
+
'latexdocstrout': ['\\item[]{{}\\verb@#pydocsignout#@{}}',
|
| 531 |
+
{hasresultnote: '--- #resultnote#'}],
|
| 532 |
+
'callfortranroutine': [{l_and(debugcapi, isstringfunction): """\
|
| 533 |
+
#ifdef USESCOMPAQFORTRAN
|
| 534 |
+
fprintf(stderr,\"debug-capi:Fortran function #ctype# #fortranname#(#callcompaqfortran#)\\n\");
|
| 535 |
+
#else
|
| 536 |
+
fprintf(stderr,\"debug-capi:Fortran function #ctype# #fortranname#(#callfortran#)\\n\");
|
| 537 |
+
#endif
|
| 538 |
+
"""},
|
| 539 |
+
{l_and(debugcapi, l_not(isstringfunction)): """\
|
| 540 |
+
fprintf(stderr,\"debug-capi:Fortran function #ctype# #fortranname#(#callfortran#)\\n\");
|
| 541 |
+
"""}
|
| 542 |
+
],
|
| 543 |
+
'_check': l_and(isfunction, l_not(isfunction_wrap))
|
| 544 |
+
}, { # Scalar function
|
| 545 |
+
'declfortranroutine': {l_and(l_not(l_or(ismoduleroutine, isintent_c)), l_not(isdummyroutine)): 'extern #ctype# #F_FUNC#(#fortranname#,#FORTRANNAME#)(#callprotoargument#);',
|
| 546 |
+
l_and(l_not(ismoduleroutine), isintent_c, l_not(isdummyroutine)): 'extern #ctype# #fortranname#(#callprotoargument#);',
|
| 547 |
+
isdummyroutine: ''
|
| 548 |
+
},
|
| 549 |
+
'routine_def': {
|
| 550 |
+
l_and(l_not(l_or(ismoduleroutine, isintent_c)),
|
| 551 |
+
l_not(isdummyroutine)):
|
| 552 |
+
(' {\"#name#\",-1,{{-1}},0,0,(char *)'
|
| 553 |
+
' #F_FUNC#(#fortranname#,#FORTRANNAME#),'
|
| 554 |
+
' (f2py_init_func)#apiname#,doc_#apiname#},'),
|
| 555 |
+
l_and(l_not(ismoduleroutine), isintent_c, l_not(isdummyroutine)):
|
| 556 |
+
(' {\"#name#\",-1,{{-1}},0,0,(char *)#fortranname#,'
|
| 557 |
+
' (f2py_init_func)#apiname#,doc_#apiname#},'),
|
| 558 |
+
isdummyroutine:
|
| 559 |
+
' {\"#name#\",-1,{{-1}},0,0,NULL,'
|
| 560 |
+
'(f2py_init_func)#apiname#,doc_#apiname#},',
|
| 561 |
+
},
|
| 562 |
+
'decl': [{iscomplexfunction_warn: ' #ctype# #name#_return_value={0,0};',
|
| 563 |
+
l_not(iscomplexfunction): ' #ctype# #name#_return_value=0;'},
|
| 564 |
+
{iscomplexfunction:
|
| 565 |
+
' PyObject *#name#_return_value_capi = Py_None;'}
|
| 566 |
+
],
|
| 567 |
+
'callfortranroutine': [
|
| 568 |
+
{hasexternals: """\
|
| 569 |
+
if (#setjmpbuf#) {
|
| 570 |
+
f2py_success = 0;
|
| 571 |
+
} else {"""},
|
| 572 |
+
{isthreadsafe: ' Py_BEGIN_ALLOW_THREADS'},
|
| 573 |
+
{hascallstatement: ''' #callstatement#;
|
| 574 |
+
/* #name#_return_value = (*f2py_func)(#callfortran#);*/
|
| 575 |
+
'''},
|
| 576 |
+
{l_not(l_or(hascallstatement, isdummyroutine))
|
| 577 |
+
: ' #name#_return_value = (*f2py_func)(#callfortran#);'},
|
| 578 |
+
{isthreadsafe: ' Py_END_ALLOW_THREADS'},
|
| 579 |
+
{hasexternals: ' }'},
|
| 580 |
+
{l_and(debugcapi, iscomplexfunction)
|
| 581 |
+
: ' fprintf(stderr,"#routdebugshowvalue#\\n",#name#_return_value.r,#name#_return_value.i);'},
|
| 582 |
+
{l_and(debugcapi, l_not(iscomplexfunction)): ' fprintf(stderr,"#routdebugshowvalue#\\n",#name#_return_value);'}],
|
| 583 |
+
'pyobjfrom': {iscomplexfunction: ' #name#_return_value_capi = pyobj_from_#ctype#1(#name#_return_value);'},
|
| 584 |
+
'need': [{l_not(isdummyroutine): 'F_FUNC'},
|
| 585 |
+
{iscomplexfunction: 'pyobj_from_#ctype#1'},
|
| 586 |
+
{islong_longfunction: 'long_long'},
|
| 587 |
+
{islong_doublefunction: 'long_double'}],
|
| 588 |
+
'returnformat': {l_not(isintent_hide): '#rformat#'},
|
| 589 |
+
'return': {iscomplexfunction: ',#name#_return_value_capi',
|
| 590 |
+
l_not(l_or(iscomplexfunction, isintent_hide)): ',#name#_return_value'},
|
| 591 |
+
'_check': l_and(isfunction, l_not(isstringfunction), l_not(isfunction_wrap))
|
| 592 |
+
}, { # String function # in use for --no-wrap
|
| 593 |
+
'declfortranroutine': 'extern void #F_FUNC#(#fortranname#,#FORTRANNAME#)(#callprotoargument#);',
|
| 594 |
+
'routine_def': {l_not(l_or(ismoduleroutine, isintent_c)):
|
| 595 |
+
' {\"#name#\",-1,{{-1}},0,0,(char *)#F_FUNC#(#fortranname#,#FORTRANNAME#),(f2py_init_func)#apiname#,doc_#apiname#},',
|
| 596 |
+
l_and(l_not(ismoduleroutine), isintent_c):
|
| 597 |
+
' {\"#name#\",-1,{{-1}},0,0,(char *)#fortranname#,(f2py_init_func)#apiname#,doc_#apiname#},'
|
| 598 |
+
},
|
| 599 |
+
'decl': [' #ctype# #name#_return_value = NULL;',
|
| 600 |
+
' int #name#_return_value_len = 0;'],
|
| 601 |
+
'callfortran':'#name#_return_value,#name#_return_value_len,',
|
| 602 |
+
'callfortranroutine':[' #name#_return_value_len = #rlength#;',
|
| 603 |
+
' if ((#name#_return_value = (string)malloc('
|
| 604 |
+
+ '#name#_return_value_len+1) == NULL) {',
|
| 605 |
+
' PyErr_SetString(PyExc_MemoryError, \"out of memory\");',
|
| 606 |
+
' f2py_success = 0;',
|
| 607 |
+
' } else {',
|
| 608 |
+
" (#name#_return_value)[#name#_return_value_len] = '\\0';",
|
| 609 |
+
' }',
|
| 610 |
+
' if (f2py_success) {',
|
| 611 |
+
{hasexternals: """\
|
| 612 |
+
if (#setjmpbuf#) {
|
| 613 |
+
f2py_success = 0;
|
| 614 |
+
} else {"""},
|
| 615 |
+
{isthreadsafe: ' Py_BEGIN_ALLOW_THREADS'},
|
| 616 |
+
"""\
|
| 617 |
+
#ifdef USESCOMPAQFORTRAN
|
| 618 |
+
(*f2py_func)(#callcompaqfortran#);
|
| 619 |
+
#else
|
| 620 |
+
(*f2py_func)(#callfortran#);
|
| 621 |
+
#endif
|
| 622 |
+
""",
|
| 623 |
+
{isthreadsafe: ' Py_END_ALLOW_THREADS'},
|
| 624 |
+
{hasexternals: ' }'},
|
| 625 |
+
{debugcapi:
|
| 626 |
+
' fprintf(stderr,"#routdebugshowvalue#\\n",#name#_return_value_len,#name#_return_value);'},
|
| 627 |
+
' } /* if (f2py_success) after (string)malloc */',
|
| 628 |
+
],
|
| 629 |
+
'returnformat': '#rformat#',
|
| 630 |
+
'return': ',#name#_return_value',
|
| 631 |
+
'freemem': ' STRINGFREE(#name#_return_value);',
|
| 632 |
+
'need': ['F_FUNC', '#ctype#', 'STRINGFREE'],
|
| 633 |
+
'_check':l_and(isstringfunction, l_not(isfunction_wrap)) # ???obsolete
|
| 634 |
+
},
|
| 635 |
+
{ # Debugging
|
| 636 |
+
'routdebugenter': ' fprintf(stderr,"debug-capi:Python C/API function #modulename#.#name#(#docsignature#)\\n");',
|
| 637 |
+
'routdebugleave': ' fprintf(stderr,"debug-capi:Python C/API function #modulename#.#name#: successful.\\n");',
|
| 638 |
+
'routdebugfailure': ' fprintf(stderr,"debug-capi:Python C/API function #modulename#.#name#: failure.\\n");',
|
| 639 |
+
'_check': debugcapi
|
| 640 |
+
}
|
| 641 |
+
]
|
| 642 |
+
|
| 643 |
+
################ Rules for arguments ##################
|
| 644 |
+
|
| 645 |
+
typedef_need_dict = {islong_long: 'long_long',
|
| 646 |
+
islong_double: 'long_double',
|
| 647 |
+
islong_complex: 'complex_long_double',
|
| 648 |
+
isunsigned_char: 'unsigned_char',
|
| 649 |
+
isunsigned_short: 'unsigned_short',
|
| 650 |
+
isunsigned: 'unsigned',
|
| 651 |
+
isunsigned_long_long: 'unsigned_long_long',
|
| 652 |
+
isunsigned_chararray: 'unsigned_char',
|
| 653 |
+
isunsigned_shortarray: 'unsigned_short',
|
| 654 |
+
isunsigned_long_longarray: 'unsigned_long_long',
|
| 655 |
+
issigned_long_longarray: 'long_long',
|
| 656 |
+
isint1: 'signed_char',
|
| 657 |
+
ischaracter_or_characterarray: 'character',
|
| 658 |
+
}
|
| 659 |
+
|
| 660 |
+
aux_rules = [
|
| 661 |
+
{
|
| 662 |
+
'separatorsfor': sepdict
|
| 663 |
+
},
|
| 664 |
+
{ # Common
|
| 665 |
+
'frompyobj': [' /* Processing auxiliary variable #varname# */',
|
| 666 |
+
{debugcapi: ' fprintf(stderr,"#vardebuginfo#\\n");'}, ],
|
| 667 |
+
'cleanupfrompyobj': ' /* End of cleaning variable #varname# */',
|
| 668 |
+
'need': typedef_need_dict,
|
| 669 |
+
},
|
| 670 |
+
# Scalars (not complex)
|
| 671 |
+
{ # Common
|
| 672 |
+
'decl': ' #ctype# #varname# = 0;',
|
| 673 |
+
'need': {hasinitvalue: 'math.h'},
|
| 674 |
+
'frompyobj': {hasinitvalue: ' #varname# = #init#;'},
|
| 675 |
+
'_check': l_and(isscalar, l_not(iscomplex)),
|
| 676 |
+
},
|
| 677 |
+
{
|
| 678 |
+
'return': ',#varname#',
|
| 679 |
+
'docstrout': '#pydocsignout#',
|
| 680 |
+
'docreturn': '#outvarname#,',
|
| 681 |
+
'returnformat': '#varrformat#',
|
| 682 |
+
'_check': l_and(isscalar, l_not(iscomplex), isintent_out),
|
| 683 |
+
},
|
| 684 |
+
# Complex scalars
|
| 685 |
+
{ # Common
|
| 686 |
+
'decl': ' #ctype# #varname#;',
|
| 687 |
+
'frompyobj': {hasinitvalue: ' #varname#.r = #init.r#, #varname#.i = #init.i#;'},
|
| 688 |
+
'_check': iscomplex
|
| 689 |
+
},
|
| 690 |
+
# String
|
| 691 |
+
{ # Common
|
| 692 |
+
'decl': [' #ctype# #varname# = NULL;',
|
| 693 |
+
' int slen(#varname#);',
|
| 694 |
+
],
|
| 695 |
+
'need':['len..'],
|
| 696 |
+
'_check':isstring
|
| 697 |
+
},
|
| 698 |
+
# Array
|
| 699 |
+
{ # Common
|
| 700 |
+
'decl': [' #ctype# *#varname# = NULL;',
|
| 701 |
+
' npy_intp #varname#_Dims[#rank#] = {#rank*[-1]#};',
|
| 702 |
+
' const int #varname#_Rank = #rank#;',
|
| 703 |
+
],
|
| 704 |
+
'need':['len..', {hasinitvalue: 'forcomb'}, {hasinitvalue: 'CFUNCSMESS'}],
|
| 705 |
+
'_check': isarray
|
| 706 |
+
},
|
| 707 |
+
# Scalararray
|
| 708 |
+
{ # Common
|
| 709 |
+
'_check': l_and(isarray, l_not(iscomplexarray))
|
| 710 |
+
}, { # Not hidden
|
| 711 |
+
'_check': l_and(isarray, l_not(iscomplexarray), isintent_nothide)
|
| 712 |
+
},
|
| 713 |
+
# Integer*1 array
|
| 714 |
+
{'need': '#ctype#',
|
| 715 |
+
'_check': isint1array,
|
| 716 |
+
'_depend': ''
|
| 717 |
+
},
|
| 718 |
+
# Integer*-1 array
|
| 719 |
+
{'need': '#ctype#',
|
| 720 |
+
'_check': l_or(isunsigned_chararray, isunsigned_char),
|
| 721 |
+
'_depend': ''
|
| 722 |
+
},
|
| 723 |
+
# Integer*-2 array
|
| 724 |
+
{'need': '#ctype#',
|
| 725 |
+
'_check': isunsigned_shortarray,
|
| 726 |
+
'_depend': ''
|
| 727 |
+
},
|
| 728 |
+
# Integer*-8 array
|
| 729 |
+
{'need': '#ctype#',
|
| 730 |
+
'_check': isunsigned_long_longarray,
|
| 731 |
+
'_depend': ''
|
| 732 |
+
},
|
| 733 |
+
# Complexarray
|
| 734 |
+
{'need': '#ctype#',
|
| 735 |
+
'_check': iscomplexarray,
|
| 736 |
+
'_depend': ''
|
| 737 |
+
},
|
| 738 |
+
# Stringarray
|
| 739 |
+
{
|
| 740 |
+
'callfortranappend': {isarrayofstrings: 'flen(#varname#),'},
|
| 741 |
+
'need': 'string',
|
| 742 |
+
'_check': isstringarray
|
| 743 |
+
}
|
| 744 |
+
]
|
| 745 |
+
|
| 746 |
+
arg_rules = [
|
| 747 |
+
{
|
| 748 |
+
'separatorsfor': sepdict
|
| 749 |
+
},
|
| 750 |
+
{ # Common
|
| 751 |
+
'frompyobj': [' /* Processing variable #varname# */',
|
| 752 |
+
{debugcapi: ' fprintf(stderr,"#vardebuginfo#\\n");'}, ],
|
| 753 |
+
'cleanupfrompyobj': ' /* End of cleaning variable #varname# */',
|
| 754 |
+
'_depend': '',
|
| 755 |
+
'need': typedef_need_dict,
|
| 756 |
+
},
|
| 757 |
+
# Doc signatures
|
| 758 |
+
{
|
| 759 |
+
'docstropt': {l_and(isoptional, isintent_nothide): '#pydocsign#'},
|
| 760 |
+
'docstrreq': {l_and(isrequired, isintent_nothide): '#pydocsign#'},
|
| 761 |
+
'docstrout': {isintent_out: '#pydocsignout#'},
|
| 762 |
+
'latexdocstropt': {l_and(isoptional, isintent_nothide): ['\\item[]{{}\\verb@#pydocsign#@{}}',
|
| 763 |
+
{hasnote: '--- #note#'}]},
|
| 764 |
+
'latexdocstrreq': {l_and(isrequired, isintent_nothide): ['\\item[]{{}\\verb@#pydocsign#@{}}',
|
| 765 |
+
{hasnote: '--- #note#'}]},
|
| 766 |
+
'latexdocstrout': {isintent_out: ['\\item[]{{}\\verb@#pydocsignout#@{}}',
|
| 767 |
+
{l_and(hasnote, isintent_hide): '--- #note#',
|
| 768 |
+
l_and(hasnote, isintent_nothide): '--- See above.'}]},
|
| 769 |
+
'depend': ''
|
| 770 |
+
},
|
| 771 |
+
# Required/Optional arguments
|
| 772 |
+
{
|
| 773 |
+
'kwlist': '"#varname#",',
|
| 774 |
+
'docsign': '#varname#,',
|
| 775 |
+
'_check': l_and(isintent_nothide, l_not(isoptional))
|
| 776 |
+
},
|
| 777 |
+
{
|
| 778 |
+
'kwlistopt': '"#varname#",',
|
| 779 |
+
'docsignopt': '#varname#=#showinit#,',
|
| 780 |
+
'docsignoptshort': '#varname#,',
|
| 781 |
+
'_check': l_and(isintent_nothide, isoptional)
|
| 782 |
+
},
|
| 783 |
+
# Docstring/BuildValue
|
| 784 |
+
{
|
| 785 |
+
'docreturn': '#outvarname#,',
|
| 786 |
+
'returnformat': '#varrformat#',
|
| 787 |
+
'_check': isintent_out
|
| 788 |
+
},
|
| 789 |
+
# Externals (call-back functions)
|
| 790 |
+
{ # Common
|
| 791 |
+
'docsignxa': {isintent_nothide: '#varname#_extra_args=(),'},
|
| 792 |
+
'docsignxashort': {isintent_nothide: '#varname#_extra_args,'},
|
| 793 |
+
'docstropt': {isintent_nothide: '#varname#_extra_args : input tuple, optional\\n Default: ()'},
|
| 794 |
+
'docstrcbs': '#cbdocstr#',
|
| 795 |
+
'latexdocstrcbs': '\\item[] #cblatexdocstr#',
|
| 796 |
+
'latexdocstropt': {isintent_nothide: '\\item[]{{}\\verb@#varname#_extra_args := () input tuple@{}} --- Extra arguments for call-back function {{}\\verb@#varname#@{}}.'},
|
| 797 |
+
'decl': [' #cbname#_t #varname#_cb = { Py_None, NULL, 0 };',
|
| 798 |
+
' #cbname#_t *#varname#_cb_ptr = &#varname#_cb;',
|
| 799 |
+
' PyTupleObject *#varname#_xa_capi = NULL;',
|
| 800 |
+
{l_not(isintent_callback):
|
| 801 |
+
' #cbname#_typedef #varname#_cptr;'}
|
| 802 |
+
],
|
| 803 |
+
'kwlistxa': {isintent_nothide: '"#varname#_extra_args",'},
|
| 804 |
+
'argformat': {isrequired: 'O'},
|
| 805 |
+
'keyformat': {isoptional: 'O'},
|
| 806 |
+
'xaformat': {isintent_nothide: 'O!'},
|
| 807 |
+
'args_capi': {isrequired: ',&#varname#_cb.capi'},
|
| 808 |
+
'keys_capi': {isoptional: ',&#varname#_cb.capi'},
|
| 809 |
+
'keys_xa': ',&PyTuple_Type,&#varname#_xa_capi',
|
| 810 |
+
'setjmpbuf': '(setjmp(#varname#_cb.jmpbuf))',
|
| 811 |
+
'callfortran': {l_not(isintent_callback): '#varname#_cptr,'},
|
| 812 |
+
'need': ['#cbname#', 'setjmp.h'],
|
| 813 |
+
'_check':isexternal
|
| 814 |
+
},
|
| 815 |
+
{
|
| 816 |
+
'frompyobj': [{l_not(isintent_callback): """\
|
| 817 |
+
if(F2PyCapsule_Check(#varname#_cb.capi)) {
|
| 818 |
+
#varname#_cptr = F2PyCapsule_AsVoidPtr(#varname#_cb.capi);
|
| 819 |
+
} else {
|
| 820 |
+
#varname#_cptr = #cbname#;
|
| 821 |
+
}
|
| 822 |
+
"""}, {isintent_callback: """\
|
| 823 |
+
if (#varname#_cb.capi==Py_None) {
|
| 824 |
+
#varname#_cb.capi = PyObject_GetAttrString(#modulename#_module,\"#varname#\");
|
| 825 |
+
if (#varname#_cb.capi) {
|
| 826 |
+
if (#varname#_xa_capi==NULL) {
|
| 827 |
+
if (PyObject_HasAttrString(#modulename#_module,\"#varname#_extra_args\")) {
|
| 828 |
+
PyObject* capi_tmp = PyObject_GetAttrString(#modulename#_module,\"#varname#_extra_args\");
|
| 829 |
+
if (capi_tmp) {
|
| 830 |
+
#varname#_xa_capi = (PyTupleObject *)PySequence_Tuple(capi_tmp);
|
| 831 |
+
Py_DECREF(capi_tmp);
|
| 832 |
+
}
|
| 833 |
+
else {
|
| 834 |
+
#varname#_xa_capi = (PyTupleObject *)Py_BuildValue(\"()\");
|
| 835 |
+
}
|
| 836 |
+
if (#varname#_xa_capi==NULL) {
|
| 837 |
+
PyErr_SetString(#modulename#_error,\"Failed to convert #modulename#.#varname#_extra_args to tuple.\\n\");
|
| 838 |
+
return NULL;
|
| 839 |
+
}
|
| 840 |
+
}
|
| 841 |
+
}
|
| 842 |
+
}
|
| 843 |
+
if (#varname#_cb.capi==NULL) {
|
| 844 |
+
PyErr_SetString(#modulename#_error,\"Callback #varname# not defined (as an argument or module #modulename# attribute).\\n\");
|
| 845 |
+
return NULL;
|
| 846 |
+
}
|
| 847 |
+
}
|
| 848 |
+
"""},
|
| 849 |
+
"""\
|
| 850 |
+
if (create_cb_arglist(#varname#_cb.capi,#varname#_xa_capi,#maxnofargs#,#nofoptargs#,&#varname#_cb.nofargs,&#varname#_cb.args_capi,\"failed in processing argument list for call-back #varname#.\")) {
|
| 851 |
+
""",
|
| 852 |
+
{debugcapi: ["""\
|
| 853 |
+
fprintf(stderr,\"debug-capi:Assuming %d arguments; at most #maxnofargs#(-#nofoptargs#) is expected.\\n\",#varname#_cb.nofargs);
|
| 854 |
+
CFUNCSMESSPY(\"for #varname#=\",#varname#_cb.capi);""",
|
| 855 |
+
{l_not(isintent_callback): """ fprintf(stderr,\"#vardebugshowvalue# (call-back in C).\\n\",#cbname#);"""}]},
|
| 856 |
+
"""\
|
| 857 |
+
CFUNCSMESS(\"Saving callback variables for `#varname#`.\\n\");
|
| 858 |
+
#varname#_cb_ptr = swap_active_#cbname#(#varname#_cb_ptr);""",
|
| 859 |
+
],
|
| 860 |
+
'cleanupfrompyobj':
|
| 861 |
+
"""\
|
| 862 |
+
CFUNCSMESS(\"Restoring callback variables for `#varname#`.\\n\");
|
| 863 |
+
#varname#_cb_ptr = swap_active_#cbname#(#varname#_cb_ptr);
|
| 864 |
+
Py_DECREF(#varname#_cb.args_capi);
|
| 865 |
+
}""",
|
| 866 |
+
'need': ['SWAP', 'create_cb_arglist'],
|
| 867 |
+
'_check':isexternal,
|
| 868 |
+
'_depend':''
|
| 869 |
+
},
|
| 870 |
+
# Scalars (not complex)
|
| 871 |
+
{ # Common
|
| 872 |
+
'decl': ' #ctype# #varname# = 0;',
|
| 873 |
+
'pyobjfrom': {debugcapi: ' fprintf(stderr,"#vardebugshowvalue#\\n",#varname#);'},
|
| 874 |
+
'callfortran': {l_or(isintent_c, isattr_value): '#varname#,', l_not(l_or(isintent_c, isattr_value)): '&#varname#,'},
|
| 875 |
+
'return': {isintent_out: ',#varname#'},
|
| 876 |
+
'_check': l_and(isscalar, l_not(iscomplex))
|
| 877 |
+
}, {
|
| 878 |
+
'need': {hasinitvalue: 'math.h'},
|
| 879 |
+
'_check': l_and(isscalar, l_not(iscomplex)),
|
| 880 |
+
}, { # Not hidden
|
| 881 |
+
'decl': ' PyObject *#varname#_capi = Py_None;',
|
| 882 |
+
'argformat': {isrequired: 'O'},
|
| 883 |
+
'keyformat': {isoptional: 'O'},
|
| 884 |
+
'args_capi': {isrequired: ',&#varname#_capi'},
|
| 885 |
+
'keys_capi': {isoptional: ',&#varname#_capi'},
|
| 886 |
+
'pyobjfrom': {isintent_inout: """\
|
| 887 |
+
f2py_success = try_pyarr_from_#ctype#(#varname#_capi,&#varname#);
|
| 888 |
+
if (f2py_success) {"""},
|
| 889 |
+
'closepyobjfrom': {isintent_inout: " } /*if (f2py_success) of #varname# pyobjfrom*/"},
|
| 890 |
+
'need': {isintent_inout: 'try_pyarr_from_#ctype#'},
|
| 891 |
+
'_check': l_and(isscalar, l_not(iscomplex), l_not(isstring),
|
| 892 |
+
isintent_nothide)
|
| 893 |
+
}, {
|
| 894 |
+
'frompyobj': [
|
| 895 |
+
# hasinitvalue...
|
| 896 |
+
# if pyobj is None:
|
| 897 |
+
# varname = init
|
| 898 |
+
# else
|
| 899 |
+
# from_pyobj(varname)
|
| 900 |
+
#
|
| 901 |
+
# isoptional and noinitvalue...
|
| 902 |
+
# if pyobj is not None:
|
| 903 |
+
# from_pyobj(varname)
|
| 904 |
+
# else:
|
| 905 |
+
# varname is uninitialized
|
| 906 |
+
#
|
| 907 |
+
# ...
|
| 908 |
+
# from_pyobj(varname)
|
| 909 |
+
#
|
| 910 |
+
{hasinitvalue: ' if (#varname#_capi == Py_None) #varname# = #init#; else',
|
| 911 |
+
'_depend': ''},
|
| 912 |
+
{l_and(isoptional, l_not(hasinitvalue)): ' if (#varname#_capi != Py_None)',
|
| 913 |
+
'_depend': ''},
|
| 914 |
+
{l_not(islogical): '''\
|
| 915 |
+
f2py_success = #ctype#_from_pyobj(&#varname#,#varname#_capi,"#pyname#() #nth# (#varname#) can\'t be converted to #ctype#");
|
| 916 |
+
if (f2py_success) {'''},
|
| 917 |
+
{islogical: '''\
|
| 918 |
+
#varname# = (#ctype#)PyObject_IsTrue(#varname#_capi);
|
| 919 |
+
f2py_success = 1;
|
| 920 |
+
if (f2py_success) {'''},
|
| 921 |
+
],
|
| 922 |
+
'cleanupfrompyobj': ' } /*if (f2py_success) of #varname#*/',
|
| 923 |
+
'need': {l_not(islogical): '#ctype#_from_pyobj'},
|
| 924 |
+
'_check': l_and(isscalar, l_not(iscomplex), isintent_nothide),
|
| 925 |
+
'_depend': ''
|
| 926 |
+
}, { # Hidden
|
| 927 |
+
'frompyobj': {hasinitvalue: ' #varname# = #init#;'},
|
| 928 |
+
'need': typedef_need_dict,
|
| 929 |
+
'_check': l_and(isscalar, l_not(iscomplex), isintent_hide),
|
| 930 |
+
'_depend': ''
|
| 931 |
+
}, { # Common
|
| 932 |
+
'frompyobj': {debugcapi: ' fprintf(stderr,"#vardebugshowvalue#\\n",#varname#);'},
|
| 933 |
+
'_check': l_and(isscalar, l_not(iscomplex)),
|
| 934 |
+
'_depend': ''
|
| 935 |
+
},
|
| 936 |
+
# Complex scalars
|
| 937 |
+
{ # Common
|
| 938 |
+
'decl': ' #ctype# #varname#;',
|
| 939 |
+
'callfortran': {isintent_c: '#varname#,', l_not(isintent_c): '&#varname#,'},
|
| 940 |
+
'pyobjfrom': {debugcapi: ' fprintf(stderr,"#vardebugshowvalue#\\n",#varname#.r,#varname#.i);'},
|
| 941 |
+
'return': {isintent_out: ',#varname#_capi'},
|
| 942 |
+
'_check': iscomplex
|
| 943 |
+
}, { # Not hidden
|
| 944 |
+
'decl': ' PyObject *#varname#_capi = Py_None;',
|
| 945 |
+
'argformat': {isrequired: 'O'},
|
| 946 |
+
'keyformat': {isoptional: 'O'},
|
| 947 |
+
'args_capi': {isrequired: ',&#varname#_capi'},
|
| 948 |
+
'keys_capi': {isoptional: ',&#varname#_capi'},
|
| 949 |
+
'need': {isintent_inout: 'try_pyarr_from_#ctype#'},
|
| 950 |
+
'pyobjfrom': {isintent_inout: """\
|
| 951 |
+
f2py_success = try_pyarr_from_#ctype#(#varname#_capi,&#varname#);
|
| 952 |
+
if (f2py_success) {"""},
|
| 953 |
+
'closepyobjfrom': {isintent_inout: " } /*if (f2py_success) of #varname# pyobjfrom*/"},
|
| 954 |
+
'_check': l_and(iscomplex, isintent_nothide)
|
| 955 |
+
}, {
|
| 956 |
+
'frompyobj': [{hasinitvalue: ' if (#varname#_capi==Py_None) {#varname#.r = #init.r#, #varname#.i = #init.i#;} else'},
|
| 957 |
+
{l_and(isoptional, l_not(hasinitvalue))
|
| 958 |
+
: ' if (#varname#_capi != Py_None)'},
|
| 959 |
+
' f2py_success = #ctype#_from_pyobj(&#varname#,#varname#_capi,"#pyname#() #nth# (#varname#) can\'t be converted to #ctype#");'
|
| 960 |
+
'\n if (f2py_success) {'],
|
| 961 |
+
'cleanupfrompyobj': ' } /*if (f2py_success) of #varname# frompyobj*/',
|
| 962 |
+
'need': ['#ctype#_from_pyobj'],
|
| 963 |
+
'_check': l_and(iscomplex, isintent_nothide),
|
| 964 |
+
'_depend': ''
|
| 965 |
+
}, { # Hidden
|
| 966 |
+
'decl': {isintent_out: ' PyObject *#varname#_capi = Py_None;'},
|
| 967 |
+
'_check': l_and(iscomplex, isintent_hide)
|
| 968 |
+
}, {
|
| 969 |
+
'frompyobj': {hasinitvalue: ' #varname#.r = #init.r#, #varname#.i = #init.i#;'},
|
| 970 |
+
'_check': l_and(iscomplex, isintent_hide),
|
| 971 |
+
'_depend': ''
|
| 972 |
+
}, { # Common
|
| 973 |
+
'pyobjfrom': {isintent_out: ' #varname#_capi = pyobj_from_#ctype#1(#varname#);'},
|
| 974 |
+
'need': ['pyobj_from_#ctype#1'],
|
| 975 |
+
'_check': iscomplex
|
| 976 |
+
}, {
|
| 977 |
+
'frompyobj': {debugcapi: ' fprintf(stderr,"#vardebugshowvalue#\\n",#varname#.r,#varname#.i);'},
|
| 978 |
+
'_check': iscomplex,
|
| 979 |
+
'_depend': ''
|
| 980 |
+
},
|
| 981 |
+
# String
|
| 982 |
+
{ # Common
|
| 983 |
+
'decl': [' #ctype# #varname# = NULL;',
|
| 984 |
+
' int slen(#varname#);',
|
| 985 |
+
' PyObject *#varname#_capi = Py_None;'],
|
| 986 |
+
'callfortran':'#varname#,',
|
| 987 |
+
'callfortranappend':'slen(#varname#),',
|
| 988 |
+
'pyobjfrom':[
|
| 989 |
+
{debugcapi:
|
| 990 |
+
' fprintf(stderr,'
|
| 991 |
+
'"#vardebugshowvalue#\\n",slen(#varname#),#varname#);'},
|
| 992 |
+
# The trailing null value for Fortran is blank.
|
| 993 |
+
{l_and(isintent_out, l_not(isintent_c)):
|
| 994 |
+
" STRINGPADN(#varname#, slen(#varname#), ' ', '\\0');"},
|
| 995 |
+
],
|
| 996 |
+
'return': {isintent_out: ',#varname#'},
|
| 997 |
+
'need': ['len..',
|
| 998 |
+
{l_and(isintent_out, l_not(isintent_c)): 'STRINGPADN'}],
|
| 999 |
+
'_check': isstring
|
| 1000 |
+
}, { # Common
|
| 1001 |
+
'frompyobj': [
|
| 1002 |
+
"""\
|
| 1003 |
+
slen(#varname#) = #elsize#;
|
| 1004 |
+
f2py_success = #ctype#_from_pyobj(&#varname#,&slen(#varname#),#init#,"""
|
| 1005 |
+
"""#varname#_capi,\"#ctype#_from_pyobj failed in converting #nth#"""
|
| 1006 |
+
"""`#varname#\' of #pyname# to C #ctype#\");
|
| 1007 |
+
if (f2py_success) {""",
|
| 1008 |
+
# The trailing null value for Fortran is blank.
|
| 1009 |
+
{l_not(isintent_c):
|
| 1010 |
+
" STRINGPADN(#varname#, slen(#varname#), '\\0', ' ');"},
|
| 1011 |
+
],
|
| 1012 |
+
'cleanupfrompyobj': """\
|
| 1013 |
+
STRINGFREE(#varname#);
|
| 1014 |
+
} /*if (f2py_success) of #varname#*/""",
|
| 1015 |
+
'need': ['#ctype#_from_pyobj', 'len..', 'STRINGFREE',
|
| 1016 |
+
{l_not(isintent_c): 'STRINGPADN'}],
|
| 1017 |
+
'_check':isstring,
|
| 1018 |
+
'_depend':''
|
| 1019 |
+
}, { # Not hidden
|
| 1020 |
+
'argformat': {isrequired: 'O'},
|
| 1021 |
+
'keyformat': {isoptional: 'O'},
|
| 1022 |
+
'args_capi': {isrequired: ',&#varname#_capi'},
|
| 1023 |
+
'keys_capi': {isoptional: ',&#varname#_capi'},
|
| 1024 |
+
'pyobjfrom': [
|
| 1025 |
+
{l_and(isintent_inout, l_not(isintent_c)):
|
| 1026 |
+
" STRINGPADN(#varname#, slen(#varname#), ' ', '\\0');"},
|
| 1027 |
+
{isintent_inout: '''\
|
| 1028 |
+
f2py_success = try_pyarr_from_#ctype#(#varname#_capi, #varname#,
|
| 1029 |
+
slen(#varname#));
|
| 1030 |
+
if (f2py_success) {'''}],
|
| 1031 |
+
'closepyobjfrom': {isintent_inout: ' } /*if (f2py_success) of #varname# pyobjfrom*/'},
|
| 1032 |
+
'need': {isintent_inout: 'try_pyarr_from_#ctype#',
|
| 1033 |
+
l_and(isintent_inout, l_not(isintent_c)): 'STRINGPADN'},
|
| 1034 |
+
'_check': l_and(isstring, isintent_nothide)
|
| 1035 |
+
}, { # Hidden
|
| 1036 |
+
'_check': l_and(isstring, isintent_hide)
|
| 1037 |
+
}, {
|
| 1038 |
+
'frompyobj': {debugcapi: ' fprintf(stderr,"#vardebugshowvalue#\\n",slen(#varname#),#varname#);'},
|
| 1039 |
+
'_check': isstring,
|
| 1040 |
+
'_depend': ''
|
| 1041 |
+
},
|
| 1042 |
+
# Array
|
| 1043 |
+
{ # Common
|
| 1044 |
+
'decl': [' #ctype# *#varname# = NULL;',
|
| 1045 |
+
' npy_intp #varname#_Dims[#rank#] = {#rank*[-1]#};',
|
| 1046 |
+
' const int #varname#_Rank = #rank#;',
|
| 1047 |
+
' PyArrayObject *capi_#varname#_as_array = NULL;',
|
| 1048 |
+
' int capi_#varname#_intent = 0;',
|
| 1049 |
+
{isstringarray: ' int slen(#varname#) = 0;'},
|
| 1050 |
+
],
|
| 1051 |
+
'callfortran':'#varname#,',
|
| 1052 |
+
'callfortranappend': {isstringarray: 'slen(#varname#),'},
|
| 1053 |
+
'return': {isintent_out: ',capi_#varname#_as_array'},
|
| 1054 |
+
'need': 'len..',
|
| 1055 |
+
'_check': isarray
|
| 1056 |
+
}, { # intent(overwrite) array
|
| 1057 |
+
'decl': ' int capi_overwrite_#varname# = 1;',
|
| 1058 |
+
'kwlistxa': '"overwrite_#varname#",',
|
| 1059 |
+
'xaformat': 'i',
|
| 1060 |
+
'keys_xa': ',&capi_overwrite_#varname#',
|
| 1061 |
+
'docsignxa': 'overwrite_#varname#=1,',
|
| 1062 |
+
'docsignxashort': 'overwrite_#varname#,',
|
| 1063 |
+
'docstropt': 'overwrite_#varname# : input int, optional\\n Default: 1',
|
| 1064 |
+
'_check': l_and(isarray, isintent_overwrite),
|
| 1065 |
+
}, {
|
| 1066 |
+
'frompyobj': ' capi_#varname#_intent |= (capi_overwrite_#varname#?0:F2PY_INTENT_COPY);',
|
| 1067 |
+
'_check': l_and(isarray, isintent_overwrite),
|
| 1068 |
+
'_depend': '',
|
| 1069 |
+
},
|
| 1070 |
+
{ # intent(copy) array
|
| 1071 |
+
'decl': ' int capi_overwrite_#varname# = 0;',
|
| 1072 |
+
'kwlistxa': '"overwrite_#varname#",',
|
| 1073 |
+
'xaformat': 'i',
|
| 1074 |
+
'keys_xa': ',&capi_overwrite_#varname#',
|
| 1075 |
+
'docsignxa': 'overwrite_#varname#=0,',
|
| 1076 |
+
'docsignxashort': 'overwrite_#varname#,',
|
| 1077 |
+
'docstropt': 'overwrite_#varname# : input int, optional\\n Default: 0',
|
| 1078 |
+
'_check': l_and(isarray, isintent_copy),
|
| 1079 |
+
}, {
|
| 1080 |
+
'frompyobj': ' capi_#varname#_intent |= (capi_overwrite_#varname#?0:F2PY_INTENT_COPY);',
|
| 1081 |
+
'_check': l_and(isarray, isintent_copy),
|
| 1082 |
+
'_depend': '',
|
| 1083 |
+
}, {
|
| 1084 |
+
'need': [{hasinitvalue: 'forcomb'}, {hasinitvalue: 'CFUNCSMESS'}],
|
| 1085 |
+
'_check': isarray,
|
| 1086 |
+
'_depend': ''
|
| 1087 |
+
}, { # Not hidden
|
| 1088 |
+
'decl': ' PyObject *#varname#_capi = Py_None;',
|
| 1089 |
+
'argformat': {isrequired: 'O'},
|
| 1090 |
+
'keyformat': {isoptional: 'O'},
|
| 1091 |
+
'args_capi': {isrequired: ',&#varname#_capi'},
|
| 1092 |
+
'keys_capi': {isoptional: ',&#varname#_capi'},
|
| 1093 |
+
'_check': l_and(isarray, isintent_nothide)
|
| 1094 |
+
}, {
|
| 1095 |
+
'frompyobj': [
|
| 1096 |
+
' #setdims#;',
|
| 1097 |
+
' capi_#varname#_intent |= #intent#;',
|
| 1098 |
+
(' const char * capi_errmess = "#modulename#.#pyname#:'
|
| 1099 |
+
' failed to create array from the #nth# `#varname#`";'),
|
| 1100 |
+
{isintent_hide:
|
| 1101 |
+
' capi_#varname#_as_array = ndarray_from_pyobj('
|
| 1102 |
+
' #atype#,#elsize#,#varname#_Dims,#varname#_Rank,'
|
| 1103 |
+
' capi_#varname#_intent,Py_None,capi_errmess);'},
|
| 1104 |
+
{isintent_nothide:
|
| 1105 |
+
' capi_#varname#_as_array = ndarray_from_pyobj('
|
| 1106 |
+
' #atype#,#elsize#,#varname#_Dims,#varname#_Rank,'
|
| 1107 |
+
' capi_#varname#_intent,#varname#_capi,capi_errmess);'},
|
| 1108 |
+
"""\
|
| 1109 |
+
if (capi_#varname#_as_array == NULL) {
|
| 1110 |
+
PyObject* capi_err = PyErr_Occurred();
|
| 1111 |
+
if (capi_err == NULL) {
|
| 1112 |
+
capi_err = #modulename#_error;
|
| 1113 |
+
PyErr_SetString(capi_err, capi_errmess);
|
| 1114 |
+
}
|
| 1115 |
+
} else {
|
| 1116 |
+
#varname# = (#ctype# *)(PyArray_DATA(capi_#varname#_as_array));
|
| 1117 |
+
""",
|
| 1118 |
+
{isstringarray:
|
| 1119 |
+
' slen(#varname#) = f2py_itemsize(#varname#);'},
|
| 1120 |
+
{hasinitvalue: [
|
| 1121 |
+
{isintent_nothide:
|
| 1122 |
+
' if (#varname#_capi == Py_None) {'},
|
| 1123 |
+
{isintent_hide: ' {'},
|
| 1124 |
+
{iscomplexarray: ' #ctype# capi_c;'},
|
| 1125 |
+
"""\
|
| 1126 |
+
int *_i,capi_i=0;
|
| 1127 |
+
CFUNCSMESS(\"#name#: Initializing #varname#=#init#\\n\");
|
| 1128 |
+
if (initforcomb(PyArray_DIMS(capi_#varname#_as_array),
|
| 1129 |
+
PyArray_NDIM(capi_#varname#_as_array),1)) {
|
| 1130 |
+
while ((_i = nextforcomb()))
|
| 1131 |
+
#varname#[capi_i++] = #init#; /* fortran way */
|
| 1132 |
+
} else {
|
| 1133 |
+
PyObject *exc, *val, *tb;
|
| 1134 |
+
PyErr_Fetch(&exc, &val, &tb);
|
| 1135 |
+
PyErr_SetString(exc ? exc : #modulename#_error,
|
| 1136 |
+
\"Initialization of #nth# #varname# failed (initforcomb).\");
|
| 1137 |
+
npy_PyErr_ChainExceptionsCause(exc, val, tb);
|
| 1138 |
+
f2py_success = 0;
|
| 1139 |
+
}
|
| 1140 |
+
}
|
| 1141 |
+
if (f2py_success) {"""]},
|
| 1142 |
+
],
|
| 1143 |
+
'cleanupfrompyobj': [ # note that this list will be reversed
|
| 1144 |
+
' } '
|
| 1145 |
+
'/* if (capi_#varname#_as_array == NULL) ... else of #varname# */',
|
| 1146 |
+
{l_not(l_or(isintent_out, isintent_hide)): """\
|
| 1147 |
+
if((PyObject *)capi_#varname#_as_array!=#varname#_capi) {
|
| 1148 |
+
Py_XDECREF(capi_#varname#_as_array); }"""},
|
| 1149 |
+
{l_and(isintent_hide, l_not(isintent_out))
|
| 1150 |
+
: """ Py_XDECREF(capi_#varname#_as_array);"""},
|
| 1151 |
+
{hasinitvalue: ' } /*if (f2py_success) of #varname# init*/'},
|
| 1152 |
+
],
|
| 1153 |
+
'_check': isarray,
|
| 1154 |
+
'_depend': ''
|
| 1155 |
+
},
|
| 1156 |
+
# Scalararray
|
| 1157 |
+
{ # Common
|
| 1158 |
+
'_check': l_and(isarray, l_not(iscomplexarray))
|
| 1159 |
+
}, { # Not hidden
|
| 1160 |
+
'_check': l_and(isarray, l_not(iscomplexarray), isintent_nothide)
|
| 1161 |
+
},
|
| 1162 |
+
# Integer*1 array
|
| 1163 |
+
{'need': '#ctype#',
|
| 1164 |
+
'_check': isint1array,
|
| 1165 |
+
'_depend': ''
|
| 1166 |
+
},
|
| 1167 |
+
# Integer*-1 array
|
| 1168 |
+
{'need': '#ctype#',
|
| 1169 |
+
'_check': isunsigned_chararray,
|
| 1170 |
+
'_depend': ''
|
| 1171 |
+
},
|
| 1172 |
+
# Integer*-2 array
|
| 1173 |
+
{'need': '#ctype#',
|
| 1174 |
+
'_check': isunsigned_shortarray,
|
| 1175 |
+
'_depend': ''
|
| 1176 |
+
},
|
| 1177 |
+
# Integer*-8 array
|
| 1178 |
+
{'need': '#ctype#',
|
| 1179 |
+
'_check': isunsigned_long_longarray,
|
| 1180 |
+
'_depend': ''
|
| 1181 |
+
},
|
| 1182 |
+
# Complexarray
|
| 1183 |
+
{'need': '#ctype#',
|
| 1184 |
+
'_check': iscomplexarray,
|
| 1185 |
+
'_depend': ''
|
| 1186 |
+
},
|
| 1187 |
+
# Character
|
| 1188 |
+
{
|
| 1189 |
+
'need': 'string',
|
| 1190 |
+
'_check': ischaracter,
|
| 1191 |
+
},
|
| 1192 |
+
# Character array
|
| 1193 |
+
{
|
| 1194 |
+
'need': 'string',
|
| 1195 |
+
'_check': ischaracterarray,
|
| 1196 |
+
},
|
| 1197 |
+
# Stringarray
|
| 1198 |
+
{
|
| 1199 |
+
'callfortranappend': {isarrayofstrings: 'flen(#varname#),'},
|
| 1200 |
+
'need': 'string',
|
| 1201 |
+
'_check': isstringarray
|
| 1202 |
+
}
|
| 1203 |
+
]
|
| 1204 |
+
|
| 1205 |
+
################# Rules for checking ###############
|
| 1206 |
+
|
| 1207 |
+
check_rules = [
|
| 1208 |
+
{
|
| 1209 |
+
'frompyobj': {debugcapi: ' fprintf(stderr,\"debug-capi:Checking `#check#\'\\n\");'},
|
| 1210 |
+
'need': 'len..'
|
| 1211 |
+
}, {
|
| 1212 |
+
'frompyobj': ' CHECKSCALAR(#check#,\"#check#\",\"#nth# #varname#\",\"#varshowvalue#\",#varname#) {',
|
| 1213 |
+
'cleanupfrompyobj': ' } /*CHECKSCALAR(#check#)*/',
|
| 1214 |
+
'need': 'CHECKSCALAR',
|
| 1215 |
+
'_check': l_and(isscalar, l_not(iscomplex)),
|
| 1216 |
+
'_break': ''
|
| 1217 |
+
}, {
|
| 1218 |
+
'frompyobj': ' CHECKSTRING(#check#,\"#check#\",\"#nth# #varname#\",\"#varshowvalue#\",#varname#) {',
|
| 1219 |
+
'cleanupfrompyobj': ' } /*CHECKSTRING(#check#)*/',
|
| 1220 |
+
'need': 'CHECKSTRING',
|
| 1221 |
+
'_check': isstring,
|
| 1222 |
+
'_break': ''
|
| 1223 |
+
}, {
|
| 1224 |
+
'need': 'CHECKARRAY',
|
| 1225 |
+
'frompyobj': ' CHECKARRAY(#check#,\"#check#\",\"#nth# #varname#\") {',
|
| 1226 |
+
'cleanupfrompyobj': ' } /*CHECKARRAY(#check#)*/',
|
| 1227 |
+
'_check': isarray,
|
| 1228 |
+
'_break': ''
|
| 1229 |
+
}, {
|
| 1230 |
+
'need': 'CHECKGENERIC',
|
| 1231 |
+
'frompyobj': ' CHECKGENERIC(#check#,\"#check#\",\"#nth# #varname#\") {',
|
| 1232 |
+
'cleanupfrompyobj': ' } /*CHECKGENERIC(#check#)*/',
|
| 1233 |
+
}
|
| 1234 |
+
]
|
| 1235 |
+
|
| 1236 |
+
########## Applying the rules. No need to modify what follows #############
|
| 1237 |
+
|
| 1238 |
+
#################### Build C/API module #######################
|
| 1239 |
+
|
| 1240 |
+
|
| 1241 |
+
def buildmodule(m, um):
|
| 1242 |
+
"""
|
| 1243 |
+
Return
|
| 1244 |
+
"""
|
| 1245 |
+
outmess(' Building module "%s"...\n' % (m['name']))
|
| 1246 |
+
ret = {}
|
| 1247 |
+
mod_rules = defmod_rules[:]
|
| 1248 |
+
vrd = capi_maps.modsign2map(m)
|
| 1249 |
+
rd = dictappend({'f2py_version': f2py_version}, vrd)
|
| 1250 |
+
funcwrappers = []
|
| 1251 |
+
funcwrappers2 = [] # F90 codes
|
| 1252 |
+
for n in m['interfaced']:
|
| 1253 |
+
nb = None
|
| 1254 |
+
for bi in m['body']:
|
| 1255 |
+
if bi['block'] not in ['interface', 'abstract interface']:
|
| 1256 |
+
errmess('buildmodule: Expected interface block. Skipping.\n')
|
| 1257 |
+
continue
|
| 1258 |
+
for b in bi['body']:
|
| 1259 |
+
if b['name'] == n:
|
| 1260 |
+
nb = b
|
| 1261 |
+
break
|
| 1262 |
+
|
| 1263 |
+
if not nb:
|
| 1264 |
+
print(
|
| 1265 |
+
'buildmodule: Could not find the body of interfaced routine "%s". Skipping.\n' % (n), file=sys.stderr)
|
| 1266 |
+
continue
|
| 1267 |
+
nb_list = [nb]
|
| 1268 |
+
if 'entry' in nb:
|
| 1269 |
+
for k, a in nb['entry'].items():
|
| 1270 |
+
nb1 = copy.deepcopy(nb)
|
| 1271 |
+
del nb1['entry']
|
| 1272 |
+
nb1['name'] = k
|
| 1273 |
+
nb1['args'] = a
|
| 1274 |
+
nb_list.append(nb1)
|
| 1275 |
+
for nb in nb_list:
|
| 1276 |
+
# requiresf90wrapper must be called before buildapi as it
|
| 1277 |
+
# rewrites assumed shape arrays as automatic arrays.
|
| 1278 |
+
isf90 = requiresf90wrapper(nb)
|
| 1279 |
+
# options is in scope here
|
| 1280 |
+
if options['emptygen']:
|
| 1281 |
+
b_path = options['buildpath']
|
| 1282 |
+
m_name = vrd['modulename']
|
| 1283 |
+
outmess(' Generating possibly empty wrappers"\n')
|
| 1284 |
+
Path(f"{b_path}/{vrd['coutput']}").touch()
|
| 1285 |
+
if isf90:
|
| 1286 |
+
# f77 + f90 wrappers
|
| 1287 |
+
outmess(f' Maybe empty "{m_name}-f2pywrappers2.f90"\n')
|
| 1288 |
+
Path(f'{b_path}/{m_name}-f2pywrappers2.f90').touch()
|
| 1289 |
+
outmess(f' Maybe empty "{m_name}-f2pywrappers.f"\n')
|
| 1290 |
+
Path(f'{b_path}/{m_name}-f2pywrappers.f').touch()
|
| 1291 |
+
else:
|
| 1292 |
+
# only f77 wrappers
|
| 1293 |
+
outmess(f' Maybe empty "{m_name}-f2pywrappers.f"\n')
|
| 1294 |
+
Path(f'{b_path}/{m_name}-f2pywrappers.f').touch()
|
| 1295 |
+
api, wrap = buildapi(nb)
|
| 1296 |
+
if wrap:
|
| 1297 |
+
if isf90:
|
| 1298 |
+
funcwrappers2.append(wrap)
|
| 1299 |
+
else:
|
| 1300 |
+
funcwrappers.append(wrap)
|
| 1301 |
+
ar = applyrules(api, vrd)
|
| 1302 |
+
rd = dictappend(rd, ar)
|
| 1303 |
+
|
| 1304 |
+
# Construct COMMON block support
|
| 1305 |
+
cr, wrap = common_rules.buildhooks(m)
|
| 1306 |
+
if wrap:
|
| 1307 |
+
funcwrappers.append(wrap)
|
| 1308 |
+
ar = applyrules(cr, vrd)
|
| 1309 |
+
rd = dictappend(rd, ar)
|
| 1310 |
+
|
| 1311 |
+
# Construct F90 module support
|
| 1312 |
+
mr, wrap = f90mod_rules.buildhooks(m)
|
| 1313 |
+
if wrap:
|
| 1314 |
+
funcwrappers2.append(wrap)
|
| 1315 |
+
ar = applyrules(mr, vrd)
|
| 1316 |
+
rd = dictappend(rd, ar)
|
| 1317 |
+
|
| 1318 |
+
for u in um:
|
| 1319 |
+
ar = use_rules.buildusevars(u, m['use'][u['name']])
|
| 1320 |
+
rd = dictappend(rd, ar)
|
| 1321 |
+
|
| 1322 |
+
needs = cfuncs.get_needs()
|
| 1323 |
+
# Add mapped definitions
|
| 1324 |
+
needs['typedefs'] += [cvar for cvar in capi_maps.f2cmap_mapped #
|
| 1325 |
+
if cvar in typedef_need_dict.values()]
|
| 1326 |
+
code = {}
|
| 1327 |
+
for n in needs.keys():
|
| 1328 |
+
code[n] = []
|
| 1329 |
+
for k in needs[n]:
|
| 1330 |
+
c = ''
|
| 1331 |
+
if k in cfuncs.includes0:
|
| 1332 |
+
c = cfuncs.includes0[k]
|
| 1333 |
+
elif k in cfuncs.includes:
|
| 1334 |
+
c = cfuncs.includes[k]
|
| 1335 |
+
elif k in cfuncs.userincludes:
|
| 1336 |
+
c = cfuncs.userincludes[k]
|
| 1337 |
+
elif k in cfuncs.typedefs:
|
| 1338 |
+
c = cfuncs.typedefs[k]
|
| 1339 |
+
elif k in cfuncs.typedefs_generated:
|
| 1340 |
+
c = cfuncs.typedefs_generated[k]
|
| 1341 |
+
elif k in cfuncs.cppmacros:
|
| 1342 |
+
c = cfuncs.cppmacros[k]
|
| 1343 |
+
elif k in cfuncs.cfuncs:
|
| 1344 |
+
c = cfuncs.cfuncs[k]
|
| 1345 |
+
elif k in cfuncs.callbacks:
|
| 1346 |
+
c = cfuncs.callbacks[k]
|
| 1347 |
+
elif k in cfuncs.f90modhooks:
|
| 1348 |
+
c = cfuncs.f90modhooks[k]
|
| 1349 |
+
elif k in cfuncs.commonhooks:
|
| 1350 |
+
c = cfuncs.commonhooks[k]
|
| 1351 |
+
else:
|
| 1352 |
+
errmess('buildmodule: unknown need %s.\n' % (repr(k)))
|
| 1353 |
+
continue
|
| 1354 |
+
code[n].append(c)
|
| 1355 |
+
mod_rules.append(code)
|
| 1356 |
+
for r in mod_rules:
|
| 1357 |
+
if ('_check' in r and r['_check'](m)) or ('_check' not in r):
|
| 1358 |
+
ar = applyrules(r, vrd, m)
|
| 1359 |
+
rd = dictappend(rd, ar)
|
| 1360 |
+
ar = applyrules(module_rules, rd)
|
| 1361 |
+
|
| 1362 |
+
fn = os.path.join(options['buildpath'], vrd['coutput'])
|
| 1363 |
+
ret['csrc'] = fn
|
| 1364 |
+
with open(fn, 'w') as f:
|
| 1365 |
+
f.write(ar['modulebody'].replace('\t', 2 * ' '))
|
| 1366 |
+
outmess(' Wrote C/API module "%s" to file "%s"\n' % (m['name'], fn))
|
| 1367 |
+
|
| 1368 |
+
if options['dorestdoc']:
|
| 1369 |
+
fn = os.path.join(
|
| 1370 |
+
options['buildpath'], vrd['modulename'] + 'module.rest')
|
| 1371 |
+
with open(fn, 'w') as f:
|
| 1372 |
+
f.write('.. -*- rest -*-\n')
|
| 1373 |
+
f.write('\n'.join(ar['restdoc']))
|
| 1374 |
+
outmess(' ReST Documentation is saved to file "%s/%smodule.rest"\n' %
|
| 1375 |
+
(options['buildpath'], vrd['modulename']))
|
| 1376 |
+
if options['dolatexdoc']:
|
| 1377 |
+
fn = os.path.join(
|
| 1378 |
+
options['buildpath'], vrd['modulename'] + 'module.tex')
|
| 1379 |
+
ret['ltx'] = fn
|
| 1380 |
+
with open(fn, 'w') as f:
|
| 1381 |
+
f.write(
|
| 1382 |
+
'%% This file is auto-generated with f2py (version:%s)\n' % (f2py_version))
|
| 1383 |
+
if 'shortlatex' not in options:
|
| 1384 |
+
f.write(
|
| 1385 |
+
'\\documentclass{article}\n\\usepackage{a4wide}\n\\begin{document}\n\\tableofcontents\n\n')
|
| 1386 |
+
f.write('\n'.join(ar['latexdoc']))
|
| 1387 |
+
if 'shortlatex' not in options:
|
| 1388 |
+
f.write('\\end{document}')
|
| 1389 |
+
outmess(' Documentation is saved to file "%s/%smodule.tex"\n' %
|
| 1390 |
+
(options['buildpath'], vrd['modulename']))
|
| 1391 |
+
if funcwrappers:
|
| 1392 |
+
wn = os.path.join(options['buildpath'], vrd['f2py_wrapper_output'])
|
| 1393 |
+
ret['fsrc'] = wn
|
| 1394 |
+
with open(wn, 'w') as f:
|
| 1395 |
+
f.write('C -*- fortran -*-\n')
|
| 1396 |
+
f.write(
|
| 1397 |
+
'C This file is autogenerated with f2py (version:%s)\n' % (f2py_version))
|
| 1398 |
+
f.write(
|
| 1399 |
+
'C It contains Fortran 77 wrappers to fortran functions.\n')
|
| 1400 |
+
lines = []
|
| 1401 |
+
for l in ('\n\n'.join(funcwrappers) + '\n').split('\n'):
|
| 1402 |
+
if 0 <= l.find('!') < 66:
|
| 1403 |
+
# don't split comment lines
|
| 1404 |
+
lines.append(l + '\n')
|
| 1405 |
+
elif l and l[0] == ' ':
|
| 1406 |
+
while len(l) >= 66:
|
| 1407 |
+
lines.append(l[:66] + '\n &')
|
| 1408 |
+
l = l[66:]
|
| 1409 |
+
lines.append(l + '\n')
|
| 1410 |
+
else:
|
| 1411 |
+
lines.append(l + '\n')
|
| 1412 |
+
lines = ''.join(lines).replace('\n &\n', '\n')
|
| 1413 |
+
f.write(lines)
|
| 1414 |
+
outmess(' Fortran 77 wrappers are saved to "%s"\n' % (wn))
|
| 1415 |
+
if funcwrappers2:
|
| 1416 |
+
wn = os.path.join(
|
| 1417 |
+
options['buildpath'], '%s-f2pywrappers2.f90' % (vrd['modulename']))
|
| 1418 |
+
ret['fsrc'] = wn
|
| 1419 |
+
with open(wn, 'w') as f:
|
| 1420 |
+
f.write('! -*- f90 -*-\n')
|
| 1421 |
+
f.write(
|
| 1422 |
+
'! This file is autogenerated with f2py (version:%s)\n' % (f2py_version))
|
| 1423 |
+
f.write(
|
| 1424 |
+
'! It contains Fortran 90 wrappers to fortran functions.\n')
|
| 1425 |
+
lines = []
|
| 1426 |
+
for l in ('\n\n'.join(funcwrappers2) + '\n').split('\n'):
|
| 1427 |
+
if 0 <= l.find('!') < 72:
|
| 1428 |
+
# don't split comment lines
|
| 1429 |
+
lines.append(l + '\n')
|
| 1430 |
+
elif len(l) > 72 and l[0] == ' ':
|
| 1431 |
+
lines.append(l[:72] + '&\n &')
|
| 1432 |
+
l = l[72:]
|
| 1433 |
+
while len(l) > 66:
|
| 1434 |
+
lines.append(l[:66] + '&\n &')
|
| 1435 |
+
l = l[66:]
|
| 1436 |
+
lines.append(l + '\n')
|
| 1437 |
+
else:
|
| 1438 |
+
lines.append(l + '\n')
|
| 1439 |
+
lines = ''.join(lines).replace('\n &\n', '\n')
|
| 1440 |
+
f.write(lines)
|
| 1441 |
+
outmess(' Fortran 90 wrappers are saved to "%s"\n' % (wn))
|
| 1442 |
+
return ret
|
| 1443 |
+
|
| 1444 |
+
################## Build C/API function #############
|
| 1445 |
+
|
| 1446 |
+
stnd = {1: 'st', 2: 'nd', 3: 'rd', 4: 'th', 5: 'th',
|
| 1447 |
+
6: 'th', 7: 'th', 8: 'th', 9: 'th', 0: 'th'}
|
| 1448 |
+
|
| 1449 |
+
|
| 1450 |
+
def buildapi(rout):
|
| 1451 |
+
rout, wrap = func2subr.assubr(rout)
|
| 1452 |
+
args, depargs = getargs2(rout)
|
| 1453 |
+
capi_maps.depargs = depargs
|
| 1454 |
+
var = rout['vars']
|
| 1455 |
+
|
| 1456 |
+
if ismoduleroutine(rout):
|
| 1457 |
+
outmess(' Constructing wrapper function "%s.%s"...\n' %
|
| 1458 |
+
(rout['modulename'], rout['name']))
|
| 1459 |
+
else:
|
| 1460 |
+
outmess(' Constructing wrapper function "%s"...\n' % (rout['name']))
|
| 1461 |
+
# Routine
|
| 1462 |
+
vrd = capi_maps.routsign2map(rout)
|
| 1463 |
+
rd = dictappend({}, vrd)
|
| 1464 |
+
for r in rout_rules:
|
| 1465 |
+
if ('_check' in r and r['_check'](rout)) or ('_check' not in r):
|
| 1466 |
+
ar = applyrules(r, vrd, rout)
|
| 1467 |
+
rd = dictappend(rd, ar)
|
| 1468 |
+
|
| 1469 |
+
# Args
|
| 1470 |
+
nth, nthk = 0, 0
|
| 1471 |
+
savevrd = {}
|
| 1472 |
+
for a in args:
|
| 1473 |
+
vrd = capi_maps.sign2map(a, var[a])
|
| 1474 |
+
if isintent_aux(var[a]):
|
| 1475 |
+
_rules = aux_rules
|
| 1476 |
+
else:
|
| 1477 |
+
_rules = arg_rules
|
| 1478 |
+
if not isintent_hide(var[a]):
|
| 1479 |
+
if not isoptional(var[a]):
|
| 1480 |
+
nth = nth + 1
|
| 1481 |
+
vrd['nth'] = repr(nth) + stnd[nth % 10] + ' argument'
|
| 1482 |
+
else:
|
| 1483 |
+
nthk = nthk + 1
|
| 1484 |
+
vrd['nth'] = repr(nthk) + stnd[nthk % 10] + ' keyword'
|
| 1485 |
+
else:
|
| 1486 |
+
vrd['nth'] = 'hidden'
|
| 1487 |
+
savevrd[a] = vrd
|
| 1488 |
+
for r in _rules:
|
| 1489 |
+
if '_depend' in r:
|
| 1490 |
+
continue
|
| 1491 |
+
if ('_check' in r and r['_check'](var[a])) or ('_check' not in r):
|
| 1492 |
+
ar = applyrules(r, vrd, var[a])
|
| 1493 |
+
rd = dictappend(rd, ar)
|
| 1494 |
+
if '_break' in r:
|
| 1495 |
+
break
|
| 1496 |
+
for a in depargs:
|
| 1497 |
+
if isintent_aux(var[a]):
|
| 1498 |
+
_rules = aux_rules
|
| 1499 |
+
else:
|
| 1500 |
+
_rules = arg_rules
|
| 1501 |
+
vrd = savevrd[a]
|
| 1502 |
+
for r in _rules:
|
| 1503 |
+
if '_depend' not in r:
|
| 1504 |
+
continue
|
| 1505 |
+
if ('_check' in r and r['_check'](var[a])) or ('_check' not in r):
|
| 1506 |
+
ar = applyrules(r, vrd, var[a])
|
| 1507 |
+
rd = dictappend(rd, ar)
|
| 1508 |
+
if '_break' in r:
|
| 1509 |
+
break
|
| 1510 |
+
if 'check' in var[a]:
|
| 1511 |
+
for c in var[a]['check']:
|
| 1512 |
+
vrd['check'] = c
|
| 1513 |
+
ar = applyrules(check_rules, vrd, var[a])
|
| 1514 |
+
rd = dictappend(rd, ar)
|
| 1515 |
+
if isinstance(rd['cleanupfrompyobj'], list):
|
| 1516 |
+
rd['cleanupfrompyobj'].reverse()
|
| 1517 |
+
if isinstance(rd['closepyobjfrom'], list):
|
| 1518 |
+
rd['closepyobjfrom'].reverse()
|
| 1519 |
+
rd['docsignature'] = stripcomma(replace('#docsign##docsignopt##docsignxa#',
|
| 1520 |
+
{'docsign': rd['docsign'],
|
| 1521 |
+
'docsignopt': rd['docsignopt'],
|
| 1522 |
+
'docsignxa': rd['docsignxa']}))
|
| 1523 |
+
optargs = stripcomma(replace('#docsignopt##docsignxa#',
|
| 1524 |
+
{'docsignxa': rd['docsignxashort'],
|
| 1525 |
+
'docsignopt': rd['docsignoptshort']}
|
| 1526 |
+
))
|
| 1527 |
+
if optargs == '':
|
| 1528 |
+
rd['docsignatureshort'] = stripcomma(
|
| 1529 |
+
replace('#docsign#', {'docsign': rd['docsign']}))
|
| 1530 |
+
else:
|
| 1531 |
+
rd['docsignatureshort'] = replace('#docsign#[#docsignopt#]',
|
| 1532 |
+
{'docsign': rd['docsign'],
|
| 1533 |
+
'docsignopt': optargs,
|
| 1534 |
+
})
|
| 1535 |
+
rd['latexdocsignatureshort'] = rd['docsignatureshort'].replace('_', '\\_')
|
| 1536 |
+
rd['latexdocsignatureshort'] = rd[
|
| 1537 |
+
'latexdocsignatureshort'].replace(',', ', ')
|
| 1538 |
+
cfs = stripcomma(replace('#callfortran##callfortranappend#', {
|
| 1539 |
+
'callfortran': rd['callfortran'], 'callfortranappend': rd['callfortranappend']}))
|
| 1540 |
+
if len(rd['callfortranappend']) > 1:
|
| 1541 |
+
rd['callcompaqfortran'] = stripcomma(replace('#callfortran# 0,#callfortranappend#', {
|
| 1542 |
+
'callfortran': rd['callfortran'], 'callfortranappend': rd['callfortranappend']}))
|
| 1543 |
+
else:
|
| 1544 |
+
rd['callcompaqfortran'] = cfs
|
| 1545 |
+
rd['callfortran'] = cfs
|
| 1546 |
+
if isinstance(rd['docreturn'], list):
|
| 1547 |
+
rd['docreturn'] = stripcomma(
|
| 1548 |
+
replace('#docreturn#', {'docreturn': rd['docreturn']})) + ' = '
|
| 1549 |
+
rd['docstrsigns'] = []
|
| 1550 |
+
rd['latexdocstrsigns'] = []
|
| 1551 |
+
for k in ['docstrreq', 'docstropt', 'docstrout', 'docstrcbs']:
|
| 1552 |
+
if k in rd and isinstance(rd[k], list):
|
| 1553 |
+
rd['docstrsigns'] = rd['docstrsigns'] + rd[k]
|
| 1554 |
+
k = 'latex' + k
|
| 1555 |
+
if k in rd and isinstance(rd[k], list):
|
| 1556 |
+
rd['latexdocstrsigns'] = rd['latexdocstrsigns'] + rd[k][0:1] +\
|
| 1557 |
+
['\\begin{description}'] + rd[k][1:] +\
|
| 1558 |
+
['\\end{description}']
|
| 1559 |
+
|
| 1560 |
+
ar = applyrules(routine_rules, rd)
|
| 1561 |
+
if ismoduleroutine(rout):
|
| 1562 |
+
outmess(' %s\n' % (ar['docshort']))
|
| 1563 |
+
else:
|
| 1564 |
+
outmess(' %s\n' % (ar['docshort']))
|
| 1565 |
+
return ar, wrap
|
| 1566 |
+
|
| 1567 |
+
|
| 1568 |
+
#################### EOF rules.py #######################
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/f2py/setup.cfg
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[bdist_rpm]
|
| 2 |
+
doc_files = docs/
|
| 3 |
+
tests/
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12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21-007: Draft Fortran 202x. https://j3-fortran.org/doc/year/21/21-007.pdf
|
| 5 |
+
|
| 6 |
+
Copyright 1999 -- 2011 Pearu Peterson all rights reserved.
|
| 7 |
+
Copyright 2011 -- present NumPy Developers.
|
| 8 |
+
Permission to use, modify, and distribute this software is given under the
|
| 9 |
+
terms of the NumPy License.
|
| 10 |
+
|
| 11 |
+
NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
# To analyze Fortran expressions to solve dimensions specifications,
|
| 15 |
+
# for instances, we implement a minimal symbolic engine for parsing
|
| 16 |
+
# expressions into a tree of expression instances. As a first
|
| 17 |
+
# instance, we care only about arithmetic expressions involving
|
| 18 |
+
# integers and operations like addition (+), subtraction (-),
|
| 19 |
+
# multiplication (*), division (Fortran / is Python //, Fortran // is
|
| 20 |
+
# concatenate), and exponentiation (**). In addition, .pyf files may
|
| 21 |
+
# contain C expressions that support here is implemented as well.
|
| 22 |
+
#
|
| 23 |
+
# TODO: support logical constants (Op.BOOLEAN)
|
| 24 |
+
# TODO: support logical operators (.AND., ...)
|
| 25 |
+
# TODO: support defined operators (.MYOP., ...)
|
| 26 |
+
#
|
| 27 |
+
__all__ = ['Expr']
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
import re
|
| 31 |
+
import warnings
|
| 32 |
+
from enum import Enum
|
| 33 |
+
from math import gcd
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
class Language(Enum):
|
| 37 |
+
"""
|
| 38 |
+
Used as Expr.tostring language argument.
|
| 39 |
+
"""
|
| 40 |
+
Python = 0
|
| 41 |
+
Fortran = 1
|
| 42 |
+
C = 2
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
class Op(Enum):
|
| 46 |
+
"""
|
| 47 |
+
Used as Expr op attribute.
|
| 48 |
+
"""
|
| 49 |
+
INTEGER = 10
|
| 50 |
+
REAL = 12
|
| 51 |
+
COMPLEX = 15
|
| 52 |
+
STRING = 20
|
| 53 |
+
ARRAY = 30
|
| 54 |
+
SYMBOL = 40
|
| 55 |
+
TERNARY = 100
|
| 56 |
+
APPLY = 200
|
| 57 |
+
INDEXING = 210
|
| 58 |
+
CONCAT = 220
|
| 59 |
+
RELATIONAL = 300
|
| 60 |
+
TERMS = 1000
|
| 61 |
+
FACTORS = 2000
|
| 62 |
+
REF = 3000
|
| 63 |
+
DEREF = 3001
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
class RelOp(Enum):
|
| 67 |
+
"""
|
| 68 |
+
Used in Op.RELATIONAL expression to specify the function part.
|
| 69 |
+
"""
|
| 70 |
+
EQ = 1
|
| 71 |
+
NE = 2
|
| 72 |
+
LT = 3
|
| 73 |
+
LE = 4
|
| 74 |
+
GT = 5
|
| 75 |
+
GE = 6
|
| 76 |
+
|
| 77 |
+
@classmethod
|
| 78 |
+
def fromstring(cls, s, language=Language.C):
|
| 79 |
+
if language is Language.Fortran:
|
| 80 |
+
return {'.eq.': RelOp.EQ, '.ne.': RelOp.NE,
|
| 81 |
+
'.lt.': RelOp.LT, '.le.': RelOp.LE,
|
| 82 |
+
'.gt.': RelOp.GT, '.ge.': RelOp.GE}[s.lower()]
|
| 83 |
+
return {'==': RelOp.EQ, '!=': RelOp.NE, '<': RelOp.LT,
|
| 84 |
+
'<=': RelOp.LE, '>': RelOp.GT, '>=': RelOp.GE}[s]
|
| 85 |
+
|
| 86 |
+
def tostring(self, language=Language.C):
|
| 87 |
+
if language is Language.Fortran:
|
| 88 |
+
return {RelOp.EQ: '.eq.', RelOp.NE: '.ne.',
|
| 89 |
+
RelOp.LT: '.lt.', RelOp.LE: '.le.',
|
| 90 |
+
RelOp.GT: '.gt.', RelOp.GE: '.ge.'}[self]
|
| 91 |
+
return {RelOp.EQ: '==', RelOp.NE: '!=',
|
| 92 |
+
RelOp.LT: '<', RelOp.LE: '<=',
|
| 93 |
+
RelOp.GT: '>', RelOp.GE: '>='}[self]
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
class ArithOp(Enum):
|
| 97 |
+
"""
|
| 98 |
+
Used in Op.APPLY expression to specify the function part.
|
| 99 |
+
"""
|
| 100 |
+
POS = 1
|
| 101 |
+
NEG = 2
|
| 102 |
+
ADD = 3
|
| 103 |
+
SUB = 4
|
| 104 |
+
MUL = 5
|
| 105 |
+
DIV = 6
|
| 106 |
+
POW = 7
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
class OpError(Exception):
|
| 110 |
+
pass
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
class Precedence(Enum):
|
| 114 |
+
"""
|
| 115 |
+
Used as Expr.tostring precedence argument.
|
| 116 |
+
"""
|
| 117 |
+
ATOM = 0
|
| 118 |
+
POWER = 1
|
| 119 |
+
UNARY = 2
|
| 120 |
+
PRODUCT = 3
|
| 121 |
+
SUM = 4
|
| 122 |
+
LT = 6
|
| 123 |
+
EQ = 7
|
| 124 |
+
LAND = 11
|
| 125 |
+
LOR = 12
|
| 126 |
+
TERNARY = 13
|
| 127 |
+
ASSIGN = 14
|
| 128 |
+
TUPLE = 15
|
| 129 |
+
NONE = 100
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
integer_types = (int,)
|
| 133 |
+
number_types = (int, float)
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def _pairs_add(d, k, v):
|
| 137 |
+
# Internal utility method for updating terms and factors data.
|
| 138 |
+
c = d.get(k)
|
| 139 |
+
if c is None:
|
| 140 |
+
d[k] = v
|
| 141 |
+
else:
|
| 142 |
+
c = c + v
|
| 143 |
+
if c:
|
| 144 |
+
d[k] = c
|
| 145 |
+
else:
|
| 146 |
+
del d[k]
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
class ExprWarning(UserWarning):
|
| 150 |
+
pass
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def ewarn(message):
|
| 154 |
+
warnings.warn(message, ExprWarning, stacklevel=2)
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
class Expr:
|
| 158 |
+
"""Represents a Fortran expression as a op-data pair.
|
| 159 |
+
|
| 160 |
+
Expr instances are hashable and sortable.
|
| 161 |
+
"""
|
| 162 |
+
|
| 163 |
+
@staticmethod
|
| 164 |
+
def parse(s, language=Language.C):
|
| 165 |
+
"""Parse a Fortran expression to a Expr.
|
| 166 |
+
"""
|
| 167 |
+
return fromstring(s, language=language)
|
| 168 |
+
|
| 169 |
+
def __init__(self, op, data):
|
| 170 |
+
assert isinstance(op, Op)
|
| 171 |
+
|
| 172 |
+
# sanity checks
|
| 173 |
+
if op is Op.INTEGER:
|
| 174 |
+
# data is a 2-tuple of numeric object and a kind value
|
| 175 |
+
# (default is 4)
|
| 176 |
+
assert isinstance(data, tuple) and len(data) == 2
|
| 177 |
+
assert isinstance(data[0], int)
|
| 178 |
+
assert isinstance(data[1], (int, str)), data
|
| 179 |
+
elif op is Op.REAL:
|
| 180 |
+
# data is a 2-tuple of numeric object and a kind value
|
| 181 |
+
# (default is 4)
|
| 182 |
+
assert isinstance(data, tuple) and len(data) == 2
|
| 183 |
+
assert isinstance(data[0], float)
|
| 184 |
+
assert isinstance(data[1], (int, str)), data
|
| 185 |
+
elif op is Op.COMPLEX:
|
| 186 |
+
# data is a 2-tuple of constant expressions
|
| 187 |
+
assert isinstance(data, tuple) and len(data) == 2
|
| 188 |
+
elif op is Op.STRING:
|
| 189 |
+
# data is a 2-tuple of quoted string and a kind value
|
| 190 |
+
# (default is 1)
|
| 191 |
+
assert isinstance(data, tuple) and len(data) == 2
|
| 192 |
+
assert (isinstance(data[0], str)
|
| 193 |
+
and data[0][::len(data[0])-1] in ('""', "''", '@@'))
|
| 194 |
+
assert isinstance(data[1], (int, str)), data
|
| 195 |
+
elif op is Op.SYMBOL:
|
| 196 |
+
# data is any hashable object
|
| 197 |
+
assert hash(data) is not None
|
| 198 |
+
elif op in (Op.ARRAY, Op.CONCAT):
|
| 199 |
+
# data is a tuple of expressions
|
| 200 |
+
assert isinstance(data, tuple)
|
| 201 |
+
assert all(isinstance(item, Expr) for item in data), data
|
| 202 |
+
elif op in (Op.TERMS, Op.FACTORS):
|
| 203 |
+
# data is {<term|base>:<coeff|exponent>} where dict values
|
| 204 |
+
# are nonzero Python integers
|
| 205 |
+
assert isinstance(data, dict)
|
| 206 |
+
elif op is Op.APPLY:
|
| 207 |
+
# data is (<function>, <operands>, <kwoperands>) where
|
| 208 |
+
# operands are Expr instances
|
| 209 |
+
assert isinstance(data, tuple) and len(data) == 3
|
| 210 |
+
# function is any hashable object
|
| 211 |
+
assert hash(data[0]) is not None
|
| 212 |
+
assert isinstance(data[1], tuple)
|
| 213 |
+
assert isinstance(data[2], dict)
|
| 214 |
+
elif op is Op.INDEXING:
|
| 215 |
+
# data is (<object>, <indices>)
|
| 216 |
+
assert isinstance(data, tuple) and len(data) == 2
|
| 217 |
+
# function is any hashable object
|
| 218 |
+
assert hash(data[0]) is not None
|
| 219 |
+
elif op is Op.TERNARY:
|
| 220 |
+
# data is (<cond>, <expr1>, <expr2>)
|
| 221 |
+
assert isinstance(data, tuple) and len(data) == 3
|
| 222 |
+
elif op in (Op.REF, Op.DEREF):
|
| 223 |
+
# data is Expr instance
|
| 224 |
+
assert isinstance(data, Expr)
|
| 225 |
+
elif op is Op.RELATIONAL:
|
| 226 |
+
# data is (<relop>, <left>, <right>)
|
| 227 |
+
assert isinstance(data, tuple) and len(data) == 3
|
| 228 |
+
else:
|
| 229 |
+
raise NotImplementedError(
|
| 230 |
+
f'unknown op or missing sanity check: {op}')
|
| 231 |
+
|
| 232 |
+
self.op = op
|
| 233 |
+
self.data = data
|
| 234 |
+
|
| 235 |
+
def __eq__(self, other):
|
| 236 |
+
return (isinstance(other, Expr)
|
| 237 |
+
and self.op is other.op
|
| 238 |
+
and self.data == other.data)
|
| 239 |
+
|
| 240 |
+
def __hash__(self):
|
| 241 |
+
if self.op in (Op.TERMS, Op.FACTORS):
|
| 242 |
+
data = tuple(sorted(self.data.items()))
|
| 243 |
+
elif self.op is Op.APPLY:
|
| 244 |
+
data = self.data[:2] + tuple(sorted(self.data[2].items()))
|
| 245 |
+
else:
|
| 246 |
+
data = self.data
|
| 247 |
+
return hash((self.op, data))
|
| 248 |
+
|
| 249 |
+
def __lt__(self, other):
|
| 250 |
+
if isinstance(other, Expr):
|
| 251 |
+
if self.op is not other.op:
|
| 252 |
+
return self.op.value < other.op.value
|
| 253 |
+
if self.op in (Op.TERMS, Op.FACTORS):
|
| 254 |
+
return (tuple(sorted(self.data.items()))
|
| 255 |
+
< tuple(sorted(other.data.items())))
|
| 256 |
+
if self.op is Op.APPLY:
|
| 257 |
+
if self.data[:2] != other.data[:2]:
|
| 258 |
+
return self.data[:2] < other.data[:2]
|
| 259 |
+
return tuple(sorted(self.data[2].items())) < tuple(
|
| 260 |
+
sorted(other.data[2].items()))
|
| 261 |
+
return self.data < other.data
|
| 262 |
+
return NotImplemented
|
| 263 |
+
|
| 264 |
+
def __le__(self, other): return self == other or self < other
|
| 265 |
+
|
| 266 |
+
def __gt__(self, other): return not (self <= other)
|
| 267 |
+
|
| 268 |
+
def __ge__(self, other): return not (self < other)
|
| 269 |
+
|
| 270 |
+
def __repr__(self):
|
| 271 |
+
return f'{type(self).__name__}({self.op}, {self.data!r})'
|
| 272 |
+
|
| 273 |
+
def __str__(self):
|
| 274 |
+
return self.tostring()
|
| 275 |
+
|
| 276 |
+
def tostring(self, parent_precedence=Precedence.NONE,
|
| 277 |
+
language=Language.Fortran):
|
| 278 |
+
"""Return a string representation of Expr.
|
| 279 |
+
"""
|
| 280 |
+
if self.op in (Op.INTEGER, Op.REAL):
|
| 281 |
+
precedence = (Precedence.SUM if self.data[0] < 0
|
| 282 |
+
else Precedence.ATOM)
|
| 283 |
+
r = str(self.data[0]) + (f'_{self.data[1]}'
|
| 284 |
+
if self.data[1] != 4 else '')
|
| 285 |
+
elif self.op is Op.COMPLEX:
|
| 286 |
+
r = ', '.join(item.tostring(Precedence.TUPLE, language=language)
|
| 287 |
+
for item in self.data)
|
| 288 |
+
r = '(' + r + ')'
|
| 289 |
+
precedence = Precedence.ATOM
|
| 290 |
+
elif self.op is Op.SYMBOL:
|
| 291 |
+
precedence = Precedence.ATOM
|
| 292 |
+
r = str(self.data)
|
| 293 |
+
elif self.op is Op.STRING:
|
| 294 |
+
r = self.data[0]
|
| 295 |
+
if self.data[1] != 1:
|
| 296 |
+
r = self.data[1] + '_' + r
|
| 297 |
+
precedence = Precedence.ATOM
|
| 298 |
+
elif self.op is Op.ARRAY:
|
| 299 |
+
r = ', '.join(item.tostring(Precedence.TUPLE, language=language)
|
| 300 |
+
for item in self.data)
|
| 301 |
+
r = '[' + r + ']'
|
| 302 |
+
precedence = Precedence.ATOM
|
| 303 |
+
elif self.op is Op.TERMS:
|
| 304 |
+
terms = []
|
| 305 |
+
for term, coeff in sorted(self.data.items()):
|
| 306 |
+
if coeff < 0:
|
| 307 |
+
op = ' - '
|
| 308 |
+
coeff = -coeff
|
| 309 |
+
else:
|
| 310 |
+
op = ' + '
|
| 311 |
+
if coeff == 1:
|
| 312 |
+
term = term.tostring(Precedence.SUM, language=language)
|
| 313 |
+
else:
|
| 314 |
+
if term == as_number(1):
|
| 315 |
+
term = str(coeff)
|
| 316 |
+
else:
|
| 317 |
+
term = f'{coeff} * ' + term.tostring(
|
| 318 |
+
Precedence.PRODUCT, language=language)
|
| 319 |
+
if terms:
|
| 320 |
+
terms.append(op)
|
| 321 |
+
elif op == ' - ':
|
| 322 |
+
terms.append('-')
|
| 323 |
+
terms.append(term)
|
| 324 |
+
r = ''.join(terms) or '0'
|
| 325 |
+
precedence = Precedence.SUM if terms else Precedence.ATOM
|
| 326 |
+
elif self.op is Op.FACTORS:
|
| 327 |
+
factors = []
|
| 328 |
+
tail = []
|
| 329 |
+
for base, exp in sorted(self.data.items()):
|
| 330 |
+
op = ' * '
|
| 331 |
+
if exp == 1:
|
| 332 |
+
factor = base.tostring(Precedence.PRODUCT,
|
| 333 |
+
language=language)
|
| 334 |
+
elif language is Language.C:
|
| 335 |
+
if exp in range(2, 10):
|
| 336 |
+
factor = base.tostring(Precedence.PRODUCT,
|
| 337 |
+
language=language)
|
| 338 |
+
factor = ' * '.join([factor] * exp)
|
| 339 |
+
elif exp in range(-10, 0):
|
| 340 |
+
factor = base.tostring(Precedence.PRODUCT,
|
| 341 |
+
language=language)
|
| 342 |
+
tail += [factor] * -exp
|
| 343 |
+
continue
|
| 344 |
+
else:
|
| 345 |
+
factor = base.tostring(Precedence.TUPLE,
|
| 346 |
+
language=language)
|
| 347 |
+
factor = f'pow({factor}, {exp})'
|
| 348 |
+
else:
|
| 349 |
+
factor = base.tostring(Precedence.POWER,
|
| 350 |
+
language=language) + f' ** {exp}'
|
| 351 |
+
if factors:
|
| 352 |
+
factors.append(op)
|
| 353 |
+
factors.append(factor)
|
| 354 |
+
if tail:
|
| 355 |
+
if not factors:
|
| 356 |
+
factors += ['1']
|
| 357 |
+
factors += ['/', '(', ' * '.join(tail), ')']
|
| 358 |
+
r = ''.join(factors) or '1'
|
| 359 |
+
precedence = Precedence.PRODUCT if factors else Precedence.ATOM
|
| 360 |
+
elif self.op is Op.APPLY:
|
| 361 |
+
name, args, kwargs = self.data
|
| 362 |
+
if name is ArithOp.DIV and language is Language.C:
|
| 363 |
+
numer, denom = [arg.tostring(Precedence.PRODUCT,
|
| 364 |
+
language=language)
|
| 365 |
+
for arg in args]
|
| 366 |
+
r = f'{numer} / {denom}'
|
| 367 |
+
precedence = Precedence.PRODUCT
|
| 368 |
+
else:
|
| 369 |
+
args = [arg.tostring(Precedence.TUPLE, language=language)
|
| 370 |
+
for arg in args]
|
| 371 |
+
args += [k + '=' + v.tostring(Precedence.NONE)
|
| 372 |
+
for k, v in kwargs.items()]
|
| 373 |
+
r = f'{name}({", ".join(args)})'
|
| 374 |
+
precedence = Precedence.ATOM
|
| 375 |
+
elif self.op is Op.INDEXING:
|
| 376 |
+
name = self.data[0]
|
| 377 |
+
args = [arg.tostring(Precedence.TUPLE, language=language)
|
| 378 |
+
for arg in self.data[1:]]
|
| 379 |
+
r = f'{name}[{", ".join(args)}]'
|
| 380 |
+
precedence = Precedence.ATOM
|
| 381 |
+
elif self.op is Op.CONCAT:
|
| 382 |
+
args = [arg.tostring(Precedence.PRODUCT, language=language)
|
| 383 |
+
for arg in self.data]
|
| 384 |
+
r = " // ".join(args)
|
| 385 |
+
precedence = Precedence.PRODUCT
|
| 386 |
+
elif self.op is Op.TERNARY:
|
| 387 |
+
cond, expr1, expr2 = [a.tostring(Precedence.TUPLE,
|
| 388 |
+
language=language)
|
| 389 |
+
for a in self.data]
|
| 390 |
+
if language is Language.C:
|
| 391 |
+
r = f'({cond}?{expr1}:{expr2})'
|
| 392 |
+
elif language is Language.Python:
|
| 393 |
+
r = f'({expr1} if {cond} else {expr2})'
|
| 394 |
+
elif language is Language.Fortran:
|
| 395 |
+
r = f'merge({expr1}, {expr2}, {cond})'
|
| 396 |
+
else:
|
| 397 |
+
raise NotImplementedError(
|
| 398 |
+
f'tostring for {self.op} and {language}')
|
| 399 |
+
precedence = Precedence.ATOM
|
| 400 |
+
elif self.op is Op.REF:
|
| 401 |
+
r = '&' + self.data.tostring(Precedence.UNARY, language=language)
|
| 402 |
+
precedence = Precedence.UNARY
|
| 403 |
+
elif self.op is Op.DEREF:
|
| 404 |
+
r = '*' + self.data.tostring(Precedence.UNARY, language=language)
|
| 405 |
+
precedence = Precedence.UNARY
|
| 406 |
+
elif self.op is Op.RELATIONAL:
|
| 407 |
+
rop, left, right = self.data
|
| 408 |
+
precedence = (Precedence.EQ if rop in (RelOp.EQ, RelOp.NE)
|
| 409 |
+
else Precedence.LT)
|
| 410 |
+
left = left.tostring(precedence, language=language)
|
| 411 |
+
right = right.tostring(precedence, language=language)
|
| 412 |
+
rop = rop.tostring(language=language)
|
| 413 |
+
r = f'{left} {rop} {right}'
|
| 414 |
+
else:
|
| 415 |
+
raise NotImplementedError(f'tostring for op {self.op}')
|
| 416 |
+
if parent_precedence.value < precedence.value:
|
| 417 |
+
# If parent precedence is higher than operand precedence,
|
| 418 |
+
# operand will be enclosed in parenthesis.
|
| 419 |
+
return '(' + r + ')'
|
| 420 |
+
return r
|
| 421 |
+
|
| 422 |
+
def __pos__(self):
|
| 423 |
+
return self
|
| 424 |
+
|
| 425 |
+
def __neg__(self):
|
| 426 |
+
return self * -1
|
| 427 |
+
|
| 428 |
+
def __add__(self, other):
|
| 429 |
+
other = as_expr(other)
|
| 430 |
+
if isinstance(other, Expr):
|
| 431 |
+
if self.op is other.op:
|
| 432 |
+
if self.op in (Op.INTEGER, Op.REAL):
|
| 433 |
+
return as_number(
|
| 434 |
+
self.data[0] + other.data[0],
|
| 435 |
+
max(self.data[1], other.data[1]))
|
| 436 |
+
if self.op is Op.COMPLEX:
|
| 437 |
+
r1, i1 = self.data
|
| 438 |
+
r2, i2 = other.data
|
| 439 |
+
return as_complex(r1 + r2, i1 + i2)
|
| 440 |
+
if self.op is Op.TERMS:
|
| 441 |
+
r = Expr(self.op, dict(self.data))
|
| 442 |
+
for k, v in other.data.items():
|
| 443 |
+
_pairs_add(r.data, k, v)
|
| 444 |
+
return normalize(r)
|
| 445 |
+
if self.op is Op.COMPLEX and other.op in (Op.INTEGER, Op.REAL):
|
| 446 |
+
return self + as_complex(other)
|
| 447 |
+
elif self.op in (Op.INTEGER, Op.REAL) and other.op is Op.COMPLEX:
|
| 448 |
+
return as_complex(self) + other
|
| 449 |
+
elif self.op is Op.REAL and other.op is Op.INTEGER:
|
| 450 |
+
return self + as_real(other, kind=self.data[1])
|
| 451 |
+
elif self.op is Op.INTEGER and other.op is Op.REAL:
|
| 452 |
+
return as_real(self, kind=other.data[1]) + other
|
| 453 |
+
return as_terms(self) + as_terms(other)
|
| 454 |
+
return NotImplemented
|
| 455 |
+
|
| 456 |
+
def __radd__(self, other):
|
| 457 |
+
if isinstance(other, number_types):
|
| 458 |
+
return as_number(other) + self
|
| 459 |
+
return NotImplemented
|
| 460 |
+
|
| 461 |
+
def __sub__(self, other):
|
| 462 |
+
return self + (-other)
|
| 463 |
+
|
| 464 |
+
def __rsub__(self, other):
|
| 465 |
+
if isinstance(other, number_types):
|
| 466 |
+
return as_number(other) - self
|
| 467 |
+
return NotImplemented
|
| 468 |
+
|
| 469 |
+
def __mul__(self, other):
|
| 470 |
+
other = as_expr(other)
|
| 471 |
+
if isinstance(other, Expr):
|
| 472 |
+
if self.op is other.op:
|
| 473 |
+
if self.op in (Op.INTEGER, Op.REAL):
|
| 474 |
+
return as_number(self.data[0] * other.data[0],
|
| 475 |
+
max(self.data[1], other.data[1]))
|
| 476 |
+
elif self.op is Op.COMPLEX:
|
| 477 |
+
r1, i1 = self.data
|
| 478 |
+
r2, i2 = other.data
|
| 479 |
+
return as_complex(r1 * r2 - i1 * i2, r1 * i2 + r2 * i1)
|
| 480 |
+
|
| 481 |
+
if self.op is Op.FACTORS:
|
| 482 |
+
r = Expr(self.op, dict(self.data))
|
| 483 |
+
for k, v in other.data.items():
|
| 484 |
+
_pairs_add(r.data, k, v)
|
| 485 |
+
return normalize(r)
|
| 486 |
+
elif self.op is Op.TERMS:
|
| 487 |
+
r = Expr(self.op, {})
|
| 488 |
+
for t1, c1 in self.data.items():
|
| 489 |
+
for t2, c2 in other.data.items():
|
| 490 |
+
_pairs_add(r.data, t1 * t2, c1 * c2)
|
| 491 |
+
return normalize(r)
|
| 492 |
+
|
| 493 |
+
if self.op is Op.COMPLEX and other.op in (Op.INTEGER, Op.REAL):
|
| 494 |
+
return self * as_complex(other)
|
| 495 |
+
elif other.op is Op.COMPLEX and self.op in (Op.INTEGER, Op.REAL):
|
| 496 |
+
return as_complex(self) * other
|
| 497 |
+
elif self.op is Op.REAL and other.op is Op.INTEGER:
|
| 498 |
+
return self * as_real(other, kind=self.data[1])
|
| 499 |
+
elif self.op is Op.INTEGER and other.op is Op.REAL:
|
| 500 |
+
return as_real(self, kind=other.data[1]) * other
|
| 501 |
+
|
| 502 |
+
if self.op is Op.TERMS:
|
| 503 |
+
return self * as_terms(other)
|
| 504 |
+
elif other.op is Op.TERMS:
|
| 505 |
+
return as_terms(self) * other
|
| 506 |
+
|
| 507 |
+
return as_factors(self) * as_factors(other)
|
| 508 |
+
return NotImplemented
|
| 509 |
+
|
| 510 |
+
def __rmul__(self, other):
|
| 511 |
+
if isinstance(other, number_types):
|
| 512 |
+
return as_number(other) * self
|
| 513 |
+
return NotImplemented
|
| 514 |
+
|
| 515 |
+
def __pow__(self, other):
|
| 516 |
+
other = as_expr(other)
|
| 517 |
+
if isinstance(other, Expr):
|
| 518 |
+
if other.op is Op.INTEGER:
|
| 519 |
+
exponent = other.data[0]
|
| 520 |
+
# TODO: other kind not used
|
| 521 |
+
if exponent == 0:
|
| 522 |
+
return as_number(1)
|
| 523 |
+
if exponent == 1:
|
| 524 |
+
return self
|
| 525 |
+
if exponent > 0:
|
| 526 |
+
if self.op is Op.FACTORS:
|
| 527 |
+
r = Expr(self.op, {})
|
| 528 |
+
for k, v in self.data.items():
|
| 529 |
+
r.data[k] = v * exponent
|
| 530 |
+
return normalize(r)
|
| 531 |
+
return self * (self ** (exponent - 1))
|
| 532 |
+
elif exponent != -1:
|
| 533 |
+
return (self ** (-exponent)) ** -1
|
| 534 |
+
return Expr(Op.FACTORS, {self: exponent})
|
| 535 |
+
return as_apply(ArithOp.POW, self, other)
|
| 536 |
+
return NotImplemented
|
| 537 |
+
|
| 538 |
+
def __truediv__(self, other):
|
| 539 |
+
other = as_expr(other)
|
| 540 |
+
if isinstance(other, Expr):
|
| 541 |
+
# Fortran / is different from Python /:
|
| 542 |
+
# - `/` is a truncate operation for integer operands
|
| 543 |
+
return normalize(as_apply(ArithOp.DIV, self, other))
|
| 544 |
+
return NotImplemented
|
| 545 |
+
|
| 546 |
+
def __rtruediv__(self, other):
|
| 547 |
+
other = as_expr(other)
|
| 548 |
+
if isinstance(other, Expr):
|
| 549 |
+
return other / self
|
| 550 |
+
return NotImplemented
|
| 551 |
+
|
| 552 |
+
def __floordiv__(self, other):
|
| 553 |
+
other = as_expr(other)
|
| 554 |
+
if isinstance(other, Expr):
|
| 555 |
+
# Fortran // is different from Python //:
|
| 556 |
+
# - `//` is a concatenate operation for string operands
|
| 557 |
+
return normalize(Expr(Op.CONCAT, (self, other)))
|
| 558 |
+
return NotImplemented
|
| 559 |
+
|
| 560 |
+
def __rfloordiv__(self, other):
|
| 561 |
+
other = as_expr(other)
|
| 562 |
+
if isinstance(other, Expr):
|
| 563 |
+
return other // self
|
| 564 |
+
return NotImplemented
|
| 565 |
+
|
| 566 |
+
def __call__(self, *args, **kwargs):
|
| 567 |
+
# In Fortran, parenthesis () are use for both function call as
|
| 568 |
+
# well as indexing operations.
|
| 569 |
+
#
|
| 570 |
+
# TODO: implement a method for deciding when __call__ should
|
| 571 |
+
# return an INDEXING expression.
|
| 572 |
+
return as_apply(self, *map(as_expr, args),
|
| 573 |
+
**dict((k, as_expr(v)) for k, v in kwargs.items()))
|
| 574 |
+
|
| 575 |
+
def __getitem__(self, index):
|
| 576 |
+
# Provided to support C indexing operations that .pyf files
|
| 577 |
+
# may contain.
|
| 578 |
+
index = as_expr(index)
|
| 579 |
+
if not isinstance(index, tuple):
|
| 580 |
+
index = index,
|
| 581 |
+
if len(index) > 1:
|
| 582 |
+
ewarn(f'C-index should be a single expression but got `{index}`')
|
| 583 |
+
return Expr(Op.INDEXING, (self,) + index)
|
| 584 |
+
|
| 585 |
+
def substitute(self, symbols_map):
|
| 586 |
+
"""Recursively substitute symbols with values in symbols map.
|
| 587 |
+
|
| 588 |
+
Symbols map is a dictionary of symbol-expression pairs.
|
| 589 |
+
"""
|
| 590 |
+
if self.op is Op.SYMBOL:
|
| 591 |
+
value = symbols_map.get(self)
|
| 592 |
+
if value is None:
|
| 593 |
+
return self
|
| 594 |
+
m = re.match(r'\A(@__f2py_PARENTHESIS_(\w+)_\d+@)\Z', self.data)
|
| 595 |
+
if m:
|
| 596 |
+
# complement to fromstring method
|
| 597 |
+
items, paren = m.groups()
|
| 598 |
+
if paren in ['ROUNDDIV', 'SQUARE']:
|
| 599 |
+
return as_array(value)
|
| 600 |
+
assert paren == 'ROUND', (paren, value)
|
| 601 |
+
return value
|
| 602 |
+
if self.op in (Op.INTEGER, Op.REAL, Op.STRING):
|
| 603 |
+
return self
|
| 604 |
+
if self.op in (Op.ARRAY, Op.COMPLEX):
|
| 605 |
+
return Expr(self.op, tuple(item.substitute(symbols_map)
|
| 606 |
+
for item in self.data))
|
| 607 |
+
if self.op is Op.CONCAT:
|
| 608 |
+
return normalize(Expr(self.op, tuple(item.substitute(symbols_map)
|
| 609 |
+
for item in self.data)))
|
| 610 |
+
if self.op is Op.TERMS:
|
| 611 |
+
r = None
|
| 612 |
+
for term, coeff in self.data.items():
|
| 613 |
+
if r is None:
|
| 614 |
+
r = term.substitute(symbols_map) * coeff
|
| 615 |
+
else:
|
| 616 |
+
r += term.substitute(symbols_map) * coeff
|
| 617 |
+
if r is None:
|
| 618 |
+
ewarn('substitute: empty TERMS expression interpreted as'
|
| 619 |
+
' int-literal 0')
|
| 620 |
+
return as_number(0)
|
| 621 |
+
return r
|
| 622 |
+
if self.op is Op.FACTORS:
|
| 623 |
+
r = None
|
| 624 |
+
for base, exponent in self.data.items():
|
| 625 |
+
if r is None:
|
| 626 |
+
r = base.substitute(symbols_map) ** exponent
|
| 627 |
+
else:
|
| 628 |
+
r *= base.substitute(symbols_map) ** exponent
|
| 629 |
+
if r is None:
|
| 630 |
+
ewarn('substitute: empty FACTORS expression interpreted'
|
| 631 |
+
' as int-literal 1')
|
| 632 |
+
return as_number(1)
|
| 633 |
+
return r
|
| 634 |
+
if self.op is Op.APPLY:
|
| 635 |
+
target, args, kwargs = self.data
|
| 636 |
+
if isinstance(target, Expr):
|
| 637 |
+
target = target.substitute(symbols_map)
|
| 638 |
+
args = tuple(a.substitute(symbols_map) for a in args)
|
| 639 |
+
kwargs = dict((k, v.substitute(symbols_map))
|
| 640 |
+
for k, v in kwargs.items())
|
| 641 |
+
return normalize(Expr(self.op, (target, args, kwargs)))
|
| 642 |
+
if self.op is Op.INDEXING:
|
| 643 |
+
func = self.data[0]
|
| 644 |
+
if isinstance(func, Expr):
|
| 645 |
+
func = func.substitute(symbols_map)
|
| 646 |
+
args = tuple(a.substitute(symbols_map) for a in self.data[1:])
|
| 647 |
+
return normalize(Expr(self.op, (func,) + args))
|
| 648 |
+
if self.op is Op.TERNARY:
|
| 649 |
+
operands = tuple(a.substitute(symbols_map) for a in self.data)
|
| 650 |
+
return normalize(Expr(self.op, operands))
|
| 651 |
+
if self.op in (Op.REF, Op.DEREF):
|
| 652 |
+
return normalize(Expr(self.op, self.data.substitute(symbols_map)))
|
| 653 |
+
if self.op is Op.RELATIONAL:
|
| 654 |
+
rop, left, right = self.data
|
| 655 |
+
left = left.substitute(symbols_map)
|
| 656 |
+
right = right.substitute(symbols_map)
|
| 657 |
+
return normalize(Expr(self.op, (rop, left, right)))
|
| 658 |
+
raise NotImplementedError(f'substitute method for {self.op}: {self!r}')
|
| 659 |
+
|
| 660 |
+
def traverse(self, visit, *args, **kwargs):
|
| 661 |
+
"""Traverse expression tree with visit function.
|
| 662 |
+
|
| 663 |
+
The visit function is applied to an expression with given args
|
| 664 |
+
and kwargs.
|
| 665 |
+
|
| 666 |
+
Traverse call returns an expression returned by visit when not
|
| 667 |
+
None, otherwise return a new normalized expression with
|
| 668 |
+
traverse-visit sub-expressions.
|
| 669 |
+
"""
|
| 670 |
+
result = visit(self, *args, **kwargs)
|
| 671 |
+
if result is not None:
|
| 672 |
+
return result
|
| 673 |
+
|
| 674 |
+
if self.op in (Op.INTEGER, Op.REAL, Op.STRING, Op.SYMBOL):
|
| 675 |
+
return self
|
| 676 |
+
elif self.op in (Op.COMPLEX, Op.ARRAY, Op.CONCAT, Op.TERNARY):
|
| 677 |
+
return normalize(Expr(self.op, tuple(
|
| 678 |
+
item.traverse(visit, *args, **kwargs)
|
| 679 |
+
for item in self.data)))
|
| 680 |
+
elif self.op in (Op.TERMS, Op.FACTORS):
|
| 681 |
+
data = {}
|
| 682 |
+
for k, v in self.data.items():
|
| 683 |
+
k = k.traverse(visit, *args, **kwargs)
|
| 684 |
+
v = (v.traverse(visit, *args, **kwargs)
|
| 685 |
+
if isinstance(v, Expr) else v)
|
| 686 |
+
if k in data:
|
| 687 |
+
v = data[k] + v
|
| 688 |
+
data[k] = v
|
| 689 |
+
return normalize(Expr(self.op, data))
|
| 690 |
+
elif self.op is Op.APPLY:
|
| 691 |
+
obj = self.data[0]
|
| 692 |
+
func = (obj.traverse(visit, *args, **kwargs)
|
| 693 |
+
if isinstance(obj, Expr) else obj)
|
| 694 |
+
operands = tuple(operand.traverse(visit, *args, **kwargs)
|
| 695 |
+
for operand in self.data[1])
|
| 696 |
+
kwoperands = dict((k, v.traverse(visit, *args, **kwargs))
|
| 697 |
+
for k, v in self.data[2].items())
|
| 698 |
+
return normalize(Expr(self.op, (func, operands, kwoperands)))
|
| 699 |
+
elif self.op is Op.INDEXING:
|
| 700 |
+
obj = self.data[0]
|
| 701 |
+
obj = (obj.traverse(visit, *args, **kwargs)
|
| 702 |
+
if isinstance(obj, Expr) else obj)
|
| 703 |
+
indices = tuple(index.traverse(visit, *args, **kwargs)
|
| 704 |
+
for index in self.data[1:])
|
| 705 |
+
return normalize(Expr(self.op, (obj,) + indices))
|
| 706 |
+
elif self.op in (Op.REF, Op.DEREF):
|
| 707 |
+
return normalize(Expr(self.op,
|
| 708 |
+
self.data.traverse(visit, *args, **kwargs)))
|
| 709 |
+
elif self.op is Op.RELATIONAL:
|
| 710 |
+
rop, left, right = self.data
|
| 711 |
+
left = left.traverse(visit, *args, **kwargs)
|
| 712 |
+
right = right.traverse(visit, *args, **kwargs)
|
| 713 |
+
return normalize(Expr(self.op, (rop, left, right)))
|
| 714 |
+
raise NotImplementedError(f'traverse method for {self.op}')
|
| 715 |
+
|
| 716 |
+
def contains(self, other):
|
| 717 |
+
"""Check if self contains other.
|
| 718 |
+
"""
|
| 719 |
+
found = []
|
| 720 |
+
|
| 721 |
+
def visit(expr, found=found):
|
| 722 |
+
if found:
|
| 723 |
+
return expr
|
| 724 |
+
elif expr == other:
|
| 725 |
+
found.append(1)
|
| 726 |
+
return expr
|
| 727 |
+
|
| 728 |
+
self.traverse(visit)
|
| 729 |
+
|
| 730 |
+
return len(found) != 0
|
| 731 |
+
|
| 732 |
+
def symbols(self):
|
| 733 |
+
"""Return a set of symbols contained in self.
|
| 734 |
+
"""
|
| 735 |
+
found = set()
|
| 736 |
+
|
| 737 |
+
def visit(expr, found=found):
|
| 738 |
+
if expr.op is Op.SYMBOL:
|
| 739 |
+
found.add(expr)
|
| 740 |
+
|
| 741 |
+
self.traverse(visit)
|
| 742 |
+
|
| 743 |
+
return found
|
| 744 |
+
|
| 745 |
+
def polynomial_atoms(self):
|
| 746 |
+
"""Return a set of expressions used as atoms in polynomial self.
|
| 747 |
+
"""
|
| 748 |
+
found = set()
|
| 749 |
+
|
| 750 |
+
def visit(expr, found=found):
|
| 751 |
+
if expr.op is Op.FACTORS:
|
| 752 |
+
for b in expr.data:
|
| 753 |
+
b.traverse(visit)
|
| 754 |
+
return expr
|
| 755 |
+
if expr.op in (Op.TERMS, Op.COMPLEX):
|
| 756 |
+
return
|
| 757 |
+
if expr.op is Op.APPLY and isinstance(expr.data[0], ArithOp):
|
| 758 |
+
if expr.data[0] is ArithOp.POW:
|
| 759 |
+
expr.data[1][0].traverse(visit)
|
| 760 |
+
return expr
|
| 761 |
+
return
|
| 762 |
+
if expr.op in (Op.INTEGER, Op.REAL):
|
| 763 |
+
return expr
|
| 764 |
+
|
| 765 |
+
found.add(expr)
|
| 766 |
+
|
| 767 |
+
if expr.op in (Op.INDEXING, Op.APPLY):
|
| 768 |
+
return expr
|
| 769 |
+
|
| 770 |
+
self.traverse(visit)
|
| 771 |
+
|
| 772 |
+
return found
|
| 773 |
+
|
| 774 |
+
def linear_solve(self, symbol):
|
| 775 |
+
"""Return a, b such that a * symbol + b == self.
|
| 776 |
+
|
| 777 |
+
If self is not linear with respect to symbol, raise RuntimeError.
|
| 778 |
+
"""
|
| 779 |
+
b = self.substitute({symbol: as_number(0)})
|
| 780 |
+
ax = self - b
|
| 781 |
+
a = ax.substitute({symbol: as_number(1)})
|
| 782 |
+
|
| 783 |
+
zero, _ = as_numer_denom(a * symbol - ax)
|
| 784 |
+
|
| 785 |
+
if zero != as_number(0):
|
| 786 |
+
raise RuntimeError(f'not a {symbol}-linear equation:'
|
| 787 |
+
f' {a} * {symbol} + {b} == {self}')
|
| 788 |
+
return a, b
|
| 789 |
+
|
| 790 |
+
|
| 791 |
+
def normalize(obj):
|
| 792 |
+
"""Normalize Expr and apply basic evaluation methods.
|
| 793 |
+
"""
|
| 794 |
+
if not isinstance(obj, Expr):
|
| 795 |
+
return obj
|
| 796 |
+
|
| 797 |
+
if obj.op is Op.TERMS:
|
| 798 |
+
d = {}
|
| 799 |
+
for t, c in obj.data.items():
|
| 800 |
+
if c == 0:
|
| 801 |
+
continue
|
| 802 |
+
if t.op is Op.COMPLEX and c != 1:
|
| 803 |
+
t = t * c
|
| 804 |
+
c = 1
|
| 805 |
+
if t.op is Op.TERMS:
|
| 806 |
+
for t1, c1 in t.data.items():
|
| 807 |
+
_pairs_add(d, t1, c1 * c)
|
| 808 |
+
else:
|
| 809 |
+
_pairs_add(d, t, c)
|
| 810 |
+
if len(d) == 0:
|
| 811 |
+
# TODO: determine correct kind
|
| 812 |
+
return as_number(0)
|
| 813 |
+
elif len(d) == 1:
|
| 814 |
+
(t, c), = d.items()
|
| 815 |
+
if c == 1:
|
| 816 |
+
return t
|
| 817 |
+
return Expr(Op.TERMS, d)
|
| 818 |
+
|
| 819 |
+
if obj.op is Op.FACTORS:
|
| 820 |
+
coeff = 1
|
| 821 |
+
d = {}
|
| 822 |
+
for b, e in obj.data.items():
|
| 823 |
+
if e == 0:
|
| 824 |
+
continue
|
| 825 |
+
if b.op is Op.TERMS and isinstance(e, integer_types) and e > 1:
|
| 826 |
+
# expand integer powers of sums
|
| 827 |
+
b = b * (b ** (e - 1))
|
| 828 |
+
e = 1
|
| 829 |
+
|
| 830 |
+
if b.op in (Op.INTEGER, Op.REAL):
|
| 831 |
+
if e == 1:
|
| 832 |
+
coeff *= b.data[0]
|
| 833 |
+
elif e > 0:
|
| 834 |
+
coeff *= b.data[0] ** e
|
| 835 |
+
else:
|
| 836 |
+
_pairs_add(d, b, e)
|
| 837 |
+
elif b.op is Op.FACTORS:
|
| 838 |
+
if e > 0 and isinstance(e, integer_types):
|
| 839 |
+
for b1, e1 in b.data.items():
|
| 840 |
+
_pairs_add(d, b1, e1 * e)
|
| 841 |
+
else:
|
| 842 |
+
_pairs_add(d, b, e)
|
| 843 |
+
else:
|
| 844 |
+
_pairs_add(d, b, e)
|
| 845 |
+
if len(d) == 0 or coeff == 0:
|
| 846 |
+
# TODO: determine correct kind
|
| 847 |
+
assert isinstance(coeff, number_types)
|
| 848 |
+
return as_number(coeff)
|
| 849 |
+
elif len(d) == 1:
|
| 850 |
+
(b, e), = d.items()
|
| 851 |
+
if e == 1:
|
| 852 |
+
t = b
|
| 853 |
+
else:
|
| 854 |
+
t = Expr(Op.FACTORS, d)
|
| 855 |
+
if coeff == 1:
|
| 856 |
+
return t
|
| 857 |
+
return Expr(Op.TERMS, {t: coeff})
|
| 858 |
+
elif coeff == 1:
|
| 859 |
+
return Expr(Op.FACTORS, d)
|
| 860 |
+
else:
|
| 861 |
+
return Expr(Op.TERMS, {Expr(Op.FACTORS, d): coeff})
|
| 862 |
+
|
| 863 |
+
if obj.op is Op.APPLY and obj.data[0] is ArithOp.DIV:
|
| 864 |
+
dividend, divisor = obj.data[1]
|
| 865 |
+
t1, c1 = as_term_coeff(dividend)
|
| 866 |
+
t2, c2 = as_term_coeff(divisor)
|
| 867 |
+
if isinstance(c1, integer_types) and isinstance(c2, integer_types):
|
| 868 |
+
g = gcd(c1, c2)
|
| 869 |
+
c1, c2 = c1//g, c2//g
|
| 870 |
+
else:
|
| 871 |
+
c1, c2 = c1/c2, 1
|
| 872 |
+
|
| 873 |
+
if t1.op is Op.APPLY and t1.data[0] is ArithOp.DIV:
|
| 874 |
+
numer = t1.data[1][0] * c1
|
| 875 |
+
denom = t1.data[1][1] * t2 * c2
|
| 876 |
+
return as_apply(ArithOp.DIV, numer, denom)
|
| 877 |
+
|
| 878 |
+
if t2.op is Op.APPLY and t2.data[0] is ArithOp.DIV:
|
| 879 |
+
numer = t2.data[1][1] * t1 * c1
|
| 880 |
+
denom = t2.data[1][0] * c2
|
| 881 |
+
return as_apply(ArithOp.DIV, numer, denom)
|
| 882 |
+
|
| 883 |
+
d = dict(as_factors(t1).data)
|
| 884 |
+
for b, e in as_factors(t2).data.items():
|
| 885 |
+
_pairs_add(d, b, -e)
|
| 886 |
+
numer, denom = {}, {}
|
| 887 |
+
for b, e in d.items():
|
| 888 |
+
if e > 0:
|
| 889 |
+
numer[b] = e
|
| 890 |
+
else:
|
| 891 |
+
denom[b] = -e
|
| 892 |
+
numer = normalize(Expr(Op.FACTORS, numer)) * c1
|
| 893 |
+
denom = normalize(Expr(Op.FACTORS, denom)) * c2
|
| 894 |
+
|
| 895 |
+
if denom.op in (Op.INTEGER, Op.REAL) and denom.data[0] == 1:
|
| 896 |
+
# TODO: denom kind not used
|
| 897 |
+
return numer
|
| 898 |
+
return as_apply(ArithOp.DIV, numer, denom)
|
| 899 |
+
|
| 900 |
+
if obj.op is Op.CONCAT:
|
| 901 |
+
lst = [obj.data[0]]
|
| 902 |
+
for s in obj.data[1:]:
|
| 903 |
+
last = lst[-1]
|
| 904 |
+
if (
|
| 905 |
+
last.op is Op.STRING
|
| 906 |
+
and s.op is Op.STRING
|
| 907 |
+
and last.data[0][0] in '"\''
|
| 908 |
+
and s.data[0][0] == last.data[0][-1]
|
| 909 |
+
):
|
| 910 |
+
new_last = as_string(last.data[0][:-1] + s.data[0][1:],
|
| 911 |
+
max(last.data[1], s.data[1]))
|
| 912 |
+
lst[-1] = new_last
|
| 913 |
+
else:
|
| 914 |
+
lst.append(s)
|
| 915 |
+
if len(lst) == 1:
|
| 916 |
+
return lst[0]
|
| 917 |
+
return Expr(Op.CONCAT, tuple(lst))
|
| 918 |
+
|
| 919 |
+
if obj.op is Op.TERNARY:
|
| 920 |
+
cond, expr1, expr2 = map(normalize, obj.data)
|
| 921 |
+
if cond.op is Op.INTEGER:
|
| 922 |
+
return expr1 if cond.data[0] else expr2
|
| 923 |
+
return Expr(Op.TERNARY, (cond, expr1, expr2))
|
| 924 |
+
|
| 925 |
+
return obj
|
| 926 |
+
|
| 927 |
+
|
| 928 |
+
def as_expr(obj):
|
| 929 |
+
"""Convert non-Expr objects to Expr objects.
|
| 930 |
+
"""
|
| 931 |
+
if isinstance(obj, complex):
|
| 932 |
+
return as_complex(obj.real, obj.imag)
|
| 933 |
+
if isinstance(obj, number_types):
|
| 934 |
+
return as_number(obj)
|
| 935 |
+
if isinstance(obj, str):
|
| 936 |
+
# STRING expression holds string with boundary quotes, hence
|
| 937 |
+
# applying repr:
|
| 938 |
+
return as_string(repr(obj))
|
| 939 |
+
if isinstance(obj, tuple):
|
| 940 |
+
return tuple(map(as_expr, obj))
|
| 941 |
+
return obj
|
| 942 |
+
|
| 943 |
+
|
| 944 |
+
def as_symbol(obj):
|
| 945 |
+
"""Return object as SYMBOL expression (variable or unparsed expression).
|
| 946 |
+
"""
|
| 947 |
+
return Expr(Op.SYMBOL, obj)
|
| 948 |
+
|
| 949 |
+
|
| 950 |
+
def as_number(obj, kind=4):
|
| 951 |
+
"""Return object as INTEGER or REAL constant.
|
| 952 |
+
"""
|
| 953 |
+
if isinstance(obj, int):
|
| 954 |
+
return Expr(Op.INTEGER, (obj, kind))
|
| 955 |
+
if isinstance(obj, float):
|
| 956 |
+
return Expr(Op.REAL, (obj, kind))
|
| 957 |
+
if isinstance(obj, Expr):
|
| 958 |
+
if obj.op in (Op.INTEGER, Op.REAL):
|
| 959 |
+
return obj
|
| 960 |
+
raise OpError(f'cannot convert {obj} to INTEGER or REAL constant')
|
| 961 |
+
|
| 962 |
+
|
| 963 |
+
def as_integer(obj, kind=4):
|
| 964 |
+
"""Return object as INTEGER constant.
|
| 965 |
+
"""
|
| 966 |
+
if isinstance(obj, int):
|
| 967 |
+
return Expr(Op.INTEGER, (obj, kind))
|
| 968 |
+
if isinstance(obj, Expr):
|
| 969 |
+
if obj.op is Op.INTEGER:
|
| 970 |
+
return obj
|
| 971 |
+
raise OpError(f'cannot convert {obj} to INTEGER constant')
|
| 972 |
+
|
| 973 |
+
|
| 974 |
+
def as_real(obj, kind=4):
|
| 975 |
+
"""Return object as REAL constant.
|
| 976 |
+
"""
|
| 977 |
+
if isinstance(obj, int):
|
| 978 |
+
return Expr(Op.REAL, (float(obj), kind))
|
| 979 |
+
if isinstance(obj, float):
|
| 980 |
+
return Expr(Op.REAL, (obj, kind))
|
| 981 |
+
if isinstance(obj, Expr):
|
| 982 |
+
if obj.op is Op.REAL:
|
| 983 |
+
return obj
|
| 984 |
+
elif obj.op is Op.INTEGER:
|
| 985 |
+
return Expr(Op.REAL, (float(obj.data[0]), kind))
|
| 986 |
+
raise OpError(f'cannot convert {obj} to REAL constant')
|
| 987 |
+
|
| 988 |
+
|
| 989 |
+
def as_string(obj, kind=1):
|
| 990 |
+
"""Return object as STRING expression (string literal constant).
|
| 991 |
+
"""
|
| 992 |
+
return Expr(Op.STRING, (obj, kind))
|
| 993 |
+
|
| 994 |
+
|
| 995 |
+
def as_array(obj):
|
| 996 |
+
"""Return object as ARRAY expression (array constant).
|
| 997 |
+
"""
|
| 998 |
+
if isinstance(obj, Expr):
|
| 999 |
+
obj = obj,
|
| 1000 |
+
return Expr(Op.ARRAY, obj)
|
| 1001 |
+
|
| 1002 |
+
|
| 1003 |
+
def as_complex(real, imag=0):
|
| 1004 |
+
"""Return object as COMPLEX expression (complex literal constant).
|
| 1005 |
+
"""
|
| 1006 |
+
return Expr(Op.COMPLEX, (as_expr(real), as_expr(imag)))
|
| 1007 |
+
|
| 1008 |
+
|
| 1009 |
+
def as_apply(func, *args, **kwargs):
|
| 1010 |
+
"""Return object as APPLY expression (function call, constructor, etc.)
|
| 1011 |
+
"""
|
| 1012 |
+
return Expr(Op.APPLY,
|
| 1013 |
+
(func, tuple(map(as_expr, args)),
|
| 1014 |
+
dict((k, as_expr(v)) for k, v in kwargs.items())))
|
| 1015 |
+
|
| 1016 |
+
|
| 1017 |
+
def as_ternary(cond, expr1, expr2):
|
| 1018 |
+
"""Return object as TERNARY expression (cond?expr1:expr2).
|
| 1019 |
+
"""
|
| 1020 |
+
return Expr(Op.TERNARY, (cond, expr1, expr2))
|
| 1021 |
+
|
| 1022 |
+
|
| 1023 |
+
def as_ref(expr):
|
| 1024 |
+
"""Return object as referencing expression.
|
| 1025 |
+
"""
|
| 1026 |
+
return Expr(Op.REF, expr)
|
| 1027 |
+
|
| 1028 |
+
|
| 1029 |
+
def as_deref(expr):
|
| 1030 |
+
"""Return object as dereferencing expression.
|
| 1031 |
+
"""
|
| 1032 |
+
return Expr(Op.DEREF, expr)
|
| 1033 |
+
|
| 1034 |
+
|
| 1035 |
+
def as_eq(left, right):
|
| 1036 |
+
return Expr(Op.RELATIONAL, (RelOp.EQ, left, right))
|
| 1037 |
+
|
| 1038 |
+
|
| 1039 |
+
def as_ne(left, right):
|
| 1040 |
+
return Expr(Op.RELATIONAL, (RelOp.NE, left, right))
|
| 1041 |
+
|
| 1042 |
+
|
| 1043 |
+
def as_lt(left, right):
|
| 1044 |
+
return Expr(Op.RELATIONAL, (RelOp.LT, left, right))
|
| 1045 |
+
|
| 1046 |
+
|
| 1047 |
+
def as_le(left, right):
|
| 1048 |
+
return Expr(Op.RELATIONAL, (RelOp.LE, left, right))
|
| 1049 |
+
|
| 1050 |
+
|
| 1051 |
+
def as_gt(left, right):
|
| 1052 |
+
return Expr(Op.RELATIONAL, (RelOp.GT, left, right))
|
| 1053 |
+
|
| 1054 |
+
|
| 1055 |
+
def as_ge(left, right):
|
| 1056 |
+
return Expr(Op.RELATIONAL, (RelOp.GE, left, right))
|
| 1057 |
+
|
| 1058 |
+
|
| 1059 |
+
def as_terms(obj):
|
| 1060 |
+
"""Return expression as TERMS expression.
|
| 1061 |
+
"""
|
| 1062 |
+
if isinstance(obj, Expr):
|
| 1063 |
+
obj = normalize(obj)
|
| 1064 |
+
if obj.op is Op.TERMS:
|
| 1065 |
+
return obj
|
| 1066 |
+
if obj.op is Op.INTEGER:
|
| 1067 |
+
return Expr(Op.TERMS, {as_integer(1, obj.data[1]): obj.data[0]})
|
| 1068 |
+
if obj.op is Op.REAL:
|
| 1069 |
+
return Expr(Op.TERMS, {as_real(1, obj.data[1]): obj.data[0]})
|
| 1070 |
+
return Expr(Op.TERMS, {obj: 1})
|
| 1071 |
+
raise OpError(f'cannot convert {type(obj)} to terms Expr')
|
| 1072 |
+
|
| 1073 |
+
|
| 1074 |
+
def as_factors(obj):
|
| 1075 |
+
"""Return expression as FACTORS expression.
|
| 1076 |
+
"""
|
| 1077 |
+
if isinstance(obj, Expr):
|
| 1078 |
+
obj = normalize(obj)
|
| 1079 |
+
if obj.op is Op.FACTORS:
|
| 1080 |
+
return obj
|
| 1081 |
+
if obj.op is Op.TERMS:
|
| 1082 |
+
if len(obj.data) == 1:
|
| 1083 |
+
(term, coeff), = obj.data.items()
|
| 1084 |
+
if coeff == 1:
|
| 1085 |
+
return Expr(Op.FACTORS, {term: 1})
|
| 1086 |
+
return Expr(Op.FACTORS, {term: 1, Expr.number(coeff): 1})
|
| 1087 |
+
if ((obj.op is Op.APPLY
|
| 1088 |
+
and obj.data[0] is ArithOp.DIV
|
| 1089 |
+
and not obj.data[2])):
|
| 1090 |
+
return Expr(Op.FACTORS, {obj.data[1][0]: 1, obj.data[1][1]: -1})
|
| 1091 |
+
return Expr(Op.FACTORS, {obj: 1})
|
| 1092 |
+
raise OpError(f'cannot convert {type(obj)} to terms Expr')
|
| 1093 |
+
|
| 1094 |
+
|
| 1095 |
+
def as_term_coeff(obj):
|
| 1096 |
+
"""Return expression as term-coefficient pair.
|
| 1097 |
+
"""
|
| 1098 |
+
if isinstance(obj, Expr):
|
| 1099 |
+
obj = normalize(obj)
|
| 1100 |
+
if obj.op is Op.INTEGER:
|
| 1101 |
+
return as_integer(1, obj.data[1]), obj.data[0]
|
| 1102 |
+
if obj.op is Op.REAL:
|
| 1103 |
+
return as_real(1, obj.data[1]), obj.data[0]
|
| 1104 |
+
if obj.op is Op.TERMS:
|
| 1105 |
+
if len(obj.data) == 1:
|
| 1106 |
+
(term, coeff), = obj.data.items()
|
| 1107 |
+
return term, coeff
|
| 1108 |
+
# TODO: find common divisor of coefficients
|
| 1109 |
+
if obj.op is Op.APPLY and obj.data[0] is ArithOp.DIV:
|
| 1110 |
+
t, c = as_term_coeff(obj.data[1][0])
|
| 1111 |
+
return as_apply(ArithOp.DIV, t, obj.data[1][1]), c
|
| 1112 |
+
return obj, 1
|
| 1113 |
+
raise OpError(f'cannot convert {type(obj)} to term and coeff')
|
| 1114 |
+
|
| 1115 |
+
|
| 1116 |
+
def as_numer_denom(obj):
|
| 1117 |
+
"""Return expression as numer-denom pair.
|
| 1118 |
+
"""
|
| 1119 |
+
if isinstance(obj, Expr):
|
| 1120 |
+
obj = normalize(obj)
|
| 1121 |
+
if obj.op in (Op.INTEGER, Op.REAL, Op.COMPLEX, Op.SYMBOL,
|
| 1122 |
+
Op.INDEXING, Op.TERNARY):
|
| 1123 |
+
return obj, as_number(1)
|
| 1124 |
+
elif obj.op is Op.APPLY:
|
| 1125 |
+
if obj.data[0] is ArithOp.DIV and not obj.data[2]:
|
| 1126 |
+
numers, denoms = map(as_numer_denom, obj.data[1])
|
| 1127 |
+
return numers[0] * denoms[1], numers[1] * denoms[0]
|
| 1128 |
+
return obj, as_number(1)
|
| 1129 |
+
elif obj.op is Op.TERMS:
|
| 1130 |
+
numers, denoms = [], []
|
| 1131 |
+
for term, coeff in obj.data.items():
|
| 1132 |
+
n, d = as_numer_denom(term)
|
| 1133 |
+
n = n * coeff
|
| 1134 |
+
numers.append(n)
|
| 1135 |
+
denoms.append(d)
|
| 1136 |
+
numer, denom = as_number(0), as_number(1)
|
| 1137 |
+
for i in range(len(numers)):
|
| 1138 |
+
n = numers[i]
|
| 1139 |
+
for j in range(len(numers)):
|
| 1140 |
+
if i != j:
|
| 1141 |
+
n *= denoms[j]
|
| 1142 |
+
numer += n
|
| 1143 |
+
denom *= denoms[i]
|
| 1144 |
+
if denom.op in (Op.INTEGER, Op.REAL) and denom.data[0] < 0:
|
| 1145 |
+
numer, denom = -numer, -denom
|
| 1146 |
+
return numer, denom
|
| 1147 |
+
elif obj.op is Op.FACTORS:
|
| 1148 |
+
numer, denom = as_number(1), as_number(1)
|
| 1149 |
+
for b, e in obj.data.items():
|
| 1150 |
+
bnumer, bdenom = as_numer_denom(b)
|
| 1151 |
+
if e > 0:
|
| 1152 |
+
numer *= bnumer ** e
|
| 1153 |
+
denom *= bdenom ** e
|
| 1154 |
+
elif e < 0:
|
| 1155 |
+
numer *= bdenom ** (-e)
|
| 1156 |
+
denom *= bnumer ** (-e)
|
| 1157 |
+
return numer, denom
|
| 1158 |
+
raise OpError(f'cannot convert {type(obj)} to numer and denom')
|
| 1159 |
+
|
| 1160 |
+
|
| 1161 |
+
def _counter():
|
| 1162 |
+
# Used internally to generate unique dummy symbols
|
| 1163 |
+
counter = 0
|
| 1164 |
+
while True:
|
| 1165 |
+
counter += 1
|
| 1166 |
+
yield counter
|
| 1167 |
+
|
| 1168 |
+
|
| 1169 |
+
COUNTER = _counter()
|
| 1170 |
+
|
| 1171 |
+
|
| 1172 |
+
def eliminate_quotes(s):
|
| 1173 |
+
"""Replace quoted substrings of input string.
|
| 1174 |
+
|
| 1175 |
+
Return a new string and a mapping of replacements.
|
| 1176 |
+
"""
|
| 1177 |
+
d = {}
|
| 1178 |
+
|
| 1179 |
+
def repl(m):
|
| 1180 |
+
kind, value = m.groups()[:2]
|
| 1181 |
+
if kind:
|
| 1182 |
+
# remove trailing underscore
|
| 1183 |
+
kind = kind[:-1]
|
| 1184 |
+
p = {"'": "SINGLE", '"': "DOUBLE"}[value[0]]
|
| 1185 |
+
k = f'{kind}@__f2py_QUOTES_{p}_{COUNTER.__next__()}@'
|
| 1186 |
+
d[k] = value
|
| 1187 |
+
return k
|
| 1188 |
+
|
| 1189 |
+
new_s = re.sub(r'({kind}_|)({single_quoted}|{double_quoted})'.format(
|
| 1190 |
+
kind=r'\w[\w\d_]*',
|
| 1191 |
+
single_quoted=r"('([^'\\]|(\\.))*')",
|
| 1192 |
+
double_quoted=r'("([^"\\]|(\\.))*")'),
|
| 1193 |
+
repl, s)
|
| 1194 |
+
|
| 1195 |
+
assert '"' not in new_s
|
| 1196 |
+
assert "'" not in new_s
|
| 1197 |
+
|
| 1198 |
+
return new_s, d
|
| 1199 |
+
|
| 1200 |
+
|
| 1201 |
+
def insert_quotes(s, d):
|
| 1202 |
+
"""Inverse of eliminate_quotes.
|
| 1203 |
+
"""
|
| 1204 |
+
for k, v in d.items():
|
| 1205 |
+
kind = k[:k.find('@')]
|
| 1206 |
+
if kind:
|
| 1207 |
+
kind += '_'
|
| 1208 |
+
s = s.replace(k, kind + v)
|
| 1209 |
+
return s
|
| 1210 |
+
|
| 1211 |
+
|
| 1212 |
+
def replace_parenthesis(s):
|
| 1213 |
+
"""Replace substrings of input that are enclosed in parenthesis.
|
| 1214 |
+
|
| 1215 |
+
Return a new string and a mapping of replacements.
|
| 1216 |
+
"""
|
| 1217 |
+
# Find a parenthesis pair that appears first.
|
| 1218 |
+
|
| 1219 |
+
# Fortran deliminator are `(`, `)`, `[`, `]`, `(/', '/)`, `/`.
|
| 1220 |
+
# We don't handle `/` deliminator because it is not a part of an
|
| 1221 |
+
# expression.
|
| 1222 |
+
left, right = None, None
|
| 1223 |
+
mn_i = len(s)
|
| 1224 |
+
for left_, right_ in (('(/', '/)'),
|
| 1225 |
+
'()',
|
| 1226 |
+
'{}', # to support C literal structs
|
| 1227 |
+
'[]'):
|
| 1228 |
+
i = s.find(left_)
|
| 1229 |
+
if i == -1:
|
| 1230 |
+
continue
|
| 1231 |
+
if i < mn_i:
|
| 1232 |
+
mn_i = i
|
| 1233 |
+
left, right = left_, right_
|
| 1234 |
+
|
| 1235 |
+
if left is None:
|
| 1236 |
+
return s, {}
|
| 1237 |
+
|
| 1238 |
+
i = mn_i
|
| 1239 |
+
j = s.find(right, i)
|
| 1240 |
+
|
| 1241 |
+
while s.count(left, i + 1, j) != s.count(right, i + 1, j):
|
| 1242 |
+
j = s.find(right, j + 1)
|
| 1243 |
+
if j == -1:
|
| 1244 |
+
raise ValueError(f'Mismatch of {left+right} parenthesis in {s!r}')
|
| 1245 |
+
|
| 1246 |
+
p = {'(': 'ROUND', '[': 'SQUARE', '{': 'CURLY', '(/': 'ROUNDDIV'}[left]
|
| 1247 |
+
|
| 1248 |
+
k = f'@__f2py_PARENTHESIS_{p}_{COUNTER.__next__()}@'
|
| 1249 |
+
v = s[i+len(left):j]
|
| 1250 |
+
r, d = replace_parenthesis(s[j+len(right):])
|
| 1251 |
+
d[k] = v
|
| 1252 |
+
return s[:i] + k + r, d
|
| 1253 |
+
|
| 1254 |
+
|
| 1255 |
+
def _get_parenthesis_kind(s):
|
| 1256 |
+
assert s.startswith('@__f2py_PARENTHESIS_'), s
|
| 1257 |
+
return s.split('_')[4]
|
| 1258 |
+
|
| 1259 |
+
|
| 1260 |
+
def unreplace_parenthesis(s, d):
|
| 1261 |
+
"""Inverse of replace_parenthesis.
|
| 1262 |
+
"""
|
| 1263 |
+
for k, v in d.items():
|
| 1264 |
+
p = _get_parenthesis_kind(k)
|
| 1265 |
+
left = dict(ROUND='(', SQUARE='[', CURLY='{', ROUNDDIV='(/')[p]
|
| 1266 |
+
right = dict(ROUND=')', SQUARE=']', CURLY='}', ROUNDDIV='/)')[p]
|
| 1267 |
+
s = s.replace(k, left + v + right)
|
| 1268 |
+
return s
|
| 1269 |
+
|
| 1270 |
+
|
| 1271 |
+
def fromstring(s, language=Language.C):
|
| 1272 |
+
"""Create an expression from a string.
|
| 1273 |
+
|
| 1274 |
+
This is a "lazy" parser, that is, only arithmetic operations are
|
| 1275 |
+
resolved, non-arithmetic operations are treated as symbols.
|
| 1276 |
+
"""
|
| 1277 |
+
r = _FromStringWorker(language=language).parse(s)
|
| 1278 |
+
if isinstance(r, Expr):
|
| 1279 |
+
return r
|
| 1280 |
+
raise ValueError(f'failed to parse `{s}` to Expr instance: got `{r}`')
|
| 1281 |
+
|
| 1282 |
+
|
| 1283 |
+
class _Pair:
|
| 1284 |
+
# Internal class to represent a pair of expressions
|
| 1285 |
+
|
| 1286 |
+
def __init__(self, left, right):
|
| 1287 |
+
self.left = left
|
| 1288 |
+
self.right = right
|
| 1289 |
+
|
| 1290 |
+
def substitute(self, symbols_map):
|
| 1291 |
+
left, right = self.left, self.right
|
| 1292 |
+
if isinstance(left, Expr):
|
| 1293 |
+
left = left.substitute(symbols_map)
|
| 1294 |
+
if isinstance(right, Expr):
|
| 1295 |
+
right = right.substitute(symbols_map)
|
| 1296 |
+
return _Pair(left, right)
|
| 1297 |
+
|
| 1298 |
+
def __repr__(self):
|
| 1299 |
+
return f'{type(self).__name__}({self.left}, {self.right})'
|
| 1300 |
+
|
| 1301 |
+
|
| 1302 |
+
class _FromStringWorker:
|
| 1303 |
+
|
| 1304 |
+
def __init__(self, language=Language.C):
|
| 1305 |
+
self.original = None
|
| 1306 |
+
self.quotes_map = None
|
| 1307 |
+
self.language = language
|
| 1308 |
+
|
| 1309 |
+
def finalize_string(self, s):
|
| 1310 |
+
return insert_quotes(s, self.quotes_map)
|
| 1311 |
+
|
| 1312 |
+
def parse(self, inp):
|
| 1313 |
+
self.original = inp
|
| 1314 |
+
unquoted, self.quotes_map = eliminate_quotes(inp)
|
| 1315 |
+
return self.process(unquoted)
|
| 1316 |
+
|
| 1317 |
+
def process(self, s, context='expr'):
|
| 1318 |
+
"""Parse string within the given context.
|
| 1319 |
+
|
| 1320 |
+
The context may define the result in case of ambiguous
|
| 1321 |
+
expressions. For instance, consider expressions `f(x, y)` and
|
| 1322 |
+
`(x, y) + (a, b)` where `f` is a function and pair `(x, y)`
|
| 1323 |
+
denotes complex number. Specifying context as "args" or
|
| 1324 |
+
"expr", the subexpression `(x, y)` will be parse to an
|
| 1325 |
+
argument list or to a complex number, respectively.
|
| 1326 |
+
"""
|
| 1327 |
+
if isinstance(s, (list, tuple)):
|
| 1328 |
+
return type(s)(self.process(s_, context) for s_ in s)
|
| 1329 |
+
|
| 1330 |
+
assert isinstance(s, str), (type(s), s)
|
| 1331 |
+
|
| 1332 |
+
# replace subexpressions in parenthesis with f2py @-names
|
| 1333 |
+
r, raw_symbols_map = replace_parenthesis(s)
|
| 1334 |
+
r = r.strip()
|
| 1335 |
+
|
| 1336 |
+
def restore(r):
|
| 1337 |
+
# restores subexpressions marked with f2py @-names
|
| 1338 |
+
if isinstance(r, (list, tuple)):
|
| 1339 |
+
return type(r)(map(restore, r))
|
| 1340 |
+
return unreplace_parenthesis(r, raw_symbols_map)
|
| 1341 |
+
|
| 1342 |
+
# comma-separated tuple
|
| 1343 |
+
if ',' in r:
|
| 1344 |
+
operands = restore(r.split(','))
|
| 1345 |
+
if context == 'args':
|
| 1346 |
+
return tuple(self.process(operands))
|
| 1347 |
+
if context == 'expr':
|
| 1348 |
+
if len(operands) == 2:
|
| 1349 |
+
# complex number literal
|
| 1350 |
+
return as_complex(*self.process(operands))
|
| 1351 |
+
raise NotImplementedError(
|
| 1352 |
+
f'parsing comma-separated list (context={context}): {r}')
|
| 1353 |
+
|
| 1354 |
+
# ternary operation
|
| 1355 |
+
m = re.match(r'\A([^?]+)[?]([^:]+)[:](.+)\Z', r)
|
| 1356 |
+
if m:
|
| 1357 |
+
assert context == 'expr', context
|
| 1358 |
+
oper, expr1, expr2 = restore(m.groups())
|
| 1359 |
+
oper = self.process(oper)
|
| 1360 |
+
expr1 = self.process(expr1)
|
| 1361 |
+
expr2 = self.process(expr2)
|
| 1362 |
+
return as_ternary(oper, expr1, expr2)
|
| 1363 |
+
|
| 1364 |
+
# relational expression
|
| 1365 |
+
if self.language is Language.Fortran:
|
| 1366 |
+
m = re.match(
|
| 1367 |
+
r'\A(.+)\s*[.](eq|ne|lt|le|gt|ge)[.]\s*(.+)\Z', r, re.I)
|
| 1368 |
+
else:
|
| 1369 |
+
m = re.match(
|
| 1370 |
+
r'\A(.+)\s*([=][=]|[!][=]|[<][=]|[<]|[>][=]|[>])\s*(.+)\Z', r)
|
| 1371 |
+
if m:
|
| 1372 |
+
left, rop, right = m.groups()
|
| 1373 |
+
if self.language is Language.Fortran:
|
| 1374 |
+
rop = '.' + rop + '.'
|
| 1375 |
+
left, right = self.process(restore((left, right)))
|
| 1376 |
+
rop = RelOp.fromstring(rop, language=self.language)
|
| 1377 |
+
return Expr(Op.RELATIONAL, (rop, left, right))
|
| 1378 |
+
|
| 1379 |
+
# keyword argument
|
| 1380 |
+
m = re.match(r'\A(\w[\w\d_]*)\s*[=](.*)\Z', r)
|
| 1381 |
+
if m:
|
| 1382 |
+
keyname, value = m.groups()
|
| 1383 |
+
value = restore(value)
|
| 1384 |
+
return _Pair(keyname, self.process(value))
|
| 1385 |
+
|
| 1386 |
+
# addition/subtraction operations
|
| 1387 |
+
operands = re.split(r'((?<!\d[edED])[+-])', r)
|
| 1388 |
+
if len(operands) > 1:
|
| 1389 |
+
result = self.process(restore(operands[0] or '0'))
|
| 1390 |
+
for op, operand in zip(operands[1::2], operands[2::2]):
|
| 1391 |
+
operand = self.process(restore(operand))
|
| 1392 |
+
op = op.strip()
|
| 1393 |
+
if op == '+':
|
| 1394 |
+
result += operand
|
| 1395 |
+
else:
|
| 1396 |
+
assert op == '-'
|
| 1397 |
+
result -= operand
|
| 1398 |
+
return result
|
| 1399 |
+
|
| 1400 |
+
# string concatenate operation
|
| 1401 |
+
if self.language is Language.Fortran and '//' in r:
|
| 1402 |
+
operands = restore(r.split('//'))
|
| 1403 |
+
return Expr(Op.CONCAT,
|
| 1404 |
+
tuple(self.process(operands)))
|
| 1405 |
+
|
| 1406 |
+
# multiplication/division operations
|
| 1407 |
+
operands = re.split(r'(?<=[@\w\d_])\s*([*]|/)',
|
| 1408 |
+
(r if self.language is Language.C
|
| 1409 |
+
else r.replace('**', '@__f2py_DOUBLE_STAR@')))
|
| 1410 |
+
if len(operands) > 1:
|
| 1411 |
+
operands = restore(operands)
|
| 1412 |
+
if self.language is not Language.C:
|
| 1413 |
+
operands = [operand.replace('@__f2py_DOUBLE_STAR@', '**')
|
| 1414 |
+
for operand in operands]
|
| 1415 |
+
# Expression is an arithmetic product
|
| 1416 |
+
result = self.process(operands[0])
|
| 1417 |
+
for op, operand in zip(operands[1::2], operands[2::2]):
|
| 1418 |
+
operand = self.process(operand)
|
| 1419 |
+
op = op.strip()
|
| 1420 |
+
if op == '*':
|
| 1421 |
+
result *= operand
|
| 1422 |
+
else:
|
| 1423 |
+
assert op == '/'
|
| 1424 |
+
result /= operand
|
| 1425 |
+
return result
|
| 1426 |
+
|
| 1427 |
+
# referencing/dereferencing
|
| 1428 |
+
if r.startswith('*') or r.startswith('&'):
|
| 1429 |
+
op = {'*': Op.DEREF, '&': Op.REF}[r[0]]
|
| 1430 |
+
operand = self.process(restore(r[1:]))
|
| 1431 |
+
return Expr(op, operand)
|
| 1432 |
+
|
| 1433 |
+
# exponentiation operations
|
| 1434 |
+
if self.language is not Language.C and '**' in r:
|
| 1435 |
+
operands = list(reversed(restore(r.split('**'))))
|
| 1436 |
+
result = self.process(operands[0])
|
| 1437 |
+
for operand in operands[1:]:
|
| 1438 |
+
operand = self.process(operand)
|
| 1439 |
+
result = operand ** result
|
| 1440 |
+
return result
|
| 1441 |
+
|
| 1442 |
+
# int-literal-constant
|
| 1443 |
+
m = re.match(r'\A({digit_string})({kind}|)\Z'.format(
|
| 1444 |
+
digit_string=r'\d+',
|
| 1445 |
+
kind=r'_(\d+|\w[\w\d_]*)'), r)
|
| 1446 |
+
if m:
|
| 1447 |
+
value, _, kind = m.groups()
|
| 1448 |
+
if kind and kind.isdigit():
|
| 1449 |
+
kind = int(kind)
|
| 1450 |
+
return as_integer(int(value), kind or 4)
|
| 1451 |
+
|
| 1452 |
+
# real-literal-constant
|
| 1453 |
+
m = re.match(r'\A({significant}({exponent}|)|\d+{exponent})({kind}|)\Z'
|
| 1454 |
+
.format(
|
| 1455 |
+
significant=r'[.]\d+|\d+[.]\d*',
|
| 1456 |
+
exponent=r'[edED][+-]?\d+',
|
| 1457 |
+
kind=r'_(\d+|\w[\w\d_]*)'), r)
|
| 1458 |
+
if m:
|
| 1459 |
+
value, _, _, kind = m.groups()
|
| 1460 |
+
if kind and kind.isdigit():
|
| 1461 |
+
kind = int(kind)
|
| 1462 |
+
value = value.lower()
|
| 1463 |
+
if 'd' in value:
|
| 1464 |
+
return as_real(float(value.replace('d', 'e')), kind or 8)
|
| 1465 |
+
return as_real(float(value), kind or 4)
|
| 1466 |
+
|
| 1467 |
+
# string-literal-constant with kind parameter specification
|
| 1468 |
+
if r in self.quotes_map:
|
| 1469 |
+
kind = r[:r.find('@')]
|
| 1470 |
+
return as_string(self.quotes_map[r], kind or 1)
|
| 1471 |
+
|
| 1472 |
+
# array constructor or literal complex constant or
|
| 1473 |
+
# parenthesized expression
|
| 1474 |
+
if r in raw_symbols_map:
|
| 1475 |
+
paren = _get_parenthesis_kind(r)
|
| 1476 |
+
items = self.process(restore(raw_symbols_map[r]),
|
| 1477 |
+
'expr' if paren == 'ROUND' else 'args')
|
| 1478 |
+
if paren == 'ROUND':
|
| 1479 |
+
if isinstance(items, Expr):
|
| 1480 |
+
return items
|
| 1481 |
+
if paren in ['ROUNDDIV', 'SQUARE']:
|
| 1482 |
+
# Expression is a array constructor
|
| 1483 |
+
if isinstance(items, Expr):
|
| 1484 |
+
items = (items,)
|
| 1485 |
+
return as_array(items)
|
| 1486 |
+
|
| 1487 |
+
# function call/indexing
|
| 1488 |
+
m = re.match(r'\A(.+)\s*(@__f2py_PARENTHESIS_(ROUND|SQUARE)_\d+@)\Z',
|
| 1489 |
+
r)
|
| 1490 |
+
if m:
|
| 1491 |
+
target, args, paren = m.groups()
|
| 1492 |
+
target = self.process(restore(target))
|
| 1493 |
+
args = self.process(restore(args)[1:-1], 'args')
|
| 1494 |
+
if not isinstance(args, tuple):
|
| 1495 |
+
args = args,
|
| 1496 |
+
if paren == 'ROUND':
|
| 1497 |
+
kwargs = dict((a.left, a.right) for a in args
|
| 1498 |
+
if isinstance(a, _Pair))
|
| 1499 |
+
args = tuple(a for a in args if not isinstance(a, _Pair))
|
| 1500 |
+
# Warning: this could also be Fortran indexing operation..
|
| 1501 |
+
return as_apply(target, *args, **kwargs)
|
| 1502 |
+
else:
|
| 1503 |
+
# Expression is a C/Python indexing operation
|
| 1504 |
+
# (e.g. used in .pyf files)
|
| 1505 |
+
assert paren == 'SQUARE'
|
| 1506 |
+
return target[args]
|
| 1507 |
+
|
| 1508 |
+
# Fortran standard conforming identifier
|
| 1509 |
+
m = re.match(r'\A\w[\w\d_]*\Z', r)
|
| 1510 |
+
if m:
|
| 1511 |
+
return as_symbol(r)
|
| 1512 |
+
|
| 1513 |
+
# fall-back to symbol
|
| 1514 |
+
r = self.finalize_string(restore(r))
|
| 1515 |
+
ewarn(
|
| 1516 |
+
f'fromstring: treating {r!r} as symbol (original={self.original})')
|
| 1517 |
+
return as_symbol(r)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/logs/owt_t5_elftokenized_full_len1024_C1_to_1024_pow1_d768_l12_h12_gbs512_8gpu_50ep_lr3e4_elfopt_t5embed_unfixed_stateprobadd_selfcond_ce_fast_20260531_225829.log
ADDED
|
@@ -0,0 +1,875 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[data] mode=elf_hfds direct-tokenized-fast path=/e2e-data/evad-tech-vla/wanghan58/data/embedded-language-flows/openwebtext-t5
|
| 2 |
+
[data] t5_tokenized_arrow_shards=75 rows=9737184 steps_per_epoch_gbs512=19018 epochs=50 total_steps=950900
|
| 3 |
+
[state-probadd] train: p_u=softmax(f(state,t)); state_in=state+Bernoulli(prob)*scale*p_u; CE(f(state_in,t), y)
|
| 4 |
+
[batch] default GBS=512 via 8gpu * batch16 * grad_accum4
|
| 5 |
+
W0531 22:58:30.730000 10413 torch/distributed/run.py:792]
|
| 6 |
+
W0531 22:58:30.730000 10413 torch/distributed/run.py:792] *****************************************
|
| 7 |
+
W0531 22:58:30.730000 10413 torch/distributed/run.py:792] Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.
|
| 8 |
+
W0531 22:58:30.730000 10413 torch/distributed/run.py:792] *****************************************
|
| 9 |
+
[W531 22:58:33.446778396 Utils.hpp:136] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 10 |
+
[W531 22:58:33.458176465 Utils.hpp:136] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 11 |
+
[W531 22:58:33.463544973 Utils.hpp:136] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 12 |
+
[W531 22:58:33.463636278 Utils.hpp:136] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 13 |
+
[W531 22:58:33.463873832 Utils.hpp:136] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 14 |
+
[W531 22:58:33.470741130 Utils.hpp:136] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 15 |
+
[W531 22:58:33.472172940 Utils.hpp:136] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 16 |
+
[W531 22:58:33.472435252 Utils.hpp:136] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 17 |
+
t-20260601065700-t4vg2-worker-0:10480:10480 [0] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 18 |
+
t-20260601065700-t4vg2-worker-0:10480:10480 [0] NCCL INFO Bootstrap: Using eth1:10.82.112.4<0>
|
| 19 |
+
t-20260601065700-t4vg2-worker-0:10480:10480 [0] NCCL INFO cudaDriverVersion 12080
|
| 20 |
+
t-20260601065700-t4vg2-worker-0:10480:10480 [0] NCCL INFO NCCL version 2.25.1+cuda12.8
|
| 21 |
+
t-20260601065700-t4vg2-worker-0:10480:10480 [0] NCCL INFO Comm config Blocking set to 1
|
| 22 |
+
t-20260601065700-t4vg2-worker-0:10487:10487 [7] NCCL INFO cudaDriverVersion 12080
|
| 23 |
+
t-20260601065700-t4vg2-worker-0:10487:10487 [7] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 24 |
+
t-20260601065700-t4vg2-worker-0:10487:10487 [7] NCCL INFO Bootstrap: Using eth1:10.82.112.4<0>
|
| 25 |
+
t-20260601065700-t4vg2-worker-0:10487:10487 [7] NCCL INFO NCCL version 2.25.1+cuda12.8
|
| 26 |
+
t-20260601065700-t4vg2-worker-0:10486:10486 [6] NCCL INFO cudaDriverVersion 12080
|
| 27 |
+
t-20260601065700-t4vg2-worker-0:10486:10486 [6] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 28 |
+
t-20260601065700-t4vg2-worker-0:10486:10486 [6] NCCL INFO Bootstrap: Using eth1:10.82.112.4<0>
|
| 29 |
+
t-20260601065700-t4vg2-worker-0:10486:10486 [6] NCCL INFO NCCL version 2.25.1+cuda12.8
|
| 30 |
+
t-20260601065700-t4vg2-worker-0:10487:10487 [7] NCCL INFO Comm config Blocking set to 1
|
| 31 |
+
t-20260601065700-t4vg2-worker-0:10482:10482 [2] NCCL INFO cudaDriverVersion 12080
|
| 32 |
+
t-20260601065700-t4vg2-worker-0:10482:10482 [2] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 33 |
+
t-20260601065700-t4vg2-worker-0:10486:10486 [6] NCCL INFO Comm config Blocking set to 1
|
| 34 |
+
t-20260601065700-t4vg2-worker-0:10485:10485 [5] NCCL INFO cudaDriverVersion 12080
|
| 35 |
+
t-20260601065700-t4vg2-worker-0:10485:10485 [5] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 36 |
+
t-20260601065700-t4vg2-worker-0:10482:10482 [2] NCCL INFO Bootstrap: Using eth1:10.82.112.4<0>
|
| 37 |
+
t-20260601065700-t4vg2-worker-0:10482:10482 [2] NCCL INFO NCCL version 2.25.1+cuda12.8
|
| 38 |
+
t-20260601065700-t4vg2-worker-0:10485:10485 [5] NCCL INFO Bootstrap: Using eth1:10.82.112.4<0>
|
| 39 |
+
t-20260601065700-t4vg2-worker-0:10485:10485 [5] NCCL INFO NCCL version 2.25.1+cuda12.8
|
| 40 |
+
t-20260601065700-t4vg2-worker-0:10484:10484 [4] NCCL INFO cudaDriverVersion 12080
|
| 41 |
+
t-20260601065700-t4vg2-worker-0:10484:10484 [4] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 42 |
+
t-20260601065700-t4vg2-worker-0:10481:10481 [1] NCCL INFO cudaDriverVersion 12080
|
| 43 |
+
t-20260601065700-t4vg2-worker-0:10481:10481 [1] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 44 |
+
t-20260601065700-t4vg2-worker-0:10483:10483 [3] NCCL INFO cudaDriverVersion 12080
|
| 45 |
+
t-20260601065700-t4vg2-worker-0:10483:10483 [3] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 46 |
+
t-20260601065700-t4vg2-worker-0:10484:10484 [4] NCCL INFO Bootstrap: Using eth1:10.82.112.4<0>
|
| 47 |
+
t-20260601065700-t4vg2-worker-0:10484:10484 [4] NCCL INFO NCCL version 2.25.1+cuda12.8
|
| 48 |
+
t-20260601065700-t4vg2-worker-0:10481:10481 [1] NCCL INFO Bootstrap: Using eth1:10.82.112.4<0>
|
| 49 |
+
t-20260601065700-t4vg2-worker-0:10483:10483 [3] NCCL INFO Bootstrap: Using eth1:10.82.112.4<0>
|
| 50 |
+
t-20260601065700-t4vg2-worker-0:10481:10481 [1] NCCL INFO NCCL version 2.25.1+cuda12.8
|
| 51 |
+
t-20260601065700-t4vg2-worker-0:10482:10482 [2] NCCL INFO Comm config Blocking set to 1
|
| 52 |
+
t-20260601065700-t4vg2-worker-0:10483:10483 [3] NCCL INFO NCCL version 2.25.1+cuda12.8
|
| 53 |
+
t-20260601065700-t4vg2-worker-0:10485:10485 [5] NCCL INFO Comm config Blocking set to 1
|
| 54 |
+
t-20260601065700-t4vg2-worker-0:10484:10484 [4] NCCL INFO Comm config Blocking set to 1
|
| 55 |
+
t-20260601065700-t4vg2-worker-0:10481:10481 [1] NCCL INFO Comm config Blocking set to 1
|
| 56 |
+
t-20260601065700-t4vg2-worker-0:10483:10483 [3] NCCL INFO Comm config Blocking set to 1
|
| 57 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO NET/Plugin: Loaded net plugin NCCL RDMA Plugin v9 (v9)
|
| 58 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO NET/Plugin: Loaded collnet plugin SHARP (v9)
|
| 59 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Plugin Path : /opt/hpcx/nccl_rdma_sharp_plugin/lib/libnccl-net.so
|
| 60 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO P2P plugin v9 IBext_v9
|
| 61 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 62 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO NET/Plugin: Loaded net plugin NCCL RDMA Plugin v9 (v9)
|
| 63 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO NET/Plugin: Loaded collnet plugin SHARP (v9)
|
| 64 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO Plugin Path : /opt/hpcx/nccl_rdma_sharp_plugin/lib/libnccl-net.so
|
| 65 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO P2P plugin v9 IBext_v9
|
| 66 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 67 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO NET/Plugin: Loaded net plugin NCCL RDMA Plugin v9 (v9)
|
| 68 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO NET/Plugin: Loaded collnet plugin SHARP (v9)
|
| 69 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO Plugin Path : /opt/hpcx/nccl_rdma_sharp_plugin/lib/libnccl-net.so
|
| 70 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO P2P plugin v9 IBext_v9
|
| 71 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 72 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO NET/Plugin: Loaded net plugin NCCL RDMA Plugin v9 (v9)
|
| 73 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO NET/Plugin: Loaded collnet plugin SHARP (v9)
|
| 74 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO Plugin Path : /opt/hpcx/nccl_rdma_sharp_plugin/lib/libnccl-net.so
|
| 75 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO P2P plugin v9 IBext_v9
|
| 76 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 77 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO NET/Plugin: Loaded net plugin NCCL RDMA Plugin v9 (v9)
|
| 78 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO NET/Plugin: Loaded collnet plugin SHARP (v9)
|
| 79 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO Plugin Path : /opt/hpcx/nccl_rdma_sharp_plugin/lib/libnccl-net.so
|
| 80 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO P2P plugin v9 IBext_v9
|
| 81 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 82 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO NET/Plugin: Loaded net plugin NCCL RDMA Plugin v9 (v9)
|
| 83 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO NET/Plugin: Loaded collnet plugin SHARP (v9)
|
| 84 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO Plugin Path : /opt/hpcx/nccl_rdma_sharp_plugin/lib/libnccl-net.so
|
| 85 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO P2P plugin v9 IBext_v9
|
| 86 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 87 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO NET/Plugin: Loaded net plugin NCCL RDMA Plugin v9 (v9)
|
| 88 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO NET/Plugin: Loaded collnet plugin SHARP (v9)
|
| 89 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO Plugin Path : /opt/hpcx/nccl_rdma_sharp_plugin/lib/libnccl-net.so
|
| 90 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO P2P plugin v9 IBext_v9
|
| 91 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 92 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO NET/Plugin: Loaded net plugin NCCL RDMA Plugin v9 (v9)
|
| 93 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO NET/Plugin: Loaded collnet plugin SHARP (v9)
|
| 94 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO Plugin Path : /opt/hpcx/nccl_rdma_sharp_plugin/lib/libnccl-net.so
|
| 95 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO P2P plugin v9 IBext_v9
|
| 96 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO NCCL_SOCKET_IFNAME set by environment to eth1
|
| 97 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO NCCL_IB_PCI_RELAXED_ORDERING set by environment to 1.
|
| 98 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO NET/IB : Using [0]mlx5_1:1/RoCE [1]mlx5_4:1/RoCE [2]mlx5_5:1/RoCE [3]mlx5_6:1/RoCE [4]mlx5_7:1/RoCE [5]mlx5_8:1/RoCE [6]mlx5_9:1/RoCE [7]mlx5_10:1/RoCE [RO]; OOB eth1:10.82.112.4<0>
|
| 99 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO PROFILER/Plugin: Could not find: libnccl-profiler.so.
|
| 100 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Using network IBext_v9
|
| 101 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO NCCL_IB_PCI_RELAXED_ORDERING set by environment to 1.
|
| 102 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO NET/IB : Using [0]mlx5_1:1/RoCE [1]mlx5_4:1/RoCE [2]mlx5_5:1/RoCE [3]mlx5_6:1/RoCE [4]mlx5_7:1/RoCE [5]mlx5_8:1/RoCE [6]mlx5_9:1/RoCE [7]mlx5_10:1/RoCE [RO]; OOB eth1:10.82.112.4<0>
|
| 103 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO NCCL_IB_PCI_RELAXED_ORDERING set by environment to 1.
|
| 104 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO NET/IB : Using [0]mlx5_1:1/RoCE [1]mlx5_4:1/RoCE [2]mlx5_5:1/RoCE [3]mlx5_6:1/RoCE [4]mlx5_7:1/RoCE [5]mlx5_8:1/RoCE [6]mlx5_9:1/RoCE [7]mlx5_10:1/RoCE [RO]; OOB eth1:10.82.112.4<0>
|
| 105 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO PROFILER/Plugin: Could not find: libnccl-profiler.so.
|
| 106 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO Using network IBext_v9
|
| 107 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO PROFILER/Plugin: Could not find: libnccl-profiler.so.
|
| 108 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO Using network IBext_v9
|
| 109 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO NCCL_IB_PCI_RELAXED_ORDERING set by environment to 1.
|
| 110 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO NET/IB : Using [0]mlx5_1:1/RoCE [1]mlx5_4:1/RoCE [2]mlx5_5:1/RoCE [3]mlx5_6:1/RoCE [4]mlx5_7:1/RoCE [5]mlx5_8:1/RoCE [6]mlx5_9:1/RoCE [7]mlx5_10:1/RoCE [RO]; OOB eth1:10.82.112.4<0>
|
| 111 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO NCCL_IB_PCI_RELAXED_ORDERING set by environment to 1.
|
| 112 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO NET/IB : Using [0]mlx5_1:1/RoCE [1]mlx5_4:1/RoCE [2]mlx5_5:1/RoCE [3]mlx5_6:1/RoCE [4]mlx5_7:1/RoCE [5]mlx5_8:1/RoCE [6]mlx5_9:1/RoCE [7]mlx5_10:1/RoCE [RO]; OOB eth1:10.82.112.4<0>
|
| 113 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO NCCL_IB_PCI_RELAXED_ORDERING set by environment to 1.
|
| 114 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO NET/IB : Using [0]mlx5_1:1/RoCE [1]mlx5_4:1/RoCE [2]mlx5_5:1/RoCE [3]mlx5_6:1/RoCE [4]mlx5_7:1/RoCE [5]mlx5_8:1/RoCE [6]mlx5_9:1/RoCE [7]mlx5_10:1/RoCE [RO]; OOB eth1:10.82.112.4<0>
|
| 115 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO PROFILER/Plugin: Could not find: libnccl-profiler.so.
|
| 116 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO Using network IBext_v9
|
| 117 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO PROFILER/Plugin: Could not find: libnccl-profiler.so.
|
| 118 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO PROFILER/Plugin: Could not find: libnccl-profiler.so.
|
| 119 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO Using network IBext_v9
|
| 120 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO Using network IBext_v9
|
| 121 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO NCCL_IB_PCI_RELAXED_ORDERING set by environment to 1.
|
| 122 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO NET/IB : Using [0]mlx5_1:1/RoCE [1]mlx5_4:1/RoCE [2]mlx5_5:1/RoCE [3]mlx5_6:1/RoCE [4]mlx5_7:1/RoCE [5]mlx5_8:1/RoCE [6]mlx5_9:1/RoCE [7]mlx5_10:1/RoCE [RO]; OOB eth1:10.82.112.4<0>
|
| 123 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO NCCL_IB_PCI_RELAXED_ORDERING set by environment to 1.
|
| 124 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO NET/IB : Using [0]mlx5_1:1/RoCE [1]mlx5_4:1/RoCE [2]mlx5_5:1/RoCE [3]mlx5_6:1/RoCE [4]mlx5_7:1/RoCE [5]mlx5_8:1/RoCE [6]mlx5_9:1/RoCE [7]mlx5_10:1/RoCE [RO]; OOB eth1:10.82.112.4<0>
|
| 125 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO PROFILER/Plugin: Could not find: libnccl-profiler.so.
|
| 126 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO PROFILER/Plugin: Could not find: libnccl-profiler.so.
|
| 127 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO Using network IBext_v9
|
| 128 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO Using network IBext_v9
|
| 129 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO ncclCommInitRankConfig comm 0x7cda170 rank 0 nranks 8 cudaDev 0 nvmlDev 0 busId 65040 commId 0xe75a53f090a7e47e - Init START
|
| 130 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO ncclCommInitRankConfig comm 0xa37f350 rank 5 nranks 8 cudaDev 5 nvmlDev 5 busId 71020 commId 0xe75a53f090a7e47e - Init START
|
| 131 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO ncclCommInitRankConfig comm 0x9d397c0 rank 2 nranks 8 cudaDev 2 nvmlDev 2 busId 69020 commId 0xe75a53f090a7e47e - Init START
|
| 132 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO ncclCommInitRankConfig comm 0x9cb2570 rank 1 nranks 8 cudaDev 1 nvmlDev 1 busId 67020 commId 0xe75a53f090a7e47e - Init START
|
| 133 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO RAS client listening socket at ::1<28028>
|
| 134 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO ncclCommInitRankConfig comm 0x8882140 rank 6 nranks 8 cudaDev 6 nvmlDev 6 busId 73020 commId 0xe75a53f090a7e47e - Init START
|
| 135 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO ncclCommInitRankConfig comm 0x93ff900 rank 7 nranks 8 cudaDev 7 nvmlDev 7 busId 75020 commId 0xe75a53f090a7e47e - Init START
|
| 136 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO RAS client listening socket at ::1<28028>
|
| 137 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO RAS client listening socket at ::1<28028>
|
| 138 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO RAS client listening socket at ::1<28028>
|
| 139 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO ncclCommInitRankConfig comm 0x8e3dd40 rank 3 nranks 8 cudaDev 3 nvmlDev 3 busId 6b020 commId 0xe75a53f090a7e47e - Init START
|
| 140 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO RAS client listening socket at ::1<28028>
|
| 141 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO ncclCommInitRankConfig comm 0x91db5f0 rank 4 nranks 8 cudaDev 4 nvmlDev 4 busId 6f020 commId 0xe75a53f090a7e47e - Init START
|
| 142 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO RAS client listening socket at ::1<28028>
|
| 143 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO RAS client listening socket at ::1<28028>
|
| 144 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO RAS client listening socket at ::1<28028>
|
| 145 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO Bootstrap timings total 0.200312 (create 0.000022, send 0.000085, recv 0.002188, ring 0.197732, delay 0.000001)
|
| 146 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO Bootstrap timings total 0.211155 (create 0.000021, send 0.000056, recv 0.006269, ring 0.197656, delay 0.000000)
|
| 147 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO Bootstrap timings total 0.200809 (create 0.000021, send 0.000064, recv 0.000094, ring 0.200354, delay 0.000001)
|
| 148 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO Bootstrap timings total 0.206544 (create 0.000022, send 0.000076, recv 0.000078, ring 0.206058, delay 0.000000)
|
| 149 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO Bootstrap timings total 0.198175 (create 0.000024, send 0.000093, recv 0.000066, ring 0.197654, delay 0.000001)
|
| 150 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Bootstrap timings total 0.276918 (create 0.000033, send 0.000076, recv 0.070420, ring 0.000154, delay 0.000001)
|
| 151 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO Bootstrap timings total 0.210634 (create 0.000023, send 0.000067, recv 0.010400, ring 0.199816, delay 0.000001)
|
| 152 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO Bootstrap timings total 0.205086 (create 0.000027, send 0.000075, recv 0.004316, ring 0.200314, delay 0.000001)
|
| 153 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO MNNVL busId 0x6b020 fabric UUID 0.0 cliqueId 0x0 state 3 healthMask 0x0
|
| 154 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO MNNVL busId 0x67020 fabric UUID 0.0 cliqueId 0x0 state 3 healthMask 0x0
|
| 155 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO MNNVL busId 0x71020 fabric UUID 0.0 cliqueId 0x0 state 3 healthMask 0x0
|
| 156 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO MNNVL busId 0x75020 fabric UUID 0.0 cliqueId 0x0 state 3 healthMask 0x0
|
| 157 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO MNNVL busId 0x6f020 fabric UUID 0.0 cliqueId 0x0 state 3 healthMask 0x0
|
| 158 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO MNNVL busId 0x65040 fabric UUID 0.0 cliqueId 0x0 state 3 healthMask 0x0
|
| 159 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO MNNVL busId 0x69020 fabric UUID 0.0 cliqueId 0x0 state 3 healthMask 0x0
|
| 160 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO MNNVL busId 0x73020 fabric UUID 0.0 cliqueId 0x0 state 3 healthMask 0x0
|
| 161 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO NCCL_TOPO_FILE set by environment to /var/run/nvidia-topologyd/virtualTopology.xml
|
| 162 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO NCCL_TOPO_FILE set by environment to /var/run/nvidia-topologyd/virtualTopology.xml
|
| 163 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO NCCL_TOPO_FILE set by environment to /var/run/nvidia-topologyd/virtualTopology.xml
|
| 164 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO NCCL_TOPO_FILE set by environment to /var/run/nvidia-topologyd/virtualTopology.xml
|
| 165 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO NCCL_TOPO_FILE set by environment to /var/run/nvidia-topologyd/virtualTopology.xml
|
| 166 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO NCCL_TOPO_FILE set by environment to /var/run/nvidia-topologyd/virtualTopology.xml
|
| 167 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO NCCL_TOPO_FILE set by environment to /var/run/nvidia-topologyd/virtualTopology.xml
|
| 168 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO NCCL_TOPO_FILE set by environment to /var/run/nvidia-topologyd/virtualTopology.xml
|
| 169 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO Setting affinity for GPU 5 to 0fffff,ffffffff,ffffffff,fc000000,00000000,00000000
|
| 170 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO NVLS multicast support is available on dev 5
|
| 171 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO Setting affinity for GPU 6 to 0fffff,ffffffff,ffffffff,fc000000,00000000,00000000
|
| 172 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO Setting affinity for GPU 1 to 03ffffff,ffffffff,ffffffff
|
| 173 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO NVLS multicast support is available on dev 1
|
| 174 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO Setting affinity for GPU 4 to 0fffff,ffffffff,ffffffff,fc000000,00000000,00000000
|
| 175 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO NVLS multicast support is available on dev 4
|
| 176 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO Setting affinity for GPU 3 to 03ffffff,ffffffff,ffffffff
|
| 177 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO NVLS multicast support is available on dev 3
|
| 178 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO Setting affinity for GPU 7 to 0fffff,ffffffff,ffffffff,fc000000,00000000,00000000
|
| 179 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO NVLS multicast support is available on dev 7
|
| 180 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Setting affinity for GPU 0 to 03ffffff,ffffffff,ffffffff
|
| 181 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO NVLS multicast support is available on dev 0
|
| 182 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO Setting affinity for GPU 2 to 03ffffff,ffffffff,ffffffff
|
| 183 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO NVLS multicast support is available on dev 6
|
| 184 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO NVLS multicast support is available on dev 2
|
| 185 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO comm 0x9d397c0 rank 2 nRanks 8 nNodes 1 localRanks 8 localRank 2 MNNVL 0
|
| 186 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO comm 0x9cb2570 rank 1 nRanks 8 nNodes 1 localRanks 8 localRank 1 MNNVL 0
|
| 187 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO comm 0x7cda170 rank 0 nRanks 8 nNodes 1 localRanks 8 localRank 0 MNNVL 0
|
| 188 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO comm 0x93ff900 rank 7 nRanks 8 nNodes 1 localRanks 8 localRank 7 MNNVL 0
|
| 189 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO comm 0x8882140 rank 6 nRanks 8 nNodes 1 localRanks 8 localRank 6 MNNVL 0
|
| 190 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO comm 0xa37f350 rank 5 nRanks 8 nNodes 1 localRanks 8 localRank 5 MNNVL 0
|
| 191 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO comm 0x91db5f0 rank 4 nRanks 8 nNodes 1 localRanks 8 localRank 4 MNNVL 0
|
| 192 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 00/24 : 0 1 2 3 4 5 6 7
|
| 193 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO comm 0x8e3dd40 rank 3 nRanks 8 nNodes 1 localRanks 8 localRank 3 MNNVL 0
|
| 194 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 01/24 : 0 1 2 3 4 5 6 7
|
| 195 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO Trees [0] -1/-1/-1->7->6 [1] -1/-1/-1->7->6 [2] -1/-1/-1->7->6 [3] -1/-1/-1->7->6 [4] -1/-1/-1->7->6 [5] -1/-1/-1->7->6 [6] -1/-1/-1->7->6 [7] -1/-1/-1->7->6 [8] -1/-1/-1->7->6 [9] -1/-1/-1->7->6 [10] -1/-1/-1->7->6 [11] -1/-1/-1->7->6 [12] -1/-1/-1->7->6 [13] -1/-1/-1->7->6 [14] -1/-1/-1->7->6 [15] -1/-1/-1->7->6 [16] -1/-1/-1->7->6 [17] -1/-1/-1->7->6 [18] -1/-1/-1->7->6 [19] -1/-1/-1->7->6 [20] -1/-1/-1->7->6 [21] -1/-1/-1->7->6 [22] -1/-1/-1->7->6 [23] -1/-1/-1->7->6
|
| 196 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO P2P Chunksize set to 524288
|
| 197 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO Trees [0] 7/-1/-1->6->5 [1] 7/-1/-1->6->5 [2] 7/-1/-1->6->5 [3] 7/-1/-1->6->5 [4] 7/-1/-1->6->5 [5] 7/-1/-1->6->5 [6] 7/-1/-1->6->5 [7] 7/-1/-1->6->5 [8] 7/-1/-1->6->5 [9] 7/-1/-1->6->5 [10] 7/-1/-1->6->5 [11] 7/-1/-1->6->5 [12] 7/-1/-1->6->5 [13] 7/-1/-1->6->5 [14] 7/-1/-1->6->5 [15] 7/-1/-1->6->5 [16] 7/-1/-1->6->5 [17] 7/-1/-1->6->5 [18] 7/-1/-1->6->5 [19] 7/-1/-1->6->5 [20] 7/-1/-1->6->5 [21] 7/-1/-1->6->5 [22] 7/-1/-1->6->5 [23] 7/-1/-1->6->5
|
| 198 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO Trees [0] 2/-1/-1->1->0 [1] 2/-1/-1->1->0 [2] 2/-1/-1->1->0 [3] 2/-1/-1->1->0 [4] 2/-1/-1->1->0 [5] 2/-1/-1->1->0 [6] 2/-1/-1->1->0 [7] 2/-1/-1->1->0 [8] 2/-1/-1->1->0 [9] 2/-1/-1->1->0 [10] 2/-1/-1->1->0 [11] 2/-1/-1->1->0 [12] 2/-1/-1->1->0 [13] 2/-1/-1->1->0 [14] 2/-1/-1->1->0 [15] 2/-1/-1->1->0 [16] 2/-1/-1->1->0 [17] 2/-1/-1->1->0 [18] 2/-1/-1->1->0 [19] 2/-1/-1->1->0 [20] 2/-1/-1->1->0 [21] 2/-1/-1->1->0 [22] 2/-1/-1->1->0 [23] 2/-1/-1->1->0
|
| 199 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 02/24 : 0 1 2 3 4 5 6 7
|
| 200 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO P2P Chunksize set to 524288
|
| 201 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO Trees [0] 6/-1/-1->5->4 [1] 6/-1/-1->5->4 [2] 6/-1/-1->5->4 [3] 6/-1/-1->5->4 [4] 6/-1/-1->5->4 [5] 6/-1/-1->5->4 [6] 6/-1/-1->5->4 [7] 6/-1/-1->5->4 [8] 6/-1/-1->5->4 [9] 6/-1/-1->5->4 [10] 6/-1/-1->5->4 [11] 6/-1/-1->5->4 [12] 6/-1/-1->5->4 [13] 6/-1/-1->5->4 [14] 6/-1/-1->5->4 [15] 6/-1/-1->5->4 [16] 6/-1/-1->5->4 [17] 6/-1/-1->5->4 [18] 6/-1/-1->5->4 [19] 6/-1/-1->5->4 [20] 6/-1/-1->5->4 [21] 6/-1/-1->5->4 [22] 6/-1/-1->5->4 [23] 6/-1/-1->5->4
|
| 202 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 03/24 : 0 1 2 3 4 5 6 7
|
| 203 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO Trees [0] 3/-1/-1->2->1 [1] 3/-1/-1->2->1 [2] 3/-1/-1->2->1 [3] 3/-1/-1->2->1 [4] 3/-1/-1->2->1 [5] 3/-1/-1->2->1 [6] 3/-1/-1->2->1 [7] 3/-1/-1->2->1 [8] 3/-1/-1->2->1 [9] 3/-1/-1->2->1 [10] 3/-1/-1->2->1 [11] 3/-1/-1->2->1 [12] 3/-1/-1->2->1 [13] 3/-1/-1->2->1 [14] 3/-1/-1->2->1 [15] 3/-1/-1->2->1 [16] 3/-1/-1->2->1 [17] 3/-1/-1->2->1 [18] 3/-1/-1->2->1 [19] 3/-1/-1->2->1 [20] 3/-1/-1->2->1 [21] 3/-1/-1->2->1 [22] 3/-1/-1->2->1 [23] 3/-1/-1->2->1
|
| 204 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO P2P Chunksize set to 524288
|
| 205 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO P2P Chunksize set to 524288
|
| 206 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO Trees [0] 5/-1/-1->4->3 [1] 5/-1/-1->4->3 [2] 5/-1/-1->4->3 [3] 5/-1/-1->4->3 [4] 5/-1/-1->4->3 [5] 5/-1/-1->4->3 [6] 5/-1/-1->4->3 [7] 5/-1/-1->4->3 [8] 5/-1/-1->4->3 [9] 5/-1/-1->4->3 [10] 5/-1/-1->4->3 [11] 5/-1/-1->4->3 [12] 5/-1/-1->4->3 [13] 5/-1/-1->4->3 [14] 5/-1/-1->4->3 [15] 5/-1/-1->4->3 [16] 5/-1/-1->4->3 [17] 5/-1/-1->4->3 [18] 5/-1/-1->4->3 [19] 5/-1/-1->4->3 [20] 5/-1/-1->4->3 [21] 5/-1/-1->4->3 [22] 5/-1/-1->4->3 [23] 5/-1/-1->4->3
|
| 207 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 04/24 : 0 1 2 3 4 5 6 7
|
| 208 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO P2P Chunksize set to 524288
|
| 209 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 05/24 : 0 1 2 3 4 5 6 7
|
| 210 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO P2P Chunksize set to 524288
|
| 211 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 06/24 : 0 1 2 3 4 5 6 7
|
| 212 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 07/24 : 0 1 2 3 4 5 6 7
|
| 213 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 08/24 : 0 1 2 3 4 5 6 7
|
| 214 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 09/24 : 0 1 2 3 4 5 6 7
|
| 215 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO Trees [0] 4/-1/-1->3->2 [1] 4/-1/-1->3->2 [2] 4/-1/-1->3->2 [3] 4/-1/-1->3->2 [4] 4/-1/-1->3->2 [5] 4/-1/-1->3->2 [6] 4/-1/-1->3->2 [7] 4/-1/-1->3->2 [8] 4/-1/-1->3->2 [9] 4/-1/-1->3->2 [10] 4/-1/-1->3->2 [11] 4/-1/-1->3->2 [12] 4/-1/-1->3->2 [13] 4/-1/-1->3->2 [14] 4/-1/-1->3->2 [15] 4/-1/-1->3->2 [16] 4/-1/-1->3->2 [17] 4/-1/-1->3->2 [18] 4/-1/-1->3->2 [19] 4/-1/-1->3->2 [20] 4/-1/-1->3->2 [21] 4/-1/-1->3->2 [22] 4/-1/-1->3->2 [23] 4/-1/-1->3->2
|
| 216 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 10/24 : 0 1 2 3 4 5 6 7
|
| 217 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 11/24 : 0 1 2 3 4 5 6 7
|
| 218 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO P2P Chunksize set to 524288
|
| 219 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 12/24 : 0 1 2 3 4 5 6 7
|
| 220 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 13/24 : 0 1 2 3 4 5 6 7
|
| 221 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 14/24 : 0 1 2 3 4 5 6 7
|
| 222 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 15/24 : 0 1 2 3 4 5 6 7
|
| 223 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 16/24 : 0 1 2 3 4 5 6 7
|
| 224 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 17/24 : 0 1 2 3 4 5 6 7
|
| 225 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 18/24 : 0 1 2 3 4 5 6 7
|
| 226 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 19/24 : 0 1 2 3 4 5 6 7
|
| 227 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 20/24 : 0 1 2 3 4 5 6 7
|
| 228 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 21/24 : 0 1 2 3 4 5 6 7
|
| 229 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 22/24 : 0 1 2 3 4 5 6 7
|
| 230 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Channel 23/24 : 0 1 2 3 4 5 6 7
|
| 231 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Trees [0] 1/-1/-1->0->-1 [1] 1/-1/-1->0->-1 [2] 1/-1/-1->0->-1 [3] 1/-1/-1->0->-1 [4] 1/-1/-1->0->-1 [5] 1/-1/-1->0->-1 [6] 1/-1/-1->0->-1 [7] 1/-1/-1->0->-1 [8] 1/-1/-1->0->-1 [9] 1/-1/-1->0->-1 [10] 1/-1/-1->0->-1 [11] 1/-1/-1->0->-1 [12] 1/-1/-1->0->-1 [13] 1/-1/-1->0->-1 [14] 1/-1/-1->0->-1 [15] 1/-1/-1->0->-1 [16] 1/-1/-1->0->-1 [17] 1/-1/-1->0->-1 [18] 1/-1/-1->0->-1 [19] 1/-1/-1->0->-1 [20] 1/-1/-1->0->-1 [21] 1/-1/-1->0->-1 [22] 1/-1/-1->0->-1 [23] 1/-1/-1->0->-1
|
| 232 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO P2P Chunksize set to 524288
|
| 233 |
+
t-20260601065700-t4vg2-worker-0:10481:10680 [1] NCCL INFO [Proxy Service] Device 1 CPU core 5
|
| 234 |
+
t-20260601065700-t4vg2-worker-0:10481:10681 [1] NCCL INFO [Proxy Service UDS] Device 1 CPU core 7
|
| 235 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Check P2P Type intraNodeP2pSupport 1 directMode 0
|
| 236 |
+
t-20260601065700-t4vg2-worker-0:10483:10682 [3] NCCL INFO [Proxy Service] Device 3 CPU core 5
|
| 237 |
+
t-20260601065700-t4vg2-worker-0:10483:10683 [3] NCCL INFO [Proxy Service UDS] Device 3 CPU core 6
|
| 238 |
+
t-20260601065700-t4vg2-worker-0:10480:10684 [0] NCCL INFO [Proxy Service] Device 0 CPU core 88
|
| 239 |
+
t-20260601065700-t4vg2-worker-0:10480:10685 [0] NCCL INFO [Proxy Service UDS] Device 0 CPU core 4
|
| 240 |
+
t-20260601065700-t4vg2-worker-0:10486:10686 [6] NCCL INFO [Proxy Service] Device 6 CPU core 90
|
| 241 |
+
t-20260601065700-t4vg2-worker-0:10486:10687 [6] NCCL INFO [Proxy Service UDS] Device 6 CPU core 92
|
| 242 |
+
t-20260601065700-t4vg2-worker-0:10487:10688 [7] NCCL INFO [Proxy Service] Device 7 CPU core 134
|
| 243 |
+
t-20260601065700-t4vg2-worker-0:10487:10689 [7] NCCL INFO [Proxy Service UDS] Device 7 CPU core 136
|
| 244 |
+
t-20260601065700-t4vg2-worker-0:10482:10690 [2] NCCL INFO [Proxy Service] Device 2 CPU core 6
|
| 245 |
+
t-20260601065700-t4vg2-worker-0:10482:10691 [2] NCCL INFO [Proxy Service UDS] Device 2 CPU core 8
|
| 246 |
+
t-20260601065700-t4vg2-worker-0:10484:10692 [4] NCCL INFO [Proxy Service] Device 4 CPU core 124
|
| 247 |
+
t-20260601065700-t4vg2-worker-0:10484:10693 [4] NCCL INFO [Proxy Service UDS] Device 4 CPU core 126
|
| 248 |
+
t-20260601065700-t4vg2-worker-0:10485:10694 [5] NCCL INFO [Proxy Service] Device 5 CPU core 92
|
| 249 |
+
t-20260601065700-t4vg2-worker-0:10485:10695 [5] NCCL INFO [Proxy Service UDS] Device 5 CPU core 94
|
| 250 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO threadThresholds 8/8/64 | 64/8/64 | 512 | 512
|
| 251 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO 24 coll channels, 24 collnet channels, 16 nvls channels, 32 p2p channels, 32 p2p channels per peer
|
| 252 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO threadThresholds 8/8/64 | 64/8/64 | 512 | 512
|
| 253 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO 24 coll channels, 24 collnet channels, 16 nvls channels, 32 p2p channels, 32 p2p channels per peer
|
| 254 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO threadThresholds 8/8/64 | 64/8/64 | 512 | 512
|
| 255 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO 24 coll channels, 24 collnet channels, 16 nvls channels, 32 p2p channels, 32 p2p channels per peer
|
| 256 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO threadThresholds 8/8/64 | 64/8/64 | 512 | 512
|
| 257 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO 24 coll channels, 24 collnet channels, 16 nvls channels, 32 p2p channels, 32 p2p channels per peer
|
| 258 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO threadThresholds 8/8/64 | 64/8/64 | 512 | 512
|
| 259 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO 24 coll channels, 24 collnet channels, 16 nvls channels, 32 p2p channels, 32 p2p channels per peer
|
| 260 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO threadThresholds 8/8/64 | 64/8/64 | 512 | 512
|
| 261 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO 24 coll channels, 24 collnet channels, 16 nvls channels, 32 p2p channels, 32 p2p channels per peer
|
| 262 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO threadThresholds 8/8/64 | 64/8/64 | 512 | 512
|
| 263 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO 24 coll channels, 24 collnet channels, 16 nvls channels, 32 p2p channels, 32 p2p channels per peer
|
| 264 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO CC Off, workFifoBytes 1048576
|
| 265 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO threadThresholds 8/8/64 | 64/8/64 | 512 | 512
|
| 266 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO 24 coll channels, 24 collnet channels, 16 nvls channels, 32 p2p channels, 32 p2p channels per peer
|
| 267 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v4 symbol.
|
| 268 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v4 symbol.
|
| 269 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v3 symbol.
|
| 270 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v3 symbol.
|
| 271 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v2 symbol, using internal tuner instead.
|
| 272 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v2 symbol, using internal tuner instead.
|
| 273 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v4 symbol.
|
| 274 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO ncclCommInitRankConfig comm 0x8882140 rank 6 nranks 8 cudaDev 6 nvmlDev 6 busId 73020 commId 0xe75a53f090a7e47e - Init COMPLETE
|
| 275 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO ncclCommInitRankConfig comm 0xa37f350 rank 5 nranks 8 cudaDev 5 nvmlDev 5 busId 71020 commId 0xe75a53f090a7e47e - Init COMPLETE
|
| 276 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v3 symbol.
|
| 277 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v2 symbol, using internal tuner instead.
|
| 278 |
+
t-20260601065700-t4vg2-worker-0:10486:10578 [6] NCCL INFO Init timings - ncclCommInitRankConfig: rank 6 nranks 8 total 2.35 (kernels 0.19, alloc 1.11, bootstrap 0.21, allgathers 0.01, topo 0.55, graphs 0.01, connections 0.25, rest 0.03)
|
| 279 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO ncclCommInitRankConfig comm 0x91db5f0 rank 4 nranks 8 cudaDev 4 nvmlDev 4 busId 6f020 commId 0xe75a53f090a7e47e - Init COMPLETE
|
| 280 |
+
t-20260601065700-t4vg2-worker-0:10485:10580 [5] NCCL INFO Init timings - ncclCommInitRankConfig: rank 5 nranks 8 total 2.35 (kernels 0.19, alloc 1.11, bootstrap 0.21, allgathers 0.01, topo 0.55, graphs 0.01, connections 0.24, rest 0.03)
|
| 281 |
+
t-20260601065700-t4vg2-worker-0:10484:10581 [4] NCCL INFO Init timings - ncclCommInitRankConfig: rank 4 nranks 8 total 2.35 (kernels 0.19, alloc 1.11, bootstrap 0.20, allgathers 0.01, topo 0.55, graphs 0.01, connections 0.24, rest 0.03)
|
| 282 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v4 symbol.
|
| 283 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v4 symbol.
|
| 284 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v3 symbol.
|
| 285 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v3 symbol.
|
| 286 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v2 symbol, using internal tuner instead.
|
| 287 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v2 symbol, using internal tuner instead.
|
| 288 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO ncclCommInitRankConfig comm 0x7cda170 rank 0 nranks 8 cudaDev 0 nvmlDev 0 busId 65040 commId 0xe75a53f090a7e47e - Init COMPLETE
|
| 289 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO ncclCommInitRankConfig comm 0x9d397c0 rank 2 nranks 8 cudaDev 2 nvmlDev 2 busId 69020 commId 0xe75a53f090a7e47e - Init COMPLETE
|
| 290 |
+
t-20260601065700-t4vg2-worker-0:10480:10576 [0] NCCL INFO Init timings - ncclCommInitRankConfig: rank 0 nranks 8 total 2.37 (kernels 0.19, alloc 1.06, bootstrap 0.28, allgathers 0.01, topo 0.55, graphs 0.01, connections 0.25, rest 0.03)
|
| 291 |
+
t-20260601065700-t4vg2-worker-0:10482:10579 [2] NCCL INFO Init timings - ncclCommInitRankConfig: rank 2 nranks 8 total 2.35 (kernels 0.19, alloc 1.11, bootstrap 0.21, allgathers 0.00, topo 0.55, graphs 0.01, connections 0.24, rest 0.04)
|
| 292 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v4 symbol.
|
| 293 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v4 symbol.
|
| 294 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v3 symbol.
|
| 295 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v3 symbol.
|
| 296 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v2 symbol, using internal tuner instead.
|
| 297 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v2 symbol, using internal tuner instead.
|
| 298 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO ncclCommInitRankConfig comm 0x93ff900 rank 7 nranks 8 cudaDev 7 nvmlDev 7 busId 75020 commId 0xe75a53f090a7e47e - Init COMPLETE
|
| 299 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO ncclCommInitRankConfig comm 0x8e3dd40 rank 3 nranks 8 cudaDev 3 nvmlDev 3 busId 6b020 commId 0xe75a53f090a7e47e - Init COMPLETE
|
| 300 |
+
t-20260601065700-t4vg2-worker-0:10487:10577 [7] NCCL INFO Init timings - ncclCommInitRankConfig: rank 7 nranks 8 total 2.35 (kernels 0.20, alloc 1.11, bootstrap 0.20, allgathers 0.01, topo 0.55, graphs 0.01, connections 0.24, rest 0.03)
|
| 301 |
+
t-20260601065700-t4vg2-worker-0:10483:10583 [3] NCCL INFO Init timings - ncclCommInitRankConfig: rank 3 nranks 8 total 2.35 (kernels 0.19, alloc 1.12, bootstrap 0.20, allgathers 0.00, topo 0.55, graphs 0.01, connections 0.25, rest 0.02)
|
| 302 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v4 symbol.
|
| 303 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v3 symbol.
|
| 304 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO TUNER/Plugin: Failed to find ncclTunerPlugin_v2 symbol, using internal tuner instead.
|
| 305 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO ncclCommInitRankConfig comm 0x9cb2570 rank 1 nranks 8 cudaDev 1 nvmlDev 1 busId 67020 commId 0xe75a53f090a7e47e - Init COMPLETE
|
| 306 |
+
t-20260601065700-t4vg2-worker-0:10481:10582 [1] NCCL INFO Init timings - ncclCommInitRankConfig: rank 1 nranks 8 total 2.35 (kernels 0.19, alloc 1.11, bootstrap 0.21, allgathers 0.01, topo 0.55, graphs 0.01, connections 0.26, rest 0.02)
|
| 307 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 00/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 308 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 01/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 309 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 02/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 310 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 00/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 311 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 01/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 312 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 00/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 313 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 03/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 314 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 02/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 315 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 01/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 316 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 04/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 317 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 03/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 318 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 02/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 319 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 05/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 320 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 04/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 321 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 03/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 322 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 06/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 323 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 05/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 324 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 04/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 325 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 07/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 326 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 06/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 327 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 05/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 328 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 08/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 329 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 07/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 330 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 06/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 331 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 00/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 332 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 09/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 333 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 08/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 334 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 07/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 335 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 01/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 336 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 10/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 337 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 09/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 338 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 08/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 339 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 02/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 340 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 11/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 341 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 10/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 342 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 00/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 343 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 09/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 344 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 03/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 345 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 12/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 346 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 11/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 347 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 00/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 348 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 00/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 349 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 01/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 350 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 10/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 351 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 04/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 352 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 13/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 353 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 12/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 354 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 02/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 355 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 01/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 356 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 01/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 357 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 11/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 358 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 05/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 359 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 14/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 360 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 13/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 361 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 03/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 362 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 02/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 363 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 02/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 364 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 12/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 365 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 06/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 366 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 15/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 367 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 14/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 368 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 04/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 369 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 03/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 370 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 03/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 371 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 13/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 372 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 07/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 373 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 16/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 374 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 00/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 375 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 15/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 376 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 05/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 377 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 04/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 378 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 04/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 379 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 14/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 380 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 08/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 381 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 17/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 382 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 01/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 383 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 16/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 384 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 06/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 385 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 05/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 386 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 05/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 387 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 15/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 388 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 09/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 389 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 18/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 390 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 02/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 391 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 17/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 392 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 07/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 393 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 06/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 394 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 06/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 395 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 16/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 396 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 10/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 397 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 19/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 398 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 03/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 399 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 18/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 400 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 08/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 401 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 07/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 402 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 07/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 403 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 17/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 404 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 11/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 405 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 20/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 406 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 04/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 407 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 19/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 408 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 09/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 409 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 08/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 410 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 08/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 411 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 18/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 412 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 12/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 413 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 21/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 414 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 05/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 415 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 20/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 416 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 10/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 417 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 09/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 418 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 09/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 419 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 19/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 420 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 13/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 421 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 22/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 422 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 06/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 423 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 21/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 424 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 11/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 425 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 10/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 426 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 10/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 427 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 20/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 428 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 14/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 429 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Channel 23/0 : 0[0] -> 1[1] via P2P/CUMEM
|
| 430 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 07/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 431 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 22/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 432 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 12/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 433 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 11/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 434 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 11/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 435 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 15/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 436 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 08/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 437 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 16/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 438 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Channel 23/0 : 5[5] -> 6[6] via P2P/CUMEM
|
| 439 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 09/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 440 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 17/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 441 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 10/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 442 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 18/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 443 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 13/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 444 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 11/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 445 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 19/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 446 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 14/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 447 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 12/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 448 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 20/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 449 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 15/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 450 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 12/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 451 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 13/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 452 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 21/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 453 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 16/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 454 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 13/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 455 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 14/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 456 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 22/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 457 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 17/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 458 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 14/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 459 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 15/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 460 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Channel 23/0 : 6[6] -> 7[7] via P2P/CUMEM
|
| 461 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 21/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 462 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 18/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 463 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 15/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 464 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 16/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 465 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 12/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 466 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 19/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 467 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 22/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 468 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 16/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 469 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 17/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 470 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 13/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 471 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 20/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 472 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Channel 23/0 : 4[4] -> 5[5] via P2P/CUMEM
|
| 473 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 17/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 474 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 18/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 475 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 14/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 476 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 21/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 477 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 18/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 478 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 19/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 479 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 15/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 480 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 22/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 481 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 20/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 482 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 16/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 483 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 19/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 484 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 21/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 485 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 17/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 486 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 20/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 487 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 22/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 488 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 18/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 489 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 21/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 490 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Channel 23/0 : 7[7] -> 0[0] via P2P/CUMEM
|
| 491 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 19/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 492 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 22/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 493 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 20/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 494 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Channel 23/0 : 2[2] -> 3[3] via P2P/CUMEM
|
| 495 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 21/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 496 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Channel 23/0 : 1[1] -> 2[2] via P2P/CUMEM
|
| 497 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 22/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 498 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Channel 23/0 : 3[3] -> 4[4] via P2P/CUMEM
|
| 499 |
+
t-20260601065700-t4vg2-worker-0:10483:10703 [3] NCCL INFO Connected all rings, use ring PXN 0 GDR 1
|
| 500 |
+
t-20260601065700-t4vg2-worker-0:10486:10702 [6] NCCL INFO Connected all rings, use ring PXN 0 GDR 1
|
| 501 |
+
t-20260601065700-t4vg2-worker-0:10482:10700 [2] NCCL INFO Connected all rings, use ring PXN 0 GDR 1
|
| 502 |
+
t-20260601065700-t4vg2-worker-0:10485:10699 [5] NCCL INFO Connected all rings, use ring PXN 0 GDR 1
|
| 503 |
+
t-20260601065700-t4vg2-worker-0:10484:10696 [4] NCCL INFO Connected all rings, use ring PXN 0 GDR 1
|
| 504 |
+
t-20260601065700-t4vg2-worker-0:10481:10701 [1] NCCL INFO Connected all rings, use ring PXN 0 GDR 1
|
| 505 |
+
t-20260601065700-t4vg2-worker-0:10487:10698 [7] NCCL INFO Connected all rings, use ring PXN 0 GDR 1
|
| 506 |
+
t-20260601065700-t4vg2-worker-0:10480:10697 [0] NCCL INFO Connected all rings, use ring PXN 0 GDR 1
|
| 507 |
+
[rank7]:[W531 22:58:38.112846371 Utils.hpp:111] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 508 |
+
[rank1]:[W531 22:58:38.113115279 Utils.hpp:111] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 509 |
+
[rank3]:[W531 22:58:38.113130224 Utils.hpp:111] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 510 |
+
[rank0]:[W531 22:58:38.113161995 Utils.hpp:111] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 511 |
+
[rank4]:[W531 22:58:38.113300427 Utils.hpp:111] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 512 |
+
[rank2]:[W531 22:58:38.113443309 Utils.hpp:111] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 513 |
+
[rank5]:[W531 22:58:38.113468953 Utils.hpp:111] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 514 |
+
[rank6]:[W531 22:58:38.113512754 Utils.hpp:111] Warning: Environment variable NCCL_ASYNC_ERROR_HANDLING is deprecated; use TORCH_NCCL_ASYNC_ERROR_HANDLING instead (function operator())
|
| 515 |
+
Muon: 58 2D params; Nesterov-AdamW: 78 other params
|
| 516 |
+
Muon: 58 2D params; Nesterov-AdamW: 78 other params
|
| 517 |
+
Muon: 58 2D params; Nesterov-AdamW: 78 other params
|
| 518 |
+
Muon: 58 2D params; Nesterov-AdamW: 78 other params
|
| 519 |
+
Muon: 58 2D params; Nesterov-AdamW: 78 other params
|
| 520 |
+
{
|
| 521 |
+
"data_mode": "elf_hfds",
|
| 522 |
+
"cache_path": "cache/owt_t5_payload1022_appendeos1.pt",
|
| 523 |
+
"data_path": "/e2e-data/evad-tech-vla/wanghan58/data/embedded-language-flows/openwebtext-t5",
|
| 524 |
+
"tokenizer_path": "/e2e-data/evad-tech-vla/wanghan58/models/hf/t5-small/tokenizer.json",
|
| 525 |
+
"text_column": "text",
|
| 526 |
+
"pack_len": 1023,
|
| 527 |
+
"append_eos": 1,
|
| 528 |
+
"num_workers": 4,
|
| 529 |
+
"shuffle_buffer": 8192,
|
| 530 |
+
"reject_txt": "cache/online_rejected.txt",
|
| 531 |
+
"out_dir": "runs/owt_t5_elftokenized_full_len1024_C1_to_1024_pow1_d768_l12_h12_gbs512_8gpu_50ep_lr3e4_elfopt_t5embed_unfixed_stateprobadd_selfcond_ce_fast_20260531_225829",
|
| 532 |
+
"subset_size": 0,
|
| 533 |
+
"resume": "",
|
| 534 |
+
"steps": 950900,
|
| 535 |
+
"batch_size": 16,
|
| 536 |
+
"grad_accum": 4,
|
| 537 |
+
"lr": 0.0003,
|
| 538 |
+
"blr": 0.001,
|
| 539 |
+
"min_lr": 0.0,
|
| 540 |
+
"lr_schedule": "constant",
|
| 541 |
+
"warmup_steps": 200,
|
| 542 |
+
"warmup_epochs": -1.0,
|
| 543 |
+
"optimizer": "muon",
|
| 544 |
+
"weight_decay": 0.0,
|
| 545 |
+
"adam_beta1": 0.9,
|
| 546 |
+
"adam_beta2": 0.95,
|
| 547 |
+
"adam_eps": 1e-08,
|
| 548 |
+
"grad_clip": 1.0,
|
| 549 |
+
"log_every": 50,
|
| 550 |
+
"save_every": 1000,
|
| 551 |
+
"dim": 768,
|
| 552 |
+
"layers": 12,
|
| 553 |
+
"heads": 12,
|
| 554 |
+
"mlp_dim": 3072,
|
| 555 |
+
"time_tokens": 4,
|
| 556 |
+
"token_embed_init": "t5_shared",
|
| 557 |
+
"token_embed_model_path": "/e2e-data/evad-tech-vla/wanghan58/models/hf/t5-small",
|
| 558 |
+
"token_embed_dim": 512,
|
| 559 |
+
"freeze_token_embed": 0,
|
| 560 |
+
"c_min": 1.0,
|
| 561 |
+
"c_max": 1024.0,
|
| 562 |
+
"c_schedule": "exp",
|
| 563 |
+
"concat_self_cond": 0,
|
| 564 |
+
"self_cond_ce": 0,
|
| 565 |
+
"self_cond_use_cfg_scale": 0,
|
| 566 |
+
"self_cond_input_cfg": 0,
|
| 567 |
+
"self_cond_cfg_distill": 0,
|
| 568 |
+
"self_cond_prob_add": 0,
|
| 569 |
+
"self_cond_prob_add_scale": 1.0,
|
| 570 |
+
"state_self_cond_prob_add": 1,
|
| 571 |
+
"state_self_cond_prob": 0.5,
|
| 572 |
+
"state_self_cond_scale": 1.0,
|
| 573 |
+
"self_cond_prob": 0.5,
|
| 574 |
+
"self_cond_cfg_min": 0.5,
|
| 575 |
+
"self_cond_cfg_max": 5.0,
|
| 576 |
+
"self_cond_cfg_formula": "elf",
|
| 577 |
+
"self_cond_kl_weight": 0.05,
|
| 578 |
+
"self_cond_kl_warmup": 1000,
|
| 579 |
+
"self_cond_teacher_temp": 1.0,
|
| 580 |
+
"seed": 1234,
|
| 581 |
+
"loader_batches_per_rank": 0,
|
| 582 |
+
"optimizer_steps_per_epoch": 0,
|
| 583 |
+
"steps_per_epoch": 0,
|
| 584 |
+
"effective_batch_size": 512
|
| 585 |
+
}
|
| 586 |
+
[data] mode=elf_hfds rows=elf_hfds length=1024 vocab=32100 seen=0 dropped=0 bos=1:</s> eos=1:</s>
|
| 587 |
+
[optim] optimizer=muon lr=3.000000e-04 blr=1.000000e-03 effective_batch=512 warmup_steps=200 lr_schedule=constant wd=0.0 loader_batches_per_rank=0 optimizer_steps_per_epoch=0
|
| 588 |
+
[embed] init=t5_shared dim=512 freeze=False model_path=/e2e-data/evad-tech-vla/wanghan58/models/hf/t5-small
|
| 589 |
+
[self_cond] ce=False use_cfg_scale=False input_cfg=False distill=False prob_add=False prob_add_scale=1.0 state_prob_add=True state_prob=0.5 state_scale=1.0 concat=False prob=0.5 scale=[0.5,5.0] formula=elf kl_weight=0.05 kl_warmup=1000 teacher_temp=1.0
|
| 590 |
+
Muon: 58 2D params; Nesterov-AdamW: 78 other params
|
| 591 |
+
Muon: 58 2D params; Nesterov-AdamW: 78 other params
|
| 592 |
+
Muon: 58 2D params; Nesterov-AdamW: 78 other params
|
| 593 |
+
[rank1]: Traceback (most recent call last):
|
| 594 |
+
[rank1]: File "/e2e-data/evad-tech-vla/wanghan58/workspace/LTA_openwebtext_dualt/mini_owt_logdirichlet/train.py", line 493, in <module>
|
| 595 |
+
[rank1]: main()
|
| 596 |
+
[rank1]: File "/e2e-data/evad-tech-vla/wanghan58/workspace/LTA_openwebtext_dualt/mini_owt_logdirichlet/train.py", line 352, in main
|
| 597 |
+
[rank1]: ids = next(it)
|
| 598 |
+
[rank1]: ^^^^^^^^
|
| 599 |
+
[rank1]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/dataloader.py", line 708, in __next__
|
| 600 |
+
[rank1]: data = self._next_data()
|
| 601 |
+
[rank1]: ^^^^^^^^^^^^^^^^^
|
| 602 |
+
[rank1]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/dataloader.py", line 1487, in _next_data
|
| 603 |
+
[rank1]: return self._process_data(data, worker_id)
|
| 604 |
+
[rank1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 605 |
+
[rank1]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/dataloader.py", line 1522, in _process_data
|
| 606 |
+
[rank1]: data.reraise()
|
| 607 |
+
[rank1]: File "/usr/local/lib/python3.12/dist-packages/torch/_utils.py", line 733, in reraise
|
| 608 |
+
[rank1]: raise exception
|
| 609 |
+
[rank1]: zipfile.BadZipFile: Caught BadZipFile in DataLoader worker process 0.
|
| 610 |
+
[rank1]: Original Traceback (most recent call last):
|
| 611 |
+
[rank1]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/_utils/worker.py", line 349, in _worker_loop
|
| 612 |
+
[rank1]: data = fetcher.fetch(index) # type: ignore[possibly-undefined]
|
| 613 |
+
[rank1]: ^^^^^^^^^^^^^^^^^^^^
|
| 614 |
+
[rank1]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/_utils/fetch.py", line 33, in fetch
|
| 615 |
+
[rank1]: data.append(next(self.dataset_iter))
|
| 616 |
+
[rank1]: ^^^^^^^^^^^^^^^^^^^^^^^
|
| 617 |
+
[rank1]: File "/e2e-data/evad-tech-vla/wanghan58/workspace/LTA_openwebtext_dualt/mini_owt_logdirichlet/data.py", line 286, in __iter__
|
| 618 |
+
[rank1]: from datasets import Sequence, load_from_disk
|
| 619 |
+
[rank1]: File "/usr/local/lib/python3.12/dist-packages/datasets/__init__.py", line 17, in <module>
|
| 620 |
+
[rank1]: from .arrow_dataset import Dataset
|
| 621 |
+
[rank1]: File "/usr/local/lib/python3.12/dist-packages/datasets/arrow_dataset.py", line 54, in <module>
|
| 622 |
+
[rank1]: import fsspec
|
| 623 |
+
[rank1]: File "/usr/local/lib/python3.12/dist-packages/fsspec/__init__.py", line 69, in <module>
|
| 624 |
+
[rank1]: process_entries()
|
| 625 |
+
[rank1]: File "/usr/local/lib/python3.12/dist-packages/fsspec/__init__.py", line 43, in process_entries
|
| 626 |
+
[rank1]: eps = entry_points()
|
| 627 |
+
[rank1]: ^^^^^^^^^^^^^^
|
| 628 |
+
[rank1]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 913, in entry_points
|
| 629 |
+
[rank1]: return EntryPoints(eps).select(**params)
|
| 630 |
+
[rank1]: ^^^^^^^^^^^^^^^^
|
| 631 |
+
[rank1]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 910, in <genexpr>
|
| 632 |
+
[rank1]: eps = itertools.chain.from_iterable(
|
| 633 |
+
[rank1]: ^
|
| 634 |
+
[rank1]: File "/usr/lib/python3.12/importlib/metadata/_itertools.py", line 16, in unique_everseen
|
| 635 |
+
[rank1]: k = key(element)
|
| 636 |
+
[rank1]: ^^^^^^^^^^^^
|
| 637 |
+
[rank1]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 835, in _normalized_name
|
| 638 |
+
[rank1]: or super()._normalized_name
|
| 639 |
+
[rank1]: ^^^^^^^^^^^^^^^^^^^^^^^^
|
| 640 |
+
[rank1]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 462, in _normalized_name
|
| 641 |
+
[rank1]: return Prepared.normalize(self.name)
|
| 642 |
+
[rank1]: ^^^^^^^^^
|
| 643 |
+
[rank1]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 457, in name
|
| 644 |
+
[rank1]: return self.metadata['Name']
|
| 645 |
+
[rank1]: ^^^^^^^^^^^^^
|
| 646 |
+
[rank1]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 445, in metadata
|
| 647 |
+
[rank1]: or self.read_text('PKG-INFO')
|
| 648 |
+
[rank1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 649 |
+
[rank1]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 819, in read_text
|
| 650 |
+
[rank1]: return self._path.joinpath(filename).read_text(encoding='utf-8')
|
| 651 |
+
[rank1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 652 |
+
[rank1]: File "/usr/lib/python3.12/zipfile/_path/__init__.py", line 339, in read_text
|
| 653 |
+
[rank1]: with self.open('r', encoding, *args, **kwargs) as strm:
|
| 654 |
+
[rank1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 655 |
+
[rank1]: File "/usr/lib/python3.12/zipfile/_path/__init__.py", line 305, in open
|
| 656 |
+
[rank1]: stream = self.root.open(self.at, zip_mode, pwd=pwd)
|
| 657 |
+
[rank1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 658 |
+
[rank1]: File "/usr/lib/python3.12/zipfile/__init__.py", line 1652, in open
|
| 659 |
+
[rank1]: raise BadZipFile(f"Overlapped entries: {zinfo.orig_filename!r} (possible zip bomb)")
|
| 660 |
+
[rank1]: zipfile.BadZipFile: Overlapped entries: 'EGG-INFO/PKG-INFO' (possible zip bomb)
|
| 661 |
+
|
| 662 |
+
[rank7]: Traceback (most recent call last):
|
| 663 |
+
[rank7]: File "/e2e-data/evad-tech-vla/wanghan58/workspace/LTA_openwebtext_dualt/mini_owt_logdirichlet/train.py", line 493, in <module>
|
| 664 |
+
[rank7]: main()
|
| 665 |
+
[rank7]: File "/e2e-data/evad-tech-vla/wanghan58/workspace/LTA_openwebtext_dualt/mini_owt_logdirichlet/train.py", line 352, in main
|
| 666 |
+
[rank7]: ids = next(it)
|
| 667 |
+
[rank7]: ^^^^^^^^
|
| 668 |
+
[rank7]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/dataloader.py", line 708, in __next__
|
| 669 |
+
[rank7]: data = self._next_data()
|
| 670 |
+
[rank7]: ^^^^^^^^^^^^^^^^^
|
| 671 |
+
[rank7]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/dataloader.py", line 1487, in _next_data
|
| 672 |
+
[rank7]: return self._process_data(data, worker_id)
|
| 673 |
+
[rank7]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 674 |
+
[rank7]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/dataloader.py", line 1522, in _process_data
|
| 675 |
+
[rank7]: data.reraise()
|
| 676 |
+
[rank7]: File "/usr/local/lib/python3.12/dist-packages/torch/_utils.py", line 733, in reraise
|
| 677 |
+
[rank7]: raise exception
|
| 678 |
+
[rank7]: zipfile.BadZipFile: Caught BadZipFile in DataLoader worker process 0.
|
| 679 |
+
[rank7]: Original Traceback (most recent call last):
|
| 680 |
+
[rank7]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/_utils/worker.py", line 349, in _worker_loop
|
| 681 |
+
[rank7]: data = fetcher.fetch(index) # type: ignore[possibly-undefined]
|
| 682 |
+
[rank7]: ^^^^^^^^^^^^^^^^^^^^
|
| 683 |
+
[rank7]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/_utils/fetch.py", line 33, in fetch
|
| 684 |
+
[rank7]: data.append(next(self.dataset_iter))
|
| 685 |
+
[rank7]: ^^^^^^^^^^^^^^^^^^^^^^^
|
| 686 |
+
[rank7]: File "/e2e-data/evad-tech-vla/wanghan58/workspace/LTA_openwebtext_dualt/mini_owt_logdirichlet/data.py", line 286, in __iter__
|
| 687 |
+
[rank7]: from datasets import Sequence, load_from_disk
|
| 688 |
+
[rank7]: File "/usr/local/lib/python3.12/dist-packages/datasets/__init__.py", line 17, in <module>
|
| 689 |
+
[rank7]: from .arrow_dataset import Dataset
|
| 690 |
+
[rank7]: File "/usr/local/lib/python3.12/dist-packages/datasets/arrow_dataset.py", line 54, in <module>
|
| 691 |
+
[rank7]: import fsspec
|
| 692 |
+
[rank7]: File "/usr/local/lib/python3.12/dist-packages/fsspec/__init__.py", line 69, in <module>
|
| 693 |
+
[rank7]: process_entries()
|
| 694 |
+
[rank7]: File "/usr/local/lib/python3.12/dist-packages/fsspec/__init__.py", line 43, in process_entries
|
| 695 |
+
[rank7]: eps = entry_points()
|
| 696 |
+
[rank7]: ^^^^^^^^^^^^^^
|
| 697 |
+
[rank7]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 913, in entry_points
|
| 698 |
+
[rank7]: return EntryPoints(eps).select(**params)
|
| 699 |
+
[rank7]: ^^^^^^^^^^^^^^^^
|
| 700 |
+
[rank7]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 910, in <genexpr>
|
| 701 |
+
[rank7]: eps = itertools.chain.from_iterable(
|
| 702 |
+
[rank7]: ^
|
| 703 |
+
[rank7]: File "/usr/lib/python3.12/importlib/metadata/_itertools.py", line 16, in unique_everseen
|
| 704 |
+
[rank7]: k = key(element)
|
| 705 |
+
[rank7]: ^^^^^^^^^^^^
|
| 706 |
+
[rank7]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 835, in _normalized_name
|
| 707 |
+
[rank7]: or super()._normalized_name
|
| 708 |
+
[rank7]: ^^^^^^^^^^^^^^^^^^^^^^^^
|
| 709 |
+
[rank7]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 462, in _normalized_name
|
| 710 |
+
[rank7]: return Prepared.normalize(self.name)
|
| 711 |
+
[rank7]: ^^^^^^^^^
|
| 712 |
+
[rank7]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 457, in name
|
| 713 |
+
[rank7]: return self.metadata['Name']
|
| 714 |
+
[rank7]: ^^^^^^^^^^^^^
|
| 715 |
+
[rank7]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 445, in metadata
|
| 716 |
+
[rank7]: or self.read_text('PKG-INFO')
|
| 717 |
+
[rank7]: ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 718 |
+
[rank7]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 819, in read_text
|
| 719 |
+
[rank7]: return self._path.joinpath(filename).read_text(encoding='utf-8')
|
| 720 |
+
[rank7]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 721 |
+
[rank7]: File "/usr/lib/python3.12/zipfile/_path/__init__.py", line 339, in read_text
|
| 722 |
+
[rank7]: with self.open('r', encoding, *args, **kwargs) as strm:
|
| 723 |
+
[rank7]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 724 |
+
[rank7]: File "/usr/lib/python3.12/zipfile/_path/__init__.py", line 305, in open
|
| 725 |
+
[rank7]: stream = self.root.open(self.at, zip_mode, pwd=pwd)
|
| 726 |
+
[rank7]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 727 |
+
[rank7]: File "/usr/lib/python3.12/zipfile/__init__.py", line 1652, in open
|
| 728 |
+
[rank7]: raise BadZipFile(f"Overlapped entries: {zinfo.orig_filename!r} (possible zip bomb)")
|
| 729 |
+
[rank7]: zipfile.BadZipFile: Overlapped entries: 'EGG-INFO/PKG-INFO' (possible zip bomb)
|
| 730 |
+
|
| 731 |
+
[rank2]: Traceback (most recent call last):
|
| 732 |
+
[rank2]: File "/e2e-data/evad-tech-vla/wanghan58/workspace/LTA_openwebtext_dualt/mini_owt_logdirichlet/train.py", line 493, in <module>
|
| 733 |
+
[rank2]: main()
|
| 734 |
+
[rank2]: File "/e2e-data/evad-tech-vla/wanghan58/workspace/LTA_openwebtext_dualt/mini_owt_logdirichlet/train.py", line 352, in main
|
| 735 |
+
[rank2]: ids = next(it)
|
| 736 |
+
[rank2]: ^^^^^^^^
|
| 737 |
+
[rank2]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/dataloader.py", line 708, in __next__
|
| 738 |
+
[rank2]: data = self._next_data()
|
| 739 |
+
[rank2]: ^^^^^^^^^^^^^^^^^
|
| 740 |
+
[rank2]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/dataloader.py", line 1487, in _next_data
|
| 741 |
+
[rank2]: return self._process_data(data, worker_id)
|
| 742 |
+
[rank2]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 743 |
+
[rank2]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/dataloader.py", line 1522, in _process_data
|
| 744 |
+
[rank2]: data.reraise()
|
| 745 |
+
[rank2]: File "/usr/local/lib/python3.12/dist-packages/torch/_utils.py", line 733, in reraise
|
| 746 |
+
[rank2]: raise exception
|
| 747 |
+
[rank2]: zipfile.BadZipFile: Caught BadZipFile in DataLoader worker process 0.
|
| 748 |
+
[rank2]: Original Traceback (most recent call last):
|
| 749 |
+
[rank2]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/_utils/worker.py", line 349, in _worker_loop
|
| 750 |
+
[rank2]: data = fetcher.fetch(index) # type: ignore[possibly-undefined]
|
| 751 |
+
[rank2]: ^^^^^^^^^^^^^^^^^^^^
|
| 752 |
+
[rank2]: File "/usr/local/lib/python3.12/dist-packages/torch/utils/data/_utils/fetch.py", line 33, in fetch
|
| 753 |
+
[rank2]: data.append(next(self.dataset_iter))
|
| 754 |
+
[rank2]: ^^^^^^^^^^^^^^^^^^^^^^^
|
| 755 |
+
[rank2]: File "/e2e-data/evad-tech-vla/wanghan58/workspace/LTA_openwebtext_dualt/mini_owt_logdirichlet/data.py", line 286, in __iter__
|
| 756 |
+
[rank2]: from datasets import Sequence, load_from_disk
|
| 757 |
+
[rank2]: File "/usr/local/lib/python3.12/dist-packages/datasets/__init__.py", line 17, in <module>
|
| 758 |
+
[rank2]: from .arrow_dataset import Dataset
|
| 759 |
+
[rank2]: File "/usr/local/lib/python3.12/dist-packages/datasets/arrow_dataset.py", line 54, in <module>
|
| 760 |
+
[rank2]: import fsspec
|
| 761 |
+
[rank2]: File "/usr/local/lib/python3.12/dist-packages/fsspec/__init__.py", line 69, in <module>
|
| 762 |
+
[rank2]: process_entries()
|
| 763 |
+
[rank2]: File "/usr/local/lib/python3.12/dist-packages/fsspec/__init__.py", line 43, in process_entries
|
| 764 |
+
[rank2]: eps = entry_points()
|
| 765 |
+
[rank2]: ^^^^^^^^^^^^^^
|
| 766 |
+
[rank2]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 913, in entry_points
|
| 767 |
+
[rank2]: return EntryPoints(eps).select(**params)
|
| 768 |
+
[rank2]: ^^^^^^^^^^^^^^^^
|
| 769 |
+
[rank2]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 910, in <genexpr>
|
| 770 |
+
[rank2]: eps = itertools.chain.from_iterable(
|
| 771 |
+
[rank2]: ^
|
| 772 |
+
[rank2]: File "/usr/lib/python3.12/importlib/metadata/_itertools.py", line 16, in unique_everseen
|
| 773 |
+
[rank2]: k = key(element)
|
| 774 |
+
[rank2]: ^^^^^^^^^^^^
|
| 775 |
+
[rank2]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 835, in _normalized_name
|
| 776 |
+
[rank2]: or super()._normalized_name
|
| 777 |
+
[rank2]: ^^^^^^^^^^^^^^^^^^^^^^^^
|
| 778 |
+
[rank2]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 462, in _normalized_name
|
| 779 |
+
[rank2]: return Prepared.normalize(self.name)
|
| 780 |
+
[rank2]: ^^^^^^^^^
|
| 781 |
+
[rank2]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 457, in name
|
| 782 |
+
[rank2]: return self.metadata['Name']
|
| 783 |
+
[rank2]: ^^^^^^^^^^^^^
|
| 784 |
+
[rank2]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 445, in metadata
|
| 785 |
+
[rank2]: or self.read_text('PKG-INFO')
|
| 786 |
+
[rank2]: ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 787 |
+
[rank2]: File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 819, in read_text
|
| 788 |
+
[rank2]: return self._path.joinpath(filename).read_text(encoding='utf-8')
|
| 789 |
+
[rank2]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 790 |
+
[rank2]: File "/usr/lib/python3.12/zipfile/_path/__init__.py", line 339, in read_text
|
| 791 |
+
[rank2]: with self.open('r', encoding, *args, **kwargs) as strm:
|
| 792 |
+
[rank2]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 793 |
+
[rank2]: File "/usr/lib/python3.12/zipfile/_path/__init__.py", line 305, in open
|
| 794 |
+
[rank2]: stream = self.root.open(self.at, zip_mode, pwd=pwd)
|
| 795 |
+
[rank2]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 796 |
+
[rank2]: File "/usr/lib/python3.12/zipfile/__init__.py", line 1646, in open
|
| 797 |
+
[rank2]: raise BadZipFile(
|
| 798 |
+
[rank2]: zipfile.BadZipFile: File name in directory 'EGG-INFO/PKG-INFO' and header b'\x1b\x91\xfe\x9e\xdf\x02\x80\xf6<\xf4\xa7\x85\xdf\xa5\xdbBj' differ.
|
| 799 |
+
|
| 800 |
+
t-20260601065700-t4vg2-worker-0:10481:10797 [1] NCCL INFO misc/socket.cc:64 -> 3
|
| 801 |
+
t-20260601065700-t4vg2-worker-0:10481:10797 [1] NCCL INFO misc/socket.cc:80 -> 3
|
| 802 |
+
t-20260601065700-t4vg2-worker-0:10481:10797 [1] NCCL INFO misc/socket.cc:828 -> 3
|
| 803 |
+
t-20260601065700-t4vg2-worker-0:10481:10797 [1] NCCL INFO misc/socket.cc:64 -> 3
|
| 804 |
+
t-20260601065700-t4vg2-worker-0:10481:10797 [1] NCCL INFO misc/socket.cc:80 -> 3
|
| 805 |
+
t-20260601065700-t4vg2-worker-0:10481:10797 [1] NCCL INFO misc/socket.cc:828 -> 3
|
| 806 |
+
t-20260601065700-t4vg2-worker-0:10481:10797 [1] NCCL INFO misc/socket.cc:64 -> 3
|
| 807 |
+
t-20260601065700-t4vg2-worker-0:10481:10797 [1] NCCL INFO misc/socket.cc:80 -> 3
|
| 808 |
+
t-20260601065700-t4vg2-worker-0:10481:10797 [1] NCCL INFO misc/socket.cc:828 -> 3
|
| 809 |
+
t-20260601065700-t4vg2-worker-0:10481:10680 [1] NCCL INFO misc/socket.cc:880 -> 3
|
| 810 |
+
t-20260601065700-t4vg2-worker-0:10487:10799 [7] NCCL INFO misc/socket.cc:64 -> 3
|
| 811 |
+
t-20260601065700-t4vg2-worker-0:10487:10799 [7] NCCL INFO misc/socket.cc:80 -> 3
|
| 812 |
+
t-20260601065700-t4vg2-worker-0:10487:10799 [7] NCCL INFO misc/socket.cc:828 -> 3
|
| 813 |
+
t-20260601065700-t4vg2-worker-0:10487:10799 [7] NCCL INFO misc/socket.cc:64 -> 3
|
| 814 |
+
t-20260601065700-t4vg2-worker-0:10487:10799 [7] NCCL INFO misc/socket.cc:80 -> 3
|
| 815 |
+
t-20260601065700-t4vg2-worker-0:10487:10799 [7] NCCL INFO misc/socket.cc:828 -> 3
|
| 816 |
+
t-20260601065700-t4vg2-worker-0:10487:10799 [7] NCCL INFO misc/socket.cc:64 -> 3
|
| 817 |
+
t-20260601065700-t4vg2-worker-0:10487:10799 [7] NCCL INFO misc/socket.cc:80 -> 3
|
| 818 |
+
t-20260601065700-t4vg2-worker-0:10487:10799 [7] NCCL INFO misc/socket.cc:828 -> 3
|
| 819 |
+
t-20260601065700-t4vg2-worker-0:10487:10688 [7] NCCL INFO misc/socket.cc:880 -> 3
|
| 820 |
+
t-20260601065700-t4vg2-worker-0:10482:10801 [2] NCCL INFO misc/socket.cc:64 -> 3
|
| 821 |
+
t-20260601065700-t4vg2-worker-0:10482:10801 [2] NCCL INFO misc/socket.cc:80 -> 3
|
| 822 |
+
t-20260601065700-t4vg2-worker-0:10482:10801 [2] NCCL INFO misc/socket.cc:828 -> 3
|
| 823 |
+
t-20260601065700-t4vg2-worker-0:10482:10801 [2] NCCL INFO misc/socket.cc:64 -> 3
|
| 824 |
+
t-20260601065700-t4vg2-worker-0:10482:10801 [2] NCCL INFO misc/socket.cc:80 -> 3
|
| 825 |
+
t-20260601065700-t4vg2-worker-0:10482:10801 [2] NCCL INFO misc/socket.cc:828 -> 3
|
| 826 |
+
t-20260601065700-t4vg2-worker-0:10482:10801 [2] NCCL INFO misc/socket.cc:64 -> 3
|
| 827 |
+
t-20260601065700-t4vg2-worker-0:10481:10680 [1] NCCL INFO misc/socket.cc:880 -> 3
|
| 828 |
+
t-20260601065700-t4vg2-worker-0:10482:10801 [2] NCCL INFO misc/socket.cc:80 -> 3
|
| 829 |
+
t-20260601065700-t4vg2-worker-0:10482:10801 [2] NCCL INFO misc/socket.cc:828 -> 3
|
| 830 |
+
t-20260601065700-t4vg2-worker-0:10482:10690 [2] NCCL INFO misc/socket.cc:880 -> 3
|
| 831 |
+
t-20260601065700-t4vg2-worker-0:10482:10801 [2] NCCL INFO misc/socket.cc:64 -> 3
|
| 832 |
+
t-20260601065700-t4vg2-worker-0:10482:10801 [2] NCCL INFO misc/socket.cc:80 -> 3
|
| 833 |
+
t-20260601065700-t4vg2-worker-0:10482:10801 [2] NCCL INFO misc/socket.cc:828 -> 3
|
| 834 |
+
t-20260601065700-t4vg2-worker-0:10481:10797 [1] NCCL INFO comm 0x9cb2570 rank 1 nranks 8 cudaDev 1 busId 67020 - Abort COMPLETE
|
| 835 |
+
W0531 22:58:40.051000 10413 torch/distributed/elastic/multiprocessing/api.py:898] Sending process 10480 closing signal SIGTERM
|
| 836 |
+
W0531 22:58:40.053000 10413 torch/distributed/elastic/multiprocessing/api.py:898] Sending process 10482 closing signal SIGTERM
|
| 837 |
+
W0531 22:58:40.053000 10413 torch/distributed/elastic/multiprocessing/api.py:898] Sending process 10483 closing signal SIGTERM
|
| 838 |
+
W0531 22:58:40.054000 10413 torch/distributed/elastic/multiprocessing/api.py:898] Sending process 10484 closing signal SIGTERM
|
| 839 |
+
W0531 22:58:40.055000 10413 torch/distributed/elastic/multiprocessing/api.py:898] Sending process 10485 closing signal SIGTERM
|
| 840 |
+
W0531 22:58:40.056000 10413 torch/distributed/elastic/multiprocessing/api.py:898] Sending process 10486 closing signal SIGTERM
|
| 841 |
+
W0531 22:58:40.057000 10413 torch/distributed/elastic/multiprocessing/api.py:898] Sending process 10487 closing signal SIGTERM
|
| 842 |
+
E0531 22:58:40.487000 10413 torch/distributed/elastic/multiprocessing/api.py:870] failed (exitcode: 1) local_rank: 1 (pid: 10481) of binary: /usr/bin/python
|
| 843 |
+
Traceback (most recent call last):
|
| 844 |
+
File "/usr/local/bin/torchrun", line 33, in <module>
|
| 845 |
+
sys.exit(load_entry_point('torch==2.7.0a0+ecf3bae40a.nv25.2', 'console_scripts', 'torchrun')())
|
| 846 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 847 |
+
File "/usr/local/lib/python3.12/dist-packages/torch/distributed/elastic/multiprocessing/errors/__init__.py", line 355, in wrapper
|
| 848 |
+
return f(*args, **kwargs)
|
| 849 |
+
^^^^^^^^^^^^^^^^^^
|
| 850 |
+
File "/usr/local/lib/python3.12/dist-packages/torch/distributed/run.py", line 918, in main
|
| 851 |
+
run(args)
|
| 852 |
+
File "/usr/local/lib/python3.12/dist-packages/torch/distributed/run.py", line 909, in run
|
| 853 |
+
elastic_launch(
|
| 854 |
+
File "/usr/local/lib/python3.12/dist-packages/torch/distributed/launcher/api.py", line 139, in __call__
|
| 855 |
+
return launch_agent(self._config, self._entrypoint, list(args))
|
| 856 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 857 |
+
File "/usr/local/lib/python3.12/dist-packages/torch/distributed/launcher/api.py", line 270, in launch_agent
|
| 858 |
+
raise ChildFailedError(
|
| 859 |
+
torch.distributed.elastic.multiprocessing.errors.ChildFailedError:
|
| 860 |
+
============================================================
|
| 861 |
+
train.py FAILED
|
| 862 |
+
------------------------------------------------------------
|
| 863 |
+
Failures:
|
| 864 |
+
<NO_OTHER_FAILURES>
|
| 865 |
+
------------------------------------------------------------
|
| 866 |
+
Root Cause (first observed failure):
|
| 867 |
+
[0]:
|
| 868 |
+
time : 2026-05-31_22:58:40
|
| 869 |
+
host : t-20260601065700-t4vg2-worker-0.t-20260601065700-t4vg2-worker.mlplatform-customtask.svc.cluster.local
|
| 870 |
+
rank : 1 (local_rank: 1)
|
| 871 |
+
exitcode : 1 (pid: 10481)
|
| 872 |
+
error_file: <N/A>
|
| 873 |
+
traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html
|
| 874 |
+
============================================================
|
| 875 |
+
[exit] 2026-05-31T22:58:40+00:00 rc=1 run=owt_t5_elftokenized_full_len1024_C1_to_1024_pow1_d768_l12_h12_gbs512_8gpu_50ep_lr3e4_elfopt_t5embed_unfixed_stateprobadd_selfcond_ce_fast_20260531_225829
|