Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kernels/portable/cpu/op_log_softmax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Tensor& log_softmax_out(
// Adjust for negative dim
dim = dim < 0 ? dim + nonzero_dim(in) : dim;

ET_SWITCH_FLOAT_TYPES(
ET_SWITCH_FLOATHBF16_TYPES(
in.scalar_type(), ctx, "_log_softmax.out", CTYPE, [&]() {
const CTYPE* const in_data = in.const_data_ptr<CTYPE>();
CTYPE* const out_data = out.mutable_data_ptr<CTYPE>();
Expand Down
18 changes: 12 additions & 6 deletions kernels/test/op_log_softmax_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@ class OpLogSoftmaxOutTest : public OperatorTest {
});
// clang-format on

EXPECT_TENSOR_CLOSE(out, expected);
if constexpr (DTYPE == ScalarType::BFloat16) {
EXPECT_TENSOR_CLOSE_WITH_TOL(
out,
expected,
1e-2,
executorch::runtime::testing::internal::kDefaultAtol);
} else {
EXPECT_TENSOR_CLOSE(out, expected);
}
}
};

Expand All @@ -88,11 +96,9 @@ TEST_F(OpLogSoftmaxOutTest, AllDtypesSupported) {
GTEST_SKIP() << "This kernel does not support dtype double";
}

test_dtype<float, ScalarType::Float>();
test_dtype<double, ScalarType::Double>();
// TODO: Also add tests for half, complex, quantized, and other types. Easiest
// way to do that would be to make TensorFactory support zeros() and ones()
// for those types.
#define TEST_ENTRY(ctype, dtype) test_dtype<ctype, ScalarType::dtype>();
ET_FORALL_FLOATHBF16_TYPES(TEST_ENTRY)
#undef TEST_ENTRY
}

TEST_F(OpLogSoftmaxOutTest, MismatchedDimensionsDies) {
Expand Down
Loading