From e49b8592d5702ddf1b2053629320750f34c9ce96 Mon Sep 17 00:00:00 2001 From: Prathik Rao Date: Mon, 8 Jan 2024 17:45:46 +0000 Subject: [PATCH] ToBFloat16 -> MakeBFloat16 --- onnxruntime/test/common/tensor_op_test_utils.h | 9 --------- onnxruntime/test/contrib_ops/layer_norm_op_test.cc | 13 +++---------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/onnxruntime/test/common/tensor_op_test_utils.h b/onnxruntime/test/common/tensor_op_test_utils.h index 277fdd71f1d85..6917aa15777a2 100644 --- a/onnxruntime/test/common/tensor_op_test_utils.h +++ b/onnxruntime/test/common/tensor_op_test_utils.h @@ -156,15 +156,6 @@ inline std::vector ToFloat16(const std::vector& data) { return result; } -inline std::vector ToBFloat16(const std::vector& data) { - std::vector result; - result.reserve(data.size()); - for (size_t i = 0; i < data.size(); i++) { - result.push_back(BFloat16(data[i])); - } - return result; -} - inline void CheckTensor(const Tensor& expected_tensor, const Tensor& output_tensor, double rtol, double atol) { ORT_ENFORCE(expected_tensor.Shape() == output_tensor.Shape(), "Expected output shape [" + expected_tensor.Shape().ToString() + diff --git a/onnxruntime/test/contrib_ops/layer_norm_op_test.cc b/onnxruntime/test/contrib_ops/layer_norm_op_test.cc index ec19af3f5d1f5..4b412516b804c 100644 --- a/onnxruntime/test/contrib_ops/layer_norm_op_test.cc +++ b/onnxruntime/test/contrib_ops/layer_norm_op_test.cc @@ -76,20 +76,13 @@ TEST(LayerNormTest, LayerNorm) { } TEST(LayerNormTest, LayerNorm_BFloat16Input) { - #ifdef USE_CUDA - int min_cuda_architecture = 530; - if (!HasCudaEnvironment(min_cuda_architecture)) { - LOGS_DEFAULT(WARNING) << "Hardware NOT support BFP16"; - return; - } - #endif OpTester test("LayerNormalization"); test.AddAttribute("epsilon", 1e-05f); std::vector dims{1, 2, 3}; - test.AddInput("x", dims, ToBFloat16({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f})); - test.AddInput("gamma", {3}, ToBFloat16({1.0f, 1.0f, 1.0f})); - test.AddOutput("output", dims, ToBFloat16({-1.2247f, 0.0f, 1.2247f, -1.2247f, 0.0f, 1.2247f})); + test.AddInput("x", dims, MakeBFloat16({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f})); + test.AddInput("gamma", {3}, MakeBFloat16({1.0f, 1.0f, 1.0f})); + test.AddOutput("output", dims, MakeBFloat16({-1.2247f, 0.0f, 1.2247f, -1.2247f, 0.0f, 1.2247f})); test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kCudaExecutionProvider}); }