| 43 | |
| 44 | template <typename Func, typename DType, typename Param> |
| 45 | void run_test( |
| 46 | Func func, std::initializer_list<size_t>&& host_x_shape, |
| 47 | std::initializer_list<size_t>&& host_y_shape, |
| 48 | std::initializer_list<size_t>&& host_z_shape, uint64_t computation, |
| 49 | uint64_t nr_elems, DType dtype, const Param& param, |
| 50 | CompNode cn = CompNode::load("xpux")) { |
| 51 | HostTensorGenerator<DType> gen; |
| 52 | auto host_x = gen(host_x_shape, cn); |
| 53 | auto host_y = gen(host_y_shape, cn); |
| 54 | auto host_z = gen(host_z_shape, cn); |
| 55 | |
| 56 | auto graph = ComputingGraph::make(); |
| 57 | SymbolVar x = opr::SharedDeviceTensor::make(*graph, *host_x.get()).rename("x"), |
| 58 | y = opr::SharedDeviceTensor::make(*graph, *host_y.get()).rename("y"), |
| 59 | z = opr::SharedDeviceTensor::make(*graph, *host_z.get()).rename("z"), |
| 60 | f = func(x, y, z, param); |
| 61 | |
| 62 | HostTensorND host_f; |
| 63 | compile_and_run(graph, f, host_f, computation, dtype.size(nr_elems)); |
| 64 | } |
| 65 | |
| 66 | template <class Param, typename Func> |
| 67 | void test_conv_group( |