Aayush-Ankit / puma-simulator

[ASPLOS 2019] PUMA-simulator provides a detailed simulation model of a dataflow architecture built with NVM (non-volatile memory), and runs ML models compiled using the puma compiler.
MIT License
58 stars 46 forks source link

Unable to run single-layer conv example on PUMA simulator. #50

Closed sms821 closed 3 years ago

sms821 commented 3 years ago

I modified the example conv-layer.cpp file to add a binding to the kernel weights as follows:

int main(int argc, char** argv) {

 Model model = Model::create("conv_layer");

 // Process parameters
 unsigned int in_size_x = 14;
 unsigned int in_size_y = 14;
 unsigned int in_channels = 32;
 unsigned int out_channels = 64;
 unsigned int k_size_x = 3;
 unsigned int k_size_y = 3;

 // Input stream
 auto in_stream = InputImagePixelStream::create(model, "in_stream", in_size_x, in_size_y, in_channels);

 // Output stream
 unsigned int out_size_x = in_size_x;
 unsigned int out_size_y = in_size_y;
 auto out_stream = OutputImagePixelStream::create(model, "out_stream", out_size_x, out_size_y, out_channels);

 // Layer
 out_stream = conv_layer(model, "", k_size_x, k_size_y, in_size_x, in_size_y, in_channels, out_channels, in_stream);

 // Compile
 model.compile();

 // Bind data
 ModelInstance modelInstance = ModelInstance::create(model);
 float* layer1Weights = new float[k_size_x * k_size_y * in_channels * out_channels];

 //Reading weights from text files
 int i=0;
 std::ifstream wf1;
 wf1.open("conv_layer_weights/wl1.txt");
 while(wf1 >> layer1Weights[i])
 { i++; }
 wf1.close();
 std::cout << "Read " << i << " weights." << std::endl;

 conv_layer_bind(modelInstance, "", layer1Weights);

 //modelInstance.bind("layer" + std::to_string(1) + "mat", layer1Weights);

 modelInstance.generateData();

 // Destroy model
 model.destroy();
 delete[] layer1Weights;

 return 0;
 }

The compilation and code/data generation happen successfully. But when I run it using the architectural simulator, I get instruction memory overflow error as follows:

Screen Shot 2021-09-20 at 12 19 23 PM

My setup is at least partially correct since I was able to run the fully-connected examples. I am on the master branch in puma-compiler and training branch in puma-simulator.

Please help me to get the conv examples working. Thanks a lot!

sms821 commented 3 years ago

Update: I switched to the stride-support branch of puma-compiler and the convolution seems to work now. Closing this issue. Thanks!