Skip to content

Commit

Permalink
For benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloud User committed May 6, 2020
1 parent 503c605 commit 4298984
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
8 changes: 4 additions & 4 deletions onnxruntime/core/mlas/lib/systolic/systolic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ inline tiled_matmul_type_t get_accelerator_mode(int mode) {

void SystolicMultiplyi8i8_i8(char accelerator_mode, bool relu, int dimI, int dimJ, int dimK,
const elem_t* in1, const elem_t* in2, elem_t* out, int divisor, __attribute__((unused)) float real_multiplier, const int32_t* bias) {
printf("Called into systolic matmul!\n");
//printf("Called into systolic matmul!\n");
bool isPowerOf2 = divisor && !(divisor & (divisor - 1));
if (!isPowerOf2) {
throw std::runtime_error("Divisor passed to systolic matmul must be power of 2");
}
int shift = sizeof(int) * 8 - __builtin_clz(divisor) - 1;

printf("Using accelerated matmul with dimensions (%d, %d, %d)\n", dimI, dimJ, dimK);
//printf("Using accelerated matmul with dimensions (%d, %d, %d)\n", dimI, dimJ, dimK);
tiled_matmul_auto(dimI, dimJ, dimK, in1, in2, bias, out, /*activation= */ relu,
shift, /*relu6_shift= */ 0, /* repeating_bias= */ 0, get_accelerator_mode(accelerator_mode));
}
Expand All @@ -48,14 +48,14 @@ void SystolicMultiplyi8i8_i8(char accelerator_mode, bool relu,
elem_t* out, int strideOut,
int divisor, __attribute__((unused)) float real_multiplier,
const int32_t* bias, int strideBias, bool repeating_bias) {
printf("Called into systolic matmul!\n");
//printf("Called into systolic matmul!\n");
bool isPowerOf2 = divisor && !(divisor & (divisor - 1));
if (!isPowerOf2) {
throw std::runtime_error("Divisor passed to systolic matmul must be power of 2");
}
int shift = sizeof(int) * 8 - __builtin_clz(divisor) - 1;

printf("Using accelerated matmul with dimensions (%d, %d, %d)\n", dimI, dimJ, dimK);
//printf("Using accelerated matmul with dimensions (%d, %d, %d)\n", dimI, dimJ, dimK);
tiled_matmul_auto(dimI, dimJ, dimK,
strideIn1, strideIn2, strideBias, strideOut,
in1, in2, bias, out, /*activation= */ relu,
Expand Down
5 changes: 5 additions & 0 deletions onnxruntime/core/mlas/lib/systolic/systolic_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -719,4 +719,9 @@ void tiled_matmul_auto(size_t dim_I, size_t dim_J, size_t dim_K,
tiled_matmul_auto(dim_I, dim_J, dim_K, dim_K, dim_J, dim_J, dim_J, A, B, D, C, act, shift, relu6_shift, repeating_bias, tiled_matmul_type);
}

__attribute__((constructor))
void cleargemmini() {
gemmini_flush(0);
}

#endif // SRC_MAIN_C_SYSTOLIC_H
4 changes: 2 additions & 2 deletions onnxruntime/core/providers/systolic/nn/qlinearconv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Status QLinearConv<StorageOrder::NHWC>::Compute(OpKernelContext* context) const
auto col_data = alloc->Alloc(SafeInt<size_t>(sizeof(int8_t)) * col_buffer_size);
col_buffer = BufferUniquePtr(col_data, BufferDeleter(alloc));
} else {
printf("1x1 case!\n");
//printf("1x1 case!\n");
}

auto* col_buffer_data = static_cast<int8_t*>(col_buffer.get());
Expand Down Expand Up @@ -405,7 +405,7 @@ Status QLinearConv<StorageOrder::NCHW>::Compute(OpKernelContext* context) const
col_buffer_shape.insert(col_buffer_shape.end(), output_dims.begin(), output_dims.end());
}
} else {
printf("1x1 case!\n");
//printf("1x1 case!\n");
}

auto* col_buffer_data = static_cast<int8_t*>(col_buffer.get());
Expand Down
6 changes: 6 additions & 0 deletions systolic_runner/imagenet_runner/src/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "tensor_helper.h"
#include "cmd_args.h"
#include "labels.h"
#include <sys/mman.h>

const char* imagenet_labels[1000] = IMAGENET_LABELS;

Expand All @@ -28,6 +29,11 @@ unsigned long long read_cycles()
}

int main(int argc, char* argv[]) {
if (mlockall(MCL_CURRENT | MCL_FUTURE) != 0) {
perror("mlockall failed");
exit(1);
}

setbuf(stdout, NULL);
printf("Loaded runner program\n");

Expand Down

0 comments on commit 4298984

Please sign in to comment.