提交 f291ce31 编写于 作者: L liuqi

Add version api.

上级 9fc3e2e1
......@@ -15,6 +15,7 @@ cc_library(
deps = [
"//mace/core",
"//mace/ops",
'//mace/codegen:version_lib',
] + if_embed_binary_program([
'//mace/codegen:generated_opencl_lib',
'//mace/codegen:generated_tuning_lib',
......@@ -34,3 +35,13 @@ cc_library(
copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1"],
linkstatic = 1,
)
cc_library(
name = "version_lib",
srcs = glob(["version/*.cc"]),
copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1"],
linkstatic = 1,
deps = [
"//mace/core",
]
)
......@@ -35,7 +35,7 @@ cc_library(
cc_library(
name = "core",
srcs = glob(["*.cc"]),
hdrs = glob(["*.h"]),
hdrs = glob(["*.h", "public/*.h"]),
copts = ["-std=c++11", "-D_GLIBCXX_USE_C99_MATH_TR1"],
linkopts = if_android(["-pie"]),
deps = [
......
......@@ -9,7 +9,7 @@
#include <malloc.h>
#include "mace/core/common.h"
#include "mace/core/registry.h"
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
#include "mace/core/types.h"
namespace mace {
......
......@@ -8,7 +8,7 @@
#include <map>
#include "mace/core/common.h"
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
namespace mace {
......
......@@ -2,7 +2,7 @@
// Copyright (c) 2017 XiaoMi All rights reserved.
//
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
#include "mace/core/types.h"
#include "mace/core/net.h"
#include "mace/core/workspace.h"
......@@ -495,8 +495,7 @@ MaceEngine::MaceEngine(const NetDef *net_def, DeviceType device_type):
ws_->CreateTensor("mace_input_node:0", GetDeviceAllocator(device_type_), DT_FLOAT);
net_ = std::move(CreateNet(*net_def, ws_.get(), device_type));
}
MaceEngine::~MaceEngine() {
}
MaceEngine::~MaceEngine(){}
const float *MaceEngine::Run(const float *input,
const std::vector<index_t> &input_shape,
std::vector<int64_t> &output_shape) {
......
......@@ -6,7 +6,7 @@
#define MACE_CORE_NET_H_
#include "mace/core/common.h"
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
namespace mace {
......
......@@ -11,7 +11,7 @@
#include "mace/core/registry.h"
#include "mace/core/tensor.h"
#include "mace/core/workspace.h"
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
namespace mace {
......
//
// Copyright (c) 2017 XiaoMi All rights reserved.
//
#ifndef MACE_CORE_PUBLIC_VERSION_H_
#define MACE_CORE_PUBLIC_VERSION_H_
#define MACE_MAJOR_VERSION 0
#define MACE_MINOR_VERSION 1
#define MACE_PATCH_VERSION 0
// MACE_VERSION_SUFFIX is non-empty for pre-releases (e.g. "-alpha", "-alpha.1",
// "-beta", "-rc", "-rc.1")
#define MACE_VERSION_SUFFIX ""
#define MACE_STR_HELPER(x) #x
#define MACE_STR(x) MACE_STR_HELPER(x)
// e.g. "0.5.0" or "0.6.0-alpha".
#define MACE_VERSION_STRING \
(MACE_STR(MACE_MAJOR_VERSION) "." MACE_STR(MACE_MINOR_VERSION) "." MACE_STR( \
MACE_PATCH_VERSION) MACE_VERSION_SUFFIX)
extern const char *MaceVersion();
extern const char *MaceGitVersion();
#endif // MACE_CORE_PUBLIC_VERSION_H_
......@@ -7,7 +7,7 @@
#include "mace/core/common.h"
#include "mace/core/tensor.h"
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
namespace mace {
......
......@@ -9,7 +9,7 @@
#include "mace/core/common.h"
#include "mace/utils/logging.h"
#include "mace/core/types.h"
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
namespace mace {
......
......@@ -6,7 +6,7 @@
#define MACE_CORE_TYPES_H_
#include "mace/core/common.h"
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
#include "mace/core/half.h"
......
......@@ -7,7 +7,7 @@
#include "mace/core/common.h"
#include "mace/core/tensor.h"
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
namespace mace {
......
......@@ -17,10 +17,12 @@
#include <iostream>
#include <cstdlib>
#include "mace/utils/command_line_flags.h"
#include "mace/core/mace.h"
#include "mace/utils/logging.h"
#include "mace/utils/env_time.h"
#include "mace/core/public/mace.h"
#include "mace/core/public/version.h"
using namespace std;
using namespace mace;
......@@ -82,7 +84,9 @@ int main(int argc, char **argv) {
return -1;
}
VLOG(0) << "model: " << model_file << std::endl
VLOG(0) << "mace version: " << MaceVersion() << std::endl
<< "mace git version: " << MaceGitVersion() << std::endl
<< "model: " << model_file << std::endl
<< "input: " << input_node << std::endl
<< "output: " << output_node << std::endl
<< "input_shape: " << input_shape << std::endl
......
......@@ -7,7 +7,7 @@
#include "mace/core/future.h"
#include "mace/core/tensor.h"
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
namespace mace {
namespace kernels {
......
......@@ -7,7 +7,7 @@
#include "mace/core/future.h"
#include "mace/core/tensor.h"
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
namespace mace {
namespace kernels {
......
......@@ -8,7 +8,7 @@
#include "mace/core/common.h"
#include "mace/core/future.h"
#include "mace/core/types.h"
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
#include "mace/core/tensor.h"
namespace mace {
......
......@@ -8,7 +8,7 @@
#include "mace/core/future.h"
#include "mace/core/common.h"
#include "mace/kernels/conv_pool_2d_util.h"
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
namespace mace {
namespace kernels {
......
......@@ -7,7 +7,7 @@
#include "mace/core/future.h"
#include "mace/core/tensor.h"
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
namespace mace {
namespace kernels {
......
......@@ -7,7 +7,6 @@
#include "mace/core/operator.h"
#include "mace/kernels/concat.h"
#include "mace/core/mace.h"
namespace mace {
template <DeviceType D, typename T>
......
......@@ -5,7 +5,7 @@
{% if mode == 0 %}
#include <vector>
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
namespace {{tag}}{
......@@ -24,7 +24,7 @@ void Create{{tensor.name}}(std::vector<mace::TensorProto> &tensors) {
{% elif mode == 1 %}
#include <vector>
#include <string>
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
namespace {
static void UpdateOp(mace::OperatorDef &op,
......@@ -95,7 +95,7 @@ void CreateOperator{{i}}(mace::OperatorDef &op) {
{% else %}
#include <vector>
#include <string>
#include "mace/core/mace.h"
#include "mace/core/public/mace.h"
namespace {{tag}} {
......
#!/usr/bin/env bash
#
# Copyright (c) 2017 XiaoMi All rights reserved.
#
OUTPUT_FILENAME=$1
if [[ -z "${OUTPUT_FILENAME}}" ]]; then
echo "Usage: $0 <filename>"
exit 1
fi
GIT_VERSION=$(git describe --long --tags)
if [[ $? != 0 ]]; then
GIT_VERSION=unknown
fi
cat <<EOF > ${OUTPUT_FILENAME}
#include "mace/core/public/version.h"
const char *MaceVersion() { return MACE_VERSION_STRING; }
const char *MaceGitVersion() { return "${GIT_VERSION}"; }
EOF
......@@ -27,6 +27,7 @@ CL_CODEGEN_DIR=${CODEGEN_DIR}/opencl
CL_BIN_DIR=${CODEGEN_DIR}/opencl_bin
TUNING_CODEGEN_DIR=${CODEGEN_DIR}/tuning
TUNING_OR_NOT=${3:-0}
VERSION_SOURCE_PATH=${CODEGEN_DIR}/version
build_and_run()
{
......@@ -95,6 +96,11 @@ bazel-bin/mace/python/tools/tf_converter --input=${TF_MODEL_FILE_PATH} \
--model_tag=${MODEL_TAG} \
--confuse=True
echo "Step 3: Generate version source"
rm -rf ${VERSION_SOURCE_PATH}
mkdir -p ${VERSION_SOURCE_PATH}
bash mace/tools/git/gen_version_source.sh ${VERSION_SOURCE_PATH}/version.cc
echo "Step 3: Run model on the phone with files"
build_and_run false
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册