frontend/pytorch: add aten::cross_entropy_loss translator and tests (fixes #29691, relates #28584) #32554
+213
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
1. Core Implementation
File:
src/frontends/pytorch/src/op/cross_entropy_loss.cppImplements the
translate_cross_entropy_lossfunction that converts PyTorch's cross_entropy_loss operation to OpenVINO operations. The implementation follows PyTorch's specification:Key features:
LogSoftmaxalong dimension 1 (class dimension)ReduceSumto select target class probabilities (NLL loss)Gather+Multiplynone(0): No reduction, returns per-sample lossmean(1): Mean of all losses (default)sum(2): Sum of all losses(N, C)and higher-dimensional inputs(N, C, d1, d2, ...)2. Operation Registration
File:
src/frontends/pytorch/src/op_table.cppOP_CONVERTER(translate_cross_entropy_loss);{"aten::cross_entropy_loss", op::translate_cross_entropy_loss},3. Tests
File:
tests/layer_tests/pytorch_tests/test_cross_entropy_loss.pyComprehensive test suite covering:
mean,sum,none)