Files
triton/tests/unit/reduce.cc

41 lines
1.1 KiB
C++
Raw Normal View History

2019-09-10 15:54:16 -04:00
#include <iomanip>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <functional>
2019-09-10 15:54:16 -04:00
#include "triton/driver/backend.h"
#include "triton/driver/stream.h"
#include "triton/tools/bench.hpp"
#include "triton/external/half.hpp"
#include "triton/runtime/function.h"
#include "cuda/cublas.h"
#include "reduce.h"
2019-09-10 15:54:16 -04:00
#include "util.h"
int main() {
// initialize default compute device
auto context = triton::driver::backend::contexts::get_default();
triton::driver::stream* stream = triton::driver::stream::create(context);
// shapes to benchmark
typedef std::tuple<std::vector<int>, int, reduce_op_t> config_t;
2019-09-10 15:54:16 -04:00
std::vector<config_t> configs = {
config_t{{32, 32}, 0, MAX},
config_t{{32, 32}, 1, ADD},
config_t{{32, 64}, 0, ADD},
config_t{{64, 32}, 1, ADD}
2019-09-10 15:54:16 -04:00
};
// does the work
int axis;
std::vector<int> shape;
reduce_op_t op;
2019-09-10 15:54:16 -04:00
for(const auto& c: configs){
std::tie(shape, axis, op) = c;
2019-09-10 15:54:16 -04:00
std::cout << "Testing " << c << " ... " << std::flush;
if(do_test(stream, shape, axis, op, 1))
2019-09-10 15:54:16 -04:00
std::cout << " Pass! " << std::endl;
else
std::cout << " Fail! " << std::endl;
}
}