Skip to content

Commit d8fb97c

Browse files
committed
feat: implement fmaxbf16 function
Signed-off-by: Krishna Pandey <[email protected]>
1 parent 0fffb9f commit d8fb97c

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

libc/src/math/fmaxbf16.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Implementation header for fmaxbf16 ----------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_MATH_FMAXBF16_H
10+
#define LLVM_LIBC_SRC_MATH_FMAXBF16_H
11+
12+
#include "src/__support/macros/config.h"
13+
#include "src/__support/macros/properties/types.h"
14+
15+
namespace LIBC_NAMESPACE_DECL {
16+
17+
bfloat16 fmaxbf16(bfloat16 x, bfloat16 y);
18+
19+
} // namespace LIBC_NAMESPACE_DECL
20+
21+
#endif // LLVM_LIBC_SRC_MATH_FMAXBF16_H

libc/src/math/generic/fmaxbf16.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Implementation of fmaxbf16 function -------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/math/fmaxbf16.h"
10+
#include "src/__support/FPUtil/BasicOperations.h"
11+
#include "src/__support/FPUtil/bfloat16.h"
12+
#include "src/__support/common.h"
13+
#include "src/__support/macros/config.h"
14+
15+
namespace LIBC_NAMESPACE_DECL {
16+
17+
LLVM_LIBC_FUNCTION(bfloat16, fmaxbf16, (bfloat16 x, bfloat16 y)) {
18+
return fputil::fmax(x, y);
19+
}
20+
21+
} // namespace LIBC_NAMESPACE_DECL
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===-- Unittests for fmaxbf16 --------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "FMaxTest.h"
10+
11+
#include "src/__support/FPUtil/bfloat16.h"
12+
#include "src/math/fmaxbf16.h"
13+
14+
LIST_FMAX_TESTS(bfloat16, LIBC_NAMESPACE::fmaxbf16)

0 commit comments

Comments
 (0)