From 511d36a8bac01ff54bb929be8699907e2a84d7d4 Mon Sep 17 00:00:00 2001 From: "Zhang, Rong A" Date: Sat, 1 Jun 2024 22:40:24 -0400 Subject: [PATCH] tests: benchdnn: graph: add tests for groupnorm --- tests/benchdnn/graph/flex_rewrite.cpp | 38 +++ tests/benchdnn/graph/ref_primitive.cpp | 1 + tests/benchdnn/graph/setting_handler.cpp | 122 ++++++++ tests/benchdnn/graph/setting_handler.hpp | 3 + tests/benchdnn/graph/utils.cpp | 31 ++ tests/benchdnn/graph/utils.hpp | 1 + .../benchdnn/inputs/graph/op/bf16/gnorm.json | 106 +++++++ tests/benchdnn/inputs/graph/op/f16/gnorm.json | 106 +++++++ tests/benchdnn/inputs/graph/op/f32/gnorm.json | 106 +++++++ .../benchdnn/inputs/graph/op/harness_bf16_all | 1 + .../benchdnn/inputs/graph/op/harness_bf16_ci | 1 + .../benchdnn/inputs/graph/op/harness_f16_all | 1 + tests/benchdnn/inputs/graph/op/harness_f16_ci | 1 + .../benchdnn/inputs/graph/op/harness_f32_all | 1 + tests/benchdnn/inputs/graph/op/harness_f32_ci | 1 + .../int8/int8_bf16_gnorm_add_fusion.json | 284 ++++++++++++++++++ .../int8/int8_bf16_gnorm_relu_fusion.json | 265 ++++++++++++++++ 17 files changed, 1069 insertions(+) create mode 100644 tests/benchdnn/inputs/graph/op/bf16/gnorm.json create mode 100644 tests/benchdnn/inputs/graph/op/f16/gnorm.json create mode 100644 tests/benchdnn/inputs/graph/op/f32/gnorm.json create mode 100644 tests/benchdnn/inputs/graph/pattern/int8/int8_bf16_gnorm_add_fusion.json create mode 100644 tests/benchdnn/inputs/graph/pattern/int8/int8_bf16_gnorm_relu_fusion.json diff --git a/tests/benchdnn/graph/flex_rewrite.cpp b/tests/benchdnn/graph/flex_rewrite.cpp index 4574e3af9ac..8247a19bc23 100644 --- a/tests/benchdnn/graph/flex_rewrite.cpp +++ b/tests/benchdnn/graph/flex_rewrite.cpp @@ -481,6 +481,43 @@ void flex_rewrite::infer_output_shape( merge_ncx(data_format, gi[out0], n, c, x); break; // infer_norm_output_shape + case dnnl::graph::op::kind::GroupNorm: + // infer shape for dst. + in0 = aop.in_lts_[0].id_; + out0 = aop.out_lts_[0].id_; + gi[out0] = gi[in0]; + // attr `keep_stats` is optional, default is `true` + if (aop.attrs_.find("keep_stats") == aop.attrs_.end() + || aop.attrs_["keep_stats"].bool_value_) { + // `true` means it has 3 output: dst, mean and var. + // need to infer shape for mean and var + if (aop.out_lts_.size() == 3) { + int64_t groups = 0; + if (aop.attrs_.find("groups") == aop.attrs_.end()) { + fprintf(stderr, + "graph: groups is required for " + "GroupNorm!\n"); + SAFE_V(FAIL); + } else { + groups = aop.attrs_["groups"].s64_value_; + } + size_t out1 = aop.out_lts_[1].id_; + size_t out2 = aop.out_lts_[2].id_; + gi[out1].clear(); + gi[out2].clear(); + // mean/var shape is N,C + std::vector mv_shape = {gi[in0][0], groups}; + gi[out1] = mv_shape; + gi[out2] = mv_shape; + } else { + fprintf(stderr, + "graph: GroupNorm output number " + "mismatch!\n"); + SAFE_V(FAIL); + } + } + break; + // infer_norm_output_shape case dnnl::graph::op::kind::LayerNorm: in0 = aop.in_lts_[0].id_; out0 = aop.out_lts_[0].id_; @@ -1040,6 +1077,7 @@ void flex_rewrite::update_output_info( case dnnl::graph::op::kind::Exp: case dnnl::graph::op::kind::GELU: case dnnl::graph::op::kind::GELUBackward: + case dnnl::graph::op::kind::GroupNorm: case dnnl::graph::op::kind::HardSigmoid: case dnnl::graph::op::kind::HardSigmoidBackward: case dnnl::graph::op::kind::HardSwish: diff --git a/tests/benchdnn/graph/ref_primitive.cpp b/tests/benchdnn/graph/ref_primitive.cpp index 95529262e31..4ae65d2ce5c 100644 --- a/tests/benchdnn/graph/ref_primitive.cpp +++ b/tests/benchdnn/graph/ref_primitive.cpp @@ -60,6 +60,7 @@ ref_primitive_t::ref_primitive_t(const deserialized_op &op) { CASE_DRIVER(conv); \ CASE_DRIVER(deconv); \ CASE_DRIVER(eltwise); \ + CASE_DRIVER(gnorm); \ CASE_DRIVER(lnorm); \ CASE_DRIVER(matmul); \ CASE_DRIVER(pool); \ diff --git a/tests/benchdnn/graph/setting_handler.cpp b/tests/benchdnn/graph/setting_handler.cpp index b84ff81dd8e..0d8bfa2b1cb 100644 --- a/tests/benchdnn/graph/setting_handler.cpp +++ b/tests/benchdnn/graph/setting_handler.cpp @@ -1010,6 +1010,128 @@ ::eltwise::settings_t get_setting( } // namespace eltwise +namespace gnorm { + +bool get_gnorm_desc(const deserialized_op &base_op_ref, ::gnorm::desc_t &d) { + auto src_dims = base_op_ref.in_lts_[0].shape_; + if (base_op_ref.has_NXC_format()) { + src_dims = base_op_ref.get_NCX_shape(0, true); + } + d.ndims = static_cast(src_dims.size()); + + base_op_ref.get_attr_s64(d.g, "groups"); + d.mb = src_dims[0]; + d.ic = src_dims[1]; + d.id = d.ndims >= 5 ? src_dims[d.ndims - 3] : 1; + d.ih = d.ndims >= 4 ? src_dims[d.ndims - 2] : 1; + d.iw = d.ndims >= 3 ? src_dims[d.ndims - 1] : 1; + + d.eps = 1e-5f; + base_op_ref.get_attr_f32(d.eps, "eps"); + + return true; +} + +bool get_gnorm_dir(const deserialized_op &base_op_ref, dir_t &dir) { + const auto &op_kind = base_op_ref.kind_; + if (op_kind == "GroupNorm") { + bool keep_stats = false; + + base_op_ref.get_attr_bool(keep_stats, "keep_stats"); + + const size_t out_size = base_op_ref.out_lts_.size(); + // output: dst, mean(opt), var(opt) + if (out_size == 1) { + dir = dir_t::FWD_I; + if (keep_stats) return false; + } else if (out_size == 3) { + dir = dir_t::FWD_D; + if (!keep_stats) return false; + } else { + return false; + } + // TODO: GroupNormBackward + } else if (op_kind == "GroupNormBackward") { + assert(!"GroupNormBackward is not supported for now"); + } else { + assert(!"unsupported op_kind"); + return false; + } + return true; +} + +bool get_gnorm_dt( + const deserialized_op &base_op_ref, std::vector &dt) { + auto src_dt = convert_dt(base_op_ref.in_lts_[0].get_data_type()); + auto dst_dt = convert_dt(base_op_ref.out_lts_[0].get_data_type()); + dt = {src_dt, dst_dt}; + return true; +} + +bool get_gnorm_flags( + const deserialized_op &base_op_ref, ::bnorm::flags_t &flags) { + bool use_affine = false; + base_op_ref.get_attr_bool(use_affine, "use_affine"); + const auto &op_kind = base_op_ref.kind_; + const size_t in_size = base_op_ref.in_lts_.size(); + if (op_kind == "GroupNorm") { + // input: src, gamma(opt), beta(opt) + if (use_affine) { + if (in_size == 3) { + flags = ::gnorm::USE_SCALE | ::gnorm::USE_SHIFT; + } else { + return false; + } + } else { + if (in_size == 1) { + flags = ::gnorm::NONE; + } else { + return false; + } + } + // TODO: add GroupNormBackward + } else if (op_kind == "GroupNormBackward") { + assert(!"GroupNormBackward is not supported for now"); + return false; + } else { + assert(!"unsupported op_kind"); + return false; + } + return true; +} + +bool get_gnorm_stag_and_dtag(const deserialized_op &base_op_ref, + std::vector> &tag) { + // src and dst may have different tags. + std::string stag, dtag; + if (!get_driver_tag_by_idx(base_op_ref, dtag, 0, true) + || !get_driver_tag_by_idx(base_op_ref, stag, 0, false)) { + return false; + } + assert(!stag.empty() && !dtag.empty()); + tag = {{std::move(stag), std::move(dtag)}}; + return true; +} + +::gnorm::settings_t get_setting( + const deserialized_op &base_op_ref, res_t *res) { + ::gnorm::settings_t op_setting; + DNN_GRAPH_CHECK_SETTINGS(get_gnorm_desc(base_op_ref, op_setting.desc), res); + DNN_GRAPH_CHECK_SETTINGS( + gnorm::get_gnorm_dir(base_op_ref, op_setting.dir.front()), res); + DNN_GRAPH_CHECK_SETTINGS( + gnorm::get_gnorm_dt(base_op_ref, op_setting.dt.front()), res); + DNN_GRAPH_CHECK_SETTINGS( + gnorm::get_gnorm_stag_and_dtag(base_op_ref, op_setting.tag), res); + DNN_GRAPH_CHECK_SETTINGS( + gnorm::get_gnorm_flags(base_op_ref, op_setting.flags.front()), res); + DNN_GRAPH_CHECK_SETTINGS( + get_graph_attr(base_op_ref, op_setting.fpmath_mode.front()), res); + return op_setting; +} + +} // namespace gnorm + namespace lnorm { bool get_lnorm_dir(const deserialized_op &base_op_ref, dir_t &dir) { diff --git a/tests/benchdnn/graph/setting_handler.hpp b/tests/benchdnn/graph/setting_handler.hpp index 6718b7f70b3..e754bff764f 100644 --- a/tests/benchdnn/graph/setting_handler.hpp +++ b/tests/benchdnn/graph/setting_handler.hpp @@ -26,6 +26,7 @@ #include "custom_driver.hpp" #include "deconv/deconv.hpp" #include "eltwise/eltwise.hpp" +#include "gnorm/gnorm.hpp" #include "lnorm/lnorm.hpp" #include "matmul/matmul.hpp" #include "pool/pool.hpp" @@ -50,6 +51,7 @@ DECLARE_GET_SETTING(conv); DECLARE_GET_SETTING(custom); DECLARE_GET_SETTING(deconv); DECLARE_GET_SETTING(eltwise); +DECLARE_GET_SETTING(gnorm); DECLARE_GET_SETTING(lnorm); DECLARE_GET_SETTING(matmul); DECLARE_GET_SETTING(pool); @@ -90,6 +92,7 @@ DECLARE_TEMPLATE_GET_SETTING(conv); DECLARE_TEMPLATE_GET_SETTING(custom); DECLARE_TEMPLATE_GET_SETTING(deconv); DECLARE_TEMPLATE_GET_SETTING(eltwise); +DECLARE_TEMPLATE_GET_SETTING(gnorm); DECLARE_TEMPLATE_GET_SETTING(lnorm); DECLARE_TEMPLATE_GET_SETTING(matmul); DECLARE_TEMPLATE_GET_SETTING(pool); diff --git a/tests/benchdnn/graph/utils.cpp b/tests/benchdnn/graph/utils.cpp index 2fe3c14f7a7..a9cfaeadced 100644 --- a/tests/benchdnn/graph/utils.cpp +++ b/tests/benchdnn/graph/utils.cpp @@ -370,6 +370,7 @@ dnnl::graph::op::kind opstr2kind(const std::string &kind) { {"Exp", dnnl::graph::op::kind::Exp}, {"GELU", dnnl::graph::op::kind::GELU}, {"GELUBackward", dnnl::graph::op::kind::GELUBackward}, + {"GroupNorm", dnnl::graph::op::kind::GroupNorm}, {"HardSigmoid", dnnl::graph::op::kind::HardSigmoid}, {"HardSigmoidBackward", dnnl::graph::op::kind::HardSigmoidBackward}, {"HardSwish", dnnl::graph::op::kind::HardSwish}, @@ -561,6 +562,7 @@ dnnl_driver_t opkind2driver(const dnnl::graph::op::kind &kind) { {dnnl::graph::op::kind::GELU, dnnl_driver_t::eltwise}, {dnnl::graph::op::kind::GELUBackward, dnnl_driver_t::eltwise}, + {dnnl::graph::op::kind::GroupNorm, dnnl_driver_t::gnorm}, {dnnl::graph::op::kind::HardSigmoid, dnnl_driver_t::eltwise}, {dnnl::graph::op::kind::HardSigmoidBackward, @@ -885,6 +887,21 @@ int get_prim_arg_name_from_graph_op_output_offset( return -1; } } break; + case dnnl::graph::op::kind::GroupNorm: { + if (output_offset == 0) + return DNNL_ARG_DST; + else if (output_offset == 1) + return DNNL_ARG_MEAN; + else if (output_offset == 2) + return DNNL_ARG_VARIANCE; + else { + BENCHDNN_PRINT(0, "Error: no matching ARG for offset %d", + static_cast(output_offset)); + assert(false); + return -1; + } + + } break; default: { return DNNL_ARG_DST; } break; @@ -1230,6 +1247,20 @@ int get_prim_arg_name_from_graph_op_input_offset( return -1; } } break; + case dnnl::graph::op::kind::GroupNorm: { + if (input_offset == 0) + return DNNL_ARG_SRC; + else if (input_offset == 1) + return DNNL_ARG_SCALE; + else if (input_offset == 2) + return DNNL_ARG_SHIFT; + else { + BENCHDNN_PRINT(0, "Error: no matching ARG for offset %zu", + input_offset); + assert(false); + return -1; + } + } break; default: { return DNNL_ARG_SRC; } break; diff --git a/tests/benchdnn/graph/utils.hpp b/tests/benchdnn/graph/utils.hpp index 7e24f3977bb..7aef69a7270 100644 --- a/tests/benchdnn/graph/utils.hpp +++ b/tests/benchdnn/graph/utils.hpp @@ -157,6 +157,7 @@ enum class dnnl_driver_t { reorder, resampling, softmax, + gnorm, others }; diff --git a/tests/benchdnn/inputs/graph/op/bf16/gnorm.json b/tests/benchdnn/inputs/graph/op/bf16/gnorm.json new file mode 100644 index 00000000000..82f45c2a916 --- /dev/null +++ b/tests/benchdnn/inputs/graph/op/bf16/gnorm.json @@ -0,0 +1,106 @@ +{ + "version": "3.6.0", + "engine_kind": "cpu", + "fpmath_mode": "strict", + "input_ports": [ + 0, + 2, + 3 + ], + "output_ports": [ + 6 + ], + "graph": [ + { + "id": 6138621056, + "name": "aten::group_norm", + "kind": "GroupNorm", + "attrs": { + "data_format": { + "type": "string", + "value": "NCX" + }, + "use_affine": { + "type": "bool", + "value": 1 + }, + "keep_stats": { + "type": "bool", + "value": 0 + }, + "epsilon": { + "type": "f32", + "value": 1e-05 + }, + "groups": { + "type": "s64", + "value": 32 + } + }, + "inputs": [ + { + "id": 0, + "dtype": "bf16", + "shape": [ + 2, + 320, + 48, + 48 + ], + "stride": [ + 737280, + 1, + 15360, + 320 + ], + "layout_type": "strided", + "property_type": "variable" + }, + { + "id": 2, + "dtype": "f32", + "shape": [ + 320 + ], + "stride": [ + 1 + ], + "layout_type": "strided", + "property_type": "constant" + }, + { + "id": 3, + "dtype": "f32", + "shape": [ + 320 + ], + "stride": [ + 1 + ], + "layout_type": "strided", + "property_type": "constant" + } + ], + "outputs": [ + { + "id": 6, + "dtype": "bf16", + "shape": [ + 2, + 320, + 48, + 48 + ], + "stride": [ + 737280, + 1, + 15360, + 320 + ], + "layout_type": "strided", + "property_type": "variable" + } + ] + } + ] +} diff --git a/tests/benchdnn/inputs/graph/op/f16/gnorm.json b/tests/benchdnn/inputs/graph/op/f16/gnorm.json new file mode 100644 index 00000000000..821a4725ba3 --- /dev/null +++ b/tests/benchdnn/inputs/graph/op/f16/gnorm.json @@ -0,0 +1,106 @@ +{ + "version": "3.6.0", + "engine_kind": "cpu", + "fpmath_mode": "strict", + "input_ports": [ + 0, + 2, + 3 + ], + "output_ports": [ + 6 + ], + "graph": [ + { + "id": 6138621056, + "name": "aten::group_norm", + "kind": "GroupNorm", + "attrs": { + "data_format": { + "type": "string", + "value": "NCX" + }, + "use_affine": { + "type": "bool", + "value": 1 + }, + "keep_stats": { + "type": "bool", + "value": 0 + }, + "epsilon": { + "type": "f32", + "value": 1e-05 + }, + "groups": { + "type": "s64", + "value": 32 + } + }, + "inputs": [ + { + "id": 0, + "dtype": "f16", + "shape": [ + 2, + 320, + 48, + 48 + ], + "stride": [ + 737280, + 1, + 15360, + 320 + ], + "layout_type": "strided", + "property_type": "variable" + }, + { + "id": 2, + "dtype": "f32", + "shape": [ + 320 + ], + "stride": [ + 1 + ], + "layout_type": "strided", + "property_type": "constant" + }, + { + "id": 3, + "dtype": "f32", + "shape": [ + 320 + ], + "stride": [ + 1 + ], + "layout_type": "strided", + "property_type": "constant" + } + ], + "outputs": [ + { + "id": 6, + "dtype": "f16", + "shape": [ + 2, + 320, + 48, + 48 + ], + "stride": [ + 737280, + 1, + 15360, + 320 + ], + "layout_type": "strided", + "property_type": "variable" + } + ] + } + ] +} diff --git a/tests/benchdnn/inputs/graph/op/f32/gnorm.json b/tests/benchdnn/inputs/graph/op/f32/gnorm.json new file mode 100644 index 00000000000..9a8870b6f80 --- /dev/null +++ b/tests/benchdnn/inputs/graph/op/f32/gnorm.json @@ -0,0 +1,106 @@ +{ + "version": "3.6.0", + "engine_kind": "cpu", + "fpmath_mode": "strict", + "input_ports": [ + 0, + 2, + 3 + ], + "output_ports": [ + 6 + ], + "graph": [ + { + "id": 6138621056, + "name": "aten::group_norm", + "kind": "GroupNorm", + "attrs": { + "data_format": { + "type": "string", + "value": "NCX" + }, + "use_affine": { + "type": "bool", + "value": 1 + }, + "keep_stats": { + "type": "bool", + "value": 0 + }, + "epsilon": { + "type": "f32", + "value": 1e-05 + }, + "groups": { + "type": "s64", + "value": 32 + } + }, + "inputs": [ + { + "id": 0, + "dtype": "f32", + "shape": [ + 2, + 320, + 48, + 48 + ], + "stride": [ + 737280, + 1, + 15360, + 320 + ], + "layout_type": "strided", + "property_type": "variable" + }, + { + "id": 2, + "dtype": "f32", + "shape": [ + 320 + ], + "stride": [ + 1 + ], + "layout_type": "strided", + "property_type": "constant" + }, + { + "id": 3, + "dtype": "f32", + "shape": [ + 320 + ], + "stride": [ + 1 + ], + "layout_type": "strided", + "property_type": "constant" + } + ], + "outputs": [ + { + "id": 6, + "dtype": "f32", + "shape": [ + 2, + 320, + 48, + 48 + ], + "stride": [ + 737280, + 1, + 15360, + 320 + ], + "layout_type": "strided", + "property_type": "variable" + } + ] + } + ] +} diff --git a/tests/benchdnn/inputs/graph/op/harness_bf16_all b/tests/benchdnn/inputs/graph/op/harness_bf16_all index 278f2072a00..6e1ed11b4cc 100644 --- a/tests/benchdnn/inputs/graph/op/harness_bf16_all +++ b/tests/benchdnn/inputs/graph/op/harness_bf16_all @@ -571,6 +571,7 @@ --reset --in-shapes=0:2x17x6x12*acdb+1:2x17x7x14*acdb --op-attrs=0:scales:1.166667x1.166667*mode:nearest --case=op/bf16/interpolate_bwd_2d.json --reset --in-shapes=0:2x17x7x14*acdb+1:2x17x6x12*acdb --op-attrs=0:scales:0.857143x0.857143*mode:nearest --case=op/bf16/interpolate_bwd_2d.json --reset --case=op/bf16/select.json +--reset --case=op/bf16/gnorm.json # only the graph compiler supports these 3 ops --reset --case=op/bf16/pow.json --reset --case=op/bf16/static_reshape.json diff --git a/tests/benchdnn/inputs/graph/op/harness_bf16_ci b/tests/benchdnn/inputs/graph/op/harness_bf16_ci index 1ae63c7bee5..159322a7931 100644 --- a/tests/benchdnn/inputs/graph/op/harness_bf16_ci +++ b/tests/benchdnn/inputs/graph/op/harness_bf16_ci @@ -16,6 +16,7 @@ --reset --case=op/bf16/sigmoid.json --reset --case=op/bf16/sub.json --reset --op-attrs=0:beta:1 --case=op/bf16/hardsigmoid.json +--reset --case=op/bf16/gnorm.json # only the graph compiler supports these 4 ops --reset --case=op/bf16/pow.json --reset --case=op/bf16/select.json diff --git a/tests/benchdnn/inputs/graph/op/harness_f16_all b/tests/benchdnn/inputs/graph/op/harness_f16_all index 0df87a25014..9b2701feb42 100644 --- a/tests/benchdnn/inputs/graph/op/harness_f16_all +++ b/tests/benchdnn/inputs/graph/op/harness_f16_all @@ -141,6 +141,7 @@ --reset --case=op/f16/sqrt.json --reset --case=op/f16/sqrt_bwd.json --reset --case=op/f16/select.json +--reset --case=op/f16/gnorm.json # reorder --reset --in-shapes=0:2x64x3x3 --case=op/f16/reorder.json # large scope diff --git a/tests/benchdnn/inputs/graph/op/harness_f16_ci b/tests/benchdnn/inputs/graph/op/harness_f16_ci index 877e7d3b628..45c45b68a1e 100644 --- a/tests/benchdnn/inputs/graph/op/harness_f16_ci +++ b/tests/benchdnn/inputs/graph/op/harness_f16_ci @@ -3,3 +3,4 @@ --reset --in-shapes=0:1x32x32x128 --op-attrs=0:data_format:NXC --case=op/f16/biasadd.json --reset --case=op/f16/min.json --reset --case=op/f16/reducel2.json +--reset --case=op/f16/gnorm.json diff --git a/tests/benchdnn/inputs/graph/op/harness_f32_all b/tests/benchdnn/inputs/graph/op/harness_f32_all index 1186bbd96f5..8b60e281a3f 100644 --- a/tests/benchdnn/inputs/graph/op/harness_f32_all +++ b/tests/benchdnn/inputs/graph/op/harness_f32_all @@ -947,6 +947,7 @@ --reset --in-shapes=0:2x9x3x8x6*acdeb+1:2x9x2x5x12*acdeb --op-attrs=0:sizes:2x5x12*mode:linear --case=op/f32/interpolate_bwd.json --reset --in-shapes=0:2x9x3x8x7*acdeb+1:2x9x2x5x12*acdeb --op-attrs=0:sizes:2x5x12*mode:linear --case=op/f32/interpolate_bwd.json --reset --case=op/f32/select.json +--reset --case=op/f32/gnorm.json # only the graph compiler supports these 3 ops --reset --case=op/f32/pow.json --reset --case=op/f32/static_reshape.json diff --git a/tests/benchdnn/inputs/graph/op/harness_f32_ci b/tests/benchdnn/inputs/graph/op/harness_f32_ci index d21c6065ddb..8bef369d0e8 100644 --- a/tests/benchdnn/inputs/graph/op/harness_f32_ci +++ b/tests/benchdnn/inputs/graph/op/harness_f32_ci @@ -52,6 +52,7 @@ --reset --case=op/f32/tanh_bwd.json --reset --case=op/f32/typecast.json --reset --op-attrs=0:alpha:2*beta:1 --case=op/f32/hardsigmoid_bwd.json +--reset --case=op/f32/gnorm.json # only the graph compiler supports these 4 ops --reset --case=op/f32/pow.json --reset --case=op/f32/select.json diff --git a/tests/benchdnn/inputs/graph/pattern/int8/int8_bf16_gnorm_add_fusion.json b/tests/benchdnn/inputs/graph/pattern/int8/int8_bf16_gnorm_add_fusion.json new file mode 100644 index 00000000000..64df82a9ad3 --- /dev/null +++ b/tests/benchdnn/inputs/graph/pattern/int8/int8_bf16_gnorm_add_fusion.json @@ -0,0 +1,284 @@ +{ + "version": "3.6.0", + "engine_kind": "cpu", + "fpmath_mode": "strict", + "input_ports": [ + 0, + 2, + 3, + 5 + ], + "output_ports": [ + 16 + ], + "graph": [ + { + "id": 6138621056, + "name": "aten::group_norm", + "kind": "GroupNorm", + "attrs": { + "data_format": { + "type": "string", + "value": "NCX" + }, + "use_affine": { + "type": "bool", + "value": 1 + }, + "keep_stats": { + "type": "bool", + "value": 0 + }, + "epsilon": { + "type": "f32", + "value": 1e-05 + }, + "groups": { + "type": "s64", + "value": 32 + } + }, + "inputs": [ + { + "id": 0, + "dtype": "bf16", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + }, + { + "id": 2, + "dtype": "f32", + "shape": [ + 32 + ], + "stride": [ + 1 + ], + "layout_type": "strided", + "property_type": "constant" + }, + { + "id": 3, + "dtype": "f32", + "shape": [ + 32 + ], + "stride": [ + 1 + ], + "layout_type": "strided", + "property_type": "constant" + } + ], + "outputs": [ + { + "id": 6, + "dtype": "bf16", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + } + ] + }, + { + "id": 4109446592, + "name": "aten::add", + "kind": "Add", + "attrs": {}, + "inputs": [ + { + "id": 5, + "dtype": "bf16", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + }, + { + "id": 6, + "dtype": "bf16", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + } + ], + "outputs": [ + { + "id": 7, + "dtype": "bf16", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + } + ] + }, + { + "id": 4109395328, + "name": "aten::to", + "kind": "TypeCast", + "attrs": {}, + "inputs": [ + { + "id": 7, + "dtype": "bf16", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + } + ], + "outputs": [ + { + "id": 12, + "dtype": "f32", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + } + ] + }, + { + "id": 6143429856, + "name": "aten::quantize_per_tensor", + "kind": "Quantize", + "attrs": { + "axis": { + "type": "s64", + "value": 1 + }, + "qtype": { + "type": "string", + "value": "per_tensor" + }, + "zps": { + "type": "s64[]", + "value": [ + 19 + ] + }, + "scales": { + "type": "f32[]", + "value": [ + 0.25 + ] + } + }, + "inputs": [ + { + "id": 12, + "dtype": "f32", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + } + ], + "outputs": [ + { + "id": 16, + "dtype": "u8", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + } + ] + } + ] +} diff --git a/tests/benchdnn/inputs/graph/pattern/int8/int8_bf16_gnorm_relu_fusion.json b/tests/benchdnn/inputs/graph/pattern/int8/int8_bf16_gnorm_relu_fusion.json new file mode 100644 index 00000000000..2ddd542a6fa --- /dev/null +++ b/tests/benchdnn/inputs/graph/pattern/int8/int8_bf16_gnorm_relu_fusion.json @@ -0,0 +1,265 @@ +{ + "version": "3.6.0", + "engine_kind": "cpu", + "fpmath_mode": "strict", + "input_ports": [ + 0, + 2, + 3 + ], + "output_ports": [ + 16 + ], + "graph": [ + { + "id": 6138621056, + "name": "aten::group_norm", + "kind": "GroupNorm", + "attrs": { + "data_format": { + "type": "string", + "value": "NCX" + }, + "use_affine": { + "type": "bool", + "value": 1 + }, + "keep_stats": { + "type": "bool", + "value": 0 + }, + "epsilon": { + "type": "f32", + "value": 1e-05 + }, + "groups": { + "type": "s64", + "value": 32 + } + }, + "inputs": [ + { + "id": 0, + "dtype": "bf16", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 1, + 1536, + 32 + ], + "layout_type": "strided", + "property_type": "variable" + }, + { + "id": 2, + "dtype": "f32", + "shape": [ + 32 + ], + "stride": [ + 1 + ], + "layout_type": "strided", + "property_type": "constant" + }, + { + "id": 3, + "dtype": "f32", + "shape": [ + 32 + ], + "stride": [ + 1 + ], + "layout_type": "strided", + "property_type": "constant" + } + ], + "outputs": [ + { + "id": 6, + "dtype": "bf16", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + } + ] + }, + { + "id": 4109446592, + "name": "aten::relu", + "kind": "ReLU", + "attrs": {}, + "inputs": [ + { + "id": 6, + "dtype": "bf16", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + } + ], + "outputs": [ + { + "id": 7, + "dtype": "bf16", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + } + ] + }, + { + "id": 4109395328, + "name": "aten::to", + "kind": "TypeCast", + "attrs": {}, + "inputs": [ + { + "id": 7, + "dtype": "bf16", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + } + ], + "outputs": [ + { + "id": 12, + "dtype": "f32", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + } + ] + }, + { + "id": 6143429856, + "name": "aten::quantize_per_tensor", + "kind": "Quantize", + "attrs": { + "axis": { + "type": "s64", + "value": 1 + }, + "qtype": { + "type": "string", + "value": "per_tensor" + }, + "zps": { + "type": "s64[]", + "value": [ + 19 + ] + }, + "scales": { + "type": "f32[]", + "value": [ + 0.25 + ] + } + }, + "inputs": [ + { + "id": 12, + "dtype": "f32", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 2304, + 48, + 1 + ], + "layout_type": "strided", + "property_type": "variable" + } + ], + "outputs": [ + { + "id": 16, + "dtype": "u8", + "shape": [ + 2, + 32, + 48, + 48 + ], + "stride": [ + 73728, + 1, + 1536, + 32 + ], + "layout_type": "strided", + "property_type": "variable" + } + ] + } + ] +}