diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 023b9d48f24..6e9a772392e 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -7,7 +7,7 @@ jobs: benchmark: uses: ROCmSoftwarePlatform/actions/.github/workflows/benchmarks.yml@main with: - rocm_version: 5.2 + rocm_version: 5.7 script_repo: migraphx-benchmark/benchmark-utils result_path: /usr/share/migraphx/test-results result_repo: ROCmSoftwarePlatform/comparison-results diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8f755dfbe4e..aad99c2cd1f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -141,6 +141,7 @@ jobs: -DROCM_ENABLE_GH_ANNOTATIONS=On \ -DCLANG_TIDY_DEPEND_ON_TARGET=Off \ -DCLANG_TIDY_CACHE=/data/tidy-cache \ + -DGPU_TARGETS=gfx908 \ .. make -j$(nproc) -k onnx-proto tf-proto tidy @@ -190,6 +191,7 @@ jobs: -DCPPCHECK_BUILD_DIR=/data/cppcheck-cache \ -DBUILD_DEV=On \ -DROCM_ENABLE_GH_ANNOTATIONS=On \ + -DGPU_TARGETS=gfx908 \ .. make -j$(nproc) cppcheck @@ -279,6 +281,7 @@ jobs: -DBUILD_DEV=On \ -DCMAKE_CXX_COMPILER_LAUNCHER=/usr/local/bin/ccache \ -DCMAKE_C_COMPILER_LAUNCHER=/usr/local/bin/ccache \ + -DGPU_TARGETS=gfx908 \ .. make -j$(nproc) tests driver @@ -336,6 +339,7 @@ jobs: steps: - name: Free space uses: jlumbroso/free-disk-space@main + continue-on-error: true with: tool-cache: true android: true diff --git a/.github/workflows/performance.yaml b/.github/workflows/performance.yaml index 95fd33e5768..eb55d727edd 100644 --- a/.github/workflows/performance.yaml +++ b/.github/workflows/performance.yaml @@ -12,7 +12,7 @@ on: rocm_release: description: ROCm Version required: true - default: '5.6' + default: '5.7' performance_reports_repo: description: Repository where performance reports are stored required: true @@ -50,7 +50,7 @@ jobs: release: uses: ROCmSoftwarePlatform/migraphx-benchmark/.github/workflows/perf-test.yml@main with: - rocm_release: ${{ github.event.inputs.rocm_release || '5.6' }} + rocm_release: ${{ github.event.inputs.rocm_release || '5.7' }} result_number: ${{ github.event.inputs.result_number || '10' }} flags: ${{ github.event.inputs.flags || '-r' }} performance_reports_repo: ${{ github.event.inputs.performance_reports_repo || 'ROCmSoftwarePlatform/migraphx-reports' }} diff --git a/.gitignore b/.gitignore index 92697fb2dd2..57ae0b01788 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,6 @@ docs/html cmake-build*/ build*/ +# Recommended location to install rbuild dependencies from README.md +depend + diff --git a/CMakeLists.txt b/CMakeLists.txt index b7ec4ec0701..499e307bc37 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,6 +162,8 @@ rocm_enable_clang_tidy( -cppcoreguidelines-pro-type-vararg -cppcoreguidelines-special-member-functions -cppcoreguidelines-virtual-class-destructor + -cppcoreguidelines-avoid-capture-default-when-capturing-this + -cppcoreguidelines-rvalue-reference-param-not-moved -google-readability-* -google-runtime-int -google-runtime-references diff --git a/Dockerfile b/Dockerfile index 69b6971f3ce..fcae5a21959 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y gnupg2 --no-install-recommends curl && curl -sL http://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - # Add rocm repository -RUN sh -c 'echo deb [arch=amd64 trusted=yes] http://repo.radeon.com/rocm/apt/5.6/ focal main > /etc/apt/sources.list.d/rocm.list' +RUN sh -c 'echo deb [arch=amd64 trusted=yes] http://repo.radeon.com/rocm/apt/5.7/ focal main > /etc/apt/sources.list.d/rocm.list' # From docs.amd.com for installing rocm. Needed to install properly RUN sh -c "echo 'Package: *\nPin: release o=repo.radeon.com\nPin-priority: 600' > /etc/apt/preferences.d/rocm-pin-600" diff --git a/Jenkinsfile b/Jenkinsfile index 1c402e96b1a..49f30cf34cc 100755 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -107,11 +107,11 @@ rocmtest clang_debug: rocmnode('cdna') { cmake_build -> stage('hipRTC Debug') { def sanitizers = "undefined" def debug_flags = "-g -O2 -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}" - cmake_build(flags: "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}' -DCMAKE_C_FLAGS_DEBUG='${debug_flags}' -DMIGRAPHX_USE_HIPRTC=On", gpu_debug: true) + cmake_build(flags: "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}' -DCMAKE_C_FLAGS_DEBUG='${debug_flags}' -DMIGRAPHX_USE_HIPRTC=On -DGPU_TARGETS=$(/opt/rocm/bin/rocminfo | grep -o -m1 'gfx.*')", gpu_debug: true) } -}, clang_release: rocmnode('cdna') { cmake_build -> +}, clang_release: rocmnode('mi100+') { cmake_build -> stage('Hip Clang Release') { - cmake_build(flags: "-DCMAKE_BUILD_TYPE=release") + cmake_build(flags: "-DCMAKE_BUILD_TYPE=release -DGPU_TARGETS=$(/opt/rocm/bin/rocminfo | grep -o -m1 'gfx.*')") stash includes: 'build/*.deb', name: 'migraphx-package' } // }, hidden_symbols: rocmnode('cdna') { cmake_build -> @@ -120,7 +120,7 @@ rocmtest clang_debug: rocmnode('cdna') { cmake_build -> // } }, all_targets_debug : rocmnode('cdna') { cmake_build -> stage('All targets Release') { - cmake_build(flags: "-DCMAKE_BUILD_TYPE=release -DMIGRAPHX_ENABLE_GPU=On -DMIGRAPHX_ENABLE_CPU=On -DMIGRAPHX_ENABLE_FPGA=On") + cmake_build(flags: "-DCMAKE_BUILD_TYPE=release -DMIGRAPHX_ENABLE_GPU=On -DMIGRAPHX_ENABLE_CPU=On -DMIGRAPHX_ENABLE_FPGA=On -DGPU_TARGETS=$(/opt/rocm/bin/rocminfo | grep -o -m1 'gfx.*')") } }, mlir_debug: rocmnode('cdna') { cmake_build -> stage('MLIR Debug') { @@ -129,13 +129,13 @@ rocmtest clang_debug: rocmnode('cdna') { cmake_build -> // Note: the -fno-sanitize= is copied from upstream LLVM_UBSAN_FLAGS. def debug_flags_cxx = "-g -O2 -fsanitize=${sanitizers} -fno-sanitize=vptr,function -fno-sanitize-recover=${sanitizers}" def debug_flags = "-g -O2 -fsanitize=${sanitizers} -fno-sanitize=vptr -fno-sanitize-recover=${sanitizers}" - cmake_build(flags: "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DMIGRAPHX_ENABLE_MLIR=On -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags_cxx}' -DCMAKE_C_FLAGS_DEBUG='${debug_flags}'") + cmake_build(flags: "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DMIGRAPHX_ENABLE_MLIR=On -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags_cxx}' -DCMAKE_C_FLAGS_DEBUG='${debug_flags}' -DGPU_TARGETS=$(/opt/rocm/bin/rocminfo | grep -o -m1 'gfx.*')") } } }, ck_release: rocmnode('mi100+') { cmake_build -> stage('CK Release') { withEnv(['MIGRAPHX_ENABLE_CK=1', 'MIGRAPHX_TUNE_CK=1']) { - cmake_build(flags: "-DCMAKE_BUILD_TYPE=release") + cmake_build(flags: "-DCMAKE_BUILD_TYPE=release -DGPU_TARGETS=$(/opt/rocm/bin/rocminfo | grep -o -m1 'gfx.*')") } } }, clang_asan: rocmnode('nogpu') { cmake_build -> @@ -159,13 +159,14 @@ def onnxnode(name, body) { } } -rocmtest onnx: onnxnode('cdna') { cmake_build -> +rocmtest onnx: onnxnode('mi100+') { cmake_build -> stage("Onnx runtime") { sh ''' apt install half #ls -lR md5sum ./build/*.deb dpkg -i ./build/*.deb + env cd /onnxruntime && ./build_and_test_onnxrt.sh ''' } diff --git a/docs/.sphinx/requirements.txt b/docs/.sphinx/requirements.txt index 55d6c9742f0..1cb36ab86ed 100644 --- a/docs/.sphinx/requirements.txt +++ b/docs/.sphinx/requirements.txt @@ -21,7 +21,7 @@ charset-normalizer==3.1.0 # via requests click==8.1.3 # via sphinx-external-toc -cryptography==41.0.3 +cryptography==41.0.4 # via pyjwt deprecated==1.2.13 # via pygithub @@ -87,7 +87,7 @@ requests==2.28.2 # via # pygithub # sphinx -rocm-docs-core>=0.20.0 +rocm-docs-core==0.24.2 # via -r requirements.in smmap==5.0.0 # via gitdb diff --git a/docs/dev_intro.rst b/docs/dev_intro.rst index 6268a68616f..a64cdd5cc38 100644 --- a/docs/dev_intro.rst +++ b/docs/dev_intro.rst @@ -131,7 +131,7 @@ In this case, we can create `argument ` objects directly fro std::vector results_vector(64); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, sol)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, sol)); An `argument ` can handle memory buffers from either the GPU or the CPU. By default when running the `program `, buffers are allocated on the corresponding target. diff --git a/docs/driver.rst b/docs/driver.rst index baa7047f124..82b12c7fad6 100755 --- a/docs/driver.rst +++ b/docs/driver.rst @@ -50,9 +50,17 @@ Runs reference and CPU or GPU implementations and checks outputs for consistency .. include:: ./driver/compile.rst -.. option:: --tolerance [double] +.. option:: --rms-tol [double] -Tolerance for errors (Default: 80) +Tolerance for RMS error (Default: 0.001) + +.. option:: --atol [double] + +Tolerance for elementwise absolute difference (Default: 0.001) + +.. option:: --rtol [double] + +Tolerance for elementwise relative difference (Default: 0.001) .. option:: -i, --per-instruction diff --git a/examples/migraphx/migraphx_driver/README.md b/examples/migraphx/migraphx_driver/README.md index cc6ba1a1662..972137ceab7 100755 --- a/examples/migraphx/migraphx_driver/README.md +++ b/examples/migraphx/migraphx_driver/README.md @@ -55,7 +55,9 @@ See below for a comprehensive list of commands and option arguments, as well as | --exhaustive-tune | Enable exhaustive search to find fastest kernel | | --fp16 | Quantize for fp16 | | --int8 | Quantize for int8 | -| --tolerance | Tolerance for errors | +| --rms-tol | Tolerance for the RMS error (Default: 0.001) | +| --atol | Tolerance for elementwise absolute difference (Default: 0.001) | +| --rtol | Tolerance for elementwise relative difference (Default: 0.001) | | --per-instruction \| -i | Verify each instruction | | --reduce \| -r | Reduce program and verify | | --iterations \| -n | Number of iterations to run for perf report | diff --git a/hip-clang.docker b/hip-clang.docker index 6f7b582576c..b1c805f2044 100755 --- a/hip-clang.docker +++ b/hip-clang.docker @@ -6,7 +6,7 @@ ARG PREFIX=/usr/local RUN dpkg --add-architecture i386 # Add rocm repository -RUN sh -c 'echo deb [arch=amd64 trusted=yes] http://repo.radeon.com/rocm/apt/5.6/ focal main > /etc/apt/sources.list.d/rocm.list' +RUN sh -c 'echo deb [arch=amd64 trusted=yes] http://repo.radeon.com/rocm/apt/5.7/ focal main > /etc/apt/sources.list.d/rocm.list' # Install dependencies RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f22d89aa04f..a00242f4de8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -197,6 +197,7 @@ register_migraphx_ops( reduce_sum relu reshape + reshape_lazy reverse rnn rnn_last_cell_output diff --git a/src/auto_contiguous.cpp b/src/auto_contiguous.cpp index 39ccc4c184e..8ccb8739776 100644 --- a/src/auto_contiguous.cpp +++ b/src/auto_contiguous.cpp @@ -25,7 +25,6 @@ #include #include #include - #include namespace migraphx { diff --git a/src/driver/main.cpp b/src/driver/main.cpp index 9ce7e98b397..4a920d66618 100644 --- a/src/driver/main.cpp +++ b/src/driver/main.cpp @@ -536,13 +536,19 @@ struct params : command struct verify : command { compiler c; - double tolerance = 80; + migraphx::verify::tolerance tols; bool per_instruction = false; bool reduce = false; void parse(argument_parser& ap) { c.parse(ap); - ap(tolerance, {"--tolerance"}, ap.help("Tolerance for errors")); + ap(tols.rms_tol, {"--rms-tol"}, ap.help("Tolerance for the RMS error (Default: 0.001)")); + ap(tols.atol, + {"--atol"}, + ap.help("Tolerance for the elementwise absolute difference (Default: 0.001)")); + ap(tols.rtol, + {"--rtol"}, + ap.help("Tolerance for the elementwise relative difference (Default: 0.001)")); ap(per_instruction, {"-i", "--per-instruction"}, ap.help("Verify each instruction"), @@ -567,15 +573,15 @@ struct verify : command if(per_instruction) { - verify_instructions(p, t, c.co, quantize, tolerance); + verify_instructions(p, t, c.co, quantize, tols); } else if(reduce) { - verify_reduced_program(p, t, c.co, quantize, m, tolerance); + verify_reduced_program(p, t, c.co, quantize, m, tols); } else { - verify_program(c.l.file, p, t, c.co, quantize, m, tolerance); + verify_program(c.l.file, p, t, c.co, quantize, m, tols); } } }; diff --git a/src/driver/verify.cpp b/src/driver/verify.cpp index bef5c546ce5..df028a693ed 100644 --- a/src/driver/verify.cpp +++ b/src/driver/verify.cpp @@ -77,24 +77,24 @@ void verify_program(const std::string& name, compile_options options, precision quantize, const parameter_map& inputs, - double tolerance) + verify::tolerance tols) { - auto x = run_ref(p, inputs); - auto y = run_target(p, t, options, quantize, inputs); + auto ref_outs = run_ref(p, inputs); + auto target_outs = run_target(p, t, options, quantize, inputs); - std::size_t output_num = x.size(); + std::size_t output_num = ref_outs.size(); for(std::size_t i = 0; i < output_num; ++i) { - if(x[i].get_shape().type() != y[i].get_shape().type() or - x[i].get_shape().lens() != y[i].get_shape().lens()) + if(ref_outs[i].get_shape().type() != target_outs[i].get_shape().type() or + ref_outs[i].get_shape().lens() != target_outs[i].get_shape().lens()) { std::cout << "FAILED: " << name << std::endl; - std::cout << "Shape mismatch {" << x[i].get_shape() << "} != {" << y[i].get_shape() - << "}" << std::endl; + std::cout << "Shape mismatch {" << ref_outs[i].get_shape() << "} != {" + << target_outs[i].get_shape() << "}" << std::endl; } else { - verify_args(name, x[i], y[i], tolerance); + verify_args(name, target_outs[i], verify::expected{ref_outs[i]}, tols); } } } @@ -103,7 +103,7 @@ void verify_instructions(const program& prog, const target& t, compile_options options, precision quantize, - double tolerance) + verify::tolerance tols) { const auto* mm_prog = prog.get_main_module(); for(auto&& ins : (*mm_prog)) @@ -134,8 +134,7 @@ void verify_instructions(const program& prog, { std::cout << "Verify: " << ins.name() << std::endl; std::cout << p << std::endl; - verify_program( - ins.name(), p, t, options, quantize, create_param_map(p, false), tolerance); + verify_program(ins.name(), p, t, options, quantize, create_param_map(p, false), tols); } catch(...) { @@ -151,7 +150,7 @@ void verify_reduced(program p, compile_options options, precision quantize, const parameter_map& inputs, - double tolerance) + verify::tolerance tols) { auto* mm = p.get_main_module(); auto last = std::prev(mm->end(), n); @@ -160,7 +159,7 @@ void verify_reduced(program p, std::cout << p << std::endl; try { - verify_program(std::to_string(n), p, t, options, quantize, inputs, tolerance); + verify_program(std::to_string(n), p, t, options, quantize, inputs, tols); } catch(const std::exception& e) { @@ -174,7 +173,7 @@ void verify_reduced_program(const program& p, compile_options options, precision quantize, const parameter_map& inputs, - double tolerance) + verify::tolerance tols) { const auto* mm = p.get_main_module(); auto n = std::distance(mm->begin(), mm->end()); @@ -187,7 +186,7 @@ void verify_reduced_program(const program& p, std::cout << "Skip: " << i << std::endl; continue; } - verify_reduced(p, i, t, options, quantize, inputs, tolerance); + verify_reduced(p, i, t, options, quantize, inputs, tols); } } diff --git a/src/driver/verify.hpp b/src/driver/verify.hpp index 285b7012c8a..63ac161f252 100644 --- a/src/driver/verify.hpp +++ b/src/driver/verify.hpp @@ -26,6 +26,7 @@ #include "precision.hpp" #include +#include namespace migraphx { namespace driver { @@ -37,18 +38,18 @@ void verify_program(const std::string& name, compile_options options = compile_options{}, precision quantize = precision::fp32, const parameter_map& inputs = {}, - double tolerance = 100); + verify::tolerance tols = verify::tolerance{}); void verify_instructions(const program& prog, const target& t, compile_options options = compile_options{}, precision quantize = precision::fp32, - double tolerance = 80); + verify::tolerance tols = verify::tolerance{}); void verify_reduced_program(const program& p, const target& t, compile_options options = compile_options{}, precision quantize = precision::fp32, const parameter_map& inputs = {}, - double tolerance = 80); + verify::tolerance tols = verify::tolerance{}); } // namespace MIGRAPHX_INLINE_NS } // namespace driver diff --git a/src/include/migraphx/instruction.hpp b/src/include/migraphx/instruction.hpp index d9fe7794aab..377804e7b75 100644 --- a/src/include/migraphx/instruction.hpp +++ b/src/include/migraphx/instruction.hpp @@ -81,6 +81,7 @@ struct MIGRAPHX_EXPORT instruction const std::vector& module_inputs() const; + /// Where this instruction is used as an input to another instruction const std::vector& outputs() const; friend bool operator==(const instruction& x, const instruction& y); diff --git a/src/include/migraphx/op/allocate.hpp b/src/include/migraphx/op/allocate.hpp index 23278384329..5d1ca929ffb 100644 --- a/src/include/migraphx/op/allocate.hpp +++ b/src/include/migraphx/op/allocate.hpp @@ -49,17 +49,22 @@ struct allocate shape compute_shape(const std::vector& inputs) const { - migraphx::check_shapes{inputs, *this, true}.has(0, 1); - // check if shape attribute is not default if(s != shape()) { + if(inputs.size() == 1) + { + migraphx::check_shapes{inputs, *this, false}.only_dims(1); + } + else + { + migraphx::check_shapes{inputs, *this, false}.has(0); + } return s; } else { + migraphx::check_shapes{inputs, *this, false}.has(1).only_dims(1); const auto& out_dims = inputs.at(0); - assert(not out_dims.dynamic()); - assert(out_dims.ndim() == 1); std::size_t max_val = std::numeric_limits::max(); std::vector dyn_dims(out_dims.lens().at(0), shape::dynamic_dimension{0, max_val}); diff --git a/src/include/migraphx/op/reshape.hpp b/src/include/migraphx/op/reshape.hpp index 2ec0bcec9f1..90843c3ecb1 100644 --- a/src/include/migraphx/op/reshape.hpp +++ b/src/include/migraphx/op/reshape.hpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved. + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,8 @@ #include #include #include -#include + +#include namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { @@ -45,8 +46,6 @@ struct reshape return pack(f(self.dims, "dims")); } - value attributes() const { return {{"require_std_shape", true}}; } - std::string name() const { return "reshape"; } shape dyn_compute_shape(shape s0) const @@ -110,27 +109,9 @@ struct reshape return it; } - template - static auto can_strides_merge(DimIterator dim_start, - DimIterator dim_last, - StrideIterator stride_start, - StrideIterator stride_last) - { - assert(std::distance(dim_start, dim_last) == std::distance(stride_start, stride_last)); - auto cstride = *std::prev(stride_last); - return std::equal(std::make_reverse_iterator(dim_last), - std::make_reverse_iterator(dim_start + 1), - std::make_reverse_iterator(stride_last - 1), - std::make_reverse_iterator(stride_start), - [&](auto dim, auto stride) { - cstride *= dim; - return stride == cstride; - }); - } - - // This will reshape the dimesions of the input shape to use the lens of - // `rdims`. If this can't be done without changing memory layout then it - // will return nullopt + // This will attempt to alias the dimensions of the input shape to the lens of + // `rdims`. Unlike reshape_lazy though we can modify memory layout with copies and this + // can remove previous nullopts that were sent back for the alias case static optional reshape_dims(const shape& input, const std::vector& rdims) { if(input.standard()) @@ -155,13 +136,8 @@ struct reshape { auto start = idims.begin() + i; auto it = compute_end_dim(start, idims.end(), rdim); - if(it == start) - return nullopt; auto n = it - start; assert((i + n) <= istrides.size()); - if(not can_strides_merge( - start, it + 1, istrides.begin() + i, istrides.begin() + i + n + 1)) - return nullopt; i += n; rstrides.push_back(istrides[i]); } @@ -170,8 +146,7 @@ struct reshape { auto start = rdims.begin() + i; auto it = compute_end_dim(start, rdims.end(), idim); - if(it == start) - return nullopt; + auto n = it - start; assert((r + n) <= rdims.size()); auto stride = istrides[i] * idim; @@ -191,15 +166,11 @@ struct reshape auto stride = rstrides.back(); for(auto d : range(rdims.begin() + rstrides.size(), rdims.end())) { - if(d != 1) - return nullopt; + (void)d; rstrides.push_back(stride); } } - if(rdims.size() != rstrides.size()) - return nullopt; - return shape{input.type(), rdims, rstrides}; } @@ -233,25 +204,24 @@ struct reshape } auto s = reshape_dims(inputs.front(), rdims); - if(not s.has_value()) - MIGRAPHX_THROW("Reshape on axis that is not packed."); if(s->elements() != inputs.front().elements()) - MIGRAPHX_THROW("Reshape: Wrong number of elements for reshape: reshape has " + + MIGRAPHX_THROW("reshape: Wrong number of elements for reshape: reshape has " + std::to_string(s->elements()) + " elements whereas the input has " + std::to_string(inputs.front().elements())); - assert(s->bytes() == inputs.front().bytes()); return *s; } shape compute_shape(std::vector inputs) const { check_shapes{inputs, *this, true}.has(1); + auto n_neg_dims = std::count(dims.begin(), dims.end(), -1); if(n_neg_dims > 1) - MIGRAPHX_THROW("Reshape: Dimensions for reshape can only have one -1 dim"); - auto s0 = inputs[0]; + MIGRAPHX_THROW("reshape: Dimensions for reshape can only have one -1 dim"); + + auto s0 = inputs.front(); if(s0.dynamic()) { return dyn_compute_shape(s0); @@ -264,10 +234,14 @@ struct reshape argument compute(const dyn_output& dyn_out, std::vector args) const { - return args[0].reshape(dyn_out.computed_shape); - } + assert(dyn_out.computed_shape.standard()); + argument result{dyn_out.computed_shape}; - std::ptrdiff_t output_alias(const std::vector&) const { return 0; } + visit_all(result, args[0])([&](auto output, auto input) { + std::copy(input.begin(), input.end(), output.begin()); + }); + return result; + } }; } // namespace op diff --git a/src/include/migraphx/op/reshape_lazy.hpp b/src/include/migraphx/op/reshape_lazy.hpp new file mode 100644 index 00000000000..7263e8006d4 --- /dev/null +++ b/src/include/migraphx/op/reshape_lazy.hpp @@ -0,0 +1,279 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef MIGRAPHX_GUARD_OPERATORS_RESHAPE_LAZY_HPP +#define MIGRAPHX_GUARD_OPERATORS_RESHAPE_LAZY_HPP + +#include +#include +#include +#include +#include +#include + +namespace migraphx { +inline namespace MIGRAPHX_INLINE_NS { +namespace op { + +struct reshape_lazy +{ + std::vector dims; + + template + static auto reflect(Self& self, F f) + { + return pack(f(self.dims, "dims")); + } + + value attributes() const { return {{"require_std_shape", true}}; } + + std::string name() const { return "reshape_lazy"; } + + shape dyn_compute_shape(shape s0) const + { + auto dyn_dims = s0.dyn_dims(); + auto num_not_fixed = std::count_if( + dyn_dims.cbegin(), dyn_dims.cend(), [](auto dd) { return not dd.is_fixed(); }); + if(num_not_fixed != 1) + { + MIGRAPHX_THROW("reshape_lazy: Only supports one non-fixed dynamic_dimension"); + } + // track number of fixed elements in input and output + std::size_t num_dims_ele = 1; + std::size_t num_dd_ele = 1; + for(std::size_t i = 0; i < dyn_dims.size(); ++i) + { + if(dyn_dims[i].is_fixed()) + { + num_dims_ele *= dims[i]; + num_dd_ele *= dyn_dims[i].min; + } + else + { + if(dims[i] != 0 and dims[i] != -1) + { + MIGRAPHX_THROW( + "reshape_lazy: Non-fixed dynamic_dimension doesn't match with 0 or -1 " + "output dimension"); + } + } + } + if(num_dims_ele != num_dd_ele) + { + MIGRAPHX_THROW("reshape_lazy: Number of fixed elements must match. Input: " + + std::to_string(num_dd_ele) + " Output: " + std::to_string(num_dims_ele)); + } + // construct output dynamic shape from dims attribute + std::vector output_dyn_dims(dims.size()); + std::transform(dims.cbegin(), + dims.cend(), + dyn_dims.cbegin(), + output_dyn_dims.begin(), + [](std::size_t dim, auto dyn_dim) { + if(not dyn_dim.is_fixed()) + return dyn_dim; + return shape::dynamic_dimension{dim, dim}; + }); + return {s0.type(), output_dyn_dims}; + } + + template + static auto compute_end_dim(Iterator start, Iterator last, std::size_t dim) + { + std::size_t x = 1; + auto it = std::find_if(start, last, [&](auto i) { + x *= i; + return x >= dim; + }); + if(x != dim) + return start; + return it; + } + + template + static auto can_strides_merge(DimIterator dim_start, + DimIterator dim_last, + StrideIterator stride_start, + StrideIterator stride_last) + { + assert(std::distance(dim_start, dim_last) == std::distance(stride_start, stride_last)); + auto cstride = *std::prev(stride_last); + return std::equal(std::make_reverse_iterator(dim_last), + std::make_reverse_iterator(dim_start + 1), + std::make_reverse_iterator(stride_last - 1), + std::make_reverse_iterator(stride_start), + [&](auto dim, auto stride) { + cstride *= dim; + return stride == cstride; + }); + } + + // This will attempt to alias the dimensions of the input shape to the lens of + // `rdims`. If this can't be done without changing memory layout then it + // will return nullopt + static optional reshape_lazy_dims(const shape& input, + const std::vector& rdims) + { + if(input.standard()) + return shape{input.type(), rdims}; + + const auto& idims = input.lens(); + const auto& istrides = input.strides(); + + std::vector rstrides; + std::size_t i = 0; + std::size_t r = 0; + while(i < idims.size() and r < rdims.size()) + { + auto idim = idims[i]; + auto rdim = rdims[r]; + if(rdim == idim) + { + rstrides.push_back(istrides[i]); + } + // squeeze + else if(rdim > idim) + { + auto start = idims.begin() + i; + auto it = compute_end_dim(start, idims.end(), rdim); + if(it == start) + return nullopt; + auto n = it - start; + assert((i + n) <= istrides.size()); + if(not can_strides_merge( + start, it + 1, istrides.begin() + i, istrides.begin() + i + n + 1)) + return nullopt; + i += n; + rstrides.push_back(istrides[i]); + } + // unsqueeze + else // if(rdim < idim) + { + auto start = rdims.begin() + i; + auto it = compute_end_dim(start, rdims.end(), idim); + if(it == start) + return nullopt; + auto n = it - start; + assert((r + n) <= rdims.size()); + auto stride = istrides[i] * idim; + std::for_each(start, it + 1, [&](auto dim) { + stride /= dim; + rstrides.push_back(stride); + }); + r += n; + } + i++; + r++; + } + + // Handle trailing 1s + if(rstrides.size() < rdims.size() and not rstrides.empty()) + { + auto stride = rstrides.back(); + for(auto d : range(rdims.begin() + rstrides.size(), rdims.end())) + { + if(d != 1) + return nullopt; + rstrides.push_back(stride); + } + } + + if(rdims.size() != rstrides.size()) + return nullopt; + + return shape{input.type(), rdims, rstrides}; + } + + shape static_compute_shape(std::vector inputs, std::size_t n_neg_dims) const + { + check_shapes{inputs, *this}.has(1); + auto&& idims = inputs.front().lens(); + std::vector rdims(dims.begin(), dims.end()); + + for(std::size_t i = 0; i < dims.size(); i++) + { + if(dims[i] == 0) + rdims[i] = idims[i]; + + // since rdims using size_t type, -1 is the max value + // is size_t that cause later compuation incorrect + if(dims[i] == -1) + rdims[i] = 1; + } + + if(n_neg_dims > 0) + { + size_t missing_dim = + inputs.front().elements() / + std::accumulate(rdims.begin(), rdims.end(), 1, std::multiplies()); + for(std::size_t i = 0; i < rdims.size(); i++) + { + if(dims[i] == -1) + rdims[i] = missing_dim; + } + } + + auto s = reshape_lazy_dims(inputs.front(), rdims); + if(not s.has_value()) + MIGRAPHX_THROW("reshape_lazy on axis that is not packed."); + + if(s->elements() != inputs.front().elements()) + MIGRAPHX_THROW( + "reshape_lazy: Wrong number of elements for reshape_lazy: reshape_lazy has " + + std::to_string(s->elements()) + " elements whereas the input has " + + std::to_string(inputs.front().elements())); + + assert(s->bytes() == inputs.front().bytes()); + return *s; + } + + shape compute_shape(std::vector inputs) const + { + check_shapes{inputs, *this, true}.has(1); + auto n_neg_dims = std::count(dims.begin(), dims.end(), -1); + if(n_neg_dims > 1) + MIGRAPHX_THROW("reshape_lazy: Dimensions for reshape_lazy can only have one -1 dim"); + auto s0 = inputs[0]; + if(s0.dynamic()) + { + return dyn_compute_shape(s0); + } + else + { + return static_compute_shape(inputs, n_neg_dims); + } + } + + argument compute(const dyn_output& dyn_out, std::vector args) const + { + return args[0].reshape(dyn_out.computed_shape); + } + + std::ptrdiff_t output_alias(const std::vector&) const { return 0; } +}; + +} // namespace op +} // namespace MIGRAPHX_INLINE_NS +} // namespace migraphx + +#endif diff --git a/src/include/migraphx/verify.hpp b/src/include/migraphx/verify.hpp index 1406f993d3d..fbea292238b 100644 --- a/src/include/migraphx/verify.hpp +++ b/src/include/migraphx/verify.hpp @@ -29,10 +29,13 @@ #include #include #include +#include #include #include +#include +MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_VERIFY_ENABLE_ALLCLOSE) namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { namespace verify { @@ -187,16 +190,103 @@ double rms_range(const R1& r1, const R2& r2) return std::numeric_limits>::max(); } +template +double get_rms_tol(const R&, std::size_t tolerance = 80) +{ + double threshold = std::numeric_limits>::epsilon() * tolerance; + return threshold; +} + +/* +C++ doesn't support named arguments, this is just wrapper that helps distinguish between actual +results v/s expected results arguments. +*/ +template +struct expected +{ + expected() = default; + explicit expected(const T& input) : x(&input) {} + const T& data() const + { + assert(x != nullptr); + return *x; + } + + private: + const T* x = nullptr; +}; + +// deduction guide for templated expected class +template +expected(const T&) -> expected; + +struct tolerance +{ + double rms_tol = 0.001; + double atol = 0.001; + double rtol = 0.001; +}; + +/* +MIGraphX implementation of numpy's np.allclose() which checks if elementwise absolute diff is within +tolerance using this formula: abs(a - b) < atol + rtol(abs(b)) +*/ +template +bool allclose(const R1& r1, const R2& r2, tolerance tols) +{ + std::size_t n = range_distance(r1); + if(n == range_distance(r2)) + { + auto idx = mismatch_idx(r1, r2, [&](auto x, auto y) { + return abs_diff(double(x), double(y)) < tols.atol + tols.rtol * std::abs(double(y)); + }); + return idx >= range_distance(r1); + } + return false; +} + template -bool verify_range(const R1& r1, const R2& r2, double tolerance = 80, double* out_error = nullptr) +bool verify_rms_range(const R1& r1, + const R2& r2, + std::size_t tolerance = 80, + double* out_rms_error = nullptr) { - double threshold = std::numeric_limits>::epsilon() * tolerance; + double threshold = get_rms_tol(r1, tolerance); auto error = rms_range(r1, r2); - if(out_error != nullptr) - *out_error = error; + if(out_rms_error != nullptr) + *out_rms_error = error; return error <= threshold; } +template +bool verify_range_with_tolerance(const R1& r1, + const expected& r2, + tolerance tols = tolerance{}, + double* out_rms_error = nullptr) +{ + auto rms_error = rms_range(r1, r2.data()); + // disable ewise_verify by default for now, it requires lot of tests to be fixed + bool ewise_verify = true; + if(enabled(MIGRAPHX_VERIFY_ENABLE_ALLCLOSE{})) + { + ewise_verify = allclose(r1, r2.data(), tols); + } + if(out_rms_error != nullptr) + *out_rms_error = rms_error; + return rms_error <= tols.rms_tol and ewise_verify; +} + +// expected argument should be passed as second, but if it is passed as the first by mistake then +// flip the order +template +bool verify_range_with_tolerance(const expected& r1, + const R2& r2, + tolerance tols = tolerance{}, + double* out_rms_error = nullptr) +{ + return verify_rms_range(r2, r1, tols, out_rms_error); +} + } // namespace verify } // namespace MIGRAPHX_INLINE_NS } // namespace migraphx diff --git a/src/include/migraphx/verify_args.hpp b/src/include/migraphx/verify_args.hpp index f5a99637cc3..56e458520b4 100644 --- a/src/include/migraphx/verify_args.hpp +++ b/src/include/migraphx/verify_args.hpp @@ -31,11 +31,15 @@ namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { -MIGRAPHX_EXPORT -bool verify_args(const std::string& name, - const argument& ref_arg, - const argument& target_arg, - double tolerance = 80); +MIGRAPHX_EXPORT bool verify_args(const std::string& name, + const argument& target_arg, + const verify::expected& ref_arg, + verify::tolerance); + +MIGRAPHX_EXPORT bool verify_args_with_tolerance(const std::string& name, + const argument& target_arg, + const verify::expected& ref_arg, + std::size_t tolerance = 80); } // namespace MIGRAPHX_INLINE_NS } // namespace migraphx diff --git a/src/targets/gpu/CMakeLists.txt b/src/targets/gpu/CMakeLists.txt index 24e7c2edd71..d6dcd182f8e 100644 --- a/src/targets/gpu/CMakeLists.txt +++ b/src/targets/gpu/CMakeLists.txt @@ -23,6 +23,10 @@ # #################################################################################### list(APPEND CMAKE_PREFIX_PATH /opt/rocm) +find_package(hip) +if(NOT GPU_TARGETS) + message(FATAL_ERROR "HIP package is broken and has no GPU_TARGETS, please pass -DGPU_TARGETS=$(/opt/rocm/bin/rocminfo | grep -o -m1 'gfx.*') to cmake to build for your gpu.") +endif() find_package(miopen) # rocblas diff --git a/src/targets/gpu/fuse_mlir.cpp b/src/targets/gpu/fuse_mlir.cpp index e40b31ddd1d..ef4158c49fb 100644 --- a/src/targets/gpu/fuse_mlir.cpp +++ b/src/targets/gpu/fuse_mlir.cpp @@ -283,9 +283,9 @@ struct find_mlir_fused_ops names.end(), ins->inputs().begin(), std::inserter(param_map, param_map.end()), - [&, &anchor_op = anchor_op](auto name, auto input) { + [&, &anchor = anchor_op](auto name, auto input) { if(input == x_ins) - return std::make_pair(pm->get_parameter(name), anchor_op); + return std::make_pair(pm->get_parameter(name), anchor); return std::make_pair(pm->get_parameter(name), mm->add_parameter(name, input->get_shape())); }); diff --git a/src/targets/gpu/lowering.cpp b/src/targets/gpu/lowering.cpp index 5a35464ec76..d0357f06c63 100644 --- a/src/targets/gpu/lowering.cpp +++ b/src/targets/gpu/lowering.cpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved. + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -89,7 +90,6 @@ struct miopen_apply offload_copy = (mod == mpm->get_root_module()) ? pass->offload_copy : false; add_generic_op("contiguous"); - add_extend_op("argmax"); add_extend_op("argmin"); add_extend_op("logsoftmax"); @@ -115,6 +115,7 @@ struct miopen_apply add_neg_op(); add_nms_op(); add_select_module_op(); + add_reshape_lazy_op(); } void copy_params() const @@ -376,6 +377,32 @@ struct miopen_apply return mod->replace_instruction(ins, ins->get_operator(), inputs, ins->module_inputs()); }); } + + /** + * Adds reshape lazy to reshape ops that can be aliased instead of copied. + * `gpu::contiguous` are added before and after the reshape; these contiguous + * instructions can be removed by the eliminate_contiguous pass. + */ + void add_reshape_lazy_op() + { + apply_map.emplace("reshape", [=](instruction_ref ins) { + std::vector before_contiguous_args = ins->inputs(); + auto before_alloc = insert_allocation(ins, std::prev(ins)->get_shape()); + before_contiguous_args.push_back(before_alloc); + auto before_contig = + mod->insert_instruction(ins, make_op("gpu::contiguous"), {before_contiguous_args}); + + auto new_lazy_reshape = mod->insert_instruction( + ins, + make_op("reshape_lazy", {{"dims", {ins->get_operator().to_value().at("dims")}}}), + before_contig); + + std::vector after_contiguous_args = {new_lazy_reshape}; + auto after_alloc = insert_allocation(new_lazy_reshape, new_lazy_reshape->get_shape()); + after_contiguous_args.push_back(after_alloc); + return mod->replace_instruction(ins, make_op("gpu::contiguous"), after_contiguous_args); + }); + } }; void lowering::apply(module_pass_manager& mpm) const diff --git a/src/verify_args.cpp b/src/verify_args.cpp index e19373ca2f8..8ae73677539 100644 --- a/src/verify_args.cpp +++ b/src/verify_args.cpp @@ -28,19 +28,20 @@ namespace migraphx { inline namespace MIGRAPHX_INLINE_NS { bool verify_args(const std::string& name, - const argument& ref_arg, const argument& target_arg, - double tolerance) + const verify::expected& ref_arg, + verify::tolerance tols) { bool passed = true; - visit_all(ref_arg, target_arg)([&](auto ref, auto target) { - double error; - passed = verify::verify_range(ref, target, tolerance, &error); + visit_all(ref_arg.data(), target_arg)([&](auto ref, auto target) { + double rms_error; + passed = + verify::verify_range_with_tolerance(target, verify::expected{ref}, tols, &rms_error); if(not passed) { // TODO: Check for nans std::cout << "FAILED: " << name << std::endl; - std::cout << "error: " << error << std::endl; + std::cout << "RMS Error: " << rms_error << std::endl; if(ref.size() < 32) std::cout << "ref:" << ref << std::endl; if(target.size() < 32) @@ -93,5 +94,16 @@ bool verify_args(const std::string& name, return passed; } +bool verify_args_with_tolerance(const std::string& name, + const argument& target_arg, + const verify::expected& ref_arg, + std::size_t tolerance) +{ + double rms_tol = 0.001; + target_arg.visit([&](auto ta) { rms_tol = verify::get_rms_tol(ta, tolerance); }); + verify::tolerance tols{rms_tol}; + return verify_args(name, target_arg, ref_arg, tols); +} + } // namespace MIGRAPHX_INLINE_NS } // namespace migraphx diff --git a/test/auto_contiguous_test.cpp b/test/auto_contiguous_test.cpp index a70e2ec1d0e..b3f401dd9d1 100644 --- a/test/auto_contiguous_test.cpp +++ b/test/auto_contiguous_test.cpp @@ -158,6 +158,31 @@ TEST_CASE(two_transpose_gather) EXPECT(m1 == m2); } +TEST_CASE(standard_reshape_lazy) +{ + migraphx::module m1; + { + auto data = m1.add_parameter("2x2", {migraphx::shape::float_type, {2, 3, 4, 5}}); + auto add = m1.add_instruction(migraphx::make_op("add"), data, data); + auto r = + m1.add_instruction(migraphx::make_op("reshape_lazy", {{"dims", {2, 1, 12, 5}}}), add); + m1.add_return({r}); + } + run_pass(m1); + + migraphx::module m2; + { + auto data = m2.add_parameter("2x2", {migraphx::shape::float_type, {2, 3, 4, 5}}); + auto add = m2.add_instruction(migraphx::make_op("add"), data, data); + auto ca = m2.add_instruction(migraphx::make_op("contiguous"), add); + auto r = + m2.add_instruction(migraphx::make_op("reshape_lazy", {{"dims", {2, 1, 12, 5}}}), ca); + m2.add_return({r}); + } + + EXPECT(m1 == m2); +} + TEST_CASE(standard_reshape) { migraphx::module m1; @@ -173,8 +198,7 @@ TEST_CASE(standard_reshape) { auto data = m2.add_parameter("2x2", {migraphx::shape::float_type, {2, 3, 4, 5}}); auto add = m2.add_instruction(migraphx::make_op("add"), data, data); - auto ca = m2.add_instruction(migraphx::make_op("contiguous"), add); - auto r = m2.add_instruction(migraphx::make_op("reshape", {{"dims", {2, 1, 12, 5}}}), ca); + auto r = m2.add_instruction(migraphx::make_op("reshape", {{"dims", {2, 1, 12, 5}}}), add); m2.add_return({r}); } diff --git a/test/gpu/codegen_literal.cpp b/test/gpu/codegen_literal.cpp index d7e1b10a3e8..2b1e7affbfb 100644 --- a/test/gpu/codegen_literal.cpp +++ b/test/gpu/codegen_literal.cpp @@ -80,7 +80,7 @@ TEST_CASE(mul_literal_round_test) migraphx::target gpu_t = migraphx::make_target("gpu"); run_prog(p, gpu_t, m, gpu_result); - EXPECT(migraphx::verify::verify_range(ref_result, gpu_result)); + EXPECT(migraphx::verify::verify_rms_range(gpu_result, ref_result)); } int main(int argc, const char* argv[]) { test::run(argc, argv); } diff --git a/test/gpu/manage_host_buffer.cpp b/test/gpu/manage_host_buffer.cpp index d2a7d23ba74..a66ee48719e 100644 --- a/test/gpu/manage_host_buffer.cpp +++ b/test/gpu/manage_host_buffer.cpp @@ -53,7 +53,6 @@ TEST_CASE(host_same_buffer_copy) migraphx::parameter_map pp; std::vector a_vec(ss.elements(), -1); std::vector b_vec(ss.elements(), 2); - std::vector c_vec(ss.elements(), 0); pp["a"] = migraphx::argument(ss, a_vec.data()); pp["b"] = migraphx::argument(ss, b_vec.data()); std::vector gpu_result; @@ -64,7 +63,8 @@ TEST_CASE(host_same_buffer_copy) auto result = p.eval(pp).back(); std::vector results_vector(ss.elements(), -1); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(c_vec, results_vector)); + std::vector gold_vec(ss.elements(), 0); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold_vec)); } TEST_CASE(arguments_lifetime) diff --git a/test/gpu/mlir.cpp b/test/gpu/mlir.cpp index c927281c9b2..c8bdb208fd4 100644 --- a/test/gpu/mlir.cpp +++ b/test/gpu/mlir.cpp @@ -133,7 +133,8 @@ bool verify_mlir(const migraphx::module& mmlir) auto inputs = generate_params(ref); auto mlir = create_program_from_mlir(mmlir); - return migraphx::verify_args("mlir", run_ref(ref, inputs), run_gpu(mlir, inputs)); + return migraphx::verify_args_with_tolerance( + "mlir", run_gpu(mlir, inputs), migraphx::verify::expected{run_ref(ref, inputs)}); } TEST_CASE(conv) diff --git a/test/gpu/quantization.cpp b/test/gpu/quantization.cpp index b048197eb8d..41682987f10 100644 --- a/test/gpu/quantization.cpp +++ b/test/gpu/quantization.cpp @@ -40,7 +40,6 @@ TEST_CASE(gpu_target_copy) { migraphx::target gpu_t = migraphx::make_target("gpu"); - migraphx::target ref_t = migraphx::make_target("ref"); migraphx::shape s{migraphx::shape::int8_type, {2, 3, 4, 5}}; auto ref_arg_orig = migraphx::generate_argument(s, 0x123456L); @@ -52,7 +51,7 @@ TEST_CASE(gpu_target_copy) std::vector val_final; ref_arg_final.visit([&](auto v) { val_final.assign(v.begin(), v.end()); }); - EXPECT(migraphx::verify::verify_range(val_orig, val_final)); + EXPECT(migraphx::verify::verify_rms_range(val_orig, val_final)); } TEST_CASE(int8_quantization) @@ -118,9 +117,12 @@ TEST_CASE(int8_quantization) // the regular pipeline uses the rewrite_quantization in the much // earlier stage. if(migraphx::gpu::mlir_enabled()) - EXPECT(migraphx::verify::verify_range(ref_result, gpu_result, 1e5)); + EXPECT(migraphx::verify::verify_range_with_tolerance( + gpu_result, + migraphx::verify::expected{ref_result}, + migraphx::verify::tolerance{0.01})); else - EXPECT(migraphx::verify::verify_range(ref_result, gpu_result)); + EXPECT(migraphx::verify::verify_rms_range(gpu_result, ref_result)); } } diff --git a/test/onnx/verify_onnx.cpp b/test/onnx/verify_onnx.cpp index f491c3e5b45..e4cc7edcc2b 100644 --- a/test/onnx/verify_onnx.cpp +++ b/test/onnx/verify_onnx.cpp @@ -47,7 +47,7 @@ TEST_CASE(averagepool_notset_test) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {12}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(averagepool_nt_cip_test) @@ -65,7 +65,7 @@ TEST_CASE(averagepool_nt_cip_test) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {8.33333}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(batch_norm_flat_test) @@ -76,15 +76,15 @@ TEST_CASE(batch_norm_flat_test) migraphx::shape x_shape{migraphx::shape::float_type, {10}}; migraphx::shape c_shape(migraphx::shape::float_type, {1}); std::vector x_data = {1.6524342, - -0.51048076, - 0.32543048, - 2.4410043, - 2.0833702, - 0.44981122, - 1.0044622, - -0.24006313, - -0.43065986, - 0.07626268}; + -0.51048076, + 0.32543048, + 2.4410043, + 2.0833702, + 0.44981122, + 1.0044622, + -0.24006313, + -0.43065986, + 0.07626268}; std::vector scale_data = {-0.02927135}; std::vector bias_data = {0.42347777}; std::vector mean_data = {-0.00449735}; @@ -111,7 +111,7 @@ TEST_CASE(batch_norm_flat_test) 0.43305403, 0.4408022, 0.42019472}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(batch_norm_rank_2_test) @@ -148,7 +148,7 @@ TEST_CASE(batch_norm_rank_2_test) 9.89948504, 9.89948504, 12.72790933}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(batch_norm_1d_test) @@ -184,7 +184,7 @@ TEST_CASE(batch_norm_1d_test) 0.4927, 0.771, -1.956, -2.123, -0.664, -0.583, -0.7207, -0.5127}; std::vector gold{tmp.cbegin(), tmp.cend()}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(batch_norm_2d_test) @@ -250,7 +250,7 @@ TEST_CASE(batch_norm_2d_test) -2.76707697e+00, 1.47579327e+01, 4.94736385e+00, 2.68847847e+01, -6.49254417e+00, 1.94286156e+00, -7.19223642e+00, -3.70413971e+00, -4.04303551e-01, -1.01827660e+01, 1.49476433e+00}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(batch_norm_3d_test) @@ -292,7 +292,7 @@ TEST_CASE(batch_norm_3d_test) 6.098, 11.03, 2.81, 2.81, 2.81, 12.125, 3.143, 8.53, 17.52, 4.938, 15.71, 1.347, 4.938, 1.167, 6.098, 12.67, 12.67, 4.453, 4.453, -0.4768, 12.67}; std::vector gold{tmp.cbegin(), tmp.cend()}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(celu_verify_test) @@ -309,12 +309,12 @@ TEST_CASE(celu_verify_test) std::vector result_vector; result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); - std::vector correct(6); + std::vector gold(6); float alpha = 0.5; - std::transform(data.begin(), data.end(), correct.begin(), [&](auto x) { + std::transform(data.begin(), data.end(), gold.begin(), [&](auto x) { return std::max(0.0f, x) + std::min(0.0f, alpha * std::expm1(x / alpha)); }); - EXPECT(migraphx::verify::verify_range(result_vector, correct)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(clip_args_type_mismatch) @@ -330,7 +330,7 @@ TEST_CASE(clip_args_type_mismatch) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {1.5, 2, 2, 1.9, 2.5, 3, 2.9, 3.2, 3.7}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(depthtospace_simple_test) @@ -348,7 +348,7 @@ TEST_CASE(depthtospace_simple_test) std::vector gold = {0, 12, 1, 13, 2, 14, 24, 36, 25, 37, 26, 38, 3, 15, 4, 16, 5, 17, 27, 39, 28, 40, 29, 41, 6, 18, 7, 19, 8, 20, 30, 42, 31, 43, 32, 44, 9, 21, 10, 22, 11, 23, 33, 45, 34, 46, 35, 47}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(spacetodepth_simple_test) @@ -366,7 +366,7 @@ TEST_CASE(spacetodepth_simple_test) std::vector gold = {0, 2, 4, 12, 14, 16, 24, 26, 28, 36, 38, 40, 1, 3, 5, 13, 15, 17, 25, 27, 29, 37, 39, 41, 6, 8, 10, 18, 20, 22, 30, 32, 34, 42, 44, 46, 7, 9, 11, 19, 21, 23, 31, 33, 35, 43, 45, 47}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(spacetodepth_depthtospace_test) @@ -374,11 +374,11 @@ TEST_CASE(spacetodepth_depthtospace_test) // space to depth auto p1 = migraphx::parse_onnx("spacetodepth_simple_test.onnx"); p1.compile(migraphx::make_target("ref")); - std::vector data_in(48); - std::iota(std::begin(data_in), std::end(data_in), 0); + std::vector gold_data_in(48); + std::iota(std::begin(gold_data_in), std::end(gold_data_in), 0); migraphx::shape s_x_1{migraphx::shape::float_type, {1, 2, 4, 6}}; migraphx::parameter_map pp1; - pp1["x"] = migraphx::argument(s_x_1, data_in.data()); + pp1["x"] = migraphx::argument(s_x_1, gold_data_in.data()); auto result1 = p1.eval(pp1).back(); // depth to space auto p2 = migraphx::parse_onnx("depthtospace_simple_test.onnx"); @@ -388,7 +388,7 @@ TEST_CASE(spacetodepth_depthtospace_test) auto result2 = p2.eval(pp2).back(); std::vector result_vector2; result2.visit([&](auto output) { result_vector2.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(result_vector2, data_in)); + EXPECT(migraphx::verify::verify_rms_range(result_vector2, gold_data_in)); } TEST_CASE(eyelike_verify_test) @@ -405,8 +405,8 @@ TEST_CASE(eyelike_verify_test) std::vector result_vector; result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); - std::vector eyelike_mat = {0., 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1.}; - EXPECT(migraphx::verify::verify_range(result_vector, eyelike_mat)); + std::vector gold_eyelike_mat = {0., 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1.}; + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold_eyelike_mat)); } TEST_CASE(eyelike_verify_negk_test) @@ -423,8 +423,8 @@ TEST_CASE(eyelike_verify_negk_test) std::vector result_vector; result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); - std::vector eyelike_mat = {0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0.}; - EXPECT(migraphx::verify::verify_range(result_vector, eyelike_mat)); + std::vector gold_eyelike_mat = {0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0.}; + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold_eyelike_mat)); } TEST_CASE(gather_elements) @@ -447,7 +447,7 @@ TEST_CASE(gather_elements) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {-0.125, 0.5625, -0.9375, 0.25, 0.5625, 0.9375}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(gemm_test) @@ -491,7 +491,7 @@ TEST_CASE(gemm_test) 0.8098607, 1.2157929, 1.1010075, 1.0706307, 1.0429881, 1.1771785, 1.2362702, 0.8239243, 1.1112559, 0.9639262, 1.0813537, 0.8825792, 1.121141, 1.1885703, 1.2227502, 1.4568202, 1.1388762, 1.55058, 1.0958102, 1.4637487, 1.5756242}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(gemm_half_test) @@ -535,7 +535,7 @@ TEST_CASE(gemm_half_test) 2.143, 2.062, 1.921, 1.836, 2.203, 1.952, 1.055, 1.225, 1.418, 1.209, 1.155, 1.42, 1.234, 1.302, 1.593, 1.368, 1.289, 1.327, 1.451, 1.394}; std::vector gold{tmp.cbegin(), tmp.cend()}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(greaterorequal_test) @@ -556,7 +556,7 @@ TEST_CASE(greaterorequal_test) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {1.0, 1.0, 0.0}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(hardsigmoid_verify_test) @@ -580,7 +580,7 @@ TEST_CASE(hardsigmoid_verify_test) std::transform(data.begin(), data.end(), gold.begin(), [&](auto x) { return std::max(0.0f, std::min(x * alpha + beta, 1.0f)); }); - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(if_else_test) @@ -602,7 +602,7 @@ TEST_CASE(if_else_test) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {0.0866565, -0.371067, 0.017719, 0.0250614, 0.0612539, -0.744683}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(if_else_test_inlined) @@ -621,7 +621,7 @@ TEST_CASE(if_else_test_inlined) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {0.0507132, -0.712328, 0.0105797, 0.04569, 0.0185013, -1.16472}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(if_then_test) @@ -644,7 +644,7 @@ TEST_CASE(if_then_test) // onnx adds ones so result should be just + 1.0 std::vector gold = {1.0625, 1.75, 0.9375, 1.125, 0.875, 0.4375}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(if_then_test_inlined) @@ -663,7 +663,7 @@ TEST_CASE(if_then_test_inlined) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {1.0625, 1.75, 0.9375, 1.125, 0.875, 0.4375}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(if_literal_test) @@ -688,14 +688,14 @@ TEST_CASE(if_literal_test) { auto result_vector = run_prog(true); std::vector gold = {1, 2, 3, 4, 5}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } // else branch { auto result_vector = run_prog(false); std::vector gold = {5, 4, 3, 2, 1}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } } @@ -726,7 +726,7 @@ TEST_CASE(if_then_else_multi_output_shapes_inlined_test) std::vector gold = { 1.0625, 1.75, 0.9375, 1.125, 0.875, 0.4375, 0.125, 1.50, -0.125, 0.250, -0.250, -1.125}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(if_then_else_multi_output_shapes_test) @@ -757,7 +757,7 @@ TEST_CASE(if_then_else_multi_output_shapes_test) std::vector gold = { 1.0625, 1.75, 0.9375, 1.125, 0.875, 0.4375, 0.125, 1.50, -0.125, 0.250, -0.250, -1.125}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(if_pl_test) @@ -789,14 +789,14 @@ TEST_CASE(if_pl_test) { auto result_vector = run_prog(true); std::vector gold = {2, 3, 4, 5, 6, 7}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } // else branch { auto result_vector = run_prog(false); std::vector gold = {1, 2, 3, 4, 5, 6}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } } @@ -835,8 +835,8 @@ TEST_CASE(if_tuple_test) auto results = run_prog(true); std::vector gold0(4, 2.0f); std::vector gold1(12, 4.0f); - EXPECT(migraphx::verify::verify_range(results.at(0), gold0)); - EXPECT(migraphx::verify::verify_range(results.at(1), gold1)); + EXPECT(migraphx::verify::verify_rms_range(results.at(0), gold0)); + EXPECT(migraphx::verify::verify_rms_range(results.at(1), gold1)); } // else branch @@ -844,8 +844,8 @@ TEST_CASE(if_tuple_test) auto results = run_prog(false); std::vector gold0(4, 3.0f); std::vector gold1(12, 5.0f); - EXPECT(migraphx::verify::verify_range(results.at(0), gold0)); - EXPECT(migraphx::verify::verify_range(results.at(1), gold1)); + EXPECT(migraphx::verify::verify_rms_range(results.at(0), gold0)); + EXPECT(migraphx::verify::verify_rms_range(results.at(1), gold1)); } } @@ -876,7 +876,7 @@ TEST_CASE(instance_norm_test) 2.54919, 3.32379, 4.09838}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(instance_norm_dyn_batch_test) @@ -918,7 +918,7 @@ TEST_CASE(instance_norm_dyn_batch_test) 2.54919, 3.32379, 4.09838}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(instance_norm_3d_test) @@ -947,7 +947,7 @@ TEST_CASE(instance_norm_3d_test) 3.18218, 4.05505}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(lessorequal_test) @@ -968,7 +968,7 @@ TEST_CASE(lessorequal_test) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {1, 0, 1}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(lpnormalization_1norm) @@ -996,7 +996,7 @@ TEST_CASE(lpnormalization_1norm) 3.f / 7.f, 0.f, 0.f}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(lpnormalization_2norm) @@ -1012,19 +1012,19 @@ TEST_CASE(lpnormalization_2norm) std::vector result_vector; result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); - std::vector correct{0.f, - 2.f / 3.f, - -2.f / 3.f, - 1.f / 3.f, - 1.f / 6.f, - -5.f / 6.f, - 3.f / 6.f, - -1.f / 6.f, - -4.f / 5.f, - 3.f / 5.f, - 0.f, - 0.f}; - EXPECT(migraphx::verify::verify_range(result_vector, correct)); + std::vector gold{0.f, + 2.f / 3.f, + -2.f / 3.f, + 1.f / 3.f, + 1.f / 6.f, + -5.f / 6.f, + 3.f / 6.f, + -1.f / 6.f, + -4.f / 5.f, + 3.f / 5.f, + 0.f, + 0.f}; + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(mean_broadcast_test) @@ -1055,7 +1055,7 @@ TEST_CASE(mean_broadcast_test) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold(24, 3); - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(mean_test) @@ -1082,7 +1082,7 @@ TEST_CASE(mean_test) const auto mean = std::accumulate(scalars.begin(), scalars.end(), 0.0) / num_data; std::vector gold(num_elms, mean); - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(mean_integral_test) @@ -1109,7 +1109,7 @@ TEST_CASE(mean_integral_test) const auto mean = std::accumulate(scalars.begin(), scalars.end(), 0) / num_data; std::vector gold(num_elms, mean); - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(mod_test) @@ -1136,7 +1136,7 @@ TEST_CASE(mod_test) std::vector gold = {0, -2, 5, 0, 2, 3, 0, -2, 5, 0, 2, 3, 0, -2, 5, 0, 2, 3, 0, -2, 5, 0, 2, 3, 0, -2, 5}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(mod_test_different_types) @@ -1164,7 +1164,7 @@ TEST_CASE(mod_test_different_types) std::vector gold = {0, -2, 5, 0, 2, 3, 0, -2, 5, 0, 2, 3, 0, -2, 5, 0, 2, 3, 0, -2, 5, 0, 2, 3, 0, -2, 5}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(mod_test_fmod) @@ -1193,7 +1193,7 @@ TEST_CASE(mod_test_fmod) 10.7, 11.2, 12.3, 13.9, -14.2, 15.8, 1.6, 3.9, 5.2, 7.0, 9.0, 1.0, -4.0, 7.0, -3.0, 1.2, 1.3, 3.1}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(mod_test_fmod_different_types) @@ -1223,7 +1223,7 @@ TEST_CASE(mod_test_fmod_different_types) 10.7, 11.2, 12.3, 13.9, -14.2, 15.8, 1.6, 3.9, 5.2, 7.0, 9.0, 1.0, -4.0, 7.0, -3.0, 1.2, 1.3, 3.1}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(nonzero_test) @@ -1242,7 +1242,7 @@ TEST_CASE(nonzero_test) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {0, 0, 1, 0, 0, 1, 0, 0}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(resize_downsample_f_test) @@ -1263,7 +1263,7 @@ TEST_CASE(resize_downsample_f_test) std::vector gold = {0.0f, 3.0f}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(resize_upsample_linear_ac_test) @@ -1298,7 +1298,7 @@ TEST_CASE(resize_upsample_linear_ac_test) 11.0f / 3, 4}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(resize_upsample_linear_test) @@ -1319,7 +1319,7 @@ TEST_CASE(resize_upsample_linear_test) std::vector gold = { 1, 1.25, 1.75, 2, 1.5, 1.75, 2.25, 2.5, 2.5, 2.75, 3.25, 3.5, 3, 3.25, 3.75, 4}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(resize_upsample_pf_test) @@ -1340,7 +1340,7 @@ TEST_CASE(resize_upsample_pf_test) std::vector gold = {1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 4}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(reversesequence_4D_verify_test) @@ -1361,7 +1361,7 @@ TEST_CASE(reversesequence_4D_verify_test) std::vector gold = { 8.0, 9.0, 10.0, 11.0, 4.0, 5.0, 6.0, 7.0, 0.0, 1.0, 2.0, 3.0, 12.0, 13.0, 14.0, 15.0}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(reversesequence_batch_verify_test) @@ -1382,7 +1382,7 @@ TEST_CASE(reversesequence_batch_verify_test) std::vector gold = { 0.0, 1.0, 2.0, 3.0, 5.0, 4.0, 6.0, 7.0, 10.0, 9.0, 8.0, 11.0, 15.0, 14.0, 13.0, 12.0}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(reversesequence_time_verify_test) @@ -1403,7 +1403,7 @@ TEST_CASE(reversesequence_time_verify_test) std::vector gold = { 3.0, 6.0, 9.0, 12.0, 2.0, 5.0, 8.0, 13.0, 1.0, 4.0, 10.0, 14.0, 0.0, 7.0, 11.0, 15.0}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(selu_test) @@ -1423,7 +1423,7 @@ TEST_CASE(selu_test) std::vector gold = {0.55, 1.05, 0, -0.10912, -0.149251, 6}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(size_verify_test) @@ -1457,7 +1457,7 @@ TEST_CASE(slice_test) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {2, 3}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(slice_5arg_test) @@ -1477,7 +1477,7 @@ TEST_CASE(slice_5arg_test) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {10, 11, 12, 13, 15, 16, 17, 18}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(slice_reverse_test) @@ -1497,7 +1497,7 @@ TEST_CASE(slice_reverse_test) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {14, 13, 12, 11, 19, 18, 17, 16}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(slice_step_test) @@ -1517,7 +1517,7 @@ TEST_CASE(slice_step_test) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {14, 12}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(softplus_test) @@ -1538,7 +1538,7 @@ TEST_CASE(softplus_test) std::transform( data.begin(), data.end(), gold.begin(), [](auto x) { return std::log1p(std::exp(x)); }); - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(softsign_test) @@ -1559,7 +1559,7 @@ TEST_CASE(softsign_test) std::transform( data.begin(), data.end(), gold.begin(), [](auto x) { return x / (1.0 + std::abs(x)); }); - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(upsample_test) @@ -1578,7 +1578,7 @@ TEST_CASE(upsample_test) std::vector gold = {1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 4}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(where_test) @@ -1620,7 +1620,7 @@ TEST_CASE(where_test) 2.0f, 1.0f, 2.0f}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } std::vector gen_trilu_test(const migraphx::shape& s, const migraphx::program& p) @@ -1645,7 +1645,7 @@ TEST_CASE(trilu_test) std::vector gold = {1, 2, 3, 4, 0, 6, 7, 8, 0, 0, 11, 12}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(trilu_batch_diff_k_test) @@ -1656,7 +1656,7 @@ TEST_CASE(trilu_batch_diff_k_test) std::vector gold = {0, 0, 3, 0, 0, 0, 0, 0, 9, 0, 0, 0}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(trilu_lower_test) @@ -1667,7 +1667,7 @@ TEST_CASE(trilu_lower_test) std::vector gold = {0, 0, 0, 0, 5, 0, 0, 0, 9, 10, 0, 0}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(trilu_out_k_test) @@ -1678,7 +1678,7 @@ TEST_CASE(trilu_out_k_test) std::vector gold(12, 0); - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(trilu_row_one_test) @@ -1689,7 +1689,7 @@ TEST_CASE(trilu_row_one_test) std::vector gold = {0, 2, 3, 4}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } int main(int argc, const char* argv[]) { test::run(argc, argv); } diff --git a/test/op_shape_test.cpp b/test/op_shape_test.cpp index 0d649690665..d03f0141ff3 100644 --- a/test/op_shape_test.cpp +++ b/test/op_shape_test.cpp @@ -88,6 +88,13 @@ TEST_CASE(allocate_static) expect_shape(out_shape, migraphx::make_op("allocate", {{"shape", to_value(out_shape)}})); } +TEST_CASE(allocate_static_input_error) +{ + migraphx::shape input{migraphx::shape::int64_type, {3}}; + migraphx::shape out_shape{migraphx::shape::float_type, {2, 3, 4}}; + expect_shape(out_shape, migraphx::make_op("allocate", {{"shape", to_value(out_shape)}}), input); +} + TEST_CASE(allocate_dyn) { migraphx::shape input{migraphx::shape::int64_type, {2}}; @@ -109,6 +116,14 @@ TEST_CASE(allocate_dyn_with_shape_attr) input); } +TEST_CASE(allocate_dyn_no_input_error) +{ + migraphx::shape shape_attr{migraphx::shape::float_type, + {{1, 4}, {3, 3}, {4, 8, {4, 6}}, {4, 8}, {4, 6}}}; + expect_shape(shape_attr, + migraphx::make_op("allocate", {{"shape", migraphx::to_value(shape_attr)}})); +} + TEST_CASE(argmax_axis0) { migraphx::shape input{migraphx::shape::half_type, {2, 3, 4, 5}}; @@ -2524,13 +2539,21 @@ TEST_CASE(reshape_shape) migraphx::shape output{migraphx::shape::float_type, lens}; expect_shape(output, migraphx::make_op("reshape", {{"dims", new_shape}}), input); } +} +TEST_CASE(reshape_shape_invalid) +{ + migraphx::shape input{migraphx::shape::float_type, {24, 1, 1, 1}}; for(auto&& new_shape : std::vector>{{8, 3, 2, 2}, {1, 3, -1, -1}, {3, 0}, {3, 2}}) { throws_shape(migraphx::make_op("reshape", {{"dims", new_shape}}), input); } +} +TEST_CASE(reshape_shape_minus1_reshapes) +{ + migraphx::shape input{migraphx::shape::float_type, {24, 1, 1, 1}}; std::vector, migraphx::shape>> minus1_tests{ {{2, -1, 3}, {migraphx::shape::float_type, {2, 4, 3}}}, {{0, -1, 0}, {migraphx::shape::float_type, {24, 1, 1}}}, @@ -2654,11 +2677,11 @@ TEST_CASE(reshape_broadcast_squeeze) expect_shape(output, migraphx::make_op("reshape", {{"dims", output.lens()}}), input); } -TEST_CASE(reshape_broadcast_squeeze_error) +TEST_CASE(reshape_broadcast_squeeze_memlayout_change) { migraphx::shape input{migraphx::shape::float_type, {2, 16, 16, 1280}, {0, 0, 0, 1}}; - std::vector new_shape = {2, 16, 20480}; - throws_shape(migraphx::make_op("reshape", {{"dims", new_shape}}), input); + migraphx::shape output{migraphx::shape::float_type, {2, 16, 256, 80}, {0, 0, 0, 16}}; + expect_shape(output, migraphx::make_op("reshape", {{"dims", output.lens()}}), input); } TEST_CASE(reshape_dyn_shape) @@ -2706,6 +2729,199 @@ TEST_CASE(reshape_non_fixed_not_matching_error) throws_shape(migraphx::make_op("reshape", {{"dims", new_shape}}), input); } +TEST_CASE(reshape_lazy_shape) +{ + migraphx::shape input{migraphx::shape::float_type, {24, 1, 1, 1}}; + for(auto&& new_shape : + std::vector>{{8, 3, 1, 1}, {1, 3, 4, 2}, {1, 3, 4, 2}}) + { + std::vector lens(new_shape.size()); + std::copy(new_shape.begin(), new_shape.end(), lens.begin()); + migraphx::shape output{migraphx::shape::float_type, lens}; + expect_shape(output, migraphx::make_op("reshape_lazy", {{"dims", new_shape}}), input); + } + + for(auto&& new_shape : + std::vector>{{8, 3, 2, 2}, {1, 3, -1, -1}, {3, 0}, {3, 2}}) + { + throws_shape(migraphx::make_op("reshape_lazy", {{"dims", new_shape}}), input); + } + + std::vector, migraphx::shape>> minus1_tests{ + {{2, -1, 3}, {migraphx::shape::float_type, {2, 4, 3}}}, + {{0, -1, 0}, {migraphx::shape::float_type, {24, 1, 1}}}, + {{2, -1, 0}, {migraphx::shape::float_type, {2, 12, 1}}}, + {{0, 0, -1}, {migraphx::shape::float_type, {24, 1, 1}}}, + {{2, 0, -1}, {migraphx::shape::float_type, {2, 1, 12}}}, + {{-1, 2, 3}, {migraphx::shape::float_type, {4, 2, 3}}}, + {{-1, 0, 3}, {migraphx::shape::float_type, {8, 1, 3}}}, + {{-1, 0, 0}, {migraphx::shape::float_type, {24, 1, 1}}}, + {{-1, 3, 0}, {migraphx::shape::float_type, {8, 3, 1}}}}; + + for(auto& it : minus1_tests) + { + expect_shape(it.second, migraphx::make_op("reshape_lazy", {{"dims", it.first}}), input); + } +} + +// This uses the permutation to compute the reshape_lazy since its simpler than +// trying to calculate strides. As we collapse or expand dimensions, we +// remove the collapsed dimensions or duplicate the expanded dimensions in +// the permutation. Then we renumber the permutation. So for dimensions of 4, +// 24, 1, 1, 1 with a permutation of 1, 0, 2, 3, 4 that reshape_lazys to 4, 1, 3, +// 4, 2, we first remove the collapsed dimensions or duplicate the expanded +// dimensions which gives 1, 0, 0, 0, 0. Then after renumbering we get a +// final permutation of 4, 0, 1, 2, 3. +TEST_CASE(reshape_lazy_nonstandard) +{ + auto input = migraphx::shape::from_permutation(migraphx::shape::float_type, + {4, 24, 1, 1, 1}, + migraphx::invert_permutation({1, 0, 2, 3, 4})); + std::vector, std::vector>> tests{ + {{4, 24}, {1, 0}}, + {{4, 24, 1, 1, 1, 1}, {1, 0, 2, 3, 4, 5}}, + {{4, 8, 3, 1, 1}, {2, 0, 1, 3, 4}}, + {{4, 1, 3, 4, 2}, {4, 0, 1, 2, 3}}, + {{4, 1, 4, 3, 2}, {4, 0, 1, 2, 3}}, + {{4, 2, 4, 3}, {3, 0, 1, 2}}, + {{4, 2, 12, 1}, {2, 0, 1, 3}}, + {{4, 2, 1, 12}, {3, 0, 1, 2}}, + {{4, 4, 2, 3}, {3, 0, 1, 2}}, + {{4, 8, 1, 3}, {3, 0, 1, 2}}, + {{4, 8, 3, 1}, {2, 0, 1, 3}}}; + + for(const auto& [dims, perm] : tests) + { + migraphx::shape output = migraphx::shape::from_permutation( + migraphx::shape::float_type, dims, migraphx::invert_permutation(perm)); + expect_shape(output, migraphx::make_op("reshape_lazy", {{"dims", dims}}), input); + } +} + +TEST_CASE(reshape_lazy_nonstandard_squeeze) +{ + auto input = migraphx::shape::from_permutation( + migraphx::shape::float_type, {2, 16, 16, 1280}, migraphx::invert_permutation({0, 2, 3, 1})); + std::vector lens = {2, 256, 1280}; + migraphx::shape output = migraphx::shape::from_permutation( + migraphx::shape::float_type, lens, migraphx::invert_permutation({0, 2, 1})); + expect_shape(output, migraphx::make_op("reshape_lazy", {{"dims", lens}}), input); +} + +TEST_CASE(reshape_lazy_nonstandard_error) +{ + auto input = migraphx::shape::from_permutation(migraphx::shape::float_type, + {4, 24, 1, 1, 1}, + migraphx::invert_permutation({1, 0, 2, 3, 4})); + for(auto&& new_shape : std::vector>{{4, 8, 3, 2, 2}, + {1}, + {4, 8, 4}, + {4, 24, 1, 1, 1, 1, 2}, + {8, 4, 4}, + {4, 1, 3, -1, -1}, + {4, 3, 0}, + {4, 3, 2}, + {3, 0}, + {3, 2}}) + { + throws_shape(migraphx::make_op("reshape_lazy", {{"dims", new_shape}}), input); + } +} + +TEST_CASE(reshape_lazy_nonpacked_unsqueeze1) +{ + migraphx::shape input{migraphx::shape::float_type, {4, 16}, {32, 2}}; + migraphx::shape output{migraphx::shape::float_type, {4, 2, 8}, {32, 16, 2}}; + expect_shape(output, migraphx::make_op("reshape_lazy", {{"dims", output.lens()}}), input); +} + +TEST_CASE(reshape_lazy_nonpacked_unsqueeze2) +{ + migraphx::shape input{migraphx::shape::float_type, {4, 16}, {32, 2}}; + migraphx::shape output{migraphx::shape::float_type, {2, 2, 16}, {64, 32, 2}}; + expect_shape(output, migraphx::make_op("reshape_lazy", {{"dims", output.lens()}}), input); +} + +TEST_CASE(reshape_lazy_nonpacked_squeeze) +{ + migraphx::shape input{migraphx::shape::float_type, {4, 16}, {32, 2}}; + migraphx::shape output{migraphx::shape::float_type, {64}, {2}}; + expect_shape(output, migraphx::make_op("reshape_lazy", {{"dims", output.lens()}}), input); +} + +TEST_CASE(reshape_lazy_broadcast_unsqueeze1) +{ + migraphx::shape input{migraphx::shape::float_type, {2, 256, 1280}, {0, 0, 1}}; + migraphx::shape output{migraphx::shape::float_type, {2, 16, 16, 1280}, {0, 0, 0, 1}}; + expect_shape(output, migraphx::make_op("reshape_lazy", {{"dims", output.lens()}}), input); +} + +TEST_CASE(reshape_lazy_broadcast_unsqueeze2) +{ + migraphx::shape input{migraphx::shape::float_type, {2, 256, 1280}, {0, 0, 1}}; + migraphx::shape output{migraphx::shape::float_type, {2, 256, 16, 80}, {0, 0, 80, 1}}; + expect_shape(output, migraphx::make_op("reshape_lazy", {{"dims", output.lens()}}), input); +} + +TEST_CASE(reshape_lazy_broadcast_squeeze) +{ + migraphx::shape input{migraphx::shape::float_type, {2, 16, 16, 1280}, {0, 0, 0, 1}}; + migraphx::shape output{migraphx::shape::float_type, {2, 256, 1280}, {0, 0, 1}}; + expect_shape(output, migraphx::make_op("reshape_lazy", {{"dims", output.lens()}}), input); +} + +TEST_CASE(reshape_lazy_broadcast_squeeze_error) +{ + migraphx::shape input{migraphx::shape::float_type, {2, 16, 16, 1280}, {0, 0, 0, 1}}; + std::vector new_shape = {2, 16, 20480}; + throws_shape(migraphx::make_op("reshape_lazy", {{"dims", new_shape}}), input); +} + +TEST_CASE(reshape_lazy_dyn_shape) +{ + migraphx::shape input{migraphx::shape::float_type, {{1, 4}, {24, 24}, {1, 1}, {1, 1}}}; + for(auto&& new_shape : std::vector>{ + {-1, 1, 1, 24}, {0, 8, 3, 1}, {-1, 3, 4, 2}, {0, 2, 4, 3}}) + { + std::vector out_dyn_dims{}; + for(std::size_t i = 0; i < new_shape.size(); ++i) + { + if(new_shape[i] == 0 or new_shape[i] == -1) + { + out_dyn_dims.push_back(input.dyn_dims().at(i)); + } + else + { + std::size_t d = new_shape[i]; + out_dyn_dims.push_back({d, d}); + } + } + migraphx::shape output{migraphx::shape::float_type, out_dyn_dims}; + expect_shape(output, migraphx::make_op("reshape_lazy", {{"dims", new_shape}}), input); + } +} + +TEST_CASE(reshape_lazy_multiple_non_fixed_error) +{ + migraphx::shape input{migraphx::shape::float_type, {{1, 4}, {24, 24}, {10, 20}, {1, 1}}}; + std::vector new_shape = {0, 1, 0, 24}; + throws_shape(migraphx::make_op("reshape_lazy", {{"dims", new_shape}}), input); +} + +TEST_CASE(reshape_lazy_fixed_ele_not_matching_error) +{ + migraphx::shape input{migraphx::shape::float_type, {{1, 4}, {24, 24}, {10, 10}, {1, 1}}}; + std::vector new_shape = {0, 1, 5, 24}; + throws_shape(migraphx::make_op("reshape_lazy", {{"dims", new_shape}}), input); +} + +TEST_CASE(reshape_lazy_non_fixed_not_matching_error) +{ + migraphx::shape input{migraphx::shape::float_type, {{1, 4}, {24, 24}, {1, 1}, {1, 1}}}; + std::vector new_shape = {2, 1, 1, 24}; + throws_shape(migraphx::make_op("reshape_lazy", {{"dims", new_shape}}), input); +} + TEST_CASE(return_shape_tuple) { using migraphx::shape; diff --git a/test/quantization.cpp b/test/quantization.cpp index bb76152a6cb..64797d83aae 100644 --- a/test/quantization.cpp +++ b/test/quantization.cpp @@ -83,7 +83,7 @@ TEST_CASE(param_add) auto hs = mm->add_instruction(migraphx::make_op("add"), hp1, hp2); auto fs = mm->add_instruction( migraphx::make_op("convert", - {{"target_type", migraphx::to_value(migraphx::shape::float_type)}}), + {{"target_type", migraphx::to_value(migraphx::shape::float_type)}}), hs); if(add_return) { @@ -1013,7 +1013,7 @@ TEST_CASE(target_copy) std::vector orig_result; run_prog(p, ref_t, m, orig_result); - EXPECT(migraphx::verify::verify_range(ref_result, orig_result)); + EXPECT(migraphx::verify::verify_rms_range(ref_result, orig_result)); } } @@ -1077,7 +1077,10 @@ TEST_CASE(int8_quantization_dot) std::vector no_quant_result; run_prog(p, ref_t, m, no_quant_result); - EXPECT(migraphx::verify::verify_range(quant_result, no_quant_result, 30000)); + EXPECT(migraphx::verify::verify_range_with_tolerance( + quant_result, + migraphx::verify::expected{no_quant_result}, + migraphx::verify::tolerance{0.003})); } } @@ -1122,7 +1125,7 @@ TEST_CASE(int8_quantization_conv) std::vector no_quant_result; run_prog(p, ref_t, no_quant_result); - EXPECT(migraphx::verify::verify_range(quant_result, no_quant_result)); + EXPECT(migraphx::verify::verify_rms_range(quant_result, no_quant_result)); } } @@ -1274,7 +1277,7 @@ TEST_CASE(test_op_capture) cap_res.visit([&](auto output) { cap_vec.assign(output.begin(), output.end()); }); res.visit([&](auto output) { vec.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(vec, cap_vec)); + EXPECT(migraphx::verify::verify_rms_range(vec, cap_vec)); } int main(int argc, const char* argv[]) { test::run(argc, argv); } diff --git a/test/ref/abs.cpp b/test/ref/abs.cpp index e415e8fd49e..15e36812c22 100644 --- a/test/ref/abs.cpp +++ b/test/ref/abs.cpp @@ -42,7 +42,7 @@ TEST_CASE(abs_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{1, 2, 3, 4}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(abs_dyn_test) @@ -62,5 +62,5 @@ TEST_CASE(abs_dyn_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{1, 2, 3, 4}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/acos.cpp b/test/ref/acos.cpp index db2c0edbd47..9b9daf3f343 100644 --- a/test/ref/acos.cpp +++ b/test/ref/acos.cpp @@ -45,7 +45,7 @@ TEST_CASE(acos_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return acosf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(acos_dyn_test) @@ -68,5 +68,5 @@ TEST_CASE(acos_dyn_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return acosf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/acosh.cpp b/test/ref/acosh.cpp index efd1e6083ca..f13a9d89d34 100644 --- a/test/ref/acosh.cpp +++ b/test/ref/acosh.cpp @@ -45,7 +45,7 @@ TEST_CASE(acosh_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return acoshf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(acosh_dyn_test) @@ -68,5 +68,5 @@ TEST_CASE(acosh_dyn_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return acoshf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/add.cpp b/test/ref/add.cpp index a5b6829aec8..ec9b7a2c40e 100644 --- a/test/ref/add.cpp +++ b/test/ref/add.cpp @@ -51,7 +51,7 @@ TEST_CASE(add_broadcast_test) std::vector results_vector(12); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(add_multibroadcast_test) @@ -75,7 +75,7 @@ TEST_CASE(add_multibroadcast_test) std::vector results_vector(12); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(add_test) @@ -91,7 +91,7 @@ TEST_CASE(add_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0, 2, 4}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(add_dyn_test) @@ -115,7 +115,7 @@ TEST_CASE(add_dyn_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0, 2, 4}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(fp16_test) @@ -134,7 +134,7 @@ TEST_CASE(fp16_test) std::vector results_vector(1); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{c}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(fp32_fp16_test) @@ -159,7 +159,7 @@ TEST_CASE(fp32_fp16_test) auto result = p.eval({}).back(); std::vector res; result.visit([&](auto output) { res.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res, gold_res)); + EXPECT(migraphx::verify::verify_rms_range(res, gold_res)); }; test_case({"all"}); diff --git a/test/ref/argmax.cpp b/test/ref/argmax.cpp index 953caa115a8..2a46856cd84 100644 --- a/test/ref/argmax.cpp +++ b/test/ref/argmax.cpp @@ -47,7 +47,7 @@ TEST_CASE(argmax_test_0) std::vector result_vec; result.visit([&](auto output) { result_vec.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(result_vec, res_gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vec, res_gold)); } TEST_CASE(argmax_test_1) @@ -66,7 +66,7 @@ TEST_CASE(argmax_test_1) std::vector result_vec; result.visit([&](auto output) { result_vec.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(result_vec, res_gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vec, res_gold)); } TEST_CASE(argmax_test_2) @@ -85,7 +85,7 @@ TEST_CASE(argmax_test_2) std::vector result_vec; result.visit([&](auto output) { result_vec.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(result_vec, res_gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vec, res_gold)); } TEST_CASE(argmax_test_neg_2) @@ -104,7 +104,7 @@ TEST_CASE(argmax_test_neg_2) std::vector result_vec; result.visit([&](auto output) { result_vec.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(result_vec, res_gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vec, res_gold)); } TEST_CASE(argmax_dyn_test) @@ -126,7 +126,7 @@ TEST_CASE(argmax_dyn_test) std::vector result_vec; result.visit([&](auto output) { result_vec.assign(output.begin(), output.end()); }); std::vector res_gold = {0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1}; - EXPECT(migraphx::verify::verify_range(result_vec, res_gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vec, res_gold)); } TEST_CASE(argmax_test_nonstd_shape) @@ -145,5 +145,5 @@ TEST_CASE(argmax_test_nonstd_shape) result.visit([&](auto output) { result_vec.assign(output.begin(), output.end()); }); std::vector res_gold_vec; res_gold.visit([&](auto output) { res_gold_vec.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(result_vec, res_gold_vec)); + EXPECT(migraphx::verify::verify_rms_range(result_vec, res_gold_vec)); } diff --git a/test/ref/argmin.cpp b/test/ref/argmin.cpp index 55d297f7d4d..922b3ca72b5 100644 --- a/test/ref/argmin.cpp +++ b/test/ref/argmin.cpp @@ -47,7 +47,7 @@ TEST_CASE(argmin_test_0) std::vector result_vec; result.visit([&](auto output) { result_vec.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(result_vec, res_gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vec, res_gold)); } TEST_CASE(argmin_test_1) @@ -66,7 +66,7 @@ TEST_CASE(argmin_test_1) std::vector result_vec; result.visit([&](auto output) { result_vec.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(result_vec, res_gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vec, res_gold)); } TEST_CASE(argmin_test_2) @@ -85,7 +85,7 @@ TEST_CASE(argmin_test_2) std::vector result_vec; result.visit([&](auto output) { result_vec.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(result_vec, res_gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vec, res_gold)); } TEST_CASE(argmin_test_neg_1) @@ -104,7 +104,7 @@ TEST_CASE(argmin_test_neg_1) std::vector result_vec; result.visit([&](auto output) { result_vec.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(result_vec, res_gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vec, res_gold)); } TEST_CASE(argmin_test_nonstd_shape) @@ -123,5 +123,5 @@ TEST_CASE(argmin_test_nonstd_shape) result.visit([&](auto output) { result_vec.assign(output.begin(), output.end()); }); std::vector res_gold_vec; res_gold.visit([&](auto output) { res_gold_vec.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(result_vec, res_gold_vec)); + EXPECT(migraphx::verify::verify_rms_range(result_vec, res_gold_vec)); } diff --git a/test/ref/asin.cpp b/test/ref/asin.cpp index 9dbfea0420d..764bc3e15c1 100644 --- a/test/ref/asin.cpp +++ b/test/ref/asin.cpp @@ -45,7 +45,7 @@ TEST_CASE(asin_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return asinf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(asin_dyn_test) @@ -68,5 +68,5 @@ TEST_CASE(asin_dyn_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return asinf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/asinh.cpp b/test/ref/asinh.cpp index 93c89d80835..b20a7ba72fd 100644 --- a/test/ref/asinh.cpp +++ b/test/ref/asinh.cpp @@ -45,7 +45,7 @@ TEST_CASE(asinh_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return asinhf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(asinh_dyn_test) @@ -68,5 +68,5 @@ TEST_CASE(asinh_dyn_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return asinhf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/atan.cpp b/test/ref/atan.cpp index c8eafe52c21..d57d3e491a6 100644 --- a/test/ref/atan.cpp +++ b/test/ref/atan.cpp @@ -45,7 +45,7 @@ TEST_CASE(atan_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return atanf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(atan_dyn_test) @@ -68,5 +68,5 @@ TEST_CASE(atan_dyn_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return atanf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/atanh.cpp b/test/ref/atanh.cpp index ce51a4e1071..70d5129536c 100644 --- a/test/ref/atanh.cpp +++ b/test/ref/atanh.cpp @@ -45,7 +45,7 @@ TEST_CASE(atanh_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return atanhf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(atanh_dyn_test) @@ -68,5 +68,5 @@ TEST_CASE(atanh_dyn_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return atanhf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/broadcast.cpp b/test/ref/broadcast.cpp index 016696c7a50..52dc24fa6d7 100644 --- a/test/ref/broadcast.cpp +++ b/test/ref/broadcast.cpp @@ -114,6 +114,6 @@ TEST_CASE(isnan_broadcast_test) auto result = p.eval({}).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - std::vector correct = {0, 0, 0, 0, 1, 1}; - EXPECT(migraphx::verify::verify_range(results_vector, correct)); + std::vector gold = {0, 0, 0, 0, 1, 1}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/ceil.cpp b/test/ref/ceil.cpp index a6ff8b42030..3d1d6c7234c 100644 --- a/test/ref/ceil.cpp +++ b/test/ref/ceil.cpp @@ -45,7 +45,7 @@ TEST_CASE(ceil_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return std::ceil(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(ceil_dyn_test) @@ -68,5 +68,5 @@ TEST_CASE(ceil_dyn_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return std::ceil(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/clip.cpp b/test/ref/clip.cpp index e346d1d9b21..011dc76becb 100644 --- a/test/ref/clip.cpp +++ b/test/ref/clip.cpp @@ -48,7 +48,7 @@ TEST_CASE(clip_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0.0, 0.0, 6.0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(clip_dyn_test) @@ -73,5 +73,5 @@ TEST_CASE(clip_dyn_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0.0, 0.0, 6.0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/concat.cpp b/test/ref/concat.cpp index 4b0c3878252..748c091f82c 100644 --- a/test/ref/concat.cpp +++ b/test/ref/concat.cpp @@ -50,11 +50,11 @@ TEST_CASE(concat_test_1) std::vector gold = {0, 1, 2, 3, 4, 10, 5, 6, 7, 8, 9, 20}; std::vector results_vector(2 * 6); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); - EXPECT(migraphx::verify::verify_range(result.get_shape().lens(), - std::vector({2, 6}))); - EXPECT(migraphx::verify::verify_range(result.get_shape().strides(), - std::vector({6, 1}))); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result.get_shape().lens(), + std::vector({2, 6}))); + EXPECT(migraphx::verify::verify_rms_range(result.get_shape().strides(), + std::vector({6, 1}))); } TEST_CASE(concat_test_2) @@ -77,11 +77,11 @@ TEST_CASE(concat_test_2) std::vector gold = {0, 1, 2, 3, 4, 10, 5, 6, 7, 8, 9, 20}; std::vector results_vector(2 * 6); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); - EXPECT(migraphx::verify::verify_range(result.get_shape().lens(), - std::vector({2, 6}))); - EXPECT(migraphx::verify::verify_range(result.get_shape().strides(), - std::vector({6, 1}))); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result.get_shape().lens(), + std::vector({2, 6}))); + EXPECT(migraphx::verify::verify_rms_range(result.get_shape().strides(), + std::vector({6, 1}))); } TEST_CASE(concat_test_3) @@ -104,11 +104,11 @@ TEST_CASE(concat_test_3) std::vector gold = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; std::vector results_vector(6 * 2); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); - EXPECT(migraphx::verify::verify_range(result.get_shape().lens(), - std::vector({6, 2}))); - EXPECT(migraphx::verify::verify_range(result.get_shape().strides(), - std::vector({2, 1}))); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result.get_shape().lens(), + std::vector({6, 2}))); + EXPECT(migraphx::verify::verify_rms_range(result.get_shape().strides(), + std::vector({2, 1}))); } TEST_CASE(concat_test_4) @@ -131,11 +131,11 @@ TEST_CASE(concat_test_4) std::vector gold = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; std::vector results_vector(6 * 2); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); - EXPECT(migraphx::verify::verify_range(result.get_shape().lens(), - std::vector({6, 2}))); - EXPECT(migraphx::verify::verify_range(result.get_shape().strides(), - std::vector({2, 1}))); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result.get_shape().lens(), + std::vector({6, 2}))); + EXPECT(migraphx::verify::verify_rms_range(result.get_shape().strides(), + std::vector({2, 1}))); } TEST_CASE(concat_dyn_test) @@ -169,7 +169,7 @@ TEST_CASE(concat_dyn_test) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); - EXPECT(migraphx::verify::verify_range(result.get_shape().lens(), - std::vector({6, 2}))); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result.get_shape().lens(), + std::vector({6, 2}))); } diff --git a/test/ref/contiguous.cpp b/test/ref/contiguous.cpp index 7b91fef268a..ffc620e20bf 100644 --- a/test/ref/contiguous.cpp +++ b/test/ref/contiguous.cpp @@ -50,7 +50,7 @@ TEST_CASE(contiguous_test) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(contiguous_param_test) @@ -74,7 +74,7 @@ TEST_CASE(contiguous_param_test) std::vector results_vector(12); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(contiguous_dyn_test) @@ -100,5 +100,5 @@ TEST_CASE(contiguous_dyn_test) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/convolution.cpp b/test/ref/convolution.cpp index 7d50efa0f29..6565c4cabe0 100644 --- a/test/ref/convolution.cpp +++ b/test/ref/convolution.cpp @@ -78,23 +78,6 @@ TEST_CASE(conv_dyn_batch_test) -0.06269585, 0.18658121, -0.03944227, 0.0111798, -0.17731084, 0.11789055, -0.09982193, 0.08142821, 0.0729029, 0.11303909, 0.12735154, 0.03885292}; - std::vector sol = {-0.20817225, - 0.87965256, - 0.14958936, - -1.24887264, - -0.06540672, - 0.20778663, - 0.40456355, - -0.99900877, - 0.4917807, - 0.1994698, - 0.64205718, - 0.37798831, - -0.25315839, - 0.44276932, - -0.16138598, - 0.79344082}; - migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {2, 3, 4, 4}}; migraphx::parameter_map params0; @@ -104,8 +87,23 @@ TEST_CASE(conv_dyn_batch_test) auto result = p.eval(params0).back(); std::vector results_vector(64); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - - EXPECT(migraphx::verify::verify_range(results_vector, sol)); + std::vector gold = {-0.20817225, + 0.87965256, + 0.14958936, + -1.24887264, + -0.06540672, + 0.20778663, + 0.40456355, + -0.99900877, + 0.4917807, + 0.1994698, + 0.64205718, + 0.37798831, + -0.25315839, + 0.44276932, + -0.16138598, + 0.79344082}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(conv_dyn_img_shape_test) @@ -139,8 +137,6 @@ TEST_CASE(conv_dyn_img_shape_test) 0.15479768, 0.46534674, 0.16970931, 0.49704618, 0.07062198, 0.01678321, 0.53150934, 0.39244495, 0.9963813}; - std::vector sol = {6.1329393, 4.3199925, 5.448438, 3.8497565}; - migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {1, 3, 4, 4}}; migraphx::parameter_map params0; @@ -151,7 +147,9 @@ TEST_CASE(conv_dyn_img_shape_test) std::vector results_vector(72); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, sol)); + std::vector gold = {6.1329393, 4.3199925, 5.448438, 3.8497565}; + + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); a = {0.95600171, 0.20768181, 0.82844489, 0.14928212, 0.51280462, 0.1359196, 0.68903648, 0.84174772, 0.425509, 0.956926, 0.82533291, 0.33821531, 0.57576055, 0.75330186, @@ -172,18 +170,18 @@ TEST_CASE(conv_dyn_img_shape_test) 0.14407301, 0.80968594, 0.38216188, 0.35692557, 0.2568538, 0.83587388, 0.43654904, 0.04974508, 0.80375029, 0.25350374, 0.1820275, 0.23369029, 0.54358755}; - sol = {6.305986, - 5.564665, - 6.122996, - 5.7262855, - 5.5546584, - 5.779489, - 5.798161, - 5.160476, - 6.702436, - 5.4851074, - 6.227567, - 5.2016754}; + gold = {6.305986, + 5.564665, + 6.122996, + 5.7262855, + 5.5546584, + 5.779489, + 5.798161, + 5.160476, + 6.702436, + 5.4851074, + 6.227567, + 5.2016754}; migraphx::shape input_fixed_shape1{migraphx::shape::float_type, {1, 3, 6, 5}}; migraphx::parameter_map params1; @@ -193,7 +191,7 @@ TEST_CASE(conv_dyn_img_shape_test) result = p.eval(params1).back(); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, sol)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(conv_dyn_weights_shape_test) @@ -221,27 +219,18 @@ TEST_CASE(conv_dyn_weights_shape_test) 0.77388606, 0.1752363, 0.74631394, 0.24604889, 0.53600244, 0.22116457, 0.81217463, 0.10789447, 0.43083784, 0.63371852, 0.69742316, 0.09536905}; - std::vector c = {0.98411968, - 0.2899219, - 0.44638833, - 0.30390816, - 0.03989896, - 0.2445332, - 0.32700131, - 0.57517075, - 0.06956476, - 0.93079306, - 0.19882314, - 0.52940601}; - std::vector sol = {1.9939406, - 2.2703054, - 1.8896171, - 2.062202, - 2.3035214, - 1.629366, - 2.1606991, - 2.1917608, - 1.6797699}; + std::vector c = {0.98411968, + 0.2899219, + 0.44638833, + 0.30390816, + 0.03989896, + 0.2445332, + 0.32700131, + 0.57517075, + 0.06956476, + 0.93079306, + 0.19882314, + 0.52940601}; migraphx::shape weight_fixed_shape0{migraphx::shape::float_type, {1, 3, 2, 2}}; @@ -252,14 +241,23 @@ TEST_CASE(conv_dyn_weights_shape_test) auto result = p.eval(params0).back(); std::vector results_vector(72); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - - EXPECT(migraphx::verify::verify_range(results_vector, sol)); - - c = {0.98411968, 0.2899219, 0.44638833, 0.30390816, 0.03989896, 0.2445332, 0.32700131, - 0.57517075, 0.06956476, 0.93079306, 0.19882314, 0.52940601, 0.35624753, 0.35938406, - 0.9111428, 0.88923574, 0.61040283, 0.2797513, 0.15479768, 0.46534674, 0.16970931, - 0.49704618, 0.07062198, 0.01678321, 0.53150934, 0.39244495, 0.9963813}; - sol = {6.1329393, 4.3199925, 5.448438, 3.8497565}; + std::vector gold = {1.9939406, + 2.2703054, + 1.8896171, + 2.062202, + 2.3035214, + 1.629366, + 2.1606991, + 2.1917608, + 1.6797699}; + + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); + + c = {0.98411968, 0.2899219, 0.44638833, 0.30390816, 0.03989896, 0.2445332, 0.32700131, + 0.57517075, 0.06956476, 0.93079306, 0.19882314, 0.52940601, 0.35624753, 0.35938406, + 0.9111428, 0.88923574, 0.61040283, 0.2797513, 0.15479768, 0.46534674, 0.16970931, + 0.49704618, 0.07062198, 0.01678321, 0.53150934, 0.39244495, 0.9963813}; + gold = {6.1329393, 4.3199925, 5.448438, 3.8497565}; migraphx::shape weights_fixed_shape1{migraphx::shape::float_type, {1, 3, 3, 3}}; migraphx::parameter_map params1; @@ -269,7 +267,7 @@ TEST_CASE(conv_dyn_weights_shape_test) result = p.eval(params1).back(); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, sol)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(conv_dyn_img_same_upper_test) @@ -313,23 +311,6 @@ TEST_CASE(conv_dyn_img_same_upper_test) 7.9253986e-02, 7.3943835e-01, 1.7813577e-01, 1.0780835e-01, 4.2304707e-01, 4.0084350e-01, 1.1114500e-01, 4.4846520e-01, 5.0109702e-01}; - std::vector sol = {3.013387, - 3.7111127, - 4.2946506, - 3.579301, - 4.5306826, - 6.1262493, - 6.332169, - 4.495293, - 4.46013, - 6.0938954, - 5.848162, - 4.514299, - 2.9587686, - 4.117671, - 3.5187216, - 2.3236327}; - migraphx::shape input_fixed_shape0{migraphx::shape::float_type, {1, 3, 4, 4}}; migraphx::parameter_map params0; @@ -339,7 +320,23 @@ TEST_CASE(conv_dyn_img_same_upper_test) auto result = p.eval(params0).back(); std::vector results_vector(16); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, sol)); + std::vector gold = {3.013387, + 3.7111127, + 4.2946506, + 3.579301, + 4.5306826, + 6.1262493, + 6.332169, + 4.495293, + 4.46013, + 6.0938954, + 5.848162, + 4.514299, + 2.9587686, + 4.117671, + 3.5187216, + 2.3236327}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(conv_dyn_kernel_same_upper_test) @@ -361,47 +358,31 @@ TEST_CASE(conv_dyn_kernel_same_upper_test) p.compile(migraphx::make_target("ref")); - std::vector a = {0.63321185, 0.6466339, 0.8515352, 0.44240063, 0.5018913, 0.5068494, - 0.75330657, 0.7383877, 0.15870683, 0.8171611, 0.56118083, 0.87004256, - 0.24401724, 0.8815178, 0.4222333, 0.27191755, - - 0.41633207, 0.2460619, 0.32004243, 0.6962248, 0.12284133, 0.2620491, - 0.96931046, 0.6030955, 0.7623861, 0.2395751, 0.61440414, 0.577285, - 0.80087787, 0.12776066, 0.26566318, 0.46569306, - - 0.96701574, 0.3850145, 0.14165345, 0.5887347, 0.7152134, 0.5295342, - 0.6303507, 0.4037548, 0.18556239, 0.79416305, 0.29107493, 0.18770285, - 0.6870904, 0.30701008, 0.314684, 0.91075855}; - std::vector c = {2.8150102e-01, - 3.3198616e-01, - 9.5149356e-01, - 7.4039467e-02, - - 9.6555042e-01, - 2.8815505e-01, - 2.5100240e-01, - 5.2186239e-01, - - 2.3850012e-01, - 8.2963020e-01, - 3.0763101e-04, - 6.7026985e-01}; - std::vector sol = {2.453681, - 2.536207, - 3.0187201, - 1.7912633, - 2.1738236, - 2.9695358, - 3.2319589, - 1.859269, - 2.5953722, - 2.50734, - 2.7736917, - 1.2229807, - 1.5900216, - 0.9225286, - 1.43048, - 0.74341124}; + std::vector a = {0.63321185, 0.6466339, 0.8515352, 0.44240063, 0.5018913, 0.5068494, + 0.75330657, 0.7383877, 0.15870683, 0.8171611, 0.56118083, 0.87004256, + 0.24401724, 0.8815178, 0.4222333, 0.27191755, + + 0.41633207, 0.2460619, 0.32004243, 0.6962248, 0.12284133, 0.2620491, + 0.96931046, 0.6030955, 0.7623861, 0.2395751, 0.61440414, 0.577285, + 0.80087787, 0.12776066, 0.26566318, 0.46569306, + + 0.96701574, 0.3850145, 0.14165345, 0.5887347, 0.7152134, 0.5295342, + 0.6303507, 0.4037548, 0.18556239, 0.79416305, 0.29107493, 0.18770285, + 0.6870904, 0.30701008, 0.314684, 0.91075855}; + std::vector c = {2.8150102e-01, + 3.3198616e-01, + 9.5149356e-01, + 7.4039467e-02, + + 9.6555042e-01, + 2.8815505e-01, + 2.5100240e-01, + 5.2186239e-01, + + 2.3850012e-01, + 8.2963020e-01, + 3.0763101e-04, + 6.7026985e-01}; migraphx::shape weight_fixed_shape0{migraphx::shape::float_type, {1, 3, 2, 2}}; @@ -412,7 +393,23 @@ TEST_CASE(conv_dyn_kernel_same_upper_test) auto result = p.eval(params0).back(); std::vector results_vector(16); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, sol)); + std::vector gold = {2.453681, + 2.536207, + 3.0187201, + 1.7912633, + 2.1738236, + 2.9695358, + 3.2319589, + 1.859269, + 2.5953722, + 2.50734, + 2.7736917, + 1.2229807, + 1.5900216, + 0.9225286, + 1.43048, + 0.74341124}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(conv_dyn_kernel_same_lower_test) @@ -434,47 +431,31 @@ TEST_CASE(conv_dyn_kernel_same_lower_test) p.compile(migraphx::make_target("ref")); - std::vector a = {0.63321185, 0.6466339, 0.8515352, 0.44240063, 0.5018913, 0.5068494, - 0.75330657, 0.7383877, 0.15870683, 0.8171611, 0.56118083, 0.87004256, - 0.24401724, 0.8815178, 0.4222333, 0.27191755, - - 0.41633207, 0.2460619, 0.32004243, 0.6962248, 0.12284133, 0.2620491, - 0.96931046, 0.6030955, 0.7623861, 0.2395751, 0.61440414, 0.577285, - 0.80087787, 0.12776066, 0.26566318, 0.46569306, - - 0.96701574, 0.3850145, 0.14165345, 0.5887347, 0.7152134, 0.5295342, - 0.6303507, 0.4037548, 0.18556239, 0.79416305, 0.29107493, 0.18770285, - 0.6870904, 0.30701008, 0.314684, 0.91075855}; - std::vector c = {2.8150102e-01, - 3.3198616e-01, - 9.5149356e-01, - 7.4039467e-02, - - 9.6555042e-01, - 2.8815505e-01, - 2.5100240e-01, - 5.2186239e-01, - - 2.3850012e-01, - 8.2963020e-01, - 3.0763101e-04, - 6.7026985e-01}; - std::vector sol = {0.91231215, - 1.1416453, - 1.00216, - 1.6813052, - 1.7131033, - 2.453681, - 2.536207, - 3.0187201, - 1.3293691, - 2.1738236, - 2.9695358, - 3.2319589, - 1.3228729, - 2.5953722, - 2.50734, - 2.7736917}; + std::vector a = {0.63321185, 0.6466339, 0.8515352, 0.44240063, 0.5018913, 0.5068494, + 0.75330657, 0.7383877, 0.15870683, 0.8171611, 0.56118083, 0.87004256, + 0.24401724, 0.8815178, 0.4222333, 0.27191755, + + 0.41633207, 0.2460619, 0.32004243, 0.6962248, 0.12284133, 0.2620491, + 0.96931046, 0.6030955, 0.7623861, 0.2395751, 0.61440414, 0.577285, + 0.80087787, 0.12776066, 0.26566318, 0.46569306, + + 0.96701574, 0.3850145, 0.14165345, 0.5887347, 0.7152134, 0.5295342, + 0.6303507, 0.4037548, 0.18556239, 0.79416305, 0.29107493, 0.18770285, + 0.6870904, 0.30701008, 0.314684, 0.91075855}; + std::vector c = {2.8150102e-01, + 3.3198616e-01, + 9.5149356e-01, + 7.4039467e-02, + + 9.6555042e-01, + 2.8815505e-01, + 2.5100240e-01, + 5.2186239e-01, + + 2.3850012e-01, + 8.2963020e-01, + 3.0763101e-04, + 6.7026985e-01}; migraphx::shape weight_fixed_shape0{migraphx::shape::float_type, {1, 3, 2, 2}}; @@ -485,7 +466,24 @@ TEST_CASE(conv_dyn_kernel_same_lower_test) auto result = p.eval(params0).back(); std::vector results_vector(16); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, sol)); + std::vector gold = {0.91231215, + 1.1416453, + 1.00216, + 1.6813052, + 1.7131033, + 2.453681, + 2.536207, + 3.0187201, + 1.3293691, + 2.1738236, + 2.9695358, + 3.2319589, + 1.3228729, + 2.5953722, + 2.50734, + 2.7736917}; + + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(conv2d_padding_stride_test) @@ -518,23 +516,6 @@ TEST_CASE(conv2d_padding_stride_test) -0.06269585, 0.18658121, -0.03944227, 0.0111798, -0.17731084, 0.11789055, -0.09982193, 0.08142821, 0.0729029, 0.11303909, 0.12735154, 0.03885292}; - std::vector s = {-0.20817225, - 0.87965256, - 0.14958936, - -1.24887264, - -0.06540672, - 0.20778663, - 0.40456355, - -0.99900877, - 0.4917807, - 0.1994698, - 0.64205718, - 0.37798831, - -0.25315839, - 0.44276932, - -0.16138598, - 0.79344082}; - migraphx::shape a_shape{migraphx::shape::float_type, {2, 3, 4, 4}}; auto al = mm->add_literal(migraphx::literal{a_shape, a}); @@ -548,7 +529,24 @@ TEST_CASE(conv2d_padding_stride_test) std::vector results_vector(16); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, s)); + std::vector gold = {-0.20817225, + 0.87965256, + 0.14958936, + -1.24887264, + -0.06540672, + 0.20778663, + 0.40456355, + -0.99900877, + 0.4917807, + 0.1994698, + 0.64205718, + 0.37798831, + -0.25315839, + 0.44276932, + -0.16138598, + 0.79344082}; + + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(conv2d_padding_test) @@ -581,18 +579,6 @@ TEST_CASE(conv2d_padding_test) 0.14747436, -0.06199479, -0.01166052, -0.12432006, -0.04494537, -0.17581205, 0.09475745, 0.1149437, -0.1014564, 0.0274073, -0.01323579, -0.11092556}; - std::vector s = { - -0.0201216, 0.40407312, -0.39005592, -0.0631946, 0.37963012, -0.64611685, 0.1349397, - -0.54113752, 0.28533003, 0.27667275, -0.16442731, -0.181494, 0.30564839, 0.58744538, - 0.32015014, 0.24969585, -0.27367792, -0.53308117, 0.41236052, 0.26136363, -0.01489828, - 0.57652152, -0.38506854, 0.119615, 0.0437076, 0.04779706, 0.57887721, 0.23126155, - 0.05695833, -0.68200272, 0.02063358, -0.10267162, 0.8062973, -0.38149622, -0.40134856, - -0.03353126, 0.38991132, -0.3478111, 0.03661491, 0.25783631, 0.62772679, -0.1961118, - 0.76423508, -0.36241418, -0.20994355, -0.12368261, -0.9406727, 0.02340185, -0.08793129, - -0.02471633, -0.58163726, -0.02211772, -0.42014724, 0.77525634, 0.504951, -0.20537445, - -0.20369984, -0.83037728, -1.40423918, -0.46160448, -0.22944322, 0.36074194, 0.49579027, - 0.46527559}; - migraphx::shape a_shape{migraphx::shape::float_type, {2, 3, 4, 4}}; auto al = mm->add_literal(migraphx::literal{a_shape, a}); @@ -606,7 +592,18 @@ TEST_CASE(conv2d_padding_test) std::vector results_vector(64); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, s)); + std::vector gold = { + -0.0201216, 0.40407312, -0.39005592, -0.0631946, 0.37963012, -0.64611685, 0.1349397, + -0.54113752, 0.28533003, 0.27667275, -0.16442731, -0.181494, 0.30564839, 0.58744538, + 0.32015014, 0.24969585, -0.27367792, -0.53308117, 0.41236052, 0.26136363, -0.01489828, + 0.57652152, -0.38506854, 0.119615, 0.0437076, 0.04779706, 0.57887721, 0.23126155, + 0.05695833, -0.68200272, 0.02063358, -0.10267162, 0.8062973, -0.38149622, -0.40134856, + -0.03353126, 0.38991132, -0.3478111, 0.03661491, 0.25783631, 0.62772679, -0.1961118, + 0.76423508, -0.36241418, -0.20994355, -0.12368261, -0.9406727, 0.02340185, -0.08793129, + -0.02471633, -0.58163726, -0.02211772, -0.42014724, 0.77525634, 0.504951, -0.20537445, + -0.20369984, -0.83037728, -1.40423918, -0.46160448, -0.22944322, 0.36074194, 0.49579027, + 0.46527559}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(conv2d_test) @@ -642,22 +639,6 @@ TEST_CASE(conv2d_test) 1.61106288e-02, -1.35080189e-01, 1.49512306e-01, 3.86456847e-02, 1.29330024e-01, -3.22975963e-02, -5.60784787e-02, -5.41997552e-02, 4.78562862e-02}; - std::vector s = {0.27039781, - 0.19105849, - -0.06339942, - -0.65087199, - 0.40867025, - 0.05063812, - -0.14907975, - 0.49018705, - -0.49197209, - 0.33236548, - -0.39374301, - 0.16012701, - 0.06574871, - 0.71606487, - -0.55201721, - -0.46427044}; migraphx::shape a_shape{migraphx::shape::float_type, {2, 3, 4, 4}}; auto al = mm->add_literal(migraphx::literal{a_shape, a}); @@ -670,7 +651,24 @@ TEST_CASE(conv2d_test) std::vector results_vector(16); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, s)); + + std::vector gold = {0.27039781, + 0.19105849, + -0.06339942, + -0.65087199, + 0.40867025, + 0.05063812, + -0.14907975, + 0.49018705, + -0.49197209, + 0.33236548, + -0.39374301, + 0.16012701, + 0.06574871, + 0.71606487, + -0.55201721, + -0.46427044}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(conv3d_test) @@ -706,22 +704,6 @@ TEST_CASE(conv3d_test) 1.61106288e-02, -1.35080189e-01, 1.49512306e-01, 3.86456847e-02, 1.29330024e-01, -3.22975963e-02, -5.60784787e-02, -5.41997552e-02, 4.78562862e-02}; - std::vector s = {0.27039781, - 0.19105849, - -0.06339942, - -0.65087199, - 0.40867025, - 0.05063812, - -0.14907975, - 0.49018705, - -0.49197209, - 0.33236548, - -0.39374301, - 0.16012701, - 0.06574871, - 0.71606487, - -0.55201721, - -0.46427044}; migraphx::shape a_shape{migraphx::shape::float_type, {2, 3, 4, 4, 1}}; auto al = mm->add_literal(migraphx::literal{a_shape, a}); @@ -738,5 +720,21 @@ TEST_CASE(conv3d_test) std::vector results_vector(16); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, s)); + std::vector gold = {0.27039781, + 0.19105849, + -0.06339942, + -0.65087199, + 0.40867025, + 0.05063812, + -0.14907975, + 0.49018705, + -0.49197209, + 0.33236548, + -0.39374301, + 0.16012701, + 0.06574871, + 0.71606487, + -0.55201721, + -0.46427044}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/convolution_backwards.cpp b/test/ref/convolution_backwards.cpp index 9f27627e602..76f21129c30 100644 --- a/test/ref/convolution_backwards.cpp +++ b/test/ref/convolution_backwards.cpp @@ -52,7 +52,7 @@ TEST_CASE(convolution_backwards_1d) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(convolution_backwards_2d) @@ -75,7 +75,7 @@ TEST_CASE(convolution_backwards_2d) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(convolution_backwards_3d) @@ -113,7 +113,7 @@ TEST_CASE(convolution_backwards_3d) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(convolution_backwards_padding1) @@ -139,7 +139,7 @@ TEST_CASE(convolution_backwards_padding1) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(convolution_backwards_padding2) @@ -165,7 +165,7 @@ TEST_CASE(convolution_backwards_padding2) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(convolution_backwards_2stride) @@ -192,7 +192,7 @@ TEST_CASE(convolution_backwards_2stride) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(convolution_backwards_2dilation) @@ -219,7 +219,7 @@ TEST_CASE(convolution_backwards_2dilation) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(convolution_backwards_dyn_batch1) @@ -247,7 +247,7 @@ TEST_CASE(convolution_backwards_dyn_batch1) 27, 15, 9, 20, 33, 24, 13, 6, 13, 21, 15, 8}; std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(convolution_backwards_dyn_batch2) @@ -288,5 +288,5 @@ TEST_CASE(convolution_backwards_dyn_batch2) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/cos.cpp b/test/ref/cos.cpp index ff8aadfe7b4..9087c7725ce 100644 --- a/test/ref/cos.cpp +++ b/test/ref/cos.cpp @@ -45,7 +45,7 @@ TEST_CASE(cos_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return cosf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(cos_dyn_test) @@ -68,5 +68,5 @@ TEST_CASE(cos_dyn_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return cosf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/cosh.cpp b/test/ref/cosh.cpp index 44f3fbe6f9e..a09c0c8db94 100644 --- a/test/ref/cosh.cpp +++ b/test/ref/cosh.cpp @@ -45,7 +45,7 @@ TEST_CASE(cosh_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return coshf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(cosh_dyn_test) @@ -68,5 +68,5 @@ TEST_CASE(cosh_dyn_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return coshf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/dimensions_of.cpp b/test/ref/dimensions_of.cpp index 5e738de2753..092b088b72c 100644 --- a/test/ref/dimensions_of.cpp +++ b/test/ref/dimensions_of.cpp @@ -47,7 +47,7 @@ TEST_CASE(dimensions_of_test0) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {2, 3, 4}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(dimensions_of_test1) @@ -67,5 +67,5 @@ TEST_CASE(dimensions_of_test1) std::vector results_vector(2); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {4, 4}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/div.cpp b/test/ref/div.cpp index 0d12d575e13..bb8b4348b92 100644 --- a/test/ref/div.cpp +++ b/test/ref/div.cpp @@ -46,7 +46,7 @@ TEST_CASE(div_test) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold(data1.size()); std::transform(data1.begin(), data1.end(), data2.begin(), gold.begin(), std::divides()); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(div_dyn_test) @@ -72,5 +72,5 @@ TEST_CASE(div_dyn_test) std::vector gold(x_data.size()); std::transform( x_data.begin(), x_data.end(), y_data.begin(), gold.begin(), std::divides()); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/dot_op.cpp b/test/ref/dot_op.cpp index eb984c269b4..2336a028b8e 100644 --- a/test/ref/dot_op.cpp +++ b/test/ref/dot_op.cpp @@ -36,38 +36,27 @@ void dot_2d_test() { migraphx::program p; - auto* mm = p.get_main_module(); - std::vector a = {-0.00925222, 0.56250403, 0.70107397, 0.75402161, -0.505885, - 1.33628943, -0.11413, -0.31270559, 1.59336732, -0.19361027, - -0.91620867, 0.40108416, -0.06969921, 0.68483471, -0.39906632, - -1.66423624, 0.69040076, -1.31490171, -0.11282616, -0.79391814}; - std::vector b = {6.09568541e-01, - -6.10527007e-01, - 3.66646462e-01, - 1.18951101e-01, - 5.58777432e-01, - -3.21296298e-01, - -5.95997198e-01, - -5.01425721e-01, - -2.84606807e-01, - -5.73673557e-01, - -8.99430260e-01, - -4.25103093e-01, - 1.53027987e+00, - -3.81407415e-04, - -3.29650255e-01}; - std::vector c = {-1.56327541e+00, - -7.09570140e-01, - -5.37424982e-01, - -2.22994831e-01, - -2.15586437e+00, - 2.09177941e-03, - -1.47279677e+00, - 2.02627040e-01, - -6.04527691e-01, - -1.29885596e+00, - 2.16294914e+00, - -1.48101497e-01}; + auto* mm = p.get_main_module(); + std::vector a = {-0.00925222, 0.56250403, 0.70107397, 0.75402161, -0.505885, + 1.33628943, -0.11413, -0.31270559, 1.59336732, -0.19361027, + -0.91620867, 0.40108416, -0.06969921, 0.68483471, -0.39906632, + -1.66423624, 0.69040076, -1.31490171, -0.11282616, -0.79391814}; + std::vector b = {6.09568541e-01, + -6.10527007e-01, + 3.66646462e-01, + 1.18951101e-01, + 5.58777432e-01, + -3.21296298e-01, + -5.95997198e-01, + -5.01425721e-01, + -2.84606807e-01, + -5.73673557e-01, + -8.99430260e-01, + -4.25103093e-01, + 1.53027987e+00, + -3.81407415e-04, + -3.29650255e-01}; + migraphx::shape a_shape{migraphx::shape::get_type{}, {4, 5}}; auto al = mm->add_literal(migraphx::literal{a_shape, a}); migraphx::shape b_shape{migraphx::shape::get_type{}, {5, 3}}; @@ -77,7 +66,20 @@ void dot_2d_test() auto result = p.eval({}).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(c, results_vector)); + std::vector gold = {-1.56327541e+00, + -7.09570140e-01, + -5.37424982e-01, + -2.22994831e-01, + -2.15586437e+00, + 2.09177941e-03, + -1.47279677e+00, + 2.02627040e-01, + -6.04527691e-01, + -1.29885596e+00, + 2.16294914e+00, + -1.48101497e-01}; + EXPECT(migraphx::verify::verify_range_with_tolerance( + results_vector, migraphx::verify::expected{gold}, migraphx::verify::tolerance{9e-6})); } TEST_CASE_REGISTER(dot_2d_test) TEST_CASE_REGISTER(dot_2d_test) @@ -87,38 +89,38 @@ void dot_4d_test() { migraphx::program p; - auto* mm = p.get_main_module(); - std::vector a = {-0.00925222, 0.56250403, 0.70107397, 0.75402161, -0.505885, - 1.33628943, -0.11413, -0.31270559, 1.59336732, -0.19361027, - -0.91620867, 0.40108416, -0.06969921, 0.68483471, -0.39906632, - -1.66423624, 0.69040076, -1.31490171, -0.11282616, -0.79391814}; - std::vector b = {6.09568541e-01, - -6.10527007e-01, - 3.66646462e-01, - 1.18951101e-01, - 5.58777432e-01, - -3.21296298e-01, - -5.95997198e-01, - -5.01425721e-01, - -2.84606807e-01, - -5.73673557e-01, - -8.99430260e-01, - -4.25103093e-01, - 1.53027987e+00, - -3.81407415e-04, - -3.29650255e-01}; - std::vector c = {-1.56327541e+00, - -7.09570140e-01, - -5.37424982e-01, - -2.22994831e-01, - -2.15586437e+00, - 2.09177941e-03, - -1.47279677e+00, - 2.02627040e-01, - -6.04527691e-01, - -1.29885596e+00, - 2.16294914e+00, - -1.48101497e-01}; + auto* mm = p.get_main_module(); + std::vector a = {-0.00925222, 0.56250403, 0.70107397, 0.75402161, -0.505885, + 1.33628943, -0.11413, -0.31270559, 1.59336732, -0.19361027, + -0.91620867, 0.40108416, -0.06969921, 0.68483471, -0.39906632, + -1.66423624, 0.69040076, -1.31490171, -0.11282616, -0.79391814}; + std::vector b = {6.09568541e-01, + -6.10527007e-01, + 3.66646462e-01, + 1.18951101e-01, + 5.58777432e-01, + -3.21296298e-01, + -5.95997198e-01, + -5.01425721e-01, + -2.84606807e-01, + -5.73673557e-01, + -8.99430260e-01, + -4.25103093e-01, + 1.53027987e+00, + -3.81407415e-04, + -3.29650255e-01}; + std::vector gold = {-1.56327541e+00, + -7.09570140e-01, + -5.37424982e-01, + -2.22994831e-01, + -2.15586437e+00, + 2.09177941e-03, + -1.47279677e+00, + 2.02627040e-01, + -6.04527691e-01, + -1.29885596e+00, + 2.16294914e+00, + -1.48101497e-01}; migraphx::shape a_shape{migraphx::shape::get_type{}, {1, 1, 4, 5}}; auto al = mm->add_literal(migraphx::literal{a_shape, a}); migraphx::shape b_shape{migraphx::shape::get_type{}, {1, 1, 5, 3}}; @@ -128,8 +130,10 @@ void dot_4d_test() auto result = p.eval({}).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(c, results_vector)); + EXPECT(migraphx::verify::verify_range_with_tolerance( + results_vector, migraphx::verify::expected{gold}, migraphx::verify::tolerance{9e-6})); } + TEST_CASE_REGISTER(dot_4d_test) TEST_CASE_REGISTER(dot_4d_test) @@ -166,24 +170,24 @@ TEST_CASE(dot_3D_test) std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - std::vector m_res = {0.18208394, - -0.49276402, - 0.87189133, - 0.75150114, - -0.55909610, - 1.00521735, - -0.95536130, - 2.27996211, - 0.06239879, - 0.74700068, - -0.01570983, - -0.85920856, - -0.59070835, - -1.70729902, - 0.40245487, - 1.80182751}; - - EXPECT(migraphx::verify::verify_range(m, m_res)); + std::vector gold = {0.18208394, + -0.49276402, + 0.87189133, + 0.75150114, + -0.55909610, + 1.00521735, + -0.95536130, + 2.27996211, + 0.06239879, + 0.74700068, + -0.01570983, + -0.85920856, + -0.59070835, + -1.70729902, + 0.40245487, + 1.80182751}; + + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_3D_C_test0) @@ -242,24 +246,24 @@ TEST_CASE(dot_3D_C_test0) std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - std::vector m_res = {0.18208394, - -0.49276402, - 0.87189133, - 0.75150114, - -0.55909610, - 1.00521735, - -0.95536130, - 2.27996211, - 0.06239879, - 0.74700068, - -0.01570983, - -0.85920856, - -0.59070835, - -1.70729902, - 0.40245487, - 1.80182751}; - - EXPECT(migraphx::verify::verify_range(m, m_res)); + std::vector gold = {0.18208394, + -0.49276402, + 0.87189133, + 0.75150114, + -0.55909610, + 1.00521735, + -0.95536130, + 2.27996211, + 0.06239879, + 0.74700068, + -0.01570983, + -0.85920856, + -0.59070835, + -1.70729902, + 0.40245487, + 1.80182751}; + + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_3D_C_test1) @@ -309,16 +313,16 @@ TEST_CASE(dot_3D_C_test1) std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - std::vector m_res = {0.18208394, - -0.49276402, - 0.87189133, - 0.75150114, - -0.55909610, - 1.00521735, - -0.95536130, - 2.27996211}; + std::vector gold = {0.18208394, + -0.49276402, + 0.87189133, + 0.75150114, + -0.55909610, + 1.00521735, + -0.95536130, + 2.27996211}; - EXPECT(migraphx::verify::verify_range(m, m_res)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_4D_test1) @@ -351,13 +355,13 @@ TEST_CASE(dot_4D_test1) std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - std::vector m_res = {0.26735861, -4.30770895, 1.05257728, -1.19954265, 0.50493170, - -0.18729756, 1.09137941, -1.09298312, 3.42956915, -0.41681939, - 0.17833257, 0.26040336, 0.15351280, 1.87632715, -0.63545406, - -0.95467340, -1.74728628, -2.42477030, 0.76262372, 0.15539164, - 3.32281958, 0.96769613, 0.43727545, 2.43019906}; + std::vector gold = {0.26735861, -4.30770895, 1.05257728, -1.19954265, 0.50493170, + -0.18729756, 1.09137941, -1.09298312, 3.42956915, -0.41681939, + 0.17833257, 0.26040336, 0.15351280, 1.87632715, -0.63545406, + -0.95467340, -1.74728628, -2.42477030, 0.76262372, 0.15539164, + 3.32281958, 0.96769613, 0.43727545, 2.43019906}; - EXPECT(migraphx::verify::verify_range(m, m_res)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_4D_alpha_beta_test) @@ -405,13 +409,13 @@ TEST_CASE(dot_4D_alpha_beta_test) std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - std::vector m_res = {-0.91147203, 0.47540785, -0.30313587, 0.43325099, -0.43711586, - 0.50928632, 0.06919868, -0.80382802, -0.05125718, -0.06685650, - -0.06972163, 0.32407764, 0.45677396, 0.25909489, 0.56911252, - -0.17183724, 0.10858734, 0.39406289, 0.04662959, 1.07979824, - 0.40355016, 0.52410648, -0.31728447, 1.09550845}; + std::vector gold = {-0.91147203, 0.47540785, -0.30313587, 0.43325099, -0.43711586, + 0.50928632, 0.06919868, -0.80382802, -0.05125718, -0.06685650, + -0.06972163, 0.32407764, 0.45677396, 0.25909489, 0.56911252, + -0.17183724, 0.10858734, 0.39406289, 0.04662959, 1.07979824, + 0.40355016, 0.52410648, -0.31728447, 1.09550845}; - EXPECT(migraphx::verify::verify_range(m, m_res)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_4D_alpha_beta_C_test) @@ -457,13 +461,13 @@ TEST_CASE(dot_4D_alpha_beta_C_test) std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - std::vector m_res = {-0.91147203, 0.47540785, -0.30313587, 0.43325099, -0.43711586, - 0.50928632, 0.06919868, -0.80382802, -0.05125718, -0.06685650, - -0.06972163, 0.32407764, 0.45677396, 0.25909489, 0.56911252, - -0.17183724, 0.10858734, 0.39406289, 0.04662959, 1.07979824, - 0.40355016, 0.52410648, -0.31728447, 1.09550845}; + std::vector gold = {-0.91147203, 0.47540785, -0.30313587, 0.43325099, -0.43711586, + 0.50928632, 0.06919868, -0.80382802, -0.05125718, -0.06685650, + -0.06972163, 0.32407764, 0.45677396, 0.25909489, 0.56911252, + -0.17183724, 0.10858734, 0.39406289, 0.04662959, 1.07979824, + 0.40355016, 0.52410648, -0.31728447, 1.09550845}; - EXPECT(migraphx::verify::verify_range(m, m_res)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_2D_C_test0) @@ -519,7 +523,7 @@ TEST_CASE(dot_2D_C_test0) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_vv_inner_product_1) @@ -555,7 +559,7 @@ TEST_CASE(dot_vv_inner_product_1) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_vv_inner_product_2) @@ -593,7 +597,7 @@ TEST_CASE(dot_vv_inner_product_2) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_vm_1) @@ -628,7 +632,7 @@ TEST_CASE(dot_vm_1) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_vm_2) @@ -665,7 +669,7 @@ TEST_CASE(dot_vm_2) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_vm_3) @@ -711,7 +715,7 @@ TEST_CASE(dot_vm_3) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_vm_4) @@ -758,7 +762,7 @@ TEST_CASE(dot_vm_4) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_mv_1) @@ -795,7 +799,7 @@ TEST_CASE(dot_mv_1) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_mv_2) @@ -834,7 +838,7 @@ TEST_CASE(dot_mv_2) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_mv_3) @@ -878,7 +882,7 @@ TEST_CASE(dot_mv_3) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_mm1_1) @@ -929,7 +933,7 @@ TEST_CASE(dot_mm1_1) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_mm1_2) @@ -982,7 +986,7 @@ TEST_CASE(dot_mm1_2) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_mm2_1) @@ -1024,7 +1028,7 @@ TEST_CASE(dot_mm2_1) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_mm2_2) @@ -1067,7 +1071,7 @@ TEST_CASE(dot_mm2_2) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_mm2_3) @@ -1116,7 +1120,7 @@ TEST_CASE(dot_mm2_3) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_mm2_4) @@ -1162,7 +1166,7 @@ TEST_CASE(dot_mm2_4) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(dot_dyn_2D_test) @@ -1202,19 +1206,19 @@ TEST_CASE(dot_dyn_2D_test) auto result = p.eval(params).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - std::vector c = {-1.56327541e+00, - -7.09570140e-01, - -5.37424982e-01, - -2.22994831e-01, - -2.15586437e+00, - 2.09177941e-03, - -1.47279677e+00, - 2.02627040e-01, - -6.04527691e-01, - -1.29885596e+00, - 2.16294914e+00, - -1.48101497e-01}; - EXPECT(migraphx::verify::verify_range(c, results_vector)); + std::vector gold = {-1.56327541e+00, + -7.09570140e-01, + -5.37424982e-01, + -2.22994831e-01, + -2.15586437e+00, + 2.09177941e-03, + -1.47279677e+00, + 2.02627040e-01, + -6.04527691e-01, + -1.29885596e+00, + 2.16294914e+00, + -1.48101497e-01}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(dot_dyn_4D_test) @@ -1256,19 +1260,19 @@ TEST_CASE(dot_dyn_4D_test) auto result = p.eval(params).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - std::vector c = {-1.56327541e+00, - -7.09570140e-01, - -5.37424982e-01, - -2.22994831e-01, - -2.15586437e+00, - 2.09177941e-03, - -1.47279677e+00, - 2.02627040e-01, - -6.04527691e-01, - -1.29885596e+00, - 2.16294914e+00, - -1.48101497e-01}; - EXPECT(migraphx::verify::verify_range(c, results_vector)); + std::vector gold = {-1.56327541e+00, + -7.09570140e-01, + -5.37424982e-01, + -2.22994831e-01, + -2.15586437e+00, + 2.09177941e-03, + -1.47279677e+00, + 2.02627040e-01, + -6.04527691e-01, + -1.29885596e+00, + 2.16294914e+00, + -1.48101497e-01}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(quant_dot_2args_multi4_1) @@ -1295,7 +1299,7 @@ TEST_CASE(quant_dot_2args_multi4_1) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(quant_dot_2args_multi4_2) @@ -1323,7 +1327,7 @@ TEST_CASE(quant_dot_2args_multi4_2) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(quant_dot_2args_multi4_3) @@ -1351,7 +1355,7 @@ TEST_CASE(quant_dot_2args_multi4_3) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(quant_dot_2args_multi4_4) @@ -1380,7 +1384,7 @@ TEST_CASE(quant_dot_2args_multi4_4) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(quant_dot_2args_general_1) @@ -1405,7 +1409,7 @@ TEST_CASE(quant_dot_2args_general_1) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(quant_dot_2args_general_2) @@ -1432,7 +1436,7 @@ TEST_CASE(quant_dot_2args_general_2) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(quant_dot_2args_general_3) @@ -1460,7 +1464,7 @@ TEST_CASE(quant_dot_2args_general_3) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(quant_dot_2args_general_4) @@ -1488,7 +1492,7 @@ TEST_CASE(quant_dot_2args_general_4) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(quant_dot_3args_general_1) @@ -1518,7 +1522,7 @@ TEST_CASE(quant_dot_3args_general_1) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(quant_dot_3args_general_2) @@ -1546,7 +1550,7 @@ TEST_CASE(quant_dot_3args_general_2) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(quant_dot_3args_general_3) @@ -1577,7 +1581,7 @@ TEST_CASE(quant_dot_3args_general_3) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(quant_dot_3args_general_4) @@ -1608,7 +1612,7 @@ TEST_CASE(quant_dot_3args_general_4) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(quant_dot_3args_general_5) @@ -1640,7 +1644,7 @@ TEST_CASE(quant_dot_3args_general_5) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(quant_dot_3args_batch_1) @@ -1674,7 +1678,7 @@ TEST_CASE(quant_dot_3args_batch_1) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } TEST_CASE(quant_dot_3args_batch_2) @@ -1713,5 +1717,5 @@ TEST_CASE(quant_dot_3args_batch_2) auto result = p.eval({}).back(); std::vector m; result.visit([&](auto output) { m.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(m, gold)); + EXPECT(migraphx::verify::verify_rms_range(m, gold)); } diff --git a/test/ref/elu.cpp b/test/ref/elu.cpp index 1e67ed5f921..87e6166ae9d 100644 --- a/test/ref/elu.cpp +++ b/test/ref/elu.cpp @@ -45,7 +45,7 @@ TEST_CASE(elu_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{elu(alpha, -1), elu(alpha, 2), elu(alpha, -3), elu(alpha, 4)}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(elu_dyn_test) @@ -67,5 +67,5 @@ TEST_CASE(elu_dyn_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{elu(alpha, -1), elu(alpha, 2), elu(alpha, -3), elu(alpha, 4)}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/erf.cpp b/test/ref/erf.cpp index d0e139cbafc..ac1ff3108d0 100644 --- a/test/ref/erf.cpp +++ b/test/ref/erf.cpp @@ -45,7 +45,7 @@ TEST_CASE(erf_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return erff(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(erf_dyn_test) @@ -68,5 +68,5 @@ TEST_CASE(erf_dyn_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return erff(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/exp.cpp b/test/ref/exp.cpp index ee2df9a3698..c1a0bc13bc5 100644 --- a/test/ref/exp.cpp +++ b/test/ref/exp.cpp @@ -45,7 +45,7 @@ TEST_CASE(exp_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return expf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(exp_dyn_test) @@ -68,5 +68,5 @@ TEST_CASE(exp_dyn_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return expf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/fill.cpp b/test/ref/fill.cpp index f80abf6d6be..f71e401d3b5 100644 --- a/test/ref/fill.cpp +++ b/test/ref/fill.cpp @@ -51,7 +51,7 @@ TEST_CASE(fill_static_int) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold(48, 3); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(fill_dyn_float) @@ -75,7 +75,7 @@ TEST_CASE(fill_dyn_float) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold(72, 7.36); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(fill_var_default_value) @@ -98,5 +98,5 @@ TEST_CASE(fill_var_default_value) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold(48, 2); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/floor.cpp b/test/ref/floor.cpp index 5309f3ea271..086706a93e9 100644 --- a/test/ref/floor.cpp +++ b/test/ref/floor.cpp @@ -45,7 +45,7 @@ TEST_CASE(floor_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return floor(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(floor_dyn_test) @@ -68,5 +68,5 @@ TEST_CASE(floor_dyn_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return floor(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/fmod.cpp b/test/ref/fmod.cpp index 00248ad6516..0d78dec4e14 100644 --- a/test/ref/fmod.cpp +++ b/test/ref/fmod.cpp @@ -45,7 +45,7 @@ TEST_CASE(fmod_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{-1, 0, -3}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(fmod_dyn_test) @@ -73,7 +73,7 @@ TEST_CASE(fmod_dyn_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{-1, 0, -3}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(fmod_float_test) @@ -92,5 +92,5 @@ TEST_CASE(fmod_float_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{-1.2f, 0.5f, -3.3f}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/gather.cpp b/test/ref/gather.cpp index 6f12a52026d..deb57bdc4e3 100644 --- a/test/ref/gather.cpp +++ b/test/ref/gather.cpp @@ -52,7 +52,7 @@ TEST_CASE(gather_non_std_test) 0.5f, 1.5f, 2.5f, 6.5f, 7.5f, 8.5f, 0.5f, 1.5f, 2.5f, 6.5f, 7.5f, 8.5f}; std::vector res_data; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, golden)); + EXPECT(migraphx::verify::verify_rms_range(res_data, golden)); } } @@ -75,7 +75,7 @@ TEST_CASE(gather_test_1) std::vector res_data(4 * 5); std::vector golden = {0.5f, 1.5f, 2.5f, 6.5f, 7.5f, 8.5f}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, golden)); + EXPECT(migraphx::verify::verify_rms_range(res_data, golden)); } TEST_CASE(gather_test_2) @@ -97,7 +97,7 @@ TEST_CASE(gather_test_2) std::vector res_data(4 * 5); std::vector golden = {0.5f, 1.5f, 2.5f, 6.5f, 7.5f, 8.5f}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, golden)); + EXPECT(migraphx::verify::verify_rms_range(res_data, golden)); } TEST_CASE(gather_test_3) @@ -119,7 +119,7 @@ TEST_CASE(gather_test_3) std::vector res_data(4 * 5); std::vector golden = {0.5f, 2.5f, 3.5f, 5.5f, 6.5f, 8.5f}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, golden)); + EXPECT(migraphx::verify::verify_rms_range(res_data, golden)); } TEST_CASE(gather_test_4) @@ -141,7 +141,7 @@ TEST_CASE(gather_test_4) std::vector res_data(4 * 5); std::vector golden = {0.5f, 2.5f, 3.5f, 5.5f, 6.5f, 8.5f}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, golden)); + EXPECT(migraphx::verify::verify_rms_range(res_data, golden)); } TEST_CASE(gather_test_5) @@ -164,7 +164,7 @@ TEST_CASE(gather_test_5) std::vector res_data{}; std::vector golden = {0.5f, 3.5f, 6.5f}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, golden)); + EXPECT(migraphx::verify::verify_rms_range(res_data, golden)); } TEST_CASE(gather_test_6) @@ -187,7 +187,7 @@ TEST_CASE(gather_test_6) std::vector res_data{}; std::vector golden = {0.5f, 3.5f, 6.5f}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, golden)); + EXPECT(migraphx::verify::verify_rms_range(res_data, golden)); } TEST_CASE(gather_test_7) @@ -210,7 +210,7 @@ TEST_CASE(gather_test_7) std::vector res_data{}; std::vector golden = {0.5f}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, golden)); + EXPECT(migraphx::verify::verify_rms_range(res_data, golden)); } TEST_CASE(gather_dyn_test0) @@ -243,7 +243,7 @@ TEST_CASE(gather_dyn_test0) std::vector gold = {1, 2, 4, 5}; std::vector results_vector(2 * 1 * 2); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); migraphx::shape sfinal{migraphx::shape::int32_type, {2, 1, 2}}; EXPECT(result.get_shape() == sfinal); } @@ -280,7 +280,7 @@ TEST_CASE(gather_dyn_test1) std::vector results_vector(1 * 2 * 4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); migraphx::shape sfinal{migraphx::shape::int32_type, {1, 2, 4}}; EXPECT(result.get_shape() == sfinal); } diff --git a/test/ref/gathernd.cpp b/test/ref/gathernd.cpp index cccde261e2d..64c4dbb3289 100644 --- a/test/ref/gathernd.cpp +++ b/test/ref/gathernd.cpp @@ -52,7 +52,7 @@ TEST_CASE(gathernd_test_1) std::vector gold{0, 3}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, gold)); + EXPECT(migraphx::verify::verify_rms_range(res_data, gold)); } TEST_CASE(gathernd_test_2) @@ -77,7 +77,7 @@ TEST_CASE(gathernd_test_2) std::vector gold{2, 3, 0, 1}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, gold)); + EXPECT(migraphx::verify::verify_rms_range(res_data, gold)); } TEST_CASE(gathernd_test_3) @@ -102,7 +102,7 @@ TEST_CASE(gathernd_test_3) std::vector gold{3, 4, 5, 0, 1, 2, 0, 1, 2, 3, 4, 5}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, gold)); + EXPECT(migraphx::verify::verify_rms_range(res_data, gold)); } TEST_CASE(gathernd_test_4) @@ -128,7 +128,7 @@ TEST_CASE(gathernd_test_4) std::vector gold{0, 1, 2, 3, 4, 5, 18, 19, 20, 21, 22, 23}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, gold)); + EXPECT(migraphx::verify::verify_rms_range(res_data, gold)); } TEST_CASE(gathernd_test_5) @@ -155,7 +155,7 @@ TEST_CASE(gathernd_test_5) std::vector gold{0, 4, 8, 11, 13, 15}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, gold)); + EXPECT(migraphx::verify::verify_rms_range(res_data, gold)); } TEST_CASE(gathernd_test_6) @@ -215,7 +215,7 @@ TEST_CASE(gathernd_dynamic0) std::vector gold{3, 4, 5, 0, 1, 2, 0, 1, 2, 3, 4, 5}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, gold)); + EXPECT(migraphx::verify::verify_rms_range(res_data, gold)); } TEST_CASE(gathernd_dynamic1) @@ -251,7 +251,7 @@ TEST_CASE(gathernd_dynamic1) std::vector gold{3, 4, 5, 0, 1, 2, 0, 1, 2, 3, 4, 5}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, gold)); + EXPECT(migraphx::verify::verify_rms_range(res_data, gold)); } TEST_CASE(gathernd_dynamic2) @@ -287,7 +287,7 @@ TEST_CASE(gathernd_dynamic2) std::vector gold{3, 4, 5, 0, 1, 2, 0, 1, 2, 3, 4, 5}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, gold)); + EXPECT(migraphx::verify::verify_rms_range(res_data, gold)); } TEST_CASE(gathernd_dynamic3) @@ -323,7 +323,7 @@ TEST_CASE(gathernd_dynamic3) std::vector res_data{}; std::vector gold{1, 0, 3, 4}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, gold)); + EXPECT(migraphx::verify::verify_rms_range(res_data, gold)); } TEST_CASE(gathernd_dynamic4) @@ -358,7 +358,7 @@ TEST_CASE(gathernd_dynamic4) std::vector res_data{}; std::vector gold{5}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, gold)); + EXPECT(migraphx::verify::verify_rms_range(res_data, gold)); } TEST_CASE(gathernd_negative_index_test_1) @@ -383,7 +383,7 @@ TEST_CASE(gathernd_negative_index_test_1) std::vector gold{2, 3, 0, 1}; result.visit([&](auto output) { res_data.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(res_data, gold)); + EXPECT(migraphx::verify::verify_rms_range(res_data, gold)); } TEST_CASE(gathernd_negative_index_test_2) diff --git a/test/ref/im2col.cpp b/test/ref/im2col.cpp index e1cce978e18..1ea7d2e7e64 100644 --- a/test/ref/im2col.cpp +++ b/test/ref/im2col.cpp @@ -40,14 +40,14 @@ TEST_CASE(im2col_3x3_no_pad_identity_test) std::size_t channels = 1; std::vector weights(channels * f[0] * f[1]); - std::vector input(channels * size[0] * size[1]); - std::iota(input.begin(), input.end(), 0); + std::vector gold(channels * size[0] * size[1]); + std::iota(gold.begin(), gold.end(), 0); migraphx::program p; auto* mm = p.get_main_module(); migraphx::shape s_image{migraphx::shape::int32_type, {1, channels, size[0], size[1]}}; migraphx::shape s_weights{migraphx::shape::int32_type, {1, channels, f[0], f[1]}}; - auto l_image = mm->add_literal(migraphx::literal{s_image, input}); + auto l_image = mm->add_literal(migraphx::literal{s_image, gold}); auto l_weights = mm->add_literal(migraphx::literal{s_weights, weights}); mm->add_instruction( migraphx::make_op("im2col", @@ -61,7 +61,7 @@ TEST_CASE(im2col_3x3_no_pad_identity_test) std::size_t col_width = (size[1] - f[1] + 2 * padding[1]) / stride[1] + 1; std::vector results_vector(channels * f[0] * f[1] * col_height * col_width); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, input)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(im2col_3x3_no_pad_test) @@ -91,14 +91,14 @@ TEST_CASE(im2col_3x3_no_pad_test) p.compile(migraphx::make_target("ref")); auto result = p.eval({}).back(); - std::vector correct = {0, 1, 2, 4, 5, 6, 8, 9, 10, 1, 2, 3, 5, 6, 7, 9, 10, 11, - 4, 5, 6, 8, 9, 10, 12, 13, 14, 5, 6, 7, 9, 10, 11, 13, 14, 15}; + std::vector gold = {0, 1, 2, 4, 5, 6, 8, 9, 10, 1, 2, 3, 5, 6, 7, 9, 10, 11, + 4, 5, 6, 8, 9, 10, 12, 13, 14, 5, 6, 7, 9, 10, 11, 13, 14, 15}; std::size_t col_height = (size[0] - f[0] + 2 * padding[0]) / stride[0] + 1; std::size_t col_width = (size[1] - f[1] + 2 * padding[1]) / stride[1] + 1; std::vector results_vector(channels * f[0] * f[1] * col_height * col_width); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, correct)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(im2col_3x3_stride_2_no_pad_test) @@ -128,15 +128,15 @@ TEST_CASE(im2col_3x3_stride_2_no_pad_test) p.compile(migraphx::make_target("ref")); auto result = p.eval({}).back(); - std::vector correct = {0, 1, 2, 6, 7, 8, 12, 13, 14, 2, 3, 4, - 8, 9, 10, 14, 15, 16, 12, 13, 14, 18, 19, 20, - 24, 25, 26, 14, 15, 16, 20, 21, 22, 26, 27, 28}; + std::vector gold = {0, 1, 2, 6, 7, 8, 12, 13, 14, 2, 3, 4, + 8, 9, 10, 14, 15, 16, 12, 13, 14, 18, 19, 20, + 24, 25, 26, 14, 15, 16, 20, 21, 22, 26, 27, 28}; std::size_t col_height = (size[0] - f[0] + 2 * padding[0]) / stride[0] + 1; std::size_t col_width = (size[1] - f[1] + 2 * padding[1]) / stride[1] + 1; std::vector results_vector(channels * f[0] * f[1] * col_height * col_width); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, correct)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(im2col_3x3_with_channels_identity_test) @@ -149,14 +149,14 @@ TEST_CASE(im2col_3x3_with_channels_identity_test) std::size_t channels = 2; std::vector weights(channels * f[0] * f[1]); - std::vector input(channels * size[0] * size[1]); - std::iota(input.begin(), input.end(), 0); + std::vector gold(channels * size[0] * size[1]); + std::iota(gold.begin(), gold.end(), 0); migraphx::program p; auto* mm = p.get_main_module(); migraphx::shape s_image{migraphx::shape::int32_type, {1, channels, size[0], size[1]}}; migraphx::shape s_weights{migraphx::shape::int32_type, {1, channels, f[0], f[1]}}; - auto l_image = mm->add_literal(migraphx::literal{s_image, input}); + auto l_image = mm->add_literal(migraphx::literal{s_image, gold}); auto l_weights = mm->add_literal(migraphx::literal{s_weights, weights}); mm->add_instruction( migraphx::make_op("im2col", @@ -170,7 +170,7 @@ TEST_CASE(im2col_3x3_with_channels_identity_test) std::size_t col_width = (size[1] - f[1] + 2 * padding[1]) / stride[1] + 1; std::vector results_vector(channels * f[0] * f[1] * col_height * col_width); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, input)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(im2col_3x3_with_padding_test) @@ -200,12 +200,12 @@ TEST_CASE(im2col_3x3_with_padding_test) p.compile(migraphx::make_target("ref")); auto result = p.eval({}).back(); - std::vector correct = {0, 0, 0, 0, 0, 1, 0, 2, 3, 0, 0, 0, 0, 1, 0, 2, 3, 0, - 0, 0, 1, 0, 2, 3, 0, 0, 0, 0, 1, 0, 2, 3, 0, 0, 0, 0}; + std::vector gold = {0, 0, 0, 0, 0, 1, 0, 2, 3, 0, 0, 0, 0, 1, 0, 2, 3, 0, + 0, 0, 1, 0, 2, 3, 0, 0, 0, 0, 1, 0, 2, 3, 0, 0, 0, 0}; std::size_t col_height = (size[0] - f[0] + 2 * padding[0]) / stride[0] + 1; std::size_t col_width = (size[1] - f[1] + 2 * padding[1]) / stride[1] + 1; std::vector results_vector(channels * f[0] * f[1] * col_height * col_width); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, correct)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/isnan.cpp b/test/ref/isnan.cpp index 30510acb2e5..f921d638b34 100644 --- a/test/ref/isnan.cpp +++ b/test/ref/isnan.cpp @@ -45,8 +45,8 @@ TEST_CASE(isnan_test) auto result = p.eval({}).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - std::vector correct = {0, 0, 1, 1, 0, 0}; - EXPECT(migraphx::verify::verify_range(results_vector, correct)); + std::vector gold = {0, 0, 1, 1, 0, 0}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } // half test @@ -64,8 +64,8 @@ TEST_CASE(isnan_test) auto result = p.eval({}).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - std::vector correct = {0, 0, 1, 1, 0, 0}; - EXPECT(migraphx::verify::verify_range(results_vector, correct)); + std::vector gold = {0, 0, 1, 1, 0, 0}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } } @@ -86,6 +86,6 @@ TEST_CASE(isnan_dyn_test) auto result = p.eval(params0).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - std::vector correct = {0, 0, 1, 1, 0, 0}; - EXPECT(migraphx::verify::verify_range(results_vector, correct)); + std::vector gold = {0, 0, 1, 1, 0, 0}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/leaky_relu.cpp b/test/ref/leaky_relu.cpp index 241c1919b3d..132c96c3e36 100644 --- a/test/ref/leaky_relu.cpp +++ b/test/ref/leaky_relu.cpp @@ -42,5 +42,5 @@ TEST_CASE(leaky_relu_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {-0.01f, 0.f, 1.f}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/log.cpp b/test/ref/log.cpp index 6a28c3f4891..ee0636ef0f9 100644 --- a/test/ref/log.cpp +++ b/test/ref/log.cpp @@ -45,7 +45,7 @@ TEST_CASE(log_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return logf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(log_dyn_test) @@ -68,5 +68,5 @@ TEST_CASE(log_dyn_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return logf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/logical_and.cpp b/test/ref/logical_and.cpp index 057814d9108..76288059f55 100644 --- a/test/ref/logical_and.cpp +++ b/test/ref/logical_and.cpp @@ -49,7 +49,7 @@ TEST_CASE(logical_and_test) data1.begin(), data1.end(), data2.begin(), gold.begin(), [](bool n1, bool n2) -> bool { return n1 and n2; }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(logical_and_dyn_test) @@ -78,5 +78,5 @@ TEST_CASE(logical_and_dyn_test) right_data.begin(), gold.begin(), [](bool n1, bool n2) -> bool { return n1 and n2; }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/logical_or.cpp b/test/ref/logical_or.cpp index 55eac634188..aa5f237eb5b 100644 --- a/test/ref/logical_or.cpp +++ b/test/ref/logical_or.cpp @@ -49,7 +49,7 @@ TEST_CASE(logical_or_test) data1.begin(), data1.end(), data2.begin(), gold.begin(), [](bool n1, bool n2) -> bool { return n1 or n2; }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(logical_or_dyn_test) @@ -78,5 +78,5 @@ TEST_CASE(logical_or_dyn_test) right_data.begin(), gold.begin(), [](bool n1, bool n2) -> bool { return n1 or n2; }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/logical_xor.cpp b/test/ref/logical_xor.cpp index 4662483e768..3ef82414c9c 100644 --- a/test/ref/logical_xor.cpp +++ b/test/ref/logical_xor.cpp @@ -49,7 +49,7 @@ TEST_CASE(logical_xor_test) data1.begin(), data1.end(), data2.begin(), gold.begin(), [](bool n1, bool n2) -> bool { return n1 ^ n2; }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(logical_xor_dyn_test) @@ -78,5 +78,5 @@ TEST_CASE(logical_xor_dyn_test) right_data.begin(), gold.begin(), [](bool n1, bool n2) -> bool { return n1 ^ n2; }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/logsoftmax.cpp b/test/ref/logsoftmax.cpp index b65627a73f2..ab870ebcced 100644 --- a/test/ref/logsoftmax.cpp +++ b/test/ref/logsoftmax.cpp @@ -61,7 +61,7 @@ TEST_CASE(logsoftmax_test_axis_0) auto result = p.eval({}).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, s)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, s)); } TEST_CASE(logsoftmax_test_axis_1) @@ -95,7 +95,7 @@ TEST_CASE(logsoftmax_test_axis_1) auto result = p.eval({}).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, s)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, s)); } TEST_CASE(logsoftmax_test_axis_2) @@ -129,7 +129,7 @@ TEST_CASE(logsoftmax_test_axis_2) auto result = p.eval({}).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, s)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, s)); } TEST_CASE(logsoftmax_test_axis_3) @@ -163,5 +163,5 @@ TEST_CASE(logsoftmax_test_axis_3) auto result = p.eval({}).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, s)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, s)); } diff --git a/test/ref/lrn.cpp b/test/ref/lrn.cpp index 083f47a1c6d..3049cd42375 100644 --- a/test/ref/lrn.cpp +++ b/test/ref/lrn.cpp @@ -43,5 +43,5 @@ TEST_CASE(lrn_test) std::vector results_vector(5); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {-2 / 1.000075, 1 / 1.00009, 0 / 1.000145, 1 / 1.00009, 2 / 1.000075}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/max.cpp b/test/ref/max.cpp index ed47c01c2aa..ffaef1ff946 100644 --- a/test/ref/max.cpp +++ b/test/ref/max.cpp @@ -45,7 +45,7 @@ TEST_CASE(max_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{7, 8, 9}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(max_dyn_test) @@ -73,5 +73,5 @@ TEST_CASE(max_dyn_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{7, 8, 9}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/min.cpp b/test/ref/min.cpp index 219e2a327db..8ffa4394527 100644 --- a/test/ref/min.cpp +++ b/test/ref/min.cpp @@ -45,7 +45,7 @@ TEST_CASE(min_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{1, 4, 3}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(min_dyn_test) @@ -73,5 +73,5 @@ TEST_CASE(min_dyn_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{1, 4, 3}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/mod.cpp b/test/ref/mod.cpp index ee6f749e152..83ad7454089 100644 --- a/test/ref/mod.cpp +++ b/test/ref/mod.cpp @@ -45,7 +45,7 @@ TEST_CASE(mod_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0, 0, 2}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(mod_dyn_test) @@ -73,7 +73,7 @@ TEST_CASE(mod_dyn_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0, 0, 2}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(mod_float_test) @@ -92,5 +92,5 @@ TEST_CASE(mod_float_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{1.0f, 2.5f, 2.0f}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/mul.cpp b/test/ref/mul.cpp index 87a8ce77d6e..b2f48662dd7 100644 --- a/test/ref/mul.cpp +++ b/test/ref/mul.cpp @@ -49,7 +49,7 @@ TEST_CASE(mul_test) data1.begin(), data1.end(), data2.begin(), gold.begin(), [](float n1, float n2) -> float { return n1 * n2; }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(mul_dyn_test) @@ -78,5 +78,5 @@ TEST_CASE(mul_dyn_test) y_data.begin(), gold.begin(), [](float n1, float n2) -> float { return n1 * n2; }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/multinomial.cpp b/test/ref/multinomial.cpp index 6a7d05dcf88..b280a1ac17e 100644 --- a/test/ref/multinomial.cpp +++ b/test/ref/multinomial.cpp @@ -78,5 +78,6 @@ TEST_CASE(multinomial_test) std::transform(res_dist.begin(), res_dist.end(), res_norm.begin(), [&](auto n) { return static_cast(n) / res_dist_sum; }); - EXPECT(migraphx::verify::verify_range(norm, res_norm, 100000)); + EXPECT(migraphx::verify::verify_range_with_tolerance( + res_norm, migraphx::verify::expected{norm}, migraphx::verify::tolerance{0.01})); } diff --git a/test/ref/neg.cpp b/test/ref/neg.cpp index 72274eba9a9..a1b9082f1fa 100644 --- a/test/ref/neg.cpp +++ b/test/ref/neg.cpp @@ -45,7 +45,7 @@ TEST_CASE(neg_test) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = data; std::transform(gold.begin(), gold.end(), gold.begin(), std::negate()); - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } TEST_CASE(neg_dyn_test) @@ -67,5 +67,5 @@ TEST_CASE(neg_dyn_test) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = a; std::transform(gold.begin(), gold.end(), gold.begin(), std::negate()); - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } diff --git a/test/ref/nonmaxsuppression.cpp b/test/ref/nonmaxsuppression.cpp index 9c42672a9ef..ef0467d6e6c 100644 --- a/test/ref/nonmaxsuppression.cpp +++ b/test/ref/nonmaxsuppression.cpp @@ -62,7 +62,7 @@ TEST_CASE(nms_dyn_out_test) std::vector result; output.visit([&](auto out) { result.assign(out.begin(), out.end()); }); std::vector gold = {0, 0, 3, 0, 0, 0, 0, 0, 5}; - EXPECT(migraphx::verify::verify_range(result, gold)); + EXPECT(migraphx::verify::verify_rms_range(result, gold)); } TEST_CASE(nms_dyn_batch_test) @@ -108,7 +108,7 @@ TEST_CASE(nms_dyn_batch_test) std::vector result; output.visit([&](auto out) { result.assign(out.begin(), out.end()); }); std::vector gold = {0, 0, 3, 0, 0, 0, 0, 0, 5, 1, 0, 3, 1, 0, 0, 1, 0, 5}; - EXPECT(migraphx::verify::verify_range(result, gold)); + EXPECT(migraphx::verify::verify_rms_range(result, gold)); } TEST_CASE(nms_dyn_boxes_test) @@ -151,7 +151,7 @@ TEST_CASE(nms_dyn_boxes_test) std::vector result; output.visit([&](auto out) { result.assign(out.begin(), out.end()); }); std::vector gold = {0, 0, 3, 0, 0, 0, 0, 0, 5}; - EXPECT(migraphx::verify::verify_range(result, gold)); + EXPECT(migraphx::verify::verify_rms_range(result, gold)); } TEST_CASE(nms_dyn_classes_test) @@ -195,7 +195,7 @@ TEST_CASE(nms_dyn_classes_test) std::vector result; output.visit([&](auto out) { result.assign(out.begin(), out.end()); }); std::vector gold = {0, 0, 3, 0, 0, 0, 0, 1, 3, 0, 1, 0}; - EXPECT(migraphx::verify::verify_range(result, gold)); + EXPECT(migraphx::verify::verify_rms_range(result, gold)); } TEST_CASE(nms_not_center_test) @@ -231,7 +231,7 @@ TEST_CASE(nms_not_center_test) std::vector result; output.visit([&](auto out) { result.assign(out.begin(), out.end()); }); std::vector gold = {0, 0, 3, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - EXPECT(migraphx::verify::verify_range(result, gold)); + EXPECT(migraphx::verify::verify_rms_range(result, gold)); } TEST_CASE(nms_test) @@ -265,7 +265,7 @@ TEST_CASE(nms_test) std::vector result; output.visit([&](auto out) { result.assign(out.begin(), out.end()); }); std::vector gold = {0, 0, 3, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - EXPECT(migraphx::verify::verify_range(result, gold)); + EXPECT(migraphx::verify::verify_rms_range(result, gold)); } TEST_CASE(nms_transpose1_test) @@ -303,7 +303,7 @@ TEST_CASE(nms_transpose1_test) std::vector result; output.visit([&](auto out) { result.assign(out.begin(), out.end()); }); std::vector gold = {0, 0, 3, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - EXPECT(migraphx::verify::verify_range(result, gold)); + EXPECT(migraphx::verify::verify_rms_range(result, gold)); } TEST_CASE(nms_transpose2_test) @@ -341,5 +341,5 @@ TEST_CASE(nms_transpose2_test) std::vector result; output.visit([&](auto out) { result.assign(out.begin(), out.end()); }); std::vector gold = {0, 0, 3, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - EXPECT(migraphx::verify::verify_range(result, gold)); + EXPECT(migraphx::verify::verify_rms_range(result, gold)); } diff --git a/test/ref/nonzero.cpp b/test/ref/nonzero.cpp index 5391bc385e0..b6a534e0ea1 100644 --- a/test/ref/nonzero.cpp +++ b/test/ref/nonzero.cpp @@ -46,5 +46,5 @@ TEST_CASE(nonzero_test) result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); std::vector gold = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0}; - EXPECT(migraphx::verify::verify_range(result_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); } diff --git a/test/ref/not.cpp b/test/ref/not.cpp index 6aeee040d59..296ffd3d229 100644 --- a/test/ref/not.cpp +++ b/test/ref/not.cpp @@ -44,7 +44,7 @@ TEST_CASE(not_test_int32) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{1, 0, 0, 0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(not_test_bool) @@ -62,7 +62,7 @@ TEST_CASE(not_test_bool) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold(data.size()); std::transform(data.begin(), data.end(), gold.begin(), [](bool n) -> bool { return not n; }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(not_dyn_test) @@ -83,5 +83,5 @@ TEST_CASE(not_dyn_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{1, 0, 0, 0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/pad.cpp b/test/ref/pad.cpp index 6bec2bdf718..c2fc9e74185 100644 --- a/test/ref/pad.cpp +++ b/test/ref/pad.cpp @@ -42,7 +42,7 @@ TEST_CASE(pad_test) std::vector results_vector(16); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0, 0, 0, 0, 0, 1, 2, 0, 0, 3, 4, 0, 0, 0, 0, 0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(pad_test_asym) @@ -57,7 +57,7 @@ TEST_CASE(pad_test_asym) std::vector results_vector(9); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{1, 2, 0, 3, 4, 0, 0, 0, 0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(pad_test_highest_half) @@ -76,7 +76,7 @@ TEST_CASE(pad_test_highest_half) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); const float x = std::numeric_limits::max(); std::vector gold{x, x, x, x, x, 1, 2, x, x, 3, 4, x, x, x, x, x}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(pad_test_lowest_half) @@ -95,7 +95,7 @@ TEST_CASE(pad_test_lowest_half) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); const float x = std::numeric_limits::lowest(); std::vector gold{x, x, x, x, x, 1, 2, x, x, 3, 4, x, x, x, x, x}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(pad_dyn_test) @@ -115,5 +115,5 @@ TEST_CASE(pad_dyn_test) std::vector results_vector(16); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0, 0, 0, 0, 0, 1, 2, 0, 0, 3, 4, 0, 0, 0, 0, 0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/pointwise.cpp b/test/ref/pointwise.cpp index 020019b98c0..a6c61664f96 100644 --- a/test/ref/pointwise.cpp +++ b/test/ref/pointwise.cpp @@ -47,5 +47,5 @@ TEST_CASE(pointwise_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0, 2, 4}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/pooling.cpp b/test/ref/pooling.cpp index 0af2273d60c..a24c5bc6dbc 100644 --- a/test/ref/pooling.cpp +++ b/test/ref/pooling.cpp @@ -51,7 +51,7 @@ TEST_CASE(avgpool_rank3_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0.25, 0.3, 0.25, 0.65, 0.7, 0.5, 0.4, 0.4, 0.35}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(avgpool_dyn_test) @@ -77,7 +77,7 @@ TEST_CASE(avgpool_dyn_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0.25, 0.3, 0.25, 0.65, 0.7, 0.5, 0.4, 0.4, 0.35}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(avgpool_dyn_pad_test) @@ -105,7 +105,7 @@ TEST_CASE(avgpool_dyn_pad_test) std::vector gold{ 0.3, 0.25, 0.3, 0.25, 0.1, 0.8, 0.65, 0.7, 0.5, 0.1, 0.1, 0.4, 0.4, 0.35, 0.6}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(avgpool_dyn_auto_pad_test) @@ -141,7 +141,7 @@ TEST_CASE(avgpool_dyn_auto_pad_test) std::vector results_vector(12); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{2.5, 2.5, 3.5, 3.5}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(avgpool_dyn_auto_pad_1d_test) @@ -175,7 +175,7 @@ TEST_CASE(avgpool_dyn_auto_pad_1d_test) 0.8, 0.65, 0.7, 0.5, 0.1, 0.4, 0.4, 0.35}; // clang-format on - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(avgpool_dyn_pad_ceil_test) @@ -212,7 +212,7 @@ TEST_CASE(avgpool_dyn_pad_ceil_test) 2.0, 2.5, 2.5, 3.0, 3.0, 3.5, 3.5, 4.0}; // clang-format on - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(avgpool_rank3_stride2_test) @@ -245,7 +245,7 @@ TEST_CASE(avgpool_rank3_stride2_test) -0.3442, 1.22005, 1.5295, 0.9965, 0.7854, -0.2915}; // clang-format on - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(avgpool_rank5_test) @@ -281,7 +281,7 @@ TEST_CASE(avgpool_rank5_test) -0.078375, 0.139375, 0.46075, 0.0285, -0.188125, -0.085, 0.378125, -0.085375, -0.04, 0.304125, 0.40775, 0.2835, 0.112375, -0.073375, 0.4355, -0.187, -0.392625, -0.258375, -0.485875, -0.0345, 0.16125, -0.131875, -0.228375, 0.068625}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(globalavgpool_test) @@ -302,7 +302,7 @@ TEST_CASE(globalavgpool_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0.25, 0.575, 0.375}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(globalavgpool_dyn_test) @@ -325,7 +325,7 @@ TEST_CASE(globalavgpool_dyn_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0.25, 0.575, 0.375}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(globallppool_test) @@ -347,7 +347,7 @@ TEST_CASE(globallppool_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0.5477225575051662, 1.307669683062202, 0.9327379053088815}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(globallppool_dyn_test) @@ -371,7 +371,7 @@ TEST_CASE(globallppool_dyn_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0.5477225575051662, 1.307669683062202, 0.9327379053088815}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(globalmaxpool_test) @@ -392,7 +392,7 @@ TEST_CASE(globalmaxpool_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0.4, 0.9, 0.7}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(globalmaxpool_dyn_test) @@ -416,7 +416,7 @@ TEST_CASE(globalmaxpool_dyn_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0.4, 0.9, 0.7}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(lppool_l1_norm_test) @@ -440,7 +440,7 @@ TEST_CASE(lppool_l1_norm_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0.5, 0.6, 0.5, 1.3, 1.4, 1.0, 0.8, 0.8, 0.7}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } // TODO: this tests compliance with a oneDNN rule and a feature that's commented out @@ -493,7 +493,7 @@ TEST_CASE(lppool_l2_norm_test) 0.7071067811865475, 0.7071067811865475, 0.6082762530298219}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(lppool_dyn_test) @@ -526,7 +526,7 @@ TEST_CASE(lppool_dyn_test) 0.7071067811865475, 0.7071067811865475, 0.6082762530298219}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(maxpool_test) @@ -565,12 +565,6 @@ TEST_CASE(maxpool_test) -0.88503587, 0.6629802, 1.47319221, -1.05829155, -0.97027361, -0.93187737, -1.39954746, -0.52359426, -0.14743951, 1.51522756, 0.2078452, -1.28156149, -1.19363916, -0.78680223, -0.89094824, 1.30212069, -0.77974445, -0.58411664, 0.48764706, -0.67132682}; - std::vector c = {1.33493888, 1.54562736, 1.22098756, 1.33493888, 1.18358743, 1.99097753, - 1.00170159, 1.45862222, 1.39087725, 1.46645272, 1.18943918, -0.01443311, - 1.47151589, 2.36277103, 2.24768877, 0.68883753, 0.82949388, 0.71550399, - 1.95433736, 2.46601582, 1.53285873, 1.95433736, 1.06763375, 1.4545635, - 1.33624589, 1.16736257, 0.6126079, 1.36892557, 2.40126371, 1.53441942, - 0.52119428, 2.07681108, 0.88494766, 1.51522756, 0.54275119, 0.6629802}; migraphx::shape a_shape{migraphx::shape::float_type, {2, 3, 6, 6}}; auto al = mm->add_literal(migraphx::literal{a_shape, a}); mm->add_instruction(migraphx::make_op("pooling", @@ -583,7 +577,15 @@ TEST_CASE(maxpool_test) auto result = p.eval({}).back(); std::vector results_vector(36); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, c)); + std::vector gold = { + 1.33493888, 1.54562736, 1.22098756, 1.33493888, 1.18358743, 1.99097753, + 1.00170159, 1.45862222, 1.39087725, 1.46645272, 1.18943918, -0.01443311, + 1.47151589, 2.36277103, 2.24768877, 0.68883753, 0.82949388, 0.71550399, + 1.95433736, 2.46601582, 1.53285873, 1.95433736, 1.06763375, 1.4545635, + 1.33624589, 1.16736257, 0.6126079, 1.36892557, 2.40126371, 1.53441942, + 0.52119428, 2.07681108, 0.88494766, 1.51522756, 0.54275119, 0.6629802}; + + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(maxpool_pad_test) @@ -591,7 +593,6 @@ TEST_CASE(maxpool_pad_test) migraphx::program p; auto* mm = p.get_main_module(); std::vector a = {-6, -5, -4, -3, -5, -1, 0, 1, 2, 3, 4, 5}; - std::vector c = {-4, -3, -4, -1, 2, 3, 4, 5}; migraphx::shape a_shape{migraphx::shape::float_type, {1, 2, 3, 2}}; auto al = mm->add_literal(migraphx::literal{a_shape, a}); mm->add_instruction(migraphx::make_op("pooling", @@ -611,8 +612,8 @@ TEST_CASE(maxpool_pad_test) auto result = p.eval({}).back(); std::vector results_vector(8); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - - EXPECT(migraphx::verify::verify_range(results_vector, c)); + std::vector gold = {-4, -3, -4, -1, 2, 3, 4, 5}; + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(maxpool_rank3_test0) @@ -635,7 +636,7 @@ TEST_CASE(maxpool_rank3_test0) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0.3, 0.4, 0.4, 0.8, 0.9, 0.9, 0.7, 0.7, 0.6}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(maxpool_rank3_test1) @@ -660,7 +661,7 @@ TEST_CASE(maxpool_rank3_test1) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0.4975, -0.0405, -0.6186, 0.6022, 0.5493, -0.8039, 1.5001, -1.1603}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(maxpool_rank3_ceil_test) @@ -694,7 +695,7 @@ TEST_CASE(maxpool_rank3_ceil_test) 0.6022, 1.1925, 0.5493, -0.8039, 0.9907, 1.5001, -1.1603, 1.2556}; // clang-format on - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(maxpool_rank5_test) @@ -727,7 +728,7 @@ TEST_CASE(maxpool_rank5_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{1.5064, 1.3655, 0.9035, 2.6859}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(maxpool_dyn_test) @@ -752,5 +753,5 @@ TEST_CASE(maxpool_dyn_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0.3, 0.4, 0.4, 0.8, 0.9, 0.9, 0.7, 0.7, 0.6}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/pow.cpp b/test/ref/pow.cpp index cba3380a823..dde8e519ba4 100644 --- a/test/ref/pow.cpp +++ b/test/ref/pow.cpp @@ -46,7 +46,7 @@ TEST_CASE(pow_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return std::pow(n, n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(pow_dyn_test) @@ -70,5 +70,5 @@ TEST_CASE(pow_dyn_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return std::pow(n, n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/prelu.cpp b/test/ref/prelu.cpp index cfe4ee8b385..a368b615a46 100644 --- a/test/ref/prelu.cpp +++ b/test/ref/prelu.cpp @@ -43,7 +43,7 @@ TEST_CASE(prelu_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {-2.0f, 0.0f, 2.0f}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(prelu_dyn_test) @@ -67,5 +67,5 @@ TEST_CASE(prelu_dyn_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {-2.0f, 0.0f, 2.0f}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/quant_convolution.cpp b/test/ref/quant_convolution.cpp index 6973f35957f..e77574ec928 100644 --- a/test/ref/quant_convolution.cpp +++ b/test/ref/quant_convolution.cpp @@ -47,25 +47,25 @@ TEST_CASE(quant_conv2d_padding_stride_test) p.compile(migraphx::make_target("ref")); auto result = p.eval({}).back(); - std::vector s = {4521, - 7014, - 7830, - 11952, - 10515, - 16734, - 19737, - 30906, - 13161, - 19542, - 19494, - 28800, - 34707, - 52590, - 54729, - 82746}; + std::vector gold = {4521, + 7014, + 7830, + 11952, + 10515, + 16734, + 19737, + 30906, + 13161, + 19542, + 19494, + 28800, + 34707, + 52590, + 54729, + 82746}; std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, s)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(quant_conv2d_padding_test) @@ -83,8 +83,8 @@ TEST_CASE(quant_conv2d_padding_test) mm->add_instruction( migraphx::make_op("quant_convolution", {{"padding", {1, 1}}, {"stride", {1, 1}}}), al, cl); p.compile(migraphx::make_target("ref")); - auto result = p.eval({}).back(); - std::vector s = { + auto result = p.eval({}).back(); + std::vector gold = { 4521, 6753, 7014, 4635, 6858, 10197, 10548, 6939, 7830, 11601, 11952, 7839, 5007, 7383, 7590, 4953, 10515, 15987, 16734, 11277, 16821, 25506, 26586, 17874, 19737, 29826, 30906, 20718, 13593, 20505, 21198, 14187, 13161, 19281, 19542, 12699, 18522, 27045, 27396, @@ -93,7 +93,7 @@ TEST_CASE(quant_conv2d_padding_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, s)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(quant_conv2d_test) @@ -114,24 +114,24 @@ TEST_CASE(quant_conv2d_test) p.compile(migraphx::make_target("ref")); auto result = p.eval({}).back(); - std::vector s = {10197, - 10548, - 11601, - 11952, - 25506, - 26586, - 29826, - 30906, - 27045, - 27396, - 28449, - 28800, - 77346, - 78426, - 81666, - 82746}; + std::vector gold = {10197, + 10548, + 11601, + 11952, + 25506, + 26586, + 29826, + 30906, + 27045, + 27396, + 28449, + 28800, + 77346, + 78426, + 81666, + 82746}; std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, s)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/random_uniform.cpp b/test/ref/random_uniform.cpp index fa7e62df587..ebe40514e76 100644 --- a/test/ref/random_uniform.cpp +++ b/test/ref/random_uniform.cpp @@ -68,7 +68,9 @@ TEST_CASE(random_uniform_test) std::uniform_real_distribution<> dis(0.0, 1.0); std::vector rand_samples(sample_size); std::generate(rand_samples.begin(), rand_samples.end(), [&]() { return dis(gen); }); - EXPECT(migraphx::verify::verify_range(result_vec, rand_samples, 100)); + EXPECT(migraphx::verify::verify_range_with_tolerance(result_vec, + migraphx::verify::expected{rand_samples}, + migraphx::verify::tolerance{0.00001})); } TEST_CASE(random_uniform_int_test) @@ -102,9 +104,9 @@ TEST_CASE(random_uniform_int_test) // Compare result with the STL's mt19937 generator std::mt19937 gen(seed); std::uniform_int_distribution dis; - std::vector rand_samples(sample_size); - std::generate(rand_samples.begin(), rand_samples.end(), [&]() { return dis(gen); }); - EXPECT(migraphx::verify::verify_range(result_vec, rand_samples)); + std::vector gold_rand_samples(sample_size); + std::generate(gold_rand_samples.begin(), gold_rand_samples.end(), [&]() { return dis(gen); }); + EXPECT(migraphx::verify::verify_rms_range(result_vec, gold_rand_samples)); } TEST_CASE(random_uniform_dyn_test) @@ -141,9 +143,9 @@ TEST_CASE(random_uniform_dyn_test) // Compare result with the STL's mt19937 generator std::mt19937 gen(seed); std::uniform_real_distribution<> dis(0.0, 1.0); - std::vector rand_samples(sample_size); - std::generate(rand_samples.begin(), rand_samples.end(), [&]() { return dis(gen); }); - EXPECT(migraphx::verify::verify_range(result_vec, rand_samples)); + std::vector gold_rand_samples(sample_size); + std::generate(gold_rand_samples.begin(), gold_rand_samples.end(), [&]() { return dis(gen); }); + EXPECT(migraphx::verify::verify_rms_range(result_vec, gold_rand_samples)); } TEST_CASE(random_uniform_and_seed_test) diff --git a/test/ref/recip.cpp b/test/ref/recip.cpp index b10ed427fe7..af53a3edf30 100644 --- a/test/ref/recip.cpp +++ b/test/ref/recip.cpp @@ -43,7 +43,7 @@ TEST_CASE(recip_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {-2.0f, 10.0f, 2.0f}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(recip_dyn_test) @@ -64,5 +64,5 @@ TEST_CASE(recip_dyn_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {-2.0f, 10.0f, 2.0f}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/reduce_max.cpp b/test/ref/reduce_max.cpp index 19b4cc9ec62..2fcfcaec729 100644 --- a/test/ref/reduce_max.cpp +++ b/test/ref/reduce_max.cpp @@ -64,7 +64,7 @@ TEST_CASE(reduce_max_dynamic_axis0) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {6, 7, 8, 9, 10}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(reduce_max_axis01) diff --git a/test/ref/relu.cpp b/test/ref/relu.cpp index 9c466134451..c68eed01e2d 100644 --- a/test/ref/relu.cpp +++ b/test/ref/relu.cpp @@ -42,7 +42,7 @@ TEST_CASE(relu_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0.f, 0.f, 1.f}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(relu_dyn_test) @@ -63,5 +63,5 @@ TEST_CASE(relu_dyn_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0.f, 0.f, 1.f}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/reshape.cpp b/test/ref/reshape.cpp index f18a0063f09..b59a6cde5c4 100644 --- a/test/ref/reshape.cpp +++ b/test/ref/reshape.cpp @@ -30,7 +30,7 @@ #include -TEST_CASE(reshape_test0) +TEST_CASE(reshape_lazy_test0) { migraphx::shape a_shape{migraphx::shape::float_type, {24, 1, 1, 1}}; std::vector data(24); @@ -39,15 +39,15 @@ TEST_CASE(reshape_test0) auto* mm = p.get_main_module(); auto l = mm->add_literal(migraphx::literal{a_shape, data}); std::vector new_shape = {8, 3, 1, 1}; - mm->add_instruction(migraphx::make_op("reshape", {{"dims", new_shape}}), l); + mm->add_instruction(migraphx::make_op("reshape_lazy", {{"dims", new_shape}}), l); p.compile(migraphx::make_target("ref")); auto result = p.eval({}).back(); std::vector results_vector{}; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, data)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, data)); } -TEST_CASE(reshape_test1) +TEST_CASE(reshape_lazy_test1) { migraphx::shape a_shape{migraphx::shape::float_type, {24, 1, 1, 1}}; std::vector data(24); @@ -56,15 +56,15 @@ TEST_CASE(reshape_test1) auto* mm = p.get_main_module(); auto l = mm->add_literal(migraphx::literal{a_shape, data}); std::vector new_shape = {1, 3, 4, 2}; - mm->add_instruction(migraphx::make_op("reshape", {{"dims", new_shape}}), l); + mm->add_instruction(migraphx::make_op("reshape_lazy", {{"dims", new_shape}}), l); p.compile(migraphx::make_target("ref")); auto result = p.eval({}).back(); std::vector results_vector{}; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, data)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, data)); } -TEST_CASE(reshape_test2) +TEST_CASE(reshape_lazy_test2) { migraphx::shape a_shape{migraphx::shape::float_type, {24, 1, 1, 1}}; std::vector data(24); @@ -73,22 +73,22 @@ TEST_CASE(reshape_test2) auto* mm = p.get_main_module(); auto l = mm->add_literal(migraphx::literal{a_shape, data}); std::vector new_shape = {1, 2, 3, 4}; - mm->add_instruction(migraphx::make_op("reshape", {{"dims", new_shape}}), l); + mm->add_instruction(migraphx::make_op("reshape_lazy", {{"dims", new_shape}}), l); p.compile(migraphx::make_target("ref")); auto result = p.eval({}).back(); std::vector results_vector{}; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, data)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, data)); } -TEST_CASE(reshape_dyn_test) +TEST_CASE(reshape_lazy_dyn_test) { migraphx::program p; auto* mm = p.get_main_module(); migraphx::shape s{migraphx::shape::float_type, {{1, 4}, {24, 24}, {1, 1}, {1, 1}}}; std::vector new_shape = {0, 8, 3, 1}; auto input = mm->add_parameter("X", s); - mm->add_instruction(migraphx::make_op("reshape", {{"dims", new_shape}}), input); + mm->add_instruction(migraphx::make_op("reshape_lazy", {{"dims", new_shape}}), input); p.compile(migraphx::make_target("ref")); std::vector data(48); @@ -99,5 +99,77 @@ TEST_CASE(reshape_dyn_test) auto result = p.eval(params).back(); std::vector results_vector{}; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, data)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, data)); +} + +TEST_CASE(reshape_test0) +{ + migraphx::shape a_shape{migraphx::shape::float_type, {24, 1, 1, 1}}; + std::vector gold(24); + std::iota(gold.begin(), gold.end(), -3); + migraphx::program p; + auto* mm = p.get_main_module(); + auto l = mm->add_literal(migraphx::literal{a_shape, gold}); + std::vector new_shape = {8, 3, 1, 1}; + mm->add_instruction(migraphx::make_op("reshape", {{"dims", new_shape}}), l); + p.compile(migraphx::make_target("ref")); + auto result = p.eval({}).back(); + std::vector results_vector{}; + result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); +} + +TEST_CASE(reshape_test1) +{ + migraphx::shape a_shape{migraphx::shape::float_type, {24, 1, 1, 1}}; + std::vector gold(24); + std::iota(gold.begin(), gold.end(), -3); + migraphx::program p; + auto* mm = p.get_main_module(); + auto l = mm->add_literal(migraphx::literal{a_shape, gold}); + std::vector new_shape = {1, 3, 4, 2}; + mm->add_instruction(migraphx::make_op("reshape", {{"dims", new_shape}}), l); + p.compile(migraphx::make_target("ref")); + auto result = p.eval({}).back(); + std::vector results_vector{}; + result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); +} + +TEST_CASE(reshape_test2) +{ + migraphx::shape a_shape{migraphx::shape::float_type, {24, 1, 1, 1}}; + std::vector gold(24); + std::iota(gold.begin(), gold.end(), -3); + migraphx::program p; + auto* mm = p.get_main_module(); + auto l = mm->add_literal(migraphx::literal{a_shape, gold}); + std::vector new_shape = {1, 2, 3, 4}; + mm->add_instruction(migraphx::make_op("reshape", {{"dims", new_shape}}), l); + p.compile(migraphx::make_target("ref")); + auto result = p.eval({}).back(); + std::vector results_vector{}; + result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); +} + +TEST_CASE(reshape_dyn_test) +{ + migraphx::program p; + auto* mm = p.get_main_module(); + migraphx::shape s{migraphx::shape::float_type, {{1, 4}, {24, 24}, {1, 1}, {1, 1}}}; + std::vector new_shape = {0, 8, 3, 1}; + auto input = mm->add_parameter("X", s); + mm->add_instruction(migraphx::make_op("reshape", {{"dims", new_shape}}), input); + p.compile(migraphx::make_target("ref")); + + std::vector gold(48); + std::iota(gold.begin(), gold.end(), -3); + migraphx::parameter_map params; + migraphx::shape input_fixed_shape{migraphx::shape::float_type, {2, 24, 1, 1}}; + params["X"] = migraphx::argument(input_fixed_shape, gold.data()); + auto result = p.eval(params).back(); + std::vector results_vector{}; + result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/reverse.cpp b/test/ref/reverse.cpp index 261fbaa9901..278fb4df475 100644 --- a/test/ref/reverse.cpp +++ b/test/ref/reverse.cpp @@ -44,9 +44,9 @@ TEST_CASE(reverse_test_axis0) auto result = p.eval({}).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - std::vector target_data = data; - std::swap_ranges(target_data.begin(), target_data.begin() + 16, target_data.begin() + 16); - EXPECT(migraphx::verify::verify_range(results_vector, target_data)); + std::vector gold = data; + std::swap_ranges(gold.begin(), gold.begin() + 16, gold.begin() + 16); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(reverse_test_axis1) @@ -63,10 +63,10 @@ TEST_CASE(reverse_test_axis1) auto result = p.eval({}).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - std::vector target_data = data; - std::reverse(target_data.begin(), target_data.begin() + 16); - std::reverse(target_data.end() - 16, target_data.end()); - EXPECT(migraphx::verify::verify_range(results_vector, target_data)); + std::vector gold = data; + std::reverse(gold.begin(), gold.begin() + 16); + std::reverse(gold.end() - 16, gold.end()); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(reverse_test_axis10) @@ -83,9 +83,9 @@ TEST_CASE(reverse_test_axis10) auto result = p.eval({}).back(); std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - std::vector target_data = data; - std::reverse(target_data.begin(), target_data.begin() + 16); - std::reverse(target_data.end() - 16, target_data.end()); - std::swap_ranges(target_data.begin(), target_data.begin() + 16, target_data.begin() + 16); - EXPECT(migraphx::verify::verify_range(results_vector, target_data)); + std::vector gold = data; + std::reverse(gold.begin(), gold.begin() + 16); + std::reverse(gold.end() - 16, gold.end()); + std::swap_ranges(gold.begin(), gold.begin() + 16, gold.begin() + 16); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/rnn_ops.cpp b/test/ref/rnn_ops.cpp index f93c0ac4ab3..7677508a240 100644 --- a/test/ref/rnn_ops.cpp +++ b/test/ref/rnn_ops.cpp @@ -145,8 +145,8 @@ TEST_CASE(rnn_forward) -0.16477929, -0.11893477}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); - EXPECT(migraphx::verify::verify_range(lho_data, lho_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(lho_data, lho_data_gold)); } { @@ -206,8 +206,8 @@ TEST_CASE(rnn_forward) 0.44193283, -0.16477929, -0.11893477}; - EXPECT(migraphx::verify::verify_range(last_output_data, last_output_data_gold)); - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(last_output_data, last_output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } { @@ -266,8 +266,8 @@ TEST_CASE(rnn_forward) 0}; std::vector last_output_data_gold{ 0.034457, 0.191679, -0.394683, -0.308897, -0.371446, 0.317082, 0.131042, -0.18736}; - EXPECT(migraphx::verify::verify_range(last_output_data, last_output_data_gold)); - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(last_output_data, last_output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // 3 args @@ -297,7 +297,7 @@ TEST_CASE(rnn_forward) std::vector last_output_data_gold{ 0.2935145, -0.23719997, -0.31123261, -0.18357255, 0., 0., 0., 0.}; - EXPECT(migraphx::verify::verify_range(last_output_data, last_output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(last_output_data, last_output_data_gold)); } // seq_len = 1 @@ -344,7 +344,7 @@ TEST_CASE(rnn_forward) 0.31708236, 0.13104209, -0.18736027}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } } @@ -438,7 +438,7 @@ TEST_CASE(rnn_reverse) 0.46251031, -0.20639211, 0.37488942}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // rnn last output as program output @@ -481,7 +481,7 @@ TEST_CASE(rnn_reverse) 0.44124447, 0.14365635, 0.14803654}; - EXPECT(migraphx::verify::verify_range(last_output_data, last_output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(last_output_data, last_output_data_gold)); } // rnn hidden states and last hidden state output as program outputs @@ -544,8 +544,8 @@ TEST_CASE(rnn_reverse) 0.14365635, 0.14803654}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); - EXPECT(migraphx::verify::verify_range(last_output_data, last_output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(last_output_data, last_output_data_gold)); } // rnn hidden states and last hidden state output as program outputs @@ -606,8 +606,8 @@ TEST_CASE(rnn_reverse) std::vector last_output_data_gold{ -0.293853, 0.167968, 0.51076, 0.402587, -0.0070999, 0.46251, -0.206392, 0.374889}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); - EXPECT(migraphx::verify::verify_range(last_output_data, last_output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(last_output_data, last_output_data_gold)); } } @@ -718,8 +718,8 @@ TEST_CASE(rnn_bidirectional) 0.14365635, 0.14803654}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); - EXPECT(migraphx::verify::verify_range(last_output_data, last_output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(last_output_data, last_output_data_gold)); } // last rnn output for program output @@ -784,8 +784,8 @@ TEST_CASE(rnn_bidirectional) 0.143656, 0.148037}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); - EXPECT(migraphx::verify::verify_range(last_output_data, last_output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(last_output_data, last_output_data_gold)); } // 4 args @@ -835,7 +835,7 @@ TEST_CASE(rnn_bidirectional) 0.14365635, 0.14803654}; - EXPECT(migraphx::verify::verify_range(last_output_data, last_output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(last_output_data, last_output_data_gold)); } // 3 args @@ -870,7 +870,7 @@ TEST_CASE(rnn_bidirectional) 0.2935145, -0.23719997, -0.31123261, -0.18357255, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}; - EXPECT(migraphx::verify::verify_range(last_output_data, last_output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(last_output_data, last_output_data_gold)); } // concatenation of hidden state for program output @@ -923,7 +923,7 @@ TEST_CASE(rnn_bidirectional) -0.20639211, 0.37488942}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } } @@ -1008,7 +1008,10 @@ TEST_CASE(rnn_fp16) std::vector last_output_data_gold{ 0.2935145, -0.23719997, -0.31123261, -0.18357255, 0., 0., 0., 0.}; - EXPECT(migraphx::verify::verify_range(last_output_data, last_output_data_gold, 5e4)); + EXPECT(migraphx::verify::verify_range_with_tolerance( + last_output_data, + migraphx::verify::expected{last_output_data_gold}, + migraphx::verify::tolerance{0.005})); } TEST_CASE(gru_forward) @@ -1106,7 +1109,7 @@ TEST_CASE(gru_forward) 0.48523626, 0.60002893, -0.3969709, 0.43360898, 0.35775262, 0.23280787, -0.52179873, -0.21944991, 0.4535257, -0.13735442, 0.51757574, 0.50380427}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // last output for output @@ -1152,7 +1155,7 @@ TEST_CASE(gru_forward) 0.51757574, 0.50380427}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // two rnn_last_hs_output operators after gru @@ -1199,7 +1202,7 @@ TEST_CASE(gru_forward) 0.51757574, 0.50380427}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // last output for output, linear_before_reset = 0 @@ -1245,7 +1248,7 @@ TEST_CASE(gru_forward) 0.6014447, 0.43445644}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } } @@ -1330,7 +1333,7 @@ TEST_CASE(gru_forward_args) -0.232523, 0.00214573, 0.231693, -0.160475, -0.518952, 0.0467166, 0.12327, -0.374162, 0.137778, 0.251976}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // 4 args (bias is used) @@ -1373,7 +1376,7 @@ TEST_CASE(gru_forward_args) -0.416866, 0.377186, 0.32922, 0.162214, -0.519973, -0.140072, 0.465076, -0.229563, 0.500164, 0.195166}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // 4 args (ih is used) @@ -1417,7 +1420,7 @@ TEST_CASE(gru_forward_args) -0.197, 0.0885705, 0.269396, -0.0414511, -0.515137, -0.03075, 0.158326, -0.296488, 0.177983, 0.519498}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } } @@ -1519,7 +1522,7 @@ TEST_CASE(gru_forward_actv_funcs) 0.51757574, 0.50380427}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // 1 activation function (sigmoid) specified @@ -1560,7 +1563,7 @@ TEST_CASE(gru_forward_actv_funcs) 0.35652235, 0.6033026, 0.52634895, 0.5815402, 0.3001663, 0.39814138, 0.4354002, 0.4310627, 0.6708563, 0.7509278}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // 1 activation function (tanh) specified @@ -1605,7 +1608,7 @@ TEST_CASE(gru_forward_actv_funcs) 0.65615714, 0.53612584}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // seq length of 1 @@ -1655,7 +1658,7 @@ TEST_CASE(gru_forward_actv_funcs) 0.6104771, 0.79759157}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } } @@ -1771,8 +1774,8 @@ TEST_CASE(gru_reverse) 0.55703, 0.54711}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); - EXPECT(migraphx::verify::verify_range(lho_data, lho_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(lho_data, lho_data_gold)); } // variable input sequence length @@ -1832,8 +1835,8 @@ TEST_CASE(gru_reverse) 0.558397, 0.664423}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); - EXPECT(migraphx::verify::verify_range(lho_data, lho_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(lho_data, lho_data_gold)); } // last output for output, linear_before_reset = 0 @@ -1879,7 +1882,7 @@ TEST_CASE(gru_reverse) 0.646604, 0.463943}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // no activation function specified, so default is used. @@ -1918,7 +1921,7 @@ TEST_CASE(gru_reverse) -0.329512, 0.476095, 0.284044, 0.392077, -0.369226, -0.3275, -0.027301, 0.143774, 0.655686, 0.782831}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // seq length of 1 @@ -1968,7 +1971,7 @@ TEST_CASE(gru_reverse) 0.610477, 0.797592}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } } @@ -2099,8 +2102,8 @@ TEST_CASE(gru_bidirectional) 0.0248217, 0.435231, -0.144448, 0.101531, -0.111305, 0.381317, 0.468983, 0.230557, 0.348021, 0.180229}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); - EXPECT(migraphx::verify::verify_range(lho_data, lho_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(lho_data, lho_data_gold)); } // same input sequence length, but shorter than max squence length @@ -2168,8 +2171,8 @@ TEST_CASE(gru_bidirectional) 0.0248217, 0.435231, -0.144448, 0.101531, -0.111305, 0.381317, 0.468983, 0.230557, 0.348021, 0.180229}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); - EXPECT(migraphx::verify::verify_range(lho_data, lho_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(lho_data, lho_data_gold)); } // variable input sequence lengths @@ -2227,8 +2230,8 @@ TEST_CASE(gru_bidirectional) -0.0271321, 0.624762, -0.117084, 0.509115, -0.0175078, 0.182457, 0.304506, 0.313825, 0.397697, 0.300873}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); - EXPECT(migraphx::verify::verify_range(lho_data, lho_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(lho_data, lho_data_gold)); } // last output for output, linear_before_reset = 0 @@ -2268,7 +2271,7 @@ TEST_CASE(gru_bidirectional) -0.10688055, -0.4767866, 0.6317833, 0.00286336, 0.53692746, -0.00617076, 0.04564289, -0.18030001, 0.39584228, 0.53879917, 0.384983, 0.2759448, 0.11611474}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } } @@ -2370,7 +2373,7 @@ TEST_CASE(gru_bidirectional_args) 0.469122, -0.306578, -0.221095, -0.106449, -0.248934, -0.00682121, 0.288407, 0.198708, 0.0695644, 0.211621, 0.00246037}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // 4 args (bias is used) @@ -2421,7 +2424,7 @@ TEST_CASE(gru_bidirectional_args) 0.476508, -0.313413, -0.0361821, -0.173037, -0.235731, -0.163113, 0.349008, 0.248674, -0.0295413, 0.291437, -0.165005}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // 4 args (ih is used) @@ -2469,7 +2472,7 @@ TEST_CASE(gru_bidirectional_args) 0.233106, 0.32996, -0.17175, 0.0190231, -0.154805, -0.205631, -0.405354, 0.519054, -0.380409, -0.0350301, -0.00633752, 0.403791, 0.181883, -0.0977917, -0.0339407, 0.413089, 0.721238, 0.431879}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } } @@ -2583,7 +2586,7 @@ TEST_CASE(gru_bidirectional_actv_funcs) 0.0248217, 0.435231, -0.144448, 0.101531, -0.111305, 0.381317, 0.468983, 0.230557, 0.348021, 0.180229}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // 1 activation function (sigmoid) specified @@ -2626,7 +2629,7 @@ TEST_CASE(gru_bidirectional_actv_funcs) 0.463795, 0.539649, 0.487682, 0.554471, 0.395916, 0.430744, 0.415923, 0.424275, 0.409655, 0.698256, 0.126883, 0.554374, 0.216137, 0.671491, 0.263833, 0.0678646, 0.132732, 0.477083, 0.802206, 0.626802}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // 1 activation function (tanh) specified @@ -2670,7 +2673,7 @@ TEST_CASE(gru_bidirectional_actv_funcs) 0.66716, -0.704461, -0.393346, -0.627123, 0.210395, 0.0563026, 0.31419, 0.759629, 0.000258222, 0.350835, -0.682684}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // 3 activation functions specified @@ -2710,7 +2713,7 @@ TEST_CASE(gru_bidirectional_actv_funcs) 1.15142, 0.457633, 0.300962, 0.361245, 0.666199, 0.330446, 0.301982, -0.443763, -0.0655817, -0.326473, 0.861394, 0.560799, -0.101768, 0.145142, 0.128956}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // 4 activation functions all specified @@ -2758,7 +2761,7 @@ TEST_CASE(gru_bidirectional_actv_funcs) 0.648851, -0.395918, 0.231694, -0.160503, 0.383289, 0.0879262, -0.0254665, 0.079043, 0.322652, 0.752701, 0.243775}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } } @@ -2873,7 +2876,7 @@ TEST_CASE(gru_bidirectional_seq_1) -0.0271321, 0.624762, -0.117084, 0.509115, -0.0175078, -0.144492, -0.0115366, 0.409153, 0.487015, 0.550755}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } TEST_CASE(gru_fp16) @@ -2983,7 +2986,8 @@ TEST_CASE(gru_fp16) -0.3969709, 0.43360898, 0.35775262, 0.23280787, -0.52179873, -0.21944991, 0.4535257, -0.13735442, 0.51757574, 0.50380427}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold, 5e4)); + EXPECT(migraphx::verify::verify_range_with_tolerance( + hs_data, migraphx::verify::expected{hs_data_gold}, migraphx::verify::tolerance{0.005})); } TEST_CASE(lstm_forward) @@ -3114,7 +3118,7 @@ TEST_CASE(lstm_forward) 0.0498799, 0.125772, 0.0533032, -0.131413, 0.0988431, -0.018085, -0.159434, 0.030266, -0.0847427, 0.0874114, 0.304256, -0.0585745, -0.0223018, 0.131113, 0.135643, -0.0566208, 0.142701, 0.0342236, -0.198664, 0.0702607}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // forward, last_output as program output @@ -3167,7 +3171,7 @@ TEST_CASE(lstm_forward) 0.0342236, -0.198664, 0.0702607}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // forward, last_cell_output as program output @@ -3220,7 +3224,7 @@ TEST_CASE(lstm_forward) 0.078598, -0.64457, 0.119811}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } } @@ -3342,7 +3346,7 @@ TEST_CASE(lstm_forward_more) 0.00496085, 0.0662588, -0.048577, -0.187329, 0.0855831, -0.0171894, -0.140202, 0.0828391, -0.165194, -0.0372928, 0.273786, -0.100877, -0.0458544, -0.0401315, 0.0737483, -0.064505, 0.136898, 0.00160891, -0.184812, 0.147774}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // forward, 8 args @@ -3391,7 +3395,7 @@ TEST_CASE(lstm_forward_more) 0.218258, 0.0944405, 0.0431211, -0.132394, 0.103489, 0.0142918, -0.123408, 0.0401075, -0.058052, 0.0795391, 0.266617, -0.0128746, 0.0309878, 0.0971544, 0.149294, -0.0492549, 0.187761, 0.0501726, -0.121584, 0.0606723}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } // forward, last_output as program output, sequence length shorter @@ -3453,7 +3457,7 @@ TEST_CASE(lstm_forward_more) 0.0342236, -0.198664, 0.0702607}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // seq_len = 1 @@ -3511,7 +3515,7 @@ TEST_CASE(lstm_forward_more) -0.121195, -0.4065, -0.252054}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); } } @@ -3641,7 +3645,7 @@ TEST_CASE(lstm_reverse) 0.960938, 0.133565, 0.269741, 0.130438, -0.0252804, 0.267356, 0.146353, 0.0789186, -0.185038, -0.026845, 0.177273, -0.0774616, 0.946669, 0.0868676, 0.044508, -0.373961, -0.0681467, 0.382748, 0.230211, -0.161537}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // reverse, sequence lengths are the same, but less than max_seq_lens @@ -3699,7 +3703,7 @@ TEST_CASE(lstm_reverse) 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // variable sequence lengths @@ -3749,7 +3753,7 @@ TEST_CASE(lstm_reverse) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // reverse, 3 args, last cell output as program output @@ -3791,7 +3795,7 @@ TEST_CASE(lstm_reverse) 0.141613, 0.348002, 0.667298}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // reverse, 3 args, 0 actv function @@ -3830,7 +3834,7 @@ TEST_CASE(lstm_reverse) 0.141613, 0.348002, 0.667298}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } } @@ -3948,7 +3952,7 @@ TEST_CASE(lstm_reverse_actv) 0.310306, 0.262902, 0.276964, 0.295002, 0.373802, 0.366785, 0.419791, 0.393216, 0.262827, 0.371441, 0.369022, 0.298262, 0.334143, 0.309444, 0.174822, 0.251634, 0.244564, 0.214386, 0.185994, 0.226699, 0.28445, 0.376092, 0.338326, 0.259502}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // reverse, 3 args, 2 actv functions @@ -3989,7 +3993,7 @@ TEST_CASE(lstm_reverse_actv) 0.233866, 0.48646, 0.481844}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // reverse, 3 args, seq_len = 1, concatenation of hidden states as program output @@ -4035,7 +4039,7 @@ TEST_CASE(lstm_reverse_actv) 0.070535, 0.327809, 0.407388}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } } @@ -4162,7 +4166,7 @@ TEST_CASE(lstm_bidirectional) 0.0971544, 0.149294, -0.0492549, 0.187761, 0.0501726, -0.121584, 0.0606723, -0.185038, -0.026845, 0.177273, -0.0774616, 0.946669, 0.0868676, 0.044508, -0.373961, -0.0681467, 0.382748, 0.230211, -0.161537}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // last hidden state as program output @@ -4205,7 +4209,7 @@ TEST_CASE(lstm_bidirectional) -0.058052, 0.0795391, 0.266617, -0.0128746, 0.0309878, 0.0971544, 0.149294, -0.0492549, 0.187761, 0.0501726, -0.121584, 0.0606723, -0.120174, 0.043157, 0.117138, -0.222188, 0.789732, 0.128538, 0.20909, 0.0553812, -0.224905, 0.32421, 0.344048, 0.271694}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // last cell output as program output @@ -4248,7 +4252,7 @@ TEST_CASE(lstm_bidirectional) -0.077353, 0.245616, 0.361023, -0.0443759, 0.0685243, 0.20465, 0.277867, -0.112934, 0.67312, 0.120508, -0.726968, 0.113845, -0.889294, 0.182463, 0.186512, -0.402334, 1.48161, 0.524116, 0.347113, 0.181813, -0.434265, 0.747833, 0.416053, 0.558713}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // 3 args, concatenation of hidden states as program output @@ -4291,7 +4295,7 @@ TEST_CASE(lstm_bidirectional) -0.0401315, 0.0737483, -0.064505, 0.136898, 0.00160891, -0.184812, 0.147774, -0.021205, -0.125423, 0.0206439, -0.187097, -0.0051453, -0.0767618, -0.0735348, -0.0826436, 0.214159, 0.262295, 0.0247127, 0.14472}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // sequence length is 1, contenation of hidden state as program output @@ -4328,7 +4332,7 @@ TEST_CASE(lstm_bidirectional) -0.0623361, 0.0598866, 0.101585, 0.0687269, -0.161725, -0.25617, -0.104351, -0.0471426, -0.0905753, 0.01506, 0.059797, 0.104239, -0.0266768, 0.0727547, -0.146298, 0.070535, 0.327809, 0.407388}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } } @@ -4480,9 +4484,9 @@ TEST_CASE(lstm_bidirectional_var_seq_lens) 0.391174, 0.0308845, -0.561745, 0.0730323, -0.326822, 0.301121, 0.219523, 0.415242, 2.08242, 0.442513, 0.187127, 0.0577626, -0.611307, 0.55454, 0.4364, 0.509436}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); - EXPECT(migraphx::verify::verify_range(last_output_data, last_output_data_gold)); - EXPECT(migraphx::verify::verify_range(last_cell_data, last_cell_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(last_output_data, last_output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(last_cell_data, last_cell_data_gold)); } // last cell output as program output @@ -4567,9 +4571,9 @@ TEST_CASE(lstm_bidirectional_var_seq_lens) -0.077353, 0.245616, 0.361023, -0.0443759, 0.0685243, 0.20465, 0.277867, -0.112934, 0.67312, 0.120508, -0.726968, 0.113845, -0.889294, 0.182463, 0.186512, -0.402334, 1.48161, 0.524116, 0.347113, 0.181813, -0.434265, 0.747833, 0.416053, 0.558713}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold)); - EXPECT(migraphx::verify::verify_range(lho_data, lho_data_gold)); - EXPECT(migraphx::verify::verify_range(lco_data, lco_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(lho_data, lho_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(lco_data, lco_data_gold)); } } @@ -4654,7 +4658,7 @@ TEST_CASE(lstm_bidirectional_actv_func) -0.0401315, 0.0737483, -0.064505, 0.136898, 0.00160891, -0.184812, 0.147774, -0.021205, -0.125423, 0.0206439, -0.187097, -0.0051453, -0.0767618, -0.0735348, -0.0826436, 0.214159, 0.262295, 0.0247127, 0.14472}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // 3 args, 1 actv func @@ -4694,7 +4698,7 @@ TEST_CASE(lstm_bidirectional_actv_func) 0.450186, 0.263538, 0.402895, 0.216177, 0.267257, 0.342535, 0.257797, 0.268563, 0.193043, 0.275645, 0.167678, 0.350889, 0.334143, 0.309444, 0.174822, 0.251634, 0.244564, 0.214386, 0.185994, 0.226699, 0.28445, 0.376092, 0.338326, 0.259502}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // 3 args, 2 actv func @@ -4727,7 +4731,7 @@ TEST_CASE(lstm_bidirectional_actv_func) 0.0737483, -0.064505, 0.136898, 0.00160891, -0.184812, 0.147774, -0.162851, -0.102647, -0.113827, -0.142818, 0.0513685, 0.0547876, 0.0201981, -0.00808453, -0.00520328, 0.0945081, 0.264123, 0.410805}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // 3 args, 4 actv func @@ -4763,7 +4767,7 @@ TEST_CASE(lstm_bidirectional_actv_func) 0.0737483, -0.064505, 0.136898, 0.00160891, -0.184812, 0.147774, 0.246078, 0.199709, 0.303753, 0.301178, 0.264634, 0.304661, 0.349371, 0.288934, 0.405483, 0.445586, 0.515814, 0.473186}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // 3 args, 5 actv func @@ -4799,7 +4803,7 @@ TEST_CASE(lstm_bidirectional_actv_func) 0.0737483, -0.064505, 0.136898, 0.00160891, -0.184812, 0.147774, -0.162851, -0.102647, -0.113827, -0.142818, 0.0513685, 0.0547876, 0.0201981, -0.00808453, -0.00520328, 0.0945081, 0.264123, 0.410805}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } // 3 args, 6 actv func @@ -4836,7 +4840,7 @@ TEST_CASE(lstm_bidirectional_actv_func) 0.0737483, -0.064505, 0.136898, 0.00160891, -0.184812, 0.147774, -0.162851, -0.102647, -0.113827, -0.142818, 0.0513685, 0.0547876, 0.0201981, -0.00808453, -0.00520328, 0.0945081, 0.264123, 0.410805}; - EXPECT(migraphx::verify::verify_range(output_data, output_data_gold)); + EXPECT(migraphx::verify::verify_rms_range(output_data, output_data_gold)); } } @@ -4981,5 +4985,5 @@ TEST_CASE(lstm_fp16) 0.0498799, 0.125772, 0.0533032, -0.131413, 0.0988431, -0.018085, -0.159434, 0.030266, -0.0847427, 0.0874114, 0.304256, -0.0585745, -0.0223018, 0.131113, 0.135643, -0.0566208, 0.142701, 0.0342236, -0.198664, 0.0702607}; - EXPECT(migraphx::verify::verify_range(hs_data, hs_data_gold, 5e4)); + EXPECT(migraphx::verify::verify_rms_range(hs_data, hs_data_gold, 5e4)); } diff --git a/test/ref/roialign.cpp b/test/ref/roialign.cpp index 0896f2202ca..11c20f50042 100644 --- a/test/ref/roialign.cpp +++ b/test/ref/roialign.cpp @@ -80,7 +80,7 @@ TEST_CASE(roialign_out_of_bound_test) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0.0f, 0.0f, 0.0f}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } } @@ -150,7 +150,7 @@ TEST_CASE(roialign_test) 0.256580025, 0.214098021, 0.279604018, 0.360000014, 0.436488032, 0.350427985, 0.288755983, 0.366139978, 0.234920025}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } { @@ -171,7 +171,7 @@ TEST_CASE(roialign_test) 0.929997, 0.66257, 0.561664, 0.481275, 0.495449, 0.666306, 0.663573, 0.372107, 0.205603, 0.192776, 0.247849}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } { @@ -192,6 +192,6 @@ TEST_CASE(roialign_test) 0.44757, 0.351855, 0.342265, 0.244475, 0.274841, 0.553644, 0.607176, 0.202392, 0.07425, 0.066087, 0.126279}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } } diff --git a/test/ref/round.cpp b/test/ref/round.cpp index 0d0a32372ce..98562591448 100644 --- a/test/ref/round.cpp +++ b/test/ref/round.cpp @@ -43,7 +43,7 @@ TEST_CASE(round_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {1.0, 2.0, 2.0, -1.0, -2.0, -2.0, 0.0, 2.0, -2.0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(round_dyn_test) @@ -64,5 +64,5 @@ TEST_CASE(round_dyn_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {1.0, 2.0, 2.0, -1.0, -2.0, -2.0, 0.0, 2.0, -2.0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/rsqrt.cpp b/test/ref/rsqrt.cpp index 00fe860abc5..0677f443b45 100644 --- a/test/ref/rsqrt.cpp +++ b/test/ref/rsqrt.cpp @@ -42,7 +42,7 @@ TEST_CASE(rsqrt_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0.5, 0.25, 0.125}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(rsqrt_dyn_test) @@ -63,5 +63,5 @@ TEST_CASE(rsqrt_dyn_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0.5, 0.25, 0.125}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/scalar.cpp b/test/ref/scalar.cpp index eb0f7bec218..7eb77bb0791 100644 --- a/test/ref/scalar.cpp +++ b/test/ref/scalar.cpp @@ -77,5 +77,5 @@ TEST_CASE(imagescaler_test) 0.53, 0.73, 0.93}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/scatter.cpp b/test/ref/scatter.cpp index 44b7504daff..15d04805557 100644 --- a/test/ref/scatter.cpp +++ b/test/ref/scatter.cpp @@ -64,7 +64,7 @@ TEST_CASE(scatter_ax0_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {2.0, 1.1, 0.0, 1.0, 0.0, 2.2, 0.0, 2.1, 1.2}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } } @@ -78,7 +78,7 @@ TEST_CASE(scatter_ax_neg_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {2.0, 1.1, 0.0, 1.0, 0.0, 2.2, 0.0, 2.1, 1.2}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } } @@ -91,7 +91,7 @@ TEST_CASE(scatter_ax1_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {1.1, 1.0, 1.2, 2.0, 2.2, 2.1, 0.0, 0.0, 0.0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } } @@ -128,7 +128,7 @@ TEST_CASE(scatter_reduction1_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold_none = {1.0, 1.1, 3.0, 2.1, 5.0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold_none)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold_none)); } } @@ -142,7 +142,7 @@ TEST_CASE(scatter_reduction2_test) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold_mul = {1.0, 2.2, 3.0, 8.4, 5.0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold_mul)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold_mul)); } } TEST_CASE(scatter_reduction3_test) @@ -155,7 +155,7 @@ TEST_CASE(scatter_reduction3_test) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold_add = {1.0, 3.1, 3.0, 6.1, 5.0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold_add)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold_add)); } } @@ -184,7 +184,7 @@ TEST_CASE(scatter_reduction_3x3_test) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold_a2 = {4.1, 4.0, 4.2, 10.0, 10.2, 10.1, 3.0, 3.0, 3.0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold_a2)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold_a2)); } } @@ -221,7 +221,7 @@ TEST_CASE(scatter_reduction_3x3_xpose1_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold_none2 = {1.1, 7.0, 3.0, 1.0, 7.2, 3.0, 1.2, 7.1, 3.0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold_none2)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold_none2)); } } @@ -236,7 +236,7 @@ TEST_CASE(scatter_reduction_3x3_xpose2_test) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold_a3 = {4.1, 10.0, 3.0, 4.0, 10.2, 3.0, 4.2, 10.1, 3.0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold_a3)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold_a3)); } } @@ -250,6 +250,6 @@ TEST_CASE(scatter_reduction_3x3_xpose3_test) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold_mul2 = {3.3, 21.0, 3.0, 3.0, 21.6, 3.0, 3.6, 21.3, 3.0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold_mul2)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold_mul2)); } } diff --git a/test/ref/scatternd_add.cpp b/test/ref/scatternd_add.cpp index 5f59322a4b5..bbaeccd3d00 100644 --- a/test/ref/scatternd_add.cpp +++ b/test/ref/scatternd_add.cpp @@ -57,7 +57,7 @@ TEST_CASE(scatternd_add_reduction_test) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{1, 3, 3, 5, 6, 6, 7, 9}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(scatternd_reduction_dyn_test) @@ -102,5 +102,5 @@ TEST_CASE(scatternd_reduction_dyn_test) 1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 6, 5, 4, 3, 4, 5, 6, 7, 9, 10, 11, 12, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/scatternd_mul.cpp b/test/ref/scatternd_mul.cpp index df7dfc8db8c..60edd042730 100644 --- a/test/ref/scatternd_mul.cpp +++ b/test/ref/scatternd_mul.cpp @@ -57,5 +57,5 @@ TEST_CASE(scatternd_mul_reduction_test) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{1, 22, 3, 40, 45, 6, 7, 96}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/scatternd_none.cpp b/test/ref/scatternd_none.cpp index a432712930d..ca65202d051 100644 --- a/test/ref/scatternd_none.cpp +++ b/test/ref/scatternd_none.cpp @@ -56,7 +56,7 @@ TEST_CASE(scatternd_shapes_test_1) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{0, 11, 0, 10, 9, 0, 0, 12}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(scatternd_shapes_test_2) @@ -86,7 +86,7 @@ TEST_CASE(scatternd_shapes_test_2) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{5, 6, 2, 4}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(scatternd_shapes_test_3) @@ -117,7 +117,7 @@ TEST_CASE(scatternd_shapes_test_3) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{9, 2, 3, 4, 5, 6, 7, 10}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(scatternd_test_1) @@ -147,7 +147,7 @@ TEST_CASE(scatternd_test_1) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{1, 11, 3, 10, 9, 6, 7, 12}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(scatternd_test_2) @@ -177,7 +177,7 @@ TEST_CASE(scatternd_test_2) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{5, 6, 3, 4}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(scatternd_test_3) @@ -207,7 +207,7 @@ TEST_CASE(scatternd_test_3) result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{9, 2, 3, 4, 5, 6, 7, 10}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(scatternd_test_4) @@ -242,7 +242,7 @@ TEST_CASE(scatternd_test_4) 7, 8, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(scatternd_test_5) @@ -273,5 +273,5 @@ TEST_CASE(scatternd_test_5) std::vector gold(32, 0); std::copy(data_vec.begin(), data_vec.begin() + 16, gold.begin()); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/select_module.cpp b/test/ref/select_module.cpp index ca0de07496e..693f979c1cb 100644 --- a/test/ref/select_module.cpp +++ b/test/ref/select_module.cpp @@ -74,7 +74,7 @@ TEST_CASE(select_module_add_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{2, 14, 5, 10, 5, 14, 14, 2}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(select_module_reduce_test0) @@ -120,7 +120,7 @@ TEST_CASE(select_module_reduce_test0) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{-5, 12, 7, 4}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(select_module_reduce_test1) @@ -166,7 +166,7 @@ TEST_CASE(select_module_reduce_test1) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{-5, 12, 7, 4, -5, 12, 7, 4}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(select_module_not_found_error) diff --git a/test/ref/sigmoid.cpp b/test/ref/sigmoid.cpp index 8b371ee0e02..a0a539ae33f 100644 --- a/test/ref/sigmoid.cpp +++ b/test/ref/sigmoid.cpp @@ -44,7 +44,7 @@ TEST_CASE(sigmoid_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{sigmoid(-1), sigmoid(2), sigmoid(-3), sigmoid(4)}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(sigmoid_dyn_test) @@ -64,5 +64,5 @@ TEST_CASE(sigmoid_dyn_test) std::vector results_vector(4); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{sigmoid(-1), sigmoid(2), sigmoid(-3), sigmoid(4)}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/sign.cpp b/test/ref/sign.cpp index 50b58e06f67..097e2ede642 100644 --- a/test/ref/sign.cpp +++ b/test/ref/sign.cpp @@ -43,7 +43,7 @@ TEST_CASE(sign_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {1.0, 1.0, -1.0, -1.0, 0.0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(sign_dyn_test) @@ -64,5 +64,5 @@ TEST_CASE(sign_dyn_test) std::vector results_vector; result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {1.0, 1.0, -1.0, -1.0, 0.0}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/sin.cpp b/test/ref/sin.cpp index 3d7fc24f94d..5390ac6855e 100644 --- a/test/ref/sin.cpp +++ b/test/ref/sin.cpp @@ -45,7 +45,7 @@ TEST_CASE(sin_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return sinf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(sin_dyn_test) @@ -68,5 +68,5 @@ TEST_CASE(sin_dyn_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return sinf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/sinh.cpp b/test/ref/sinh.cpp index ccfe5de978c..b8f8ab65551 100644 --- a/test/ref/sinh.cpp +++ b/test/ref/sinh.cpp @@ -45,7 +45,7 @@ TEST_CASE(sinh_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return sinhf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(sinh_dynamic_test) @@ -67,5 +67,5 @@ TEST_CASE(sinh_dynamic_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return sinhf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/slice.cpp b/test/ref/slice.cpp index 8c2193a96a3..993ac92a097 100644 --- a/test/ref/slice.cpp +++ b/test/ref/slice.cpp @@ -48,7 +48,7 @@ TEST_CASE(slice_test_1) std::vector gold = {1, 2, 4, 5, 7, 8, 10, 11}; std::vector results_vector(2 * 2 * 2); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); EXPECT(result.get_shape() == sresult); } @@ -72,7 +72,7 @@ TEST_CASE(slice_test_2) std::vector gold = {0, 1, 3, 4, 6, 7, 9, 10}; std::vector results_vector(2 * 2 * 2); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); EXPECT(result.get_shape() == sresult); } @@ -99,7 +99,7 @@ TEST_CASE(slice_var_inputs_static0) std::vector gold = {1, 2, 4, 5, 7, 8, 10, 11}; std::vector results_vector(2 * 2 * 2); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(slice_var_inputs_static1) @@ -125,7 +125,7 @@ TEST_CASE(slice_var_inputs_static1) std::vector gold = {1, 2, 4, 5, 7, 8, 10, 11}; std::vector results_vector(2 * 2 * 2); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(slice_var_inputs_static2) @@ -154,7 +154,7 @@ TEST_CASE(slice_var_inputs_static2) std::vector gold = {0, 1, 3, 4, 6, 7, 9, 10}; std::vector results_vector(2 * 2 * 2); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(slice_var_inputs_dyn) @@ -182,7 +182,7 @@ TEST_CASE(slice_var_inputs_dyn) std::vector gold = {1, 2, 4, 5, 7, 8, 10, 11}; std::vector results_vector(2 * 2 * 2); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(slice_dyn_test0) @@ -213,7 +213,7 @@ TEST_CASE(slice_dyn_test0) std::vector results_vector(2 * 1 * 2); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); EXPECT(result.get_shape() == sresult); } @@ -244,6 +244,6 @@ TEST_CASE(slice_dyn_test1) std::vector gold = {0, 1, 3, 4, 6, 7, 9, 10}; std::vector results_vector(2 * 2 * 2); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); EXPECT(result.get_shape() == sresult); } diff --git a/test/ref/softmax.cpp b/test/ref/softmax.cpp index 01cc1bcdfa5..a5819122c07 100644 --- a/test/ref/softmax.cpp +++ b/test/ref/softmax.cpp @@ -33,9 +33,9 @@ TEST_CASE(softmax_simple_test) { migraphx::program p; - auto* mm = p.get_main_module(); - std::vector a = {0.25, 0.75}; - std::vector s = {0.377541, 0.622459}; + auto* mm = p.get_main_module(); + std::vector a = {0.25, 0.75}; + std::vector gold = {0.377541, 0.622459}; migraphx::shape a_shape{migraphx::shape::float_type, {1, 2}}; auto al = mm->add_literal(migraphx::literal{a_shape, a}); mm->add_instruction(migraphx::make_op("softmax", {{"axis", 1}}), al); @@ -43,7 +43,7 @@ TEST_CASE(softmax_simple_test) auto result = p.eval({}).back(); std::vector results_vector(2); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, s)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(softmax_test) @@ -76,7 +76,7 @@ TEST_CASE(softmax_test) 2.02392387e+00, -9.42091495e-02, -3.77683818e-01, 2.05638766e+00, 2.93796062e-01, -6.02131486e-01, 2.70461679e-01, -8.92358482e-01, 1.04388881e+00, 2.66154885e-01}; - std::vector s = { + std::vector gold = { 0.30191708, 0.59879845, 0.50029165, 0.24915339, 0.36823985, 0.13190967, 0.0349741, 0.18750034, 0.21905553, 0.27000085, 0.0547399, 0.56318235, 0.47422904, 0.78964758, 0.91381913, 0.44601166, 0.47902739, 0.13120073, 0.4449684, 0.18766427, 0.15753111, @@ -103,7 +103,7 @@ TEST_CASE(softmax_test) auto result = p.eval({}).back(); std::vector results_vector(120); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(results_vector, s)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(softmax_dyn_test) @@ -147,7 +147,7 @@ TEST_CASE(softmax_dyn_test) auto result = p.eval(params).back(); std::vector results_vector(120); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - std::vector s = { + std::vector gold = { 0.30191708, 0.59879845, 0.50029165, 0.24915339, 0.36823985, 0.13190967, 0.0349741, 0.18750034, 0.21905553, 0.27000085, 0.0547399, 0.56318235, 0.47422904, 0.78964758, 0.91381913, 0.44601166, 0.47902739, 0.13120073, 0.4449684, 0.18766427, 0.15753111, @@ -166,5 +166,5 @@ TEST_CASE(softmax_dyn_test) 0.13268511, 0.61795473, 0.49703068, 0.41696799, 0.10175809, 0.71028161, 0.29929739, 0.17377149, 0.76075399, 0.20071237, 0.32632929, 0.36892858, 0.09416146, 0.26656723, 0.42914796}; - EXPECT(migraphx::verify::verify_range(results_vector, s)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/sqdiff.cpp b/test/ref/sqdiff.cpp index 68bac4cfa4f..f82c41fbb93 100644 --- a/test/ref/sqdiff.cpp +++ b/test/ref/sqdiff.cpp @@ -43,7 +43,7 @@ TEST_CASE(sqdiff_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {4, 4, 4}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(sqdiff_dyn_test) @@ -67,5 +67,5 @@ TEST_CASE(sqdiff_dyn_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {4, 4, 4}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/sqrt.cpp b/test/ref/sqrt.cpp index 5718ab144ce..1257984c5f5 100644 --- a/test/ref/sqrt.cpp +++ b/test/ref/sqrt.cpp @@ -45,7 +45,7 @@ TEST_CASE(sqrt_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return sqrtf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(sqrt_dynamic_test) @@ -68,5 +68,5 @@ TEST_CASE(sqrt_dynamic_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return sqrtf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/sub.cpp b/test/ref/sub.cpp index 03ed68138c2..7c98ff1db9a 100644 --- a/test/ref/sub.cpp +++ b/test/ref/sub.cpp @@ -43,7 +43,7 @@ TEST_CASE(sub_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {-2, -2, -2}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(sub_dyn_test) @@ -67,5 +67,5 @@ TEST_CASE(sub_dyn_test) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {-2, -2, -2}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/tan.cpp b/test/ref/tan.cpp index d2c18428550..c02c97fcf45 100644 --- a/test/ref/tan.cpp +++ b/test/ref/tan.cpp @@ -45,7 +45,7 @@ TEST_CASE(tan_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return tanf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(tan_dynamic_test) @@ -68,5 +68,5 @@ TEST_CASE(tan_dynamic_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return tanf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/tanh.cpp b/test/ref/tanh.cpp index 9a218ec08fa..427a7b3fab9 100644 --- a/test/ref/tanh.cpp +++ b/test/ref/tanh.cpp @@ -45,7 +45,7 @@ TEST_CASE(tanh_test) std::vector gold = data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return tanhf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(tanh_dynamic_test) @@ -68,5 +68,5 @@ TEST_CASE(tanh_dynamic_test) std::vector gold = input_data; std::transform( gold.begin(), gold.end(), gold.begin(), [](float n) -> float { return tanhf(n); }); - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/transpose.cpp b/test/ref/transpose.cpp index dbabc6fc98b..5111357623b 100644 --- a/test/ref/transpose.cpp +++ b/test/ref/transpose.cpp @@ -59,7 +59,7 @@ TEST_CASE(transpose_test) std::vector results_vector(12); result2.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } } @@ -86,5 +86,5 @@ TEST_CASE(transpose_dyn_test) std::vector results_vector(12); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } diff --git a/test/ref/where.cpp b/test/ref/where.cpp index 33094235343..1f601d9dc7b 100644 --- a/test/ref/where.cpp +++ b/test/ref/where.cpp @@ -54,7 +54,7 @@ TEST_CASE(where_test) for(int i = 0; i < gold.size(); ++i) gold[i] = b[i] ? x[i] : y[i]; - EXPECT(migraphx::verify::verify_range(result_vec, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vec, gold)); } TEST_CASE(where_dyn_test) @@ -85,7 +85,7 @@ TEST_CASE(where_dyn_test) std::vector results_vector(3 * 3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold{1, 1, 1, 2, 2, 2, 1, 2, 1}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } TEST_CASE(where_broadcasted_inputs_test) @@ -113,5 +113,5 @@ TEST_CASE(where_broadcasted_inputs_test) for(int i = 0; i < gold.size(); ++i) gold[i] = b[i] ? x[i] : y[i]; - EXPECT(migraphx::verify::verify_range(result_vec, gold)); + EXPECT(migraphx::verify::verify_rms_range(result_vec, gold)); } diff --git a/test/ref_dev_examples.cpp b/test/ref_dev_examples.cpp index 55bd90e4301..bc5b169c90a 100644 --- a/test/ref_dev_examples.cpp +++ b/test/ref_dev_examples.cpp @@ -140,24 +140,6 @@ TEST_CASE(handling_tensors) -0.06269585, 0.18658121, -0.03944227, 0.0111798, -0.17731084, 0.11789055, -0.09982193, 0.08142821, 0.0729029, 0.11303909, 0.12735154, 0.03885292}; - // Solution vector - std::vector sol = {-0.20817225, - 0.87965256, - 0.14958936, - -1.24887264, - -0.06540672, - 0.20778663, - 0.40456355, - -0.99900877, - 0.4917807, - 0.1994698, - 0.64205718, - 0.37798831, - -0.25315839, - 0.44276932, - -0.16138598, - 0.79344082}; - // Create the arguments in a parameter_map migraphx::parameter_map params; params["X"] = migraphx::argument(input_shape, a.data()); @@ -167,8 +149,25 @@ TEST_CASE(handling_tensors) auto result = p.eval(params).back(); std::vector results_vector(64); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); - - EXPECT(migraphx::verify::verify_range(results_vector, sol)); + // Solution vector + std::vector gold = {-0.20817225, + 0.87965256, + 0.14958936, + -1.24887264, + -0.06540672, + 0.20778663, + 0.40456355, + -0.99900877, + 0.4917807, + 0.1994698, + 0.64205718, + 0.37798831, + -0.25315839, + 0.44276932, + -0.16138598, + 0.79344082}; + + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } int main(int argc, const char* argv[]) { test::run(argc, argv); } diff --git a/test/rewrite_pooling_test.cpp b/test/rewrite_pooling_test.cpp index 802b26e9f98..b7977cd7a5c 100644 --- a/test/rewrite_pooling_test.cpp +++ b/test/rewrite_pooling_test.cpp @@ -50,10 +50,10 @@ TEST_CASE(rewrite_pooling_test) migraphx::module m; auto input = m.add_parameter("x", s); auto ret = m.add_instruction(migraphx::make_op("pooling", - {{"mode", mode}, - {"padding", {0, 0, 0}}, - {"stride", {1, 1, 1}}, - {"lengths", {3, 4, 5}}}), + {{"mode", mode}, + {"padding", {0, 0, 0}}, + {"stride", {1, 1, 1}}, + {"lengths", {3, 4, 5}}}), input); m.add_return({ret}); return m; @@ -138,10 +138,10 @@ TEST_CASE(rewrite_avepooling_na3_test) auto input = m.add_parameter("x", s); auto ret = m.add_instruction(migraphx::make_op("pooling", - {{"mode", migraphx::op::pooling_mode::max}, - {"padding", {0, 0, 0}}, - {"stride", {1, 1, 1}}, - {"lengths", {3, 3, 5}}}), + {{"mode", migraphx::op::pooling_mode::max}, + {"padding", {0, 0, 0}}, + {"stride", {1, 1, 1}}, + {"lengths", {3, 3, 5}}}), input); m.add_return({ret}); return m; @@ -166,10 +166,10 @@ TEST_CASE(literal_rewrite_pooling_test) auto* mm = p.get_main_module(); auto input = mm->add_literal(migraphx::literal(s, data)); auto ret = mm->add_instruction(migraphx::make_op("pooling", - {{"mode", mode}, - {"padding", {0, 0, 0}}, - {"stride", {1, 1, 1}}, - {"lengths", {3, 4, 5}}}), + {{"mode", mode}, + {"padding", {0, 0, 0}}, + {"stride", {1, 1, 1}}, + {"lengths", {3, 4, 5}}}), input); mm->add_return({ret}); return p; @@ -197,7 +197,7 @@ TEST_CASE(literal_rewrite_pooling_test) auto result1 = p1.eval({}).back(); auto result2 = p2.eval({}).back(); visit_all(result1, result2)( - [&](auto r1, auto r2) { EXPECT(migraphx::verify::verify_range(r1, r2)); }); + [&](auto r1, auto r2) { EXPECT(migraphx::verify::verify_rms_range(r1, r2)); }); }; test_rewrite_pooling(migraphx::op::pooling_mode::max, diff --git a/test/run_on_target_test.cpp b/test/run_on_target_test.cpp index eefcabfc097..d8eb677f772 100644 --- a/test/run_on_target_test.cpp +++ b/test/run_on_target_test.cpp @@ -68,7 +68,7 @@ TEST_CASE(eval_run_on_target) std::vector results_vector(3); result.visit([&](auto output) { results_vector.assign(output.begin(), output.end()); }); std::vector gold = {0.5, 0.25, 0.125}; - EXPECT(migraphx::verify::verify_range(results_vector, gold)); + EXPECT(migraphx::verify::verify_rms_range(results_vector, gold)); } int main(int argc, const char* argv[]) { test::run(argc, argv); } diff --git a/test/shape_test.cpp b/test/shape_test.cpp index dc80b6d5b8c..8097b4f55b6 100644 --- a/test/shape_test.cpp +++ b/test/shape_test.cpp @@ -956,13 +956,13 @@ TEST_CASE(test_with_type) TEST_CASE(test_multi_index) { migraphx::shape s{migraphx::shape::float_type, {2, 4, 6}}; - EXPECT(migraphx::verify::verify_range(s.multi(0), std::vector{0, 0, 0})); - EXPECT(migraphx::verify::verify_range(s.multi(4), std::vector{0, 0, 4})); - EXPECT(migraphx::verify::verify_range(s.multi(6), std::vector{0, 1, 0})); - EXPECT(migraphx::verify::verify_range(s.multi(8), std::vector{0, 1, 2})); - EXPECT(migraphx::verify::verify_range(s.multi(24), std::vector{1, 0, 0})); - EXPECT(migraphx::verify::verify_range(s.multi(30), std::vector{1, 1, 0})); - EXPECT(migraphx::verify::verify_range(s.multi(34), std::vector{1, 1, 4})); + EXPECT(migraphx::verify::verify_rms_range(s.multi(0), std::vector{0, 0, 0})); + EXPECT(migraphx::verify::verify_rms_range(s.multi(4), std::vector{0, 0, 4})); + EXPECT(migraphx::verify::verify_rms_range(s.multi(6), std::vector{0, 1, 0})); + EXPECT(migraphx::verify::verify_rms_range(s.multi(8), std::vector{0, 1, 2})); + EXPECT(migraphx::verify::verify_rms_range(s.multi(24), std::vector{1, 0, 0})); + EXPECT(migraphx::verify::verify_rms_range(s.multi(30), std::vector{1, 1, 0})); + EXPECT(migraphx::verify::verify_rms_range(s.multi(34), std::vector{1, 1, 4})); } TEST_CASE(find_permutation_2d_standard) diff --git a/test/simplify_qdq_test.cpp b/test/simplify_qdq_test.cpp index d846c30450c..b9010e495f1 100644 --- a/test/simplify_qdq_test.cpp +++ b/test/simplify_qdq_test.cpp @@ -479,11 +479,11 @@ TEST_CASE(conv_pooling_dot) auto q1 = add_quantize_op(m1, "quantizelinear", input, scale, zero); auto d5 = add_quantize_op(m1, "dequantizelinear", q1, scale, zero); auto c1 = m1.add_instruction(migraphx::make_op("convolution", - {{"padding", {0, 0, 0, 0}}, - {"stride", {1, 1}}, - {"dilation", {1, 1}}, - {"group", 1}, - {"padding_mode", 0}}), + {{"padding", {0, 0, 0, 0}}, + {"stride", {1, 1}}, + {"dilation", {1, 1}}, + {"group", 1}, + {"padding_mode", 0}}), d5, d1); auto bc1 = m1.add_instruction( @@ -526,11 +526,11 @@ TEST_CASE(conv_pooling_dot) auto d3 = add_quantize_op(m2, "dequantizelinear", ab, scale, zero); auto q1 = add_quantize_op(m2, "quantizelinear", input, scale, zero); auto c1 = m2.add_instruction(migraphx::make_op("quant_convolution", - {{"padding", {0, 0, 0, 0}}, - {"stride", {1, 1}}, - {"dilation", {1, 1}}, - {"group", 1}, - {"padding_mode", 0}}), + {{"padding", {0, 0, 0, 0}}, + {"stride", {1, 1}}, + {"dilation", {1, 1}}, + {"group", 1}, + {"padding_mode", 0}}), q1, weights); auto d5 = add_quantize_op(m2, "dequantizelinear", c1, scale1); @@ -585,11 +585,11 @@ TEST_CASE(mobilenet_snippet) auto q1 = add_quantize_op(mm, "quantizelinear", input, scale, zero); auto d5 = add_quantize_op(mm, "dequantizelinear", q1, scale, zero); auto c1 = mm.add_instruction(migraphx::make_op("convolution", - {{"padding", {0, 0, 0, 0}}, - {"stride", {1, 1}}, - {"dilation", {1, 1}}, - {"group", 1}, - {"padding_mode", 0}}), + {{"padding", {0, 0, 0, 0}}, + {"stride", {1, 1}}, + {"dilation", {1, 1}}, + {"group", 1}, + {"padding_mode", 0}}), d5, d1); auto bc1 = mm.add_instruction( @@ -700,7 +700,7 @@ TEST_CASE(conv_correctness) auto result2 = p2.eval({{"input", input}, {"weights", weights}}).back(); std::vector rv2(16); result2.visit([&](auto output) { rv2.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(rv1, rv2)); + EXPECT(migraphx::verify::verify_rms_range(rv1, rv2)); } TEST_CASE(dot_correctness) @@ -750,7 +750,7 @@ TEST_CASE(dot_correctness) auto result2 = p2.eval({{"a", a}, {"b", b}}).back(); std::vector rv2(sh3.elements()); result2.visit([&](auto output) { rv2.assign(output.begin(), output.end()); }); - EXPECT(migraphx::verify::verify_range(rv1, rv2)); + EXPECT(migraphx::verify::verify_rms_range(rv1, rv2)); } int main(int argc, const char* argv[]) { test::run(argc, argv); } diff --git a/test/verify/run_verify.cpp b/test/verify/run_verify.cpp index 01ab753fe6d..66a7f197639 100644 --- a/test/verify/run_verify.cpp +++ b/test/verify/run_verify.cpp @@ -251,7 +251,8 @@ void run_verify::verify(const std::string& name, std::size_t num = gold.size(); for(std::size_t i = 0; ((i < num) and passed); ++i) { - passed &= migraphx::verify_args(tname, gold[i], result[i]); + passed &= migraphx::verify_args_with_tolerance( + tname, result[i], migraphx::verify::expected{gold[i]}); } if(not passed or migraphx::enabled(MIGRAPHX_TRACE_TEST{})) diff --git a/tools/docker/sles.docker b/tools/docker/sles.docker index 1cc4657a13d..cbd082be621 100644 --- a/tools/docker/sles.docker +++ b/tools/docker/sles.docker @@ -3,7 +3,7 @@ FROM registry.suse.com/suse/sle15:15.4 RUN sh -c 'echo -e "\ [rocm]\n\ name=rocm\n\ -baseurl=https://repo.radeon.com/rocm/zyp/5.6/main\n\ +baseurl=https://repo.radeon.com/rocm/zyp/5.7/main\n\ enabled=1\n\ gpgcheck=1\n\ gpgkey=https://repo.radeon.com/rocm/rocm.gpg.key\n\ diff --git a/tools/docker/ubuntu_2204.dockerfile b/tools/docker/ubuntu_2204.dockerfile index 06440bf50e9..423c0cd2780 100644 --- a/tools/docker/ubuntu_2204.dockerfile +++ b/tools/docker/ubuntu_2204.dockerfile @@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y gnupg2 --no-install-recommends curl && curl -fsSL http://repo.radeon.com/rocm/rocm.gpg.key | gpg --dearmor -o /etc/apt/trusted.gpg.d/rocm-keyring.gpg # Add rocm repository -RUN sh -c "echo 'deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/rocm-keyring.gpg] http://repo.radeon.com/rocm/apt/5.5 jammy main' > /etc/apt/sources.list.d/rocm.list" +RUN sh -c "echo 'deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/rocm-keyring.gpg] http://repo.radeon.com/rocm/apt/5.7 jammy main' > /etc/apt/sources.list.d/rocm.list" # From docs.amd.com for installing rocm. Needed to install properly RUN sh -c "echo 'Package: *\nPin: release o=repo.radeon.com\nPin-priority: 600' > /etc/apt/preferences.d/rocm-pin-600" @@ -87,7 +87,7 @@ RUN test -f /usr/local/hash || exit 1 RUN pip3 install yapf==0.28.0 # Install doc requirements -ADD doc/requirements.txt /doc-requirements.txt +ADD docs/.sphinx/requirements.txt /doc-requirements.txt RUN pip3 install -r /doc-requirements.txt # Download real models to run onnx unit tests