Skip to content

Commit 57a88d0

Browse files
wzt1997TaoLv
authored andcommitted
tests: benchdnn: graph: remove useles utility functions
1 parent 6f14365 commit 57a88d0

File tree

2 files changed

+6
-93
lines changed

2 files changed

+6
-93
lines changed

tests/benchdnn/graph/utils.cpp

-84
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,7 @@
1818
#include <set>
1919
#include <vector>
2020

21-
#include "oneapi/dnnl/dnnl_graph.h"
22-
2321
#include "cpu/platform.hpp"
24-
#ifdef DNNL_WITH_SYCL
25-
#include "dnnl_sycl.hpp"
26-
#endif
27-
28-
#if DNNL_GPU_RUNTIME == DNNL_RUNTIME_OCL
29-
#include "oneapi/dnnl/dnnl_graph_ocl.hpp"
30-
#endif
31-
3222
#include "utils.hpp"
3323
#include "utils/timer.hpp"
3424

@@ -343,17 +333,6 @@ sycl::queue &get_queue() {
343333
}
344334
#endif // DNNL_WITH_SYCL
345335

346-
bool is_sycl_engine() {
347-
#if DNNL_CPU_RUNTIME == DNNL_RUNTIME_SYCL
348-
if (is_cpu()) return true;
349-
#endif
350-
351-
#if DNNL_GPU_RUNTIME == DNNL_RUNTIME_SYCL
352-
if (!is_cpu()) return true;
353-
#endif
354-
return false;
355-
}
356-
357336
dnnl::graph::op::kind opstr2kind(const std::string &kind) {
358337
const std::unordered_map<std::string, dnnl::graph::op::kind> op_map = {
359338
{"Abs", dnnl::graph::op::kind::Abs},
@@ -672,46 +651,6 @@ dnnl_driver_t opkind2driver(const dnnl::graph::op::kind &kind) {
672651
return dnnl_driver_t::others;
673652
}
674653

675-
bool is_nxc_lt_arg(const std::string &kind, const int exec_arg) {
676-
// Mapping from the op kind to a set that indicates which input arg needs
677-
// reorder
678-
static const std::unordered_map<std::string, std::unordered_set<int>>
679-
input_arg_for_reorder = {
680-
{"AvgPool", {DNNL_ARG_SRC}},
681-
{"AvgPoolBackward", {DNNL_ARG_DIFF_DST}},
682-
{"BatchNormInference", {DNNL_ARG_SRC}},
683-
{"BatchNormForwardTraining", {DNNL_ARG_SRC}},
684-
{"BiasAddBackward", {DNNL_ARG_SRC}},
685-
{"Interpolate", {DNNL_ARG_SRC}},
686-
{"MaxPool", {DNNL_ARG_SRC}},
687-
{"Convolution", {DNNL_ARG_SRC}},
688-
{"ConvolutionBackwardData", {DNNL_ARG_DIFF_DST}},
689-
{"ConvTranspose", {DNNL_ARG_SRC}},
690-
{"ConvTransposeBackwardData", {DNNL_ARG_DIFF_DST}},
691-
{"BatchNormTrainingBackward",
692-
{DNNL_ARG_SRC, DNNL_ARG_DIFF_DST}},
693-
{"BiasAdd", {DNNL_ARG_SRC_0, DNNL_ARG_SRC_1}},
694-
{"InterpolateBackward", {DNNL_ARG_DIFF_DST}},
695-
{"MaxPoolBackward", {DNNL_ARG_SRC, DNNL_ARG_DIFF_DST}},
696-
{"ConvolutionBackwardWeights",
697-
{DNNL_ARG_SRC, DNNL_ARG_DIFF_DST}},
698-
{"ConvTransposeBackwardWeights",
699-
{DNNL_ARG_SRC, DNNL_ARG_DIFF_DST}},
700-
{"PReLU", {DNNL_ARG_SRC, DNNL_ARG_WEIGHTS}},
701-
{"PReLUBackward",
702-
{DNNL_ARG_SRC, DNNL_ARG_WEIGHTS,
703-
DNNL_ARG_DIFF_DST}},
704-
};
705-
706-
const auto iter = input_arg_for_reorder.find(kind);
707-
if (iter != input_arg_for_reorder.end()) {
708-
const auto &args_to_reorder = iter->second;
709-
return args_to_reorder.find(exec_arg) != args_to_reorder.end();
710-
} else {
711-
return false;
712-
}
713-
}
714-
715654
// when length is 3, return "abc", when length is 5, return "abcde"
716655
std::string get_default_tag(size_t length) {
717656
std::string mtag;
@@ -846,29 +785,6 @@ void permute_md(dnn_mem_t &mem, std::vector<int64_t> permutation) {
846785
assert(st == dnnl_success);
847786
mem.md_ = clone_md(permuted_md.get());
848787
}
849-
void reshape_md(dnn_mem_t &mem, const dnnl::memory::dims &reshaped_dims,
850-
const dnnl::memory::dims &reshaped_strides) {
851-
852-
const auto data_type = static_cast<dnnl::memory::data_type>(mem.dt());
853-
dnnl::memory::desc md(reshaped_dims, data_type, reshaped_strides);
854-
// Dirty hack to replace md with another one.
855-
// TODO: replace it with a better solution.
856-
auto st = dnnl_memory_desc_destroy(mem.md_);
857-
(void)st;
858-
assert(st == dnnl_success);
859-
mem.md_ = clone_md(md.get());
860-
}
861-
862-
void reshape_md(dnn_mem_t &mem, const dnnl::memory::dims &reshaped_dims) {
863-
dnnl::memory::desc md(clone_md(mem.md_));
864-
dnnl::memory::desc reshaped_md = md.reshape(reshaped_dims);
865-
// Dirty hack to replace md with another one.
866-
// TODO: replace it with a better solution.
867-
auto st = dnnl_memory_desc_destroy(mem.md_);
868-
(void)st;
869-
assert(st == dnnl_success);
870-
mem.md_ = clone_md(reshaped_md.get());
871-
}
872788

873789
int get_prim_arg_name_from_graph_op_output_offset(
874790
dnnl::graph::op::kind op_kind, size_t output_offset) {

tests/benchdnn/graph/utils.hpp

+6-9
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@
3636
#endif
3737

3838
#ifdef DNNL_WITH_SYCL
39+
#include "dnnl_sycl.hpp"
3940
#include "oneapi/dnnl/dnnl_graph_sycl.hpp"
4041
#endif
4142

43+
#if DNNL_GPU_RUNTIME == DNNL_RUNTIME_OCL
44+
#include "oneapi/dnnl/dnnl_graph_ocl.hpp"
45+
#endif
46+
4247
#include "common.hpp"
4348
#include "dnnl_common.hpp"
4449

@@ -99,7 +104,7 @@ struct scratchpad_mm_mgr {
99104
std::unordered_multimap<size_t, std::shared_ptr<void>> map_size_ptr_;
100105
std::unordered_set<void *> free_ptr_;
101106
};
102-
bool is_sycl_engine();
107+
103108
sycl::queue &get_queue();
104109
#endif // DNNL_WITH_SYCL
105110

@@ -160,14 +165,6 @@ dnnl_driver_t opkind2driver(const dnnl::graph::op::kind &kind);
160165
// permute md based on permutation
161166
void permute_md(dnn_mem_t &mem, std::vector<int64_t> permutation);
162167

163-
void reshape_md(dnn_mem_t &mem, const dnnl::memory::dims &reshaped_dims);
164-
165-
void reshape_md(dnn_mem_t &mem, const dnnl::memory::dims &reshaped_dims,
166-
const dnnl::memory::dims &reshaped_strides);
167-
168-
// check whether the logical tensor is in NXC format
169-
bool is_nxc_lt_arg(const std::string &kind, const int exec_arg);
170-
171168
// get primitive's arg name according to graph op's output offset
172169
// i.e. If BatchNormForwardTraining's 2-nd output is ReLU's 1-st input
173170
// the output offset of 2 needs to be mapped to primitive's

0 commit comments

Comments
 (0)