提交 b812c7a9 编写于 作者: W wuchenghui

support new version of nnlib named nngraph

上级 8619928b
...@@ -58,9 +58,9 @@ bool HexagonControlWrapper::Config() { ...@@ -58,9 +58,9 @@ bool HexagonControlWrapper::Config() {
bool HexagonControlWrapper::Init() { bool HexagonControlWrapper::Init() {
LOG(INFO) << "Hexagon init"; LOG(INFO) << "Hexagon init";
nn_id_ = hexagon_nn_init(); MACE_CHECK(hexagon_nn_init(&nn_id_) == 0, "hexagon_nn_init failed");
ResetPerfInfo(); ResetPerfInfo();
return nn_id_ != 0; return true;
} }
bool HexagonControlWrapper::Finalize() { bool HexagonControlWrapper::Finalize() {
...@@ -139,8 +139,19 @@ bool HexagonControlWrapper::SetupGraph(const NetDef &net_def, ...@@ -139,8 +139,19 @@ bool HexagonControlWrapper::SetupGraph(const NetDef &net_def,
inputs[i].output_idx = op.node_input()[i].output_port(); inputs[i].output_idx = op.node_input()[i].output_port();
} }
outputs.resize(op.out_max_byte_size().size()); outputs.resize(op.out_max_byte_size().size());
for (int i = 0; i < op.out_max_byte_size().size(); ++i) { for (size_t i = 0; i < op.out_max_byte_size().size(); ++i) {
outputs[i].max_size = op.out_max_byte_size()[i]; outputs[i].rank = op.output_shape()[i].dims().size();
for (size_t j = 0; j < outputs[i].rank; ++j) {
outputs[i].max_sizes[j] = op.output_shape()[i].dims()[j];
}
if (outputs[i].rank == 0) {
outputs[i].rank = 1;
outputs[i].max_sizes[0] = 1;
}
outputs[i].max_sizes[outputs[i].rank] = 0;
outputs[i].elementsize = GetEnumTypeSize(op.output_type()[i]);
outputs[i].zero_offset = 0;
outputs[i].stepsize = 0;
} }
cached_inputs.push_back(inputs); cached_inputs.push_back(inputs);
cached_outputs.push_back(outputs); cached_outputs.push_back(outputs);
...@@ -215,13 +226,13 @@ bool HexagonControlWrapper::SetupGraph(const NetDef &net_def, ...@@ -215,13 +226,13 @@ bool HexagonControlWrapper::SetupGraph(const NetDef &net_def,
int64_t t1 = NowMicros(); int64_t t1 = NowMicros();
int res = hexagon_nn_prepare(nn_id_); MACE_CHECK(hexagon_nn_prepare(nn_id_) == 0, "hexagon_nn_prepare failed");
int64_t t2 = NowMicros(); int64_t t2 = NowMicros();
VLOG(1) << "Setup time: " << t1 - t0 << " " << t2 - t1; VLOG(1) << "Setup time: " << t1 - t0 << " " << t2 - t1;
return res == 0; return true;
} }
bool HexagonControlWrapper::TeardownGraph() { bool HexagonControlWrapper::TeardownGraph() {
...@@ -289,6 +300,7 @@ void HexagonControlWrapper::GetPerfInfo() { ...@@ -289,6 +300,7 @@ void HexagonControlWrapper::GetPerfInfo() {
std::string node_type(node_type_buf); std::string node_type(node_type_buf);
LOG(INFO) << "node id: " << perf_info[i].node_id LOG(INFO) << "node id: " << perf_info[i].node_id
<< ", node type: " << node_type << ", node type: " << node_type
<< ", node type id: " << node_type_id
<< ", executions: " << perf_info[i].executions << ", executions: " << perf_info[i].executions
<< ", duration: " << node_id_counters[node_id]; << ", duration: " << node_id_counters[node_id];
......
...@@ -77,8 +77,11 @@ struct hexagon_nn_input { ...@@ -77,8 +77,11 @@ struct hexagon_nn_input {
}; };
typedef struct hexagon_nn_output hexagon_nn_output; typedef struct hexagon_nn_output hexagon_nn_output;
struct hexagon_nn_output { struct hexagon_nn_output {
unsigned int max_size; unsigned int rank;
unsigned int unused; unsigned int max_sizes[8];
unsigned int elementsize;
int zero_offset;
float stepsize;
}; };
typedef struct hexagon_nn_perfinfo hexagon_nn_perfinfo; typedef struct hexagon_nn_perfinfo hexagon_nn_perfinfo;
struct hexagon_nn_perfinfo { struct hexagon_nn_perfinfo {
...@@ -128,7 +131,7 @@ struct hexagon_nn_const_node { ...@@ -128,7 +131,7 @@ struct hexagon_nn_const_node {
}; };
__QAIC_HEADER_EXPORT int __QAIC_HEADER(hexagon_nn_config)(void) __QAIC_HEADER_EXPORT int __QAIC_HEADER(hexagon_nn_config)(void)
__QAIC_HEADER_ATTRIBUTE; __QAIC_HEADER_ATTRIBUTE;
__QAIC_HEADER_EXPORT int __QAIC_HEADER(hexagon_nn_init)(void) __QAIC_HEADER_EXPORT int __QAIC_HEADER(hexagon_nn_init)(hexagon_nn_nn_id* g)
__QAIC_HEADER_ATTRIBUTE; __QAIC_HEADER_ATTRIBUTE;
__QAIC_HEADER_EXPORT int __QAIC_HEADER(hexagon_nn_set_debug_level)( __QAIC_HEADER_EXPORT int __QAIC_HEADER(hexagon_nn_set_debug_level)(
hexagon_nn_nn_id id, int level) __QAIC_HEADER_ATTRIBUTE; hexagon_nn_nn_id id, int level) __QAIC_HEADER_ATTRIBUTE;
......
/*
* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the
* disclaimer below) provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* /*
* You probably want to * You probably want to
...@@ -107,6 +73,7 @@ DEF_OP_WREF(QuantizedRelu_8) ...@@ -107,6 +73,7 @@ DEF_OP_WREF(QuantizedRelu_8)
DEF_OP_WREF(QuantizedReluX_8) DEF_OP_WREF(QuantizedReluX_8)
DEF_OP_WREF(QuantizedMaxPool_8) DEF_OP_WREF(QuantizedMaxPool_8)
DEF_OP_WREF(QuantizedAvgPool_8) DEF_OP_WREF(QuantizedAvgPool_8)
DEF_OP_WREF(QuantizedL2Pool_8)
DEF_OP_WREF(QuantizedConcat_8) DEF_OP_WREF(QuantizedConcat_8)
DEF_OP_WREF(QuantizedBiasAdd_8p8to32) DEF_OP_WREF(QuantizedBiasAdd_8p8to32)
DEF_OP_WREF(Min_f) DEF_OP_WREF(Min_f)
...@@ -122,6 +89,7 @@ DEF_OP(MatMul_f) ...@@ -122,6 +89,7 @@ DEF_OP(MatMul_f)
DEF_OP(Relu_f) DEF_OP(Relu_f)
DEF_OP(ReluX_f) DEF_OP(ReluX_f)
DEF_OP(AvgPool_f) DEF_OP(AvgPool_f)
DEF_OP(L2Pool_f)
DEF_OP(MaxPool_f) DEF_OP(MaxPool_f)
DEF_OP(Concat_f) DEF_OP(Concat_f)
DEF_OP(BiasAdd_f) DEF_OP(BiasAdd_f)
...@@ -187,6 +155,7 @@ DEF_OP_WREF(QuantizedSigmoid_8) ...@@ -187,6 +155,7 @@ DEF_OP_WREF(QuantizedSigmoid_8)
DEF_OP_WREF(QuantizedTanh_8) DEF_OP_WREF(QuantizedTanh_8)
DEF_OP_WREF(QuantizedSoftmax_8) DEF_OP_WREF(QuantizedSoftmax_8)
DEF_OP_WREF(QuantizedLRN_8) DEF_OP_WREF(QuantizedLRN_8)
DEF_OP_WREF(Quantizedpad2d_frame_8p)
DEF_OP_WREF(QuantizedSub_8p8to32) DEF_OP_WREF(QuantizedSub_8p8to32)
DEF_OP_WREF(QuantizedMaximum_8) DEF_OP_WREF(QuantizedMaximum_8)
DEF_OP_WREF(QuantizedMinimum_8) DEF_OP_WREF(QuantizedMinimum_8)
...@@ -194,23 +163,77 @@ DEF_OP_WREF(QuantizedMinimum_8) ...@@ -194,23 +163,77 @@ DEF_OP_WREF(QuantizedMinimum_8)
DEF_OP(Pad_f) DEF_OP(Pad_f)
DEF_OP(SpaceToBatchND_f) DEF_OP(SpaceToBatchND_f)
DEF_OP(BatchToSpaceND_f) DEF_OP(BatchToSpaceND_f)
DEF_OP(QuantizedSpaceToBatchND_8)
DEF_OP(QuantizedBatchToSpaceND_8)
DEF_OP(QuantizedPad_8) DEF_OP(QuantizedPad_8)
DEF_OP(ResizeBilinear_f) DEF_OP(ResizeBilinear_f)
DEF_OP(QuantizedResizeBilinear_8)
DEF_OP(ConcatV2_f) DEF_OP(ConcatV2_f)
DEF_OP(ConcatV2_int32) DEF_OP(ConcatV2_int32)
DEF_OP(Prod_int32) DEF_OP(Prod_int32)
DEF_OP(Slice_int32) DEF_OP(Slice_int32)
DEF_OP(QuantizedAdd_8p8to8) DEF_OP(QuantizedAdd_8p8to8)
DEF_OP(QuantizedResizeBilinear_8)
DEF_OP(Supernode_8x8p8to8_d32)
DEF_OP(Convert_to_d32)
DEF_OP(Convert_from_d32)
DEF_OP_WREF(QuantizedMaxPool_8_d32)
DEF_OP_WREF(QuantizedConcat_8_d32)
DEF_OP_WREF(QuantizedAvgPool_8_d32)
DEF_OP(Sink)
DEF_OP_WREF(QuantizedPRelu_8_d32)
DEF_OP_WREF(AutoQuantize) DEF_OP_WREF(AutoQuantize)
DEF_OP_WREF(QuantizedDepthwiseConv2d_8x8to32) DEF_OP_WREF(QuantizedDepthwiseConv2d_8x8to32)
DEF_OP(DepthwiseConv2d_f) DEF_OP(DepthwiseConv2d_f)
DEF_OP(QuantizedBiasAdd_8p8to8) DEF_OP(DepthwiseSupernode_8x8p8to8)
DEF_OP(DepthwiseSupernode_8x8p8to8_d32)
DEF_OP_WREF(QuantizedMul_8x8to8_d32)
DEF_OP(FullyConnected_u8)
#if 0
DEF_OP_WREF(QuantizedFC_8x8p8to8)
#endif
DEF_OP_WREF(QuantizedAdd_8p8to8_d32)
DEF_OP_WREF(QuantizedClamp_8)
DEF_OP(Clamp_f)
DEF_OP(QuantizeForTest_d32)
DEF_OP(Close_d32)
DEF_OP_WREF(QuantizedSub_8p8to8_d32)
DEF_OP(InputSupernode_8x8p8to8_outd32)
DEF_OP(QuantizedLRN_8_d32)
DEF_OP_WREF(QuantizedBiasAdd_32p32to32)
DEF_OP_WREF(Quantize_int32)
DEF_OP(Supernode_8x8p32to8)
DEF_OP(DepthwiseSupernode_8x8p32to8)
DEF_OP(Supernode_8x8p32to8_d32)
DEF_OP(DepthwiseSupernode_8x8p32to8_d32)
DEF_OP(InputSupernode_8x8p32to8_outd32)
DEF_OP(PPrint_8_d32)
DEF_OP(PPrintWithPadding_8_d32)
DEF_OP_WREF(AutoQuantize_d32)
DEF_OP_WREF(QuantizedTanh_8_d32)
DEF_OP_WREF(QuantizedSigmoid_8_d32)
DEF_OP_WREF(QuantizedSoftmax_8_d32)
DEF_OP_WREF(QuantizedL2Pool_8_d32)
DEF_OP(Gather_f)
DEF_OP(Gather_int32)
DEF_OP(Gather_8)
DEF_OP(Table_f)
DEF_OP(Table_int32)
DEF_OP(Table_8)
DEF_OP(FillPadding_8_d32)
DEF_OP(QuantizedResizeBilinear_8_d32)
#ifdef __SELF_DEF_OP_WREF #ifdef __SELF_DEF_OP_WREF
#undef __SELF_DEF_OP_WREF #undef __SELF_DEF_OP_WREF
#undef DEF_OP_WREF #undef DEF_OP_WREF
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册