24 #ifndef ARM_COMPUTE_CL 25 #error "This example needs to be built with -DARM_COMPUTE_CL" 37 using namespace utils;
39 class CLSGEMMExample :
public Example 42 void do_setup(
int argc,
char **argv)
override 53 stream.open(argv[1], std::fstream::in);
56 if(argc < 3 || (argc < 4 && stream.bad()))
59 std::cout <<
"Usage: 1) ./build/cl_sgemm input_matrix_1.npy input_matrix_2.npy [input_matrix_3.npy] [alpha = 1] [beta = 0]\n";
60 std::cout <<
" 2) ./build/cl_sgemm M N K [alpha = 1.0f] [beta = 0.0f]\n\n";
61 std::cout <<
"Too few or no input_matrices provided. Using M=7, N=3, K=5, alpha=1.0f and beta=0.0f\n\n";
80 stream.open(argv[3], std::fstream::in);
89 alpha = strtof(argv[4],
nullptr);
94 beta = strtof(argv[5],
nullptr);
100 alpha = strtof(argv[3],
nullptr);
104 beta = strtof(argv[4],
nullptr);
111 size_t M = strtol(argv[1],
nullptr, 10);
112 size_t N = strtol(argv[2],
nullptr, 10);
113 size_t K = strtol(argv[3],
nullptr, 10);
121 alpha = strtof(argv[4],
nullptr);
125 beta = strtof(argv[5],
nullptr);
134 sgemm.configure(&src0, &src1, (src2.info()->total_size() > 0) ? &src2 :
nullptr, &
dst,
alpha,
beta);
137 src0.allocator()->allocate();
138 src1.allocator()->allocate();
147 output_filename =
"sgemm_out.npy";
152 src2.allocator()->allocate();
158 src2.allocator()->allocate();
168 void do_run()
override 176 void do_teardown()
override 178 if(!output_filename.empty())
190 std::string output_filename{};
198 int main(
int argc,
char **argv)
200 return utils::run_example<CLSGEMMExample>(argc, argv);
Basic implementation of the OpenCL tuner interface.
bool is_fortran()
Return true if a NPY file is in fortran order.
void init_tensor(T &tensor, arm_compute::DataType dt)
Initialise the tensor's metadata with the dimensions of the NPY file currently open.
ITensorAllocator * allocator()
Return a pointer to the tensor's allocator.
void fill_tensor(T &tensor)
Fill a tensor with the content of the currently open NPY file.
1 channel, 1 F32 per channel
This file contains all available output stages for GEMMLowp on OpenCL.
void fill_random_tensor(T &tensor, float lower_bound, float upper_bound)
int main(int argc, char **argv)
Main program for sgemm test.
Basic function to execute GEMM on OpenCL.
static CLScheduler & get()
Access the scheduler singleton.
bool is_open()
Return true if a NPY file is currently open.
virtual void allocate()=0
Interface to be implemented by the child class to allocate the tensor.
void save_to_npy(T &tensor, const std::string &npy_filename, bool fortran_order)
Template helper function to save a tensor image to a NPY file.
void sync()
Blocks until all commands in the associated command queue have finished.
Store the tensor's metadata.
void open(const std::string &npy_filename)
Open a NPY file and reads its metadata.
void init_sgemm_output(T &dst, T &src0, T &src1, arm_compute::DataType dt)
void default_init(ICLTuner *cl_tuner=nullptr)
Initialises the context and command queue used by the scheduler to default values and sets a default ...
Basic implementation of the OpenCL tensor interface.