Browse Source

!429 回退 'Pull Request !426 : UT test'

Merge pull request !429 from 王涛/revert-merge-426-master
pull/430/MERGE
i-robot Gitee 4 years ago
parent
commit
69f5d5790b
3 changed files with 7 additions and 3725 deletions
  1. +0
    -64
      tests/ut/parser/parser_ut_utils.cc
  2. +0
    -6
      tests/ut/parser/parser_ut_utils.h
  3. +7
    -3655
      tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc

+ 0
- 64
tests/ut/parser/parser_ut_utils.cc View File

@@ -17,7 +17,6 @@
#include "ut/parser/parser_ut_utils.h"
#include "framework/common/debug/ge_log.h"
#include "graph/utils/graph_utils.h"
#include <limits.h>

namespace ge {
void ParerUTestsUtils::ClearParserInnerCtx() {
@@ -67,68 +66,5 @@ void GraphBuilder::AddDataEdge(const NodePtr &src_node, int src_idx, const NodeP
void GraphBuilder::AddControlEdge(const NodePtr &src_node, const NodePtr &dst_node) {
GraphUtils::AddEdge(src_node->GetOutControlAnchor(), dst_node->GetInControlAnchor());
}

ge::MemBuffer* MemBufferFromFile(const char *path) {
char path_temp[PATH_MAX + 1] = {0x00};
if(strlen(path) > PATH_MAX || nullptr == realpath(path, path_temp)) {
return nullptr;
}
FILE *fp = fopen(path_temp, "r+");
if (fp == nullptr) {
return nullptr;
}

// get model file length
if (0 != fseek(fp, 0, SEEK_END)) {
fclose(fp);
return nullptr;
}
long file_length = ftell(fp);
if (fseek(fp, 0, SEEK_SET)) {
fclose(fp);
return nullptr;
}
if (file_length <= 0) {
fclose(fp);
return nullptr;
}

// alloc model buffer
void *data = malloc((unsigned int)file_length);
if (!data) {
fclose(fp);
return nullptr;
}

// read file into memory
uint32_t read_size = (uint32_t)fread(data, 1, (unsigned int)file_length, fp);

// check if read success
if ((long)read_size != file_length) {
free(data);
data = nullptr;
fclose(fp);
return nullptr;
}

// close model file
fclose(fp);

// create an MemBuffer
MemBuffer* membuf = new MemBuffer();
if (!membuf) {
free(data);
data = nullptr;
return nullptr;
}
membuf->data = malloc((unsigned int)read_size);

// set size && data
membuf->size = (uint32_t)read_size;
memcpy((char*)membuf->data, (char*)data, read_size);
free(data);
return membuf;
}

} // namespace ut
} // namespace ge

+ 0
- 6
tests/ut/parser/parser_ut_utils.h View File

@@ -21,15 +21,9 @@
#include "graph/compute_graph.h"

namespace ge {
struct MemBuffer {
void *data;
uint32_t size;
};

class ParerUTestsUtils {
public:
static void ClearParserInnerCtx();
static MemBuffer* MemBufferFromFile(const char *path);
};
namespace ut {
class GraphBuilder {


+ 7
- 3655
tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc
File diff suppressed because it is too large
View File


Loading…
Cancel
Save