Code Monkey home page Code Monkey logo

Comments (2)

yuxianzhi avatar yuxianzhi commented on August 27, 2024

maybe your model is converted by using INT8_FP16 parameter in post_training_quantization.

INT8_FP16 is only supported on armv8.2 machine.

INT8_FP32 is supported on armv7, armv8, x86_avx512f, x86_avx512_vnni.

please reconvert model by using INT8_FP32, and make sure that your machine supports x86_avx512 or x86_avx512_vnni.

from bolt.

avan-debug avatar avan-debug commented on August 27, 2024

when i use "./post_training_quantization -p ppo_cnn_ptq_input.bolt -i INT8_FP32 -b true -q NOQUANT -c 0 -o false" to build a quantized model, i meet a problem
[ERROR] thread 29537 file /home/xys/bolt-master/compute/tensor/src/cpu/x86/int8/convolution.cpp line 128: got an error: Not Match
here is my code:
#include "bolt.h"
#include "stdlib.h"
#include "stdio.h"
#include "c_common.h"
#include <time.h>

static ModelHandle model;

int main(){
char* model_path = "ppo_cnn_int8_q.bolt";
// ResultHandle result;
AFFINITY_TYPE affinity = CPU_HIGH_PERFORMANCE;
char* algorithm_path=NULL;
model = CreateModel(model_path,affinity,algorithm_path);
int num_inputs = GetNumInputsFromModel(model);
// printf("num_inputs is: %d\n",num_inputs);
if(num_inputs==0)return 0;
char name;
name = (char
) malloc(sizeof(char*));
name = (char)malloc(sizeof(char)128);
int n,c,h,w;
DATA_TYPE dt;
DATA_FORMAT df;
double total_time, inf_time;
GetInputDataInfoFromModel(model,num_inputs,name,&n,&c,&h,&w,&dt,&df);
printf("num_inputs: %d\nname: %s\nn: %d\nc: %d\nh: %d\nw: %d\ndt: %d\ndf: %d\n",num_inputs,name[0],n,c,h,w,dt,df);
// RunModel(model,result,1,)
n = 4;
PrepareModel(model,num_inputs,(const char
*)name,&n,&c,&h,&w,&dt,&df);
// FreeResultHandle(result);
ResultHandle result = AllocAllResultHandle(model);
float **data;
data = malloc(sizeof (float )num_inputs);
for(int i=0;i<=num_inputs;i++){
(data+i) = malloc(sizeof(float)nch
w
2);
for(int j=0;j<=nchw-1;j++){
((data+i)+j) = (float)(j1.2);
}
for(int j=n
chw;j<=nchw2-1;j++){
((data+i)+j) = (float)((j-nch*w)*1.2);
}
}

clock_t start, end;
printf("after prepare model \n");
int times = 128;
for(int k = 0; k < times; k++) {

    for(int i=0; i<=num_inputs; i++){
        *(data+i) = malloc(sizeof(float)*n*c*h*w*2);
        for(int j=0;j<=n*c*h*w*-1;j++){
            *(*(data+i)+j) = (float)(j*1.2);
        }
        for(int j=n*c*h*w;j<=n*c*h*w*2-1;j++){
            *(*(data+i)+j) = (float)((j-n*c*h*w)*1.2);
        }
    }
    start = clock();
    RunModel(model, result, num_inputs, (const char **) name, (void **) data);
    end = clock();
    inf_time = (double)(end - start) / CLOCKS_PER_SEC;
    total_time += ((double)(end - start) / CLOCKS_PER_SEC);
    printf("infer time ================ %f\n", inf_time);

}
printf("after RunModel model \n");

end = clock();

// total_time = (double)(end - start) / CLOCKS_PER_SEC;
printf("infer time avg================ %f\n", total_time / times);

int num_outputs = GetNumOutputsFromResultHandle(result);
float **output = NULL;
float **outputFloat;
void **outputData;

// output = malloc(sizeof (float *)num_inputs);
// for(int i=0;i<=num_inputs;i++){
// (output+i) = malloc(sizeof(float)nch
w);
// }

// GetOutputDataInfoFromResultHandle(model,num_outputs,name,&n,&c,&h,&w,&dt,&df);
printf("num_outputs is: %d\n", num_outputs);
outputData = (void **)malloc(sizeof(void *) * num_outputs);
GetOutputDataFromResultHandle(result, num_outputs, outputData);
outputFloat = (float **)outputData;

float k[5];

/**
for(int j = 0; j < 4; j++){
printf("outputFloat[0][%d] ==== %f\n", j, outputFloat[0][j]);
}

for(int j = 0; j < 8; j++){
    printf("outputFloat[1][%d] ==== %f\n", j, outputFloat[1][j]);
}

k[0] = outputFloat[0][0];
for(int j = 0; j < 4; j++){
    k[j + 1] = outputFloat[1][j];
}

for(int j = 0; j < 5; j++){
    printf("k[%d] ==== %f\n", j, k[j]);
}

**/
// GetOutputDataInfoFromResultHandle(result,num_outputs,name,&n,&c,&h,&w,&dt,&df);
// printf("length: %d\nname: %s",nchw,name[0]);
// GetOutputDataFromResultHandle(result,num_outputs,(void **)output);
// for(int i=0;i<=n
chw-1;i++){
// printf("%f",data[0][i]);
// }
// printf("\n");

return 0;

}

from bolt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.