Optimized le.Tensor_out returns b <= a for reverse-argument broadcasts
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- machine-learning
Línea de trabajo
Start with kernels/optimized/cpu/op_le.cpp and the reverse-argument handling described in the issue; then inspect the related tests in kernels/test/op_le_test.cpp. Add regression coverage that exercises the optimized paths with matching input and output dtypes. Done means those paths produce the expected a <= b results for the listed broadcast shapes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
With the optimized CPU kernels, le.Tensor_out returns b <= a instead of a <= b when the left operand is the one being broadcast and both inputs and the output share a dtype (for example two Bool masks, or a non-Bool output).
Repro (C++ kernel test)
TensorFactory<ScalarType::Bool> tf;
Tensor a = tf.make({4}, {false, true, false, true});
Tensor b = tf.make({2, 4}, {false, false, true, true, true, true, false, false});
Tensor out = tf.zeros({2, 4});
torch::executor::aten::le_outf(context_, a, b, out);
| Result | |
|---|---|
Expected (a <= b, also what the portable kernel returns) |
{1, 0, 1, 1, 1, 1, 1, 0} |
| Optimized kernel | {1, 1, 0, 1, 0, 1, 1, 1} (that is b <= a) |
The same happens for Float and Int inputs with a Float/Int output, on all three reverse-argument broadcast paths: (4,) vs (2, 4), (2, 1) vs (2, 3), and (2, 1, 2) vs (2, 3, 2). Float inputs with a Bool output are not affected, because select_optimized_path returns kNone when the output dtype differs and the portable comparison is used.
Cause
select_optimized_path returns kBroadcast2dBy1dReverseArguments, kBroadcastLastDimReverseArguments or kBroadcastNdByNdReverseArguments when the left operand is the broadcast one, and handle_broadcast_elementwise then calls the lambda with the operands swapped. op_div.cpp and op_add_sub_impl.h account for this by swapping their lambda on those paths, but op_le.cpp always passes x.le(y):
https://github.com/pytorch/executorch/blob/aed328df53/kernels/optimized/cpu/op_le.cpp#L57-L63
The existing BroadcastLastDimReverseTest, BroadcastNdByNdReverseTest and similar tests in kernels/test/op_le_test.cpp use a Bool output with Int inputs, so they take the portable path and never exercise the optimized broadcast code.
I have a fix with regression tests and will open a PR.
Versions
main at aed328df53, built from source with CMake (EXECUTORCH_BUILD_TESTS=ON, EXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON), Ubuntu, x86_64, GCC 15.2.0.
- Lenguaje dominante
- Python
- Estrellas
- 5.1k
- Forks
- 1.2k
- Merge medio
- 1 d 22 h
- PR fusionados (30 d)
- 675
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pytorch/executorch
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
pytorch/executorch#24434 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
pytorch/executorch#24410 ·
Los mantenedores suelen responder en 1 día
-
enhancement triaged
Dificultad 2/5 Medio día Aptitud para principiantes 68/100
pytorch/executorch#21640 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
pytorch/executorch#24502 ·
Los mantenedores suelen responder en 1 día
-
`install_executorch.sh` fails in a fresh uv virtual environment: `No module named pip`Posiblemente ocupada @mshr-h la tomó hace 3 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
pytorch/executorch#24417 ·
Los mantenedores suelen responder en 1 día
Todos los issues de pytorch/executorch
Issues similares
-
curriculum documentation quality
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
githubnext/gh-aw-workshop#5367 ·
Los mantenedores suelen responder en 3 días
-
Create Noise Latents ignores randomize_seed and produces the same noise every runPosiblemente ocupada @griptapeops la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
griptape-ai/griptape-nodes-library-diffusers#127 ·
Los mantenedores suelen responder en 1 día
-
Jenkins capacity report: metrics history is lost when archiving a month failsPosiblemente ocupada @RaphaelFakhri la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
adoptium/infrastructure#4568 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
huggingface/deep-rl-class#723 ·
-
premises-missing
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
WingedGuardian/GENesis-AGI#3928 ·
Los mantenedores suelen responder en 1 día