MCPcopy Create free account
hub / github.com/ddsggcs/cv_learning_resnet50 / LoadData

Function LoadData

practice/cpp/5th_codegen/resnet_codegen.cc:35–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34template <typename T>
35void* LoadData(const std::string& file_name, int len, bool is_float) {
36 T* data = (T*)malloc(len * sizeof(T));
37 FILE* fp = fopen(file_name.c_str(), "r");
38 // std::cout << "file_name = " << file_name << ", fp = " << fp << std::endl;
39 for (auto i = 0; i < len; i++) {
40 float x = 0;
41 fscanf(fp, "%f", &x);
42 data[i] = is_float ? x : (int)x;
43 }
44 fclose(fp);
45 __global_weight[put_cnt++] = data;
46 return (void*)data;
47}
48
49float* LoadCon2dWeightPreLoad(const std::string& name, int len) {
50 auto file_name = "../../model/resnet50_weight/resnet50_" + name + "_weight.txt";

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected