Skip to content
Snippets Groups Projects
Commit caee043f authored by Hashim Sharif's avatar Hashim Sharif
Browse files

Adding SampKnobs in sim-mode

parent a52d0a81
No related branches found
No related tags found
No related merge requests found
...@@ -303,6 +303,10 @@ void* tensorConvSampSim(void* input_ptr, void* filter_ptr, ...@@ -303,6 +303,10 @@ void* tensorConvSampSim(void* input_ptr, void* filter_ptr,
hostToDeviceCopy(input); hostToDeviceCopy(input);
hostToDeviceCopy(filter); hostToDeviceCopy(filter);
convertToFP32(input);
convertToFP32(filter);
// Zeroing (+Scaling) Filter elements to 'Simulate' input sampling // Zeroing (+Scaling) Filter elements to 'Simulate' input sampling
sampleFilter(filter, skip_rate, skip_offset); sampleFilter(filter, skip_rate, skip_offset);
...@@ -341,7 +345,7 @@ void* tensorConvSampSim(void* input_ptr, void* filter_ptr, ...@@ -341,7 +345,7 @@ void* tensorConvSampSim(void* input_ptr, void* filter_ptr,
DEBUG("**Output Tensor Dims, n = %d, c = %d, h = %d, w = %d \n", n, c, h, w); DEBUG("**Output Tensor Dims, n = %d, c = %d, h = %d, w = %d \n", n, c, h, w);
Tensor* output; Tensor* output;
output = (Tensor*) create4DTensor((cudnnDataType_t) input->data_type, output = (Tensor*) create4DTensor((cudnnDataType_t) float_type,
CUDNN_TENSOR_NCHW, n, c, h, w); CUDNN_TENSOR_NCHW, n, c, h, w);
...@@ -646,6 +650,15 @@ bool isPerforation(int swing){ ...@@ -646,6 +650,15 @@ bool isPerforation(int swing){
} }
bool isSampling(int swing){
if(swing >= 31 && swing <= 39)
return true;
else
return false;
}
int getSwing(int swing){ int getSwing(int swing){
#ifdef PROMISE_TUNER_ENABLED #ifdef PROMISE_TUNER_ENABLED
...@@ -670,6 +683,9 @@ int getSwing(int swing){ ...@@ -670,6 +683,9 @@ int getSwing(int swing){
class PerfParams{ class PerfParams{
public: public:
...@@ -728,6 +744,52 @@ PerfParams getPerfParams(int swing){ ...@@ -728,6 +744,52 @@ PerfParams getPerfParams(int swing){
class SampParams{
public:
int skip_rate;
int skip_offset;
SampParams(){
skip_rate = 1;
skip_offset = 0;
}
SampParams(int skip_rate1, int skip_offset1){
skip_rate = skip_rate1;
skip_offset = skip_offset1;
}
};
SampParams getSampParams(int swing){
std::map<int, SampParams> samp_knob_map;
SampParams params31(2, 0);
samp_knob_map[31] = params31;
SampParams params32(2, 1);
samp_knob_map[32] = params32;
SampParams params33(4, 0);
samp_knob_map[33] = params33;
SampParams params34(4, 1);
samp_knob_map[34] = params34;
return samp_knob_map[swing];
}
/***** API for Autotuner Use - Not the ApproxHPVM Wrapper API */ /***** API for Autotuner Use - Not the ApproxHPVM Wrapper API */
void* ConvLayer_PROMISE(void* input, float i_min, float i_max, void* ConvLayer_PROMISE(void* input, float i_min, float i_max,
...@@ -774,6 +836,20 @@ void* ConvLayer_PROMISE(void* input, float i_min, float i_max, ...@@ -774,6 +836,20 @@ void* ConvLayer_PROMISE(void* input, float i_min, float i_max,
} }
if(isSampling(swing)){
SampParams params = getSampParams(swing);
DEBUG("params.skip_rate = %d, params.skip_offset = %d \n",
params.skip_rate, params.skip_offset);
conv_out = tensorConvSampSim(input, filter,
conv_pad_h, conv_pad_w,
conv_stride_h, conv_stride_w, 1, 1,
params.skip_rate, params.skip_offset);
}
if (isHalfPrecision(swing)){ if (isHalfPrecision(swing)){
conv_out = tensorHalfConvolution(input, filter, conv_out = tensorHalfConvolution(input, filter,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment