Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
6139494f
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6139494f
编写于
8月 03, 2020
作者:
H
hangq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add doc for include file & clang-format include file
上级
60362ce7
变更
66
隐藏空白更改
内联
并排
Showing
66 changed file
with
339 addition
and
193 deletion
+339
-193
mindspore/lite/include/context.h
mindspore/lite/include/context.h
+26
-30
mindspore/lite/include/lite_session.h
mindspore/lite/include/lite_session.h
+45
-7
mindspore/lite/include/model.h
mindspore/lite/include/model.h
+61
-5
mindspore/lite/include/ms_tensor.h
mindspore/lite/include/ms_tensor.h
+58
-18
mindspore/lite/src/context.cc
mindspore/lite/src/context.cc
+2
-2
mindspore/lite/src/ir/tensor.h
mindspore/lite/src/ir/tensor.h
+1
-1
mindspore/lite/src/lite_session.cc
mindspore/lite/src/lite_session.cc
+28
-11
mindspore/lite/src/lite_session.h
mindspore/lite/src/lite_session.h
+4
-5
mindspore/lite/src/model.cc
mindspore/lite/src/model.cc
+10
-10
mindspore/lite/src/runtime/kernel/arm/base/concat_base.h
mindspore/lite/src/runtime/kernel/arm/base/concat_base.h
+2
-2
mindspore/lite/src/runtime/kernel/arm/base/convolution_base.cc
...pore/lite/src/runtime/kernel/arm/base/convolution_base.cc
+1
-1
mindspore/lite/src/runtime/kernel/arm/base/convolution_base.h
...spore/lite/src/runtime/kernel/arm/base/convolution_base.h
+2
-2
mindspore/lite/src/runtime/kernel/arm/base/crop_base.h
mindspore/lite/src/runtime/kernel/arm/base/crop_base.h
+2
-2
mindspore/lite/src/runtime/kernel/arm/base/fullconnection_base.h
...re/lite/src/runtime/kernel/arm/base/fullconnection_base.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/base/pooling_base.h
mindspore/lite/src/runtime/kernel/arm/base/pooling_base.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/base/prior_box.h
mindspore/lite/src/runtime/kernel/arm/base/prior_box.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/base/quant_dtype_cast.h
...spore/lite/src/runtime/kernel/arm/base/quant_dtype_cast.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/base/reshape_base.h
mindspore/lite/src/runtime/kernel/arm/base/reshape_base.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/activation.h
mindspore/lite/src/runtime/kernel/arm/fp32/activation.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/addn.cc
mindspore/lite/src/runtime/kernel/arm/fp32/addn.cc
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic.h
mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self.h
mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/cast.cc
mindspore/lite/src/runtime/kernel/arm/fp32/cast.cc
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/cast.h
mindspore/lite/src/runtime/kernel/arm/fp32/cast.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/expandDims.h
mindspore/lite/src/runtime/kernel/arm/fp32/expandDims.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/fill.h
mindspore/lite/src/runtime/kernel/arm/fp32/fill.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/gather.h
mindspore/lite/src/runtime/kernel/arm/fp32/gather.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/gatherNd.h
mindspore/lite/src/runtime/kernel/arm/fp32/gatherNd.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/local_response_norm.h
...re/lite/src/runtime/kernel/arm/fp32/local_response_norm.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/one_hot.cc
mindspore/lite/src/runtime/kernel/arm/fp32/one_hot.cc
+2
-2
mindspore/lite/src/runtime/kernel/arm/fp32/pad.cc
mindspore/lite/src/runtime/kernel/arm/fp32/pad.cc
+2
-2
mindspore/lite/src/runtime/kernel/arm/fp32/power.h
mindspore/lite/src/runtime/kernel/arm/fp32/power.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/prelu.h
mindspore/lite/src/runtime/kernel/arm/fp32/prelu.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/reduce.cc
mindspore/lite/src/runtime/kernel/arm/fp32/reduce.cc
+3
-3
mindspore/lite/src/runtime/kernel/arm/fp32/resize.cc
mindspore/lite/src/runtime/kernel/arm/fp32/resize.cc
+5
-5
mindspore/lite/src/runtime/kernel/arm/fp32/reverse.h
mindspore/lite/src/runtime/kernel/arm/fp32/reverse.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/scale.h
mindspore/lite/src/runtime/kernel/arm/fp32/scale.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/scatter_nd.h
mindspore/lite/src/runtime/kernel/arm/fp32/scatter_nd.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/slice.cc
mindspore/lite/src/runtime/kernel/arm/fp32/slice.cc
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/space_to_depth.h
mindspore/lite/src/runtime/kernel/arm/fp32/space_to_depth.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/sparse_to_dense.h
mindspore/lite/src/runtime/kernel/arm/fp32/sparse_to_dense.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/split.h
mindspore/lite/src/runtime/kernel/arm/fp32/split.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/strided_slice.h
mindspore/lite/src/runtime/kernel/arm/fp32/strided_slice.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/unsqueeze.h
mindspore/lite/src/runtime/kernel/arm/fp32/unsqueeze.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/where.h
mindspore/lite/src/runtime/kernel/arm/fp32/where.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/int8/add_int8.h
mindspore/lite/src/runtime/kernel/arm/int8/add_int8.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/int8/arithmetic_self_int8.h
...e/lite/src/runtime/kernel/arm/int8/arithmetic_self_int8.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/int8/hswish_int8.h
mindspore/lite/src/runtime/kernel/arm/int8/hswish_int8.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/int8/mul_int8.h
mindspore/lite/src/runtime/kernel/arm/int8/mul_int8.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.h
mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/int8/relu_int8.h
mindspore/lite/src/runtime/kernel/arm/int8/relu_int8.h
+1
-1
mindspore/lite/src/scheduler.cc
mindspore/lite/src/scheduler.cc
+1
-1
mindspore/lite/test/st/converter_test.cc
mindspore/lite/test/st/converter_test.cc
+2
-2
mindspore/lite/test/ut/src/infer_test.cc
mindspore/lite/test/ut/src/infer_test.cc
+9
-9
mindspore/lite/test/ut/src/runtime/kernel/arm/fp32/activation_fp32_test.cc
...st/ut/src/runtime/kernel/arm/fp32/activation_fp32_test.cc
+1
-1
mindspore/lite/test/ut/src/runtime/kernel/arm/fp32/conv1x1_fp32_tests.cc
...test/ut/src/runtime/kernel/arm/fp32/conv1x1_fp32_tests.cc
+2
-2
mindspore/lite/test/ut/src/runtime/kernel/arm/fp32/deconvolution_fp32_tests.cc
...t/src/runtime/kernel/arm/fp32/deconvolution_fp32_tests.cc
+4
-4
mindspore/lite/test/ut/src/runtime/kernel/arm/fp32/fullconnection_fp32_tests.cc
.../src/runtime/kernel/arm/fp32/fullconnection_fp32_tests.cc
+2
-2
mindspore/lite/test/ut/src/runtime/kernel/arm/fp32/space_to_depth_fp32_tests.cc
.../src/runtime/kernel/arm/fp32/space_to_depth_fp32_tests.cc
+1
-1
mindspore/lite/test/ut/src/runtime/kernel/arm/int8/arithmetic_self_int8_tests.cc
...src/runtime/kernel/arm/int8/arithmetic_self_int8_tests.cc
+6
-6
mindspore/lite/test/ut/src/runtime/kernel/arm/int8/crop_int8_tests.cc
...te/test/ut/src/runtime/kernel/arm/int8/crop_int8_tests.cc
+10
-10
mindspore/lite/test/ut/src/runtime/kernel/arm/int8/deconv_int8_tests.cc
.../test/ut/src/runtime/kernel/arm/int8/deconv_int8_tests.cc
+1
-1
mindspore/lite/test/ut/src/runtime/kernel/arm/int8/fullconnection_int8_tests.cc
.../src/runtime/kernel/arm/int8/fullconnection_int8_tests.cc
+1
-1
mindspore/lite/test/ut/src/runtime/kernel/arm/int8/quant_dtype_cast_tests.cc
.../ut/src/runtime/kernel/arm/int8/quant_dtype_cast_tests.cc
+2
-2
mindspore/lite/tools/benchmark/benchmark.cc
mindspore/lite/tools/benchmark/benchmark.cc
+6
-6
mindspore/lite/tools/converter/quantizer/post_training.cc
mindspore/lite/tools/converter/quantizer/post_training.cc
+3
-3
未找到文件。
mindspore/lite/include/context.h
浏览文件 @
6139494f
...
...
@@ -22,57 +22,53 @@
#include "include/ms_tensor.h"
namespace
mindspore
::
lite
{
//
brief Allocator defined by MindSpore Lite
//
//
note List public class and interface for reference
//
/ \brief Allocator defined by MindSpore Lite.
//
/
//
/ \note List public class and interface for reference.
class
Allocator
;
/// \brief CpuBindMode defined by MindSpore Lite.
enum
CpuBindMode
{
MID_CPU
=
-
1
,
/**< bind mid cpu first */
HIGHER_CPU
=
1
,
/**< bind higher cpu first */
NO_BIND
=
0
/**< no bind */
};
typedef
enum
{
DT_CPU
,
DT_GPU
,
DT_NPU
}
DeviceType
;
/// \brief DeviceType defined by MindSpore Lite.
typedef
enum
{
DT_CPU
,
/**< CPU device type */
DT_GPU
,
/**< GPU device type */
DT_NPU
/**< NPU device type */
}
DeviceType
;
//
brief NPUContext defined by MindSpore Lite
//
/ \brief DeviceContext defined by MindSpore Lite.
typedef
struct
{
int
freq
{
3
};
int
fmkType
{
0
};
int
modelType
{
0
};
int
deviceType
{
0
};
std
::
string
modelName
=
"default"
;
}
NPUContext
;
// brief DeviceContext defined by MindSpore Lite
typedef
struct
{
DeviceType
type
;
NPUContext
npuCtx
;
DeviceType
type
;
/**< device type */
}
DeviceContext
;
//
brief Context defined by MindSpore Lite
//
/ \
brief Context defined by MindSpore Lite
class
MS_API
Context
{
public:
//
brief Constructor of MindSpore Lite context using default value for parameters
//
//
return Instance of MindSpore Lite c
ontext.
//
/ \brief Constructor of MindSpore Lite context using default value for parameters.
//
/
//
/ \return Instance of MindSpore Lite C
ontext.
Context
();
//
brief Constructor of MindSpore Lite context using input value for parameters
//
//
param[in] threadNum Define the threadNum during the runtime.
//
param[in] allocator Define the allocator for malloc.
//
param[in] deviceCtx Define device information during the runtime.
//
/ \brief Constructor of MindSpore Lite Context using input value for parameters.
//
/
//
/ \
param[in] threadNum Define the threadNum during the runtime.
//
/ \
param[in] allocator Define the allocator for malloc.
//
/ \
param[in] deviceCtx Define device information during the runtime.
Context
(
int
threadNum
,
std
::
shared_ptr
<
Allocator
>
allocator
,
DeviceContext
deviceCtx
);
//
brief Destructor of MindSpore Lite context
//
/ \brief Destructor of MindSpore Lite Context.
virtual
~
Context
();
public:
DeviceContext
device
Ctx
;
int
thread
Num
=
2
;
std
::
shared_ptr
<
Allocator
>
allocator
;
CpuBindMode
cpu
BindMode
=
MID_CPU
;
DeviceContext
device
_ctx_
{
DT_CPU
}
;
int
thread
_num_
=
2
;
/**< thread number config for thread pool */
std
::
shared_ptr
<
Allocator
>
allocator
=
nullptr
;
CpuBindMode
cpu
_bind_mode_
=
MID_CPU
;
};
}
// namespace mindspore::lite
#endif // MINDSPORE_LITE_INCLUDE_CONTEXT_H_
mindspore/lite/include/lite_session.h
浏览文件 @
6139494f
...
...
@@ -26,25 +26,63 @@
namespace
mindspore
{
namespace
session
{
/// \brief LiteSession defined by MindSpore Lite.
class
MS_API
LiteSession
{
public:
virtual
~
LiteSession
()
=
default
;
/// \brief Static method to create a LiteSession pointer.
///
/// \param[in] context Define the context of session to be created.
///
/// \return Pointer of MindSpore Lite LiteSession.
static
LiteSession
*
CreateSession
(
lite
::
Context
*
context
);
virtual
void
BindThread
(
bool
ifBind
)
=
0
;
/// \brief Destructor of MindSpore Lite LiteSession.
virtual
~
LiteSession
()
=
default
;
static
LiteSession
*
CreateSession
(
lite
::
Context
*
context
);
/// \brief Try to bind or unbind threads in the thread pool to specified cpu core.
///
/// \param[in] if_bind Define weather to bind or unbind threads.
virtual
void
BindThread
(
bool
if_bind
)
=
0
;
/// \brief Compile MindSpore lite model.
///
/// \note CompileGraph should called before RunGraph.
///
/// \param[in] model Define the model to be compiled.
///
/// \return ErrorCode of compile graph.
virtual
int
CompileGraph
(
lite
::
Model
*
model
)
=
0
;
virtual
std
::
vector
<
tensor
::
MSTensor
*>
GetInputs
()
=
0
;
/// \brief Get input MindSpore Lite MSTensors of model.
///
/// \return A vector of MindSpore Lite MSTensor.
virtual
std
::
vector
<
tensor
::
MSTensor
*>
GetInputs
()
const
=
0
;
virtual
std
::
vector
<
tensor
::
MSTensor
*>
GetInputsByName
(
std
::
string
name
)
=
0
;
/// \brief Get input MindSpore Lite MSTensors of model by node name.
///
/// \param[in] node_name Define node name.
///
/// \return A vector of MindSpore Lite MSTensor.
virtual
std
::
vector
<
tensor
::
MSTensor
*>
GetInputsByName
(
const
std
::
string
&
node_name
)
const
=
0
;
/// \brief Run model compiled by this session.
///
/// \note RunGraph should called after CompileGraph.
///
/// \return ErrorCode of run graph.
virtual
int
RunGraph
()
=
0
;
virtual
std
::
vector
<
tensor
::
MSTensor
*>
GetOutputs
()
=
0
;
/// \brief Get output MindSpore Lite MSTensors of model.
///
/// \return A vector of MindSpore Lite MSTensor.
virtual
std
::
vector
<
tensor
::
MSTensor
*>
GetOutputs
()
const
=
0
;
virtual
std
::
vector
<
tensor
::
MSTensor
*>
GetOutputsByName
(
std
::
string
name
)
=
0
;
/// \brief Get output MindSpore Lite MSTensors of model by node name.
///
/// \param[in] node_name Define node name.
///
/// \return A vector of MindSpore Lite MSTensor.
virtual
std
::
vector
<
tensor
::
MSTensor
*>
GetOutputsByName
(
const
std
::
string
&
node_name
)
const
=
0
;
};
}
// namespace session
}
// namespace mindspore
...
...
mindspore/lite/include/model.h
浏览文件 @
6139494f
...
...
@@ -23,32 +23,88 @@
#include "schema/model_generated.h"
namespace
mindspore
{
/// \brief ModelImpl defined by MindSpore Lite.
///
/// \note List public class and interface for reference.
class
ModelImpl
;
namespace
lite
{
/// \brief Primitive defined by MindSpore Lite.
///
/// \note List public class and interface for reference.
class
Primitive
;
/// \brief Model defined by MindSpore Lite.
class
Model
{
public:
/// \brief Static method to create a Model pointer.
///
/// \param[in] model_buf Define the buffer read from a model file.
/// \param[in] size Define bytes numbers of model buffer.
///
/// \return Pointer of MindSpore Lite Model.
static
std
::
shared_ptr
<
Model
>
Import
(
const
char
*
model_buf
,
size_t
size
);
virtual
~
Model
()
=
default
;
/// \brief Constructor of MindSpore Lite Model using default value for parameters.
///
/// \return Instance of MindSpore Lite Model.
Model
()
=
default
;
/// \brief Destructor of MindSpore Lite Model.
virtual
~
Model
()
=
default
;
/// \brief Get MindSpore Lite Primitive by name.
///
/// \param[in] name Define name of primitive to be returned.
///
/// \return A pointer of MindSpore Lite Primitive.
lite
::
Primitive
*
GetOp
(
const
std
::
string
&
name
)
const
;
/// \brief Get MindSpore Lite MetaGraph.
///
/// \return A pointer of MindSpore Lite MetaGraph.
const
schema
::
MetaGraph
*
GetMetaGraph
()
const
;
std
::
shared_ptr
<
ModelImpl
>
GetModelImpl
();
/// \brief Get MindSpore Lite ModelImpl.
///
/// \return A pointer of MindSpore Lite ModelImpl.
std
::
shared_ptr
<
ModelImpl
>
model_impl
();
/// \brief Free MetaGraph in MindSpore Lite Model.
void
FreeMetaGraph
();
protected:
std
::
shared_ptr
<
ModelImpl
>
model
Impl
=
nullptr
;
std
::
shared_ptr
<
ModelImpl
>
model
_impl_
=
nullptr
;
};
/// \brief ModelBuilder defined by MindSpore Lite.
class
ModelBuilder
{
public:
/// \brief OutEdge defined by MindSpore Lite.
struct
OutEdge
{
std
::
string
nodeId
;
size_t
outEdgeIndex
;
std
::
string
nodeId
;
/**< Id of a node linked by this edge */
size_t
outEdgeIndex
;
/**< Index of this edge */
};
/// \brief Constructor of MindSpore Lite Model using default value for parameters.
///
/// \return Instance of MindSpore Lite ModelBuilder.
ModelBuilder
()
=
default
;
/// \brief Destructor of MindSpore Lite ModelBuilder.
virtual
~
ModelBuilder
()
=
default
;
/// \brief Add primitive into model builder for model building.
///
/// \param[in] op Define the primitive to be added.
/// \param[in] inputs Define input edge of primitive to be added.
///
/// \return Id of the primitive added.
virtual
std
::
string
AddOp
(
const
lite
::
Primitive
&
op
,
const
std
::
vector
<
OutEdge
>
&
inputs
)
=
0
;
/// \brief Finish constructing the model.
///
/// \return A pointer of MindSpore Lite Model.
virtual
Model
*
Construct
();
};
}
// namespace lite
...
...
mindspore/lite/include/ms_tensor.h
浏览文件 @
6139494f
...
...
@@ -25,46 +25,86 @@
namespace
mindspore
{
#define MS_API __attribute__((visibility("default")))
namespace
tensor
{
/// \brief MSTensor defined by MindSpore Lite.
class
MS_API
MSTensor
{
public:
/// \brief Constructor of MindSpore Lite MSTensor.
///
/// \return Instance of MindSpore Lite MSTensor.
MSTensor
()
=
default
;
// brief Create a MSTensor pointer.
//
// param data_type DataTypeId of tensor to be created.
// param shape Shape of tensor to be created.
// return MSTensor pointer.
/// \brief Static method to create a MSTensor pointer.
///
/// \param[in] data_type Define data type of tensor to be created.
/// \param[in] shape Define Shape of tensor to be created.
///
/// \note TypeId is defined in mindspore/mindspore/core/ir/dtype/type_id.h. Only number types in TypeId enum is
/// suitable for MSTensor.
///
/// \return A pointer of MSTensor.
static
MSTensor
*
CreateTensor
(
TypeId
data_type
,
const
std
::
vector
<
int
>
&
shape
);
/// \brief Destructor of MindSpore Lite Model.
virtual
~
MSTensor
()
=
default
;
/// \brief Get data type of the MindSpore Lite MSTensor.
///
/// \note TypeId is defined in mindspore/mindspore/core/ir/dtype/type_id.h. Only number types in TypeId enum is
/// suitable for MSTensor.
///
/// \return MindSpore Lite TypeId of the MindSpore Lite MSTensor.
virtual
TypeId
data_type
()
const
=
0
;
virtual
TypeId
set_data_type
(
const
TypeId
data_type
)
=
0
;
/// \brief Set data type for the MindSpore Lite MSTensor.
///
/// \param[in] data_type Define MindSpore Lite TypeId to be set into the MindSpore Lite MSTensor.
///
/// \return MindSpore Lite TypeId of the MindSpore Lite MSTensor after set.
virtual
TypeId
set_data_type
(
TypeId
data_type
)
=
0
;
/// \brief Get shape of the MindSpore Lite MSTensor.
///
/// \return A vector of int as the shape of the MindSpore Lite MSTensor.
virtual
std
::
vector
<
int
>
shape
()
const
=
0
;
/// \brief Set shape for the MindSpore Lite MSTensor.
///
/// \param[in] shape Define A vector of int as shape to be set into the MindSpore Lite MSTensor.
///
/// \return size of shape of the MindSpore Lite MSTensor after set.
virtual
size_t
set_shape
(
const
std
::
vector
<
int
>
&
shape
)
=
0
;
/// \brief Get size of the dimension of the MindSpore Lite MSTensor index by the parameter index.
///
/// \param[in] index Define index of dimension returned.
///
/// \return Size of dimension of the MindSpore Lite MSTensor.
virtual
int
DimensionSize
(
size_t
index
)
const
=
0
;
// brief Get number of element in MSTensor.
//
// return Number of element in MSTensor.
/// \brief Get number of element in MSTensor.
///
/// \return Number of element in MSTensor.
virtual
int
ElementsNum
()
const
=
0
;
/// \brief Get hash of the MindSpore Lite MSTensor.
///
/// \return Hash of the MindSpore Lite MSTensor.
virtual
std
::
size_t
hash
()
const
=
0
;
// brief Get byte size of data in MSTensor.
//
// return Byte size of data in MSTensor.
/// \brief Get byte size of data in MSTensor.
///
/// \return Byte size of data in MSTensor.
virtual
size_t
Size
()
const
=
0
;
// brief Get pointer of data in MSTensor.
//
// The data pointer can be used to both write or read data in MSTensor.
//
// return A pointer points to data in MSTensor.
/// \brief Get pointer of data in MSTensor.
///
/// \note The data pointer can be used to both write or read data in MSTensor.
///
/// \return A pointer points to data in MSTensor.
virtual
void
*
MutableData
()
const
=
0
;
};
using
MultiTensor
=
std
::
vector
<
std
::
vector
<
std
::
shared_ptr
<
tensor
::
MSTensor
>>>
;
}
// namespace tensor
}
// namespace mindspore
#endif // MINDSPORE_INCLUDE_MS_TENSOR_H_
mindspore/lite/src/context.cc
浏览文件 @
6139494f
...
...
@@ -24,8 +24,8 @@ Context::~Context() = default;
Context
::
Context
(
int
threadNum
,
std
::
shared_ptr
<
Allocator
>
allocator
,
DeviceContext
deviceCtx
)
{
this
->
allocator
=
std
::
move
(
allocator
);
this
->
thread
Num
=
threadNum
;
this
->
device
Ctx
=
std
::
move
(
deviceCtx
);
this
->
thread
_num_
=
threadNum
;
this
->
device
_ctx_
=
std
::
move
(
deviceCtx
);
}
}
// namespace mindspore::lite
mindspore/lite/src/ir/tensor.h
浏览文件 @
6139494f
...
...
@@ -197,7 +197,7 @@ class LiteTensor : public mindspore::tensor::MSTensor {
TypeId
data_type
()
const
override
;
TypeId
set_data_type
(
const
TypeId
data_type
)
override
;
TypeId
set_data_type
(
TypeId
data_type
)
override
;
std
::
vector
<
int
>
shape
()
const
override
;
...
...
mindspore/lite/src/lite_session.cc
浏览文件 @
6139494f
...
...
@@ -152,7 +152,7 @@ int LiteSession::CompileGraph(Model *model) {
return
RET_OK
;
}
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
LiteSession
::
GetInputs
()
{
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
LiteSession
::
GetInputs
()
const
{
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
ret
;
for
(
auto
&
iter
:
this
->
input_map
)
{
auto
&
node_input_tensors
=
iter
.
second
;
...
...
@@ -167,7 +167,7 @@ std::vector<mindspore::tensor::MSTensor *> LiteSession::GetInputs() {
int
LiteSession
::
RunGraph
()
{
MS_EXCEPTION_IF_NULL
(
this
->
context_
);
SetMaxWokerNum
(
context_
->
thread
Num
);
SetMaxWokerNum
(
context_
->
thread
_num_
);
Executor
executor
;
return
executor
.
Run
(
this
->
inputs
,
this
->
outputs
,
this
->
kernels
,
this
->
context_
->
allocator
.
get
());
}
...
...
@@ -178,7 +178,7 @@ int LiteSession::RunGraph(const kernel::KernelCallBack &before, const kernel::Ke
return
executor
.
Run
(
this
->
inputs
,
this
->
outputs
,
this
->
kernels
,
this
->
context_
->
allocator
.
get
(),
before
,
after
);
}
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
LiteSession
::
GetOutputs
()
{
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
LiteSession
::
GetOutputs
()
const
{
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
ret
;
for
(
auto
&
iter
:
this
->
output_map
)
{
auto
&
node_output_tensors
=
iter
.
second
;
...
...
@@ -193,20 +193,20 @@ std::vector<mindspore::tensor::MSTensor *> LiteSession::GetOutputs() {
int
LiteSession
::
Init
(
Context
*
context
)
{
MS_EXCEPTION_IF_NULL
(
context
);
this
->
context_
=
new
(
std
::
nothrow
)
Context
(
context
->
thread
Num
,
context
->
allocator
,
context
->
deviceCtx
);
this
->
context_
=
new
(
std
::
nothrow
)
Context
(
context
->
thread
_num_
,
context
->
allocator
,
context
->
device_ctx_
);
if
(
this
->
context_
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"new context failed"
;
return
RET_MEMORY_FAILED
;
}
this
->
context_
->
cpu
BindMode
=
context
->
cpuBindMode
;
ConfigThreadPool
(
context
->
cpu
BindMode
,
context
->
threadNum
);
this
->
context_
->
cpu
_bind_mode_
=
context
->
cpu_bind_mode_
;
ConfigThreadPool
(
context
->
cpu
_bind_mode_
,
context
->
thread_num_
);
auto
ret
=
KernelRegistry
::
GetInstance
()
->
Init
();
if
(
ret
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"KernelRegistry Init Failed."
;
return
ret
;
}
#if SUPPORT_GPU
if
(
context_
->
device
Ctx
.
type
==
DT_GPU
)
{
if
(
context_
->
device
_ctx_
.
type
==
DT_GPU
)
{
auto
opencl_runtime
=
lite
::
opencl
::
OpenCLRuntime
::
GetInstance
();
opencl_runtime
->
Init
();
}
...
...
@@ -215,8 +215,8 @@ int LiteSession::Init(Context *context) {
}
void
LiteSession
::
BindThread
(
bool
ifBind
)
{
if
(
this
->
context_
->
cpu
BindMode
!=
NO_BIND
)
{
DoAllThreadBind
(
ifBind
,
static_cast
<
int
>
(
this
->
context_
->
cpu
BindMode
));
if
(
this
->
context_
->
cpu
_bind_mode_
!=
NO_BIND
)
{
DoAllThreadBind
(
ifBind
,
static_cast
<
int
>
(
this
->
context_
->
cpu
_bind_mode_
));
}
}
...
...
@@ -237,8 +237,25 @@ LiteSession::~LiteSession() {
}
}
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
LiteSession
::
GetInputsByName
(
std
::
string
name
)
{
return
input_map
[
name
];
}
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
LiteSession
::
GetOutputsByName
(
std
::
string
name
)
{
return
output_map
[
name
];
}
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
LiteSession
::
GetInputsByName
(
const
std
::
string
&
name
)
const
{
auto
ret
=
input_map
.
find
(
name
);
if
(
ret
==
input_map
.
end
())
{
MS_LOG
(
WARNING
)
<<
"Node "
<<
name
<<
" is not an input node"
;
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
empty_ret
;
return
empty_ret
;
}
return
ret
->
second
;
}
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
LiteSession
::
GetOutputsByName
(
const
std
::
string
&
name
)
const
{
auto
ret
=
output_map
.
find
(
name
);
if
(
ret
==
output_map
.
end
())
{
MS_LOG
(
WARNING
)
<<
"Node "
<<
name
<<
" is not an output node"
;
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
empty_ret
;
return
empty_ret
;
}
return
ret
->
second
;
}
}
// namespace lite
session
::
LiteSession
*
session
::
LiteSession
::
CreateSession
(
lite
::
Context
*
context
)
{
...
...
mindspore/lite/src/lite_session.h
浏览文件 @
6139494f
...
...
@@ -42,17 +42,17 @@ class LiteSession : public session::LiteSession {
int
CompileGraph
(
Model
*
model
)
override
;
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
GetInputs
()
override
;
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
GetInputs
()
const
override
;
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
GetInputsByName
(
std
::
string
name
)
override
;
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
GetInputsByName
(
const
std
::
string
&
name
)
const
override
;
int
RunGraph
()
override
;
int
RunGraph
(
const
kernel
::
KernelCallBack
&
before
=
nullptr
,
const
kernel
::
KernelCallBack
&
after
=
nullptr
);
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
GetOutputs
()
override
;
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
GetOutputs
()
const
override
;
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
GetOutputsByName
(
std
::
string
name
)
override
;
std
::
vector
<
mindspore
::
tensor
::
MSTensor
*>
GetOutputsByName
(
const
std
::
string
&
name
)
const
override
;
protected:
int
ConvertTensors
(
const
lite
::
Model
*
model
);
...
...
@@ -75,4 +75,3 @@ class LiteSession : public session::LiteSession {
}
// namespace lite
}
// namespace mindspore
#endif // MINDSPORE_LITE_SRC_LITE_SESSION_H_
mindspore/lite/src/model.cc
浏览文件 @
6139494f
...
...
@@ -26,28 +26,28 @@ namespace mindspore::lite {
std
::
shared_ptr
<
Model
>
Model
::
Import
(
const
char
*
model_buf
,
size_t
size
)
{
auto
model
=
std
::
make_shared
<
Model
>
();
model
->
model
Impl
=
ModelImpl
::
Import
(
model_buf
,
size
);
model
->
model
_impl_
=
ModelImpl
::
Import
(
model_buf
,
size
);
return
model
;
}
lite
::
Primitive
*
Model
::
GetOp
(
const
std
::
string
&
name
)
const
{
MS_EXCEPTION_IF_NULL
(
model
Impl
);
return
const_cast
<
Primitive
*>
(
model
Impl
->
GetOp
(
name
));
MS_EXCEPTION_IF_NULL
(
model
_impl_
);
return
const_cast
<
Primitive
*>
(
model
_impl_
->
GetOp
(
name
));
}
void
Model
::
FreeMetaGraph
()
{
MS_EXCEPTION_IF_NULL
(
model
Impl
);
return
model
Impl
->
FreeMetaGraph
();
MS_EXCEPTION_IF_NULL
(
model
_impl_
);
return
model
_impl_
->
FreeMetaGraph
();
}
const
schema
::
MetaGraph
*
Model
::
GetMetaGraph
()
const
{
MS_EXCEPTION_IF_NULL
(
model
Impl
);
return
model
Impl
->
GetMetaGraph
();
MS_EXCEPTION_IF_NULL
(
model
_impl_
);
return
model
_impl_
->
GetMetaGraph
();
}
std
::
shared_ptr
<
ModelImpl
>
Model
::
GetModelI
mpl
()
{
MS_EXCEPTION_IF_NULL
(
model
Impl
);
return
this
->
model
Impl
;
std
::
shared_ptr
<
ModelImpl
>
Model
::
model_i
mpl
()
{
MS_EXCEPTION_IF_NULL
(
model
_impl_
);
return
this
->
model
_impl_
;
}
}
// namespace mindspore::lite
mindspore/lite/src/runtime/kernel/arm/base/concat_base.h
浏览文件 @
6139494f
...
...
@@ -29,8 +29,8 @@ class ConcatBaseCPUKernel : public LiteKernel {
public:
ConcatBaseCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{
opParameter
->
thread_num_
=
ctx
->
thread
Num
;
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{
opParameter
->
thread_num_
=
ctx
->
thread
_num_
;
concat_param_
=
reinterpret_cast
<
ConcatParameter
*>
(
opParameter
);
}
...
...
mindspore/lite/src/runtime/kernel/arm/base/convolution_base.cc
浏览文件 @
6139494f
...
...
@@ -87,7 +87,7 @@ int ConvolutionBaseCPUKernel::Init() {
conv_param_
->
output_h_
=
output
->
Height
();
conv_param_
->
output_w_
=
output
->
Width
();
conv_param_
->
output_channel_
=
output
->
Channel
();
conv_param_
->
thread_num_
=
ctx_
->
thread
Num
;
conv_param_
->
thread_num_
=
ctx_
->
thread
_num_
;
return
RET_OK
;
}
...
...
mindspore/lite/src/runtime/kernel/arm/base/convolution_base.h
浏览文件 @
6139494f
...
...
@@ -38,8 +38,8 @@ class ConvolutionBaseCPUKernel : public LiteKernel {
public:
ConvolutionBaseCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{
opParameter
->
thread_num_
=
ctx
->
thread
Num
;
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{
opParameter
->
thread_num_
=
ctx
->
thread
_num_
;
conv_param_
=
reinterpret_cast
<
ConvParameter
*>
(
opParameter
);
}
~
ConvolutionBaseCPUKernel
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/base/crop_base.h
浏览文件 @
6139494f
...
...
@@ -28,8 +28,8 @@ class CropBaseCPUKernel : public LiteKernel {
public:
CropBaseCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{
opParameter
->
thread_num_
=
ctx
->
thread
Num
;
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{
opParameter
->
thread_num_
=
ctx
->
thread
_num_
;
}
~
CropBaseCPUKernel
()
=
default
;
...
...
mindspore/lite/src/runtime/kernel/arm/base/fullconnection_base.h
浏览文件 @
6139494f
...
...
@@ -29,7 +29,7 @@ class FullconnectionBaseCPUKernel : public LiteKernel {
public:
FullconnectionBaseCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{
fc_param_
=
reinterpret_cast
<
MatMulParameter
*>
(
opParameter
);
}
~
FullconnectionBaseCPUKernel
()
=
default
;
...
...
mindspore/lite/src/runtime/kernel/arm/base/pooling_base.h
浏览文件 @
6139494f
...
...
@@ -30,7 +30,7 @@ class PoolingBaseCPUKernel : public LiteKernel {
public:
PoolingBaseCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{
pooling_param_
=
reinterpret_cast
<
PoolingParameter
*>
(
opParameter
);
}
~
PoolingBaseCPUKernel
()
=
default
;
...
...
mindspore/lite/src/runtime/kernel/arm/base/prior_box.h
浏览文件 @
6139494f
...
...
@@ -29,7 +29,7 @@ class PriorBoxCPUKernel : public LiteKernel {
public:
PriorBoxCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{
prior_box_param_
=
reinterpret_cast
<
PriorBoxParameter
*>
(
opParameter
);
}
~
PriorBoxCPUKernel
()
=
default
;
...
...
mindspore/lite/src/runtime/kernel/arm/base/quant_dtype_cast.h
浏览文件 @
6139494f
...
...
@@ -25,7 +25,7 @@ class QuantDTypeCastCPUKernel : public LiteKernel {
public:
QuantDTypeCastCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_num_
(
ctx
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_num_
(
ctx
->
thread
_num_
)
{}
~
QuantDTypeCastCPUKernel
()
=
default
;
int
Init
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/base/reshape_base.h
浏览文件 @
6139494f
...
...
@@ -28,7 +28,7 @@ class ReshapeBaseCPUKernel : public LiteKernel {
public:
ReshapeBaseCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{
reshape_param_
=
reinterpret_cast
<
ReshapeParameter
*>
(
opParameter
);
}
~
ReshapeBaseCPUKernel
()
=
default
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/activation.h
浏览文件 @
6139494f
...
...
@@ -26,7 +26,7 @@ class ActivationCPUKernel : public LiteKernel {
public:
ActivationCPUKernel
(
OpParameter
*
param
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
param
,
inputs
,
outputs
),
thread_count_
(
ctx
->
thread
Num
)
{
:
LiteKernel
(
param
,
inputs
,
outputs
),
thread_count_
(
ctx
->
thread
_num_
)
{
type_
=
(
reinterpret_cast
<
ActivationParameter
*>
(
param
))
->
type_
;
alpha_
=
(
reinterpret_cast
<
ActivationParameter
*>
(
param
))
->
alpha_
;
}
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/addn.cc
浏览文件 @
6139494f
...
...
@@ -101,7 +101,7 @@ kernel::LiteKernel *CpuAddNFp32KernelCreator(const std::vector<lite::tensor::Ten
return
nullptr
;
}
MS_ASSERT
(
desc
.
type
==
schema
::
PrimitiveType_AddN
);
op_parameter
->
thread_num_
=
ctx
->
thread
Num
;
op_parameter
->
thread_num_
=
ctx
->
thread
_num_
;
auto
*
kernel
=
new
(
std
::
nothrow
)
AddNCPUKernel
(
op_parameter
,
inputs
,
outputs
);
if
(
kernel
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"new AddNCPUKernel fail!"
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic.h
浏览文件 @
6139494f
...
...
@@ -49,7 +49,7 @@ class ArithmeticCPUKernel : public LiteKernel {
public:
ArithmeticCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_count_
(
ctx
->
thread
Num
)
{
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_count_
(
ctx
->
thread
_num_
)
{
switch
(
parameter
->
type_
)
{
case
PrimitiveType_Mul
:
arithmetic_run_
=
ElementMul
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic_self.h
浏览文件 @
6139494f
...
...
@@ -45,7 +45,7 @@ class ArithmeticSelfCPUKernel : public LiteKernel {
public:
explicit
ArithmeticSelfCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{
switch
(
parameter
->
type_
)
{
case
PrimitiveType_Abs
:
arithmeticSelf_run_
=
ElementAbs
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/cast.cc
浏览文件 @
6139494f
...
...
@@ -95,7 +95,7 @@ kernel::LiteKernel *CpuCastFp32KernelCreator(const std::vector<lite::tensor::Ten
MS_LOG
(
ERROR
)
<<
"Input context is nullptr!"
;
return
nullptr
;
}
if
(
ctx
->
thread
Num
==
0
)
{
if
(
ctx
->
thread
_num_
==
0
)
{
MS_LOG
(
ERROR
)
<<
"context thread num is 0!"
;
return
nullptr
;
}
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/cast.h
浏览文件 @
6139494f
...
...
@@ -26,7 +26,7 @@ class CastCPUKernel : public LiteKernel {
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
)
{
if
(
ctx
!=
nullptr
)
{
thread_num_
=
ctx
->
thread
Num
;
thread_num_
=
ctx
->
thread
_num_
;
}
}
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/expandDims.h
浏览文件 @
6139494f
...
...
@@ -31,7 +31,7 @@ class ExpandDimsCPUKernel : public LiteKernel {
public:
ExpandDimsCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{}
~
ExpandDimsCPUKernel
()
override
=
default
;
int
Init
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/fill.h
浏览文件 @
6139494f
...
...
@@ -29,7 +29,7 @@ class FillCPUKernel : public LiteKernel {
public:
FillCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{}
~
FillCPUKernel
()
override
=
default
;
int
Init
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/gather.h
浏览文件 @
6139494f
...
...
@@ -26,7 +26,7 @@ class GatherCPUKernel : public LiteKernel {
public:
GatherCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_count_
(
ctx
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_count_
(
ctx
->
thread
_num_
)
{}
~
GatherCPUKernel
()
override
=
default
;
int
Init
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/gatherNd.h
浏览文件 @
6139494f
...
...
@@ -31,7 +31,7 @@ class GatherNdCPUKernel : public LiteKernel {
public:
GatherNdCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{}
~
GatherNdCPUKernel
()
override
;
int
Init
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/local_response_norm.h
浏览文件 @
6139494f
...
...
@@ -26,7 +26,7 @@ class LocalResponseNormCPUKernel : public LiteKernel {
public:
LocalResponseNormCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_count_
(
ctx
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_count_
(
ctx
->
thread
_num_
)
{}
~
LocalResponseNormCPUKernel
()
override
=
default
;
int
Init
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/one_hot.cc
浏览文件 @
6139494f
...
...
@@ -58,7 +58,7 @@ int OneHotCPUKernel::Init() {
MS_LOG
(
ERROR
)
<<
"OneHot context nullptr"
;
return
RET_NULL_PTR
;
}
thread_num_
=
context_
->
thread
Num
;
thread_num_
=
context_
->
thread
_num_
;
const
int
indices_rank
=
static_cast
<
int
>
(
inputs_
.
at
(
0
)
->
shape
().
size
());
if
(
axis_
<
0
)
{
...
...
@@ -148,7 +148,7 @@ int OneHotCPUKernel::GetParams() {
}
int
OneHotCPUKernel
::
Run
()
{
int
error_code
=
LiteBackendParallelLaunch
(
RunOneHot
,
this
,
context_
->
thread
Num
);
int
error_code
=
LiteBackendParallelLaunch
(
RunOneHot
,
this
,
context_
->
thread
_num_
);
if
(
error_code
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"OneHot function error error_code["
<<
error_code
<<
"]"
;
return
RET_ERROR
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/pad.cc
浏览文件 @
6139494f
...
...
@@ -79,7 +79,7 @@ int PadCPUKernel::RunImpl(int task_id) {
auto
input_data
=
reinterpret_cast
<
float
*>
(
input
->
Data
());
auto
output_data
=
reinterpret_cast
<
float
*>
(
output
->
Data
());
Pad
(
input_data
,
output_data
,
in_
,
out_
,
pad_param_
->
paddings_
,
task_id
,
context_
->
thread
Num
);
Pad
(
input_data
,
output_data
,
in_
,
out_
,
pad_param_
->
paddings_
,
task_id
,
context_
->
thread
_num_
);
return
RET_OK
;
}
...
...
@@ -92,7 +92,7 @@ int PadCPUKernel::Run() {
// todo parallel memset to save time
memset
(
output_data
,
0
,
output_size
*
sizeof
(
float
));
int
error_code
=
LiteBackendParallelLaunch
(
PadImpl
,
this
,
context_
->
thread
Num
);
int
error_code
=
LiteBackendParallelLaunch
(
PadImpl
,
this
,
context_
->
thread
_num_
);
if
(
error_code
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"Pad run error, error_code["
<<
error_code
<<
"]"
;
return
RET_ERROR
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/power.h
浏览文件 @
6139494f
...
...
@@ -28,7 +28,7 @@ class PowerCPUKernel : public LiteKernel {
PowerCPUKernel
(
PowerParameter
*
param
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
reinterpret_cast
<
OpParameter
*>
(
param
),
inputs
,
outputs
),
thread_count_
(
ctx
->
thread
Num
),
thread_count_
(
ctx
->
thread
_num_
),
power_
(
param
->
power_
),
scale_
(
param
->
scale_
),
shift_
(
param
->
shift_
)
{}
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/prelu.h
浏览文件 @
6139494f
...
...
@@ -30,7 +30,7 @@ class PReluCPUKernel : public LiteKernel {
public:
PReluCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{
prelu_param_
=
(
reinterpret_cast
<
PReluParameter
*>
(
opParameter
));
}
~
PReluCPUKernel
()
=
default
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/reduce.cc
浏览文件 @
6139494f
...
...
@@ -138,7 +138,7 @@ int ReduceCPUKernel::Init() {
int
ReduceCPUKernel
::
CallReduceUnit
(
int
task_id
)
{
auto
ret
=
reducer_
(
outer_size_
,
inner_size_
,
axis_size_
,
src_data_
,
tmp_shape_
.
data
(),
dst_data_
,
task_id
,
context_
->
thread
Num
);
context_
->
thread
_num_
);
return
ret
;
}
...
...
@@ -167,7 +167,7 @@ int ReduceCPUKernel::Run() {
inner_size_
*=
tmp_shape_
[
k
];
}
axis_size_
=
tmp_shape_
[
axis
];
auto
error_code
=
LiteBackendParallelLaunch
(
ReduceImpl
,
this
,
context_
->
thread
Num
);
auto
error_code
=
LiteBackendParallelLaunch
(
ReduceImpl
,
this
,
context_
->
thread
_num_
);
if
(
error_code
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"Reduce run error, error_code["
<<
error_code
<<
"]"
;
return
RET_ERROR
;
...
...
@@ -187,7 +187,7 @@ int ReduceCPUKernel::Run() {
}
axis_size_
=
tmp_shape_
[
last_reduce_axis
];
dst_data_
=
reinterpret_cast
<
float
*>
(
outputs_
.
at
(
0
)
->
Data
());
auto
error_code
=
LiteBackendParallelLaunch
(
ReduceImpl
,
this
,
context_
->
thread
Num
);
auto
error_code
=
LiteBackendParallelLaunch
(
ReduceImpl
,
this
,
context_
->
thread
_num_
);
if
(
error_code
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"Reduce run error, error_code["
<<
error_code
<<
"]"
;
return
RET_ERROR
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/resize.cc
浏览文件 @
6139494f
...
...
@@ -172,10 +172,10 @@ int ResizeCPUKernel::RunImpl(int task_id) {
layout_convertor_
(
input_data
,
exec_input_data_
,
input
->
Batch
(),
input
->
Height
()
*
input
->
Width
(),
input
->
Channel
());
ret
=
ResizeBilinear
(
exec_input_data_
,
output_data
,
inputs_
[
0
]
->
shape
().
data
(),
outputs_
[
0
]
->
shape
().
data
(),
align_corners_
,
task_id
,
context_
->
thread
Num
);
align_corners_
,
task_id
,
context_
->
thread
_num_
);
}
else
{
ret
=
ResizeBilinear
(
input_data
,
output_data
,
inputs_
[
0
]
->
shape
().
data
(),
outputs_
[
0
]
->
shape
().
data
(),
align_corners_
,
task_id
,
context_
->
thread
Num
);
align_corners_
,
task_id
,
context_
->
thread
_num_
);
}
break
;
}
...
...
@@ -188,10 +188,10 @@ int ResizeCPUKernel::RunImpl(int task_id) {
layout_convertor_
(
input_data
,
exec_input_data_
,
input
->
Batch
(),
input
->
Height
()
*
input
->
Width
(),
input
->
Channel
());
ret
=
ResizeNearestNeighbor
(
exec_input_data_
,
output_data
,
input_shape
.
data
(),
outputs_
[
0
]
->
shape
().
data
(),
task_id
,
context_
->
thread
Num
);
task_id
,
context_
->
thread
_num_
);
}
else
{
ret
=
ResizeNearestNeighbor
(
input_data
,
output_data
,
input_shape
.
data
(),
outputs_
[
0
]
->
shape
().
data
(),
task_id
,
context_
->
thread
Num
);
context_
->
thread
_num_
);
}
break
;
}
...
...
@@ -205,7 +205,7 @@ int ResizeCPUKernel::RunImpl(int task_id) {
}
int
ResizeCPUKernel
::
Run
()
{
int
error_code
=
LiteBackendParallelLaunch
(
ResizeImpl
,
this
,
context_
->
thread
Num
);
int
error_code
=
LiteBackendParallelLaunch
(
ResizeImpl
,
this
,
context_
->
thread
_num_
);
if
(
error_code
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"Resize run error, error_code["
<<
error_code
<<
"]"
;
return
RET_ERROR
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/reverse.h
浏览文件 @
6139494f
...
...
@@ -30,7 +30,7 @@ class ReverseCPUKernel : public LiteKernel {
public:
ReverseCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{}
~
ReverseCPUKernel
()
{
if
(
tmp_
!=
nullptr
)
{
free
(
tmp_
);
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/scale.h
浏览文件 @
6139494f
...
...
@@ -26,7 +26,7 @@ class ScaleCPUKernel : public LiteKernel {
public:
explicit
ScaleCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_num_
(
ctx
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_num_
(
ctx
->
thread
_num_
)
{}
~
ScaleCPUKernel
()
override
=
default
;
int
Init
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/scatter_nd.h
浏览文件 @
6139494f
...
...
@@ -27,7 +27,7 @@ class ScatterNDCPUKernel : public LiteKernel {
public:
explicit
ScatterNDCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_num_
(
ctx
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_num_
(
ctx
->
thread
_num_
)
{}
~
ScatterNDCPUKernel
()
override
=
default
;
int
Init
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/slice.cc
浏览文件 @
6139494f
...
...
@@ -107,7 +107,7 @@ kernel::LiteKernel *CpuSliceFp32KernelCreator(const std::vector<lite::tensor::Te
return
nullptr
;
}
MS_ASSERT
(
desc
.
type
==
schema
::
PrimitiveType_Slice
);
op_parameter
->
thread_num_
=
ctx
->
thread
Num
;
op_parameter
->
thread_num_
=
ctx
->
thread
_num_
;
auto
*
kernel
=
new
(
std
::
nothrow
)
SliceCPUKernel
(
op_parameter
,
inputs
,
outputs
);
if
(
kernel
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"new SliceCPUKernel fail!"
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/space_to_depth.h
浏览文件 @
6139494f
...
...
@@ -25,7 +25,7 @@ class SpaceToDepthCPUKernel : public LiteKernel {
public:
SpaceToDepthCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_num_
(
ctx
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_num_
(
ctx
->
thread
_num_
)
{}
~
SpaceToDepthCPUKernel
()
=
default
;
int
SpaceToDepth
(
int
task_id
);
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/sparse_to_dense.h
浏览文件 @
6139494f
...
...
@@ -30,7 +30,7 @@ class SparseToDenseCPUKernel : public LiteKernel {
public:
SparseToDenseCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{
s2d_param_
=
(
reinterpret_cast
<
SparseToDenseParameter
*>
(
opParameter
));
}
~
SparseToDenseCPUKernel
()
=
default
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/split.h
浏览文件 @
6139494f
...
...
@@ -26,7 +26,7 @@ class SplitCPUKernel : public LiteKernel {
public:
SplitCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_num_
(
ctx
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_num_
(
ctx
->
thread
_num_
)
{}
~
SplitCPUKernel
()
override
=
default
;
int
Init
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/strided_slice.h
浏览文件 @
6139494f
...
...
@@ -26,7 +26,7 @@ class StridedSliceCPUKernel : public LiteKernel {
public:
StridedSliceCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_num_
(
ctx
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_num_
(
ctx
->
thread
_num_
)
{}
~
StridedSliceCPUKernel
()
override
=
default
;
int
Init
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/unsqueeze.h
浏览文件 @
6139494f
...
...
@@ -28,7 +28,7 @@ class UnsqueezeCPUKernel : public LiteKernel {
public:
UnsqueezeCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{}
~
UnsqueezeCPUKernel
()
=
default
;
int
Init
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/where.h
浏览文件 @
6139494f
...
...
@@ -30,7 +30,7 @@ class WhereCPUKernel : public LiteKernel {
public:
WhereCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{
where_param_
=
reinterpret_cast
<
WhereParameter
*>
(
opParameter
);
}
~
WhereCPUKernel
()
=
default
;
...
...
mindspore/lite/src/runtime/kernel/arm/int8/add_int8.h
浏览文件 @
6139494f
...
...
@@ -26,7 +26,7 @@ class QuantizedAddCPUKernel : public LiteKernel {
public:
explicit
QuantizedAddCPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx_
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx_
->
thread
_num_
)
{}
~
QuantizedAddCPUKernel
()
override
{}
int
Init
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/int8/arithmetic_self_int8.h
浏览文件 @
6139494f
...
...
@@ -37,7 +37,7 @@ class ArithmeticSelfInt8CPUKernel : public LiteKernel {
public:
explicit
ArithmeticSelfInt8CPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
Num
)
{
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread
_num_
)
{
switch
(
parameter
->
type_
)
{
case
PrimitiveType_Round
:
arithmeticSelf_run_
=
ElementRound
;
...
...
mindspore/lite/src/runtime/kernel/arm/int8/hswish_int8.h
浏览文件 @
6139494f
...
...
@@ -26,7 +26,7 @@ class HswishInt8CPUKernel : public LiteKernel {
public:
HswishInt8CPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_count_
(
ctx
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_count_
(
ctx
->
thread
_num_
)
{}
~
HswishInt8CPUKernel
()
override
=
default
;
int
Init
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/int8/mul_int8.h
浏览文件 @
6139494f
...
...
@@ -26,7 +26,7 @@ class MulInt8CPUKernel : public LiteKernel {
public:
explicit
MulInt8CPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx_
->
thread
Num
)
{}
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
ctx_
(
ctx
),
thread_count_
(
ctx_
->
thread
_num_
)
{}
~
MulInt8CPUKernel
()
override
{};
int
Init
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.h
浏览文件 @
6139494f
...
...
@@ -29,7 +29,7 @@ class PadInt8CPUKernel : public LiteKernel {
explicit
PadInt8CPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
)
{
opParameter
->
thread_num_
=
ctx
->
thread
Num
;
opParameter
->
thread_num_
=
ctx
->
thread
_num_
;
pad_param_
=
reinterpret_cast
<
PadParameter
*>
(
opParameter
);
}
~
PadInt8CPUKernel
()
override
{
FreeQuantParam
();
};
...
...
mindspore/lite/src/runtime/kernel/arm/int8/relu_int8.h
浏览文件 @
6139494f
...
...
@@ -27,7 +27,7 @@ class ReluInt8CPUKernel : public LiteKernel {
public:
ReluInt8CPUKernel
(
OpParameter
*
parameter
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_count_
(
ctx
->
thread
Num
)
{
:
LiteKernel
(
parameter
,
inputs
,
outputs
),
thread_count_
(
ctx
->
thread
_num_
)
{
type_
=
(
reinterpret_cast
<
ActivationParameter
*>
(
parameter
))
->
type_
;
}
~
ReluInt8CPUKernel
()
override
=
default
;
...
...
mindspore/lite/src/scheduler.cc
浏览文件 @
6139494f
...
...
@@ -159,7 +159,7 @@ kernel::LiteKernel *Scheduler::ScheduleNode(const std::vector<tensor::Tensor *>
MS_ASSERT
(
nullptr
!=
primitive
);
auto
data_type
=
inputs
.
front
()
->
data_type
();
kernel
::
KernelKey
desc
{
kernel
::
KERNEL_ARCH
::
kCPU
,
data_type
,
primitive
->
Type
()};
if
(
context_
->
device
Ctx
.
type
==
DT_GPU
)
{
if
(
context_
->
device
_ctx_
.
type
==
DT_GPU
)
{
desc
.
arch
=
kernel
::
KERNEL_ARCH
::
kGPU
;
auto
*
kernel
=
KernelFactory
::
GetInstance
()
->
GetKernel
(
inputs
,
outputs
,
primitive
,
context_
,
desc
);
if
(
nullptr
!=
kernel
)
{
...
...
mindspore/lite/test/st/converter_test.cc
浏览文件 @
6139494f
...
...
@@ -47,8 +47,8 @@ TEST_F(ConverterTest, TestOCR_02) {
}
TEST_F
(
ConverterTest
,
TestHebing
)
{
const
char
*
argv
[]
=
{
"./converter"
,
"--fmk=CAFFE"
,
"--modelFile=./hiai/model_hebing_3branch.
caffemodel
"
,
"--weightFile=./models/model_hebing_3branch.
prototxt
"
,
const
char
*
argv
[]
=
{
"./converter"
,
"--fmk=CAFFE"
,
"--modelFile=./hiai/model_hebing_3branch.
prototxt
"
,
"--weightFile=./models/model_hebing_3branch.
caffemodel
"
,
"--outputFile=./models/model_hebing_3branch"
};
auto
status
=
RunConverter
(
5
,
argv
);
ASSERT_EQ
(
status
,
RET_OK
);
...
...
mindspore/lite/test/ut/src/infer_test.cc
浏览文件 @
6139494f
...
...
@@ -104,9 +104,9 @@ TEST_F(InferTest, TestConvNode) {
meta_graph
.
reset
();
content
=
nullptr
;
auto
context
=
new
lite
::
Context
;
context
->
cpu
BindMode
=
lite
::
NO_BIND
;
context
->
device
Ctx
.
type
=
lite
::
DT_CPU
;
context
->
thread
Num
=
4
;
context
->
cpu
_bind_mode_
=
lite
::
NO_BIND
;
context
->
device
_ctx_
.
type
=
lite
::
DT_CPU
;
context
->
thread
_num_
=
4
;
auto
session
=
session
::
LiteSession
::
CreateSession
(
context
);
ASSERT_NE
(
nullptr
,
session
);
auto
ret
=
session
->
CompileGraph
(
model
.
get
());
...
...
@@ -201,9 +201,9 @@ TEST_F(InferTest, TestAddNode) {
meta_graph
.
reset
();
content
=
nullptr
;
auto
context
=
new
lite
::
Context
;
context
->
cpu
BindMode
=
lite
::
NO_BIND
;
context
->
device
Ctx
.
type
=
lite
::
DT_GPU
;
context
->
thread
Num
=
4
;
context
->
cpu
_bind_mode_
=
lite
::
NO_BIND
;
context
->
device
_ctx_
.
type
=
lite
::
DT_GPU
;
context
->
thread
_num_
=
4
;
auto
session
=
session
::
LiteSession
::
CreateSession
(
context
);
ASSERT_NE
(
nullptr
,
session
);
auto
ret
=
session
->
CompileGraph
(
model
.
get
());
...
...
@@ -252,9 +252,9 @@ TEST_F(InferTest, TestModel) {
ASSERT_NE
(
nullptr
,
model
);
delete
[]
buf
[
0
];
auto
context
=
new
lite
::
Context
;
context
->
cpu
BindMode
=
lite
::
NO_BIND
;
context
->
device
Ctx
.
type
=
lite
::
DT_CPU
;
context
->
thread
Num
=
4
;
context
->
cpu
_bind_mode_
=
lite
::
NO_BIND
;
context
->
device
_ctx_
.
type
=
lite
::
DT_CPU
;
context
->
thread
_num_
=
4
;
auto
session
=
session
::
LiteSession
::
CreateSession
(
context
);
ASSERT_NE
(
nullptr
,
session
);
auto
ret
=
session
->
CompileGraph
(
model
.
get
());
...
...
mindspore/lite/test/ut/src/runtime/kernel/arm/fp32/activation_fp32_test.cc
浏览文件 @
6139494f
...
...
@@ -112,7 +112,7 @@ TEST_F(TestActivationFp32, HSwishFp32) {
auto
creator
=
lite
::
KernelRegistry
::
GetInstance
()
->
GetCreator
(
desc
);
ASSERT_NE
(
creator
,
nullptr
);
lite
::
Context
ctx
;
ctx
.
thread
Num
=
7
;
ctx
.
thread
_num_
=
7
;
kernel
::
LiteKernel
*
kernel
=
creator
(
inputs_tensor
,
outputs_tensor
,
reinterpret_cast
<
OpParameter
*>
(
&
op_param
),
&
ctx
,
desc
);
ASSERT_NE
(
kernel
,
nullptr
);
...
...
mindspore/lite/test/ut/src/runtime/kernel/arm/fp32/conv1x1_fp32_tests.cc
浏览文件 @
6139494f
...
...
@@ -292,7 +292,7 @@ TEST_F(TestConv1x1Fp32, Conv1x1Test1) {
std
::
vector
<
lite
::
tensor
::
Tensor
*>
outputs_
;
auto
conv_param
=
new
ConvParameter
();
lite
::
Context
*
ctx
=
new
lite
::
Context
();
ctx
->
thread
Num
=
1
;
ctx
->
thread
_num_
=
1
;
float
*
correct
;
int
total_size
=
Conv1x1TestInit1
(
&
inputs_
,
&
outputs_
,
conv_param
,
&
correct
);
kernel
::
Convolution1x1CPUKernel
*
conv1x1
=
...
...
@@ -360,7 +360,7 @@ TEST_F(TestConv1x1Fp32, Conv1x1Test2) {
std
::
vector
<
lite
::
tensor
::
Tensor
*>
outputs_
;
auto
conv_param
=
new
ConvParameter
();
lite
::
Context
*
ctx
=
new
lite
::
Context
();
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
float
*
correct
;
int
total_size
=
Conv1x1TestInit2
(
&
inputs_
,
&
outputs_
,
conv_param
,
&
correct
);
kernel
::
Convolution1x1CPUKernel
*
conv1x1
=
...
...
mindspore/lite/test/ut/src/runtime/kernel/arm/fp32/deconvolution_fp32_tests.cc
浏览文件 @
6139494f
...
...
@@ -293,7 +293,7 @@ TEST_F(TestDeConvolutionFp32, DeConvTest1) {
std
::
vector
<
lite
::
tensor
::
Tensor
*>
outputs_
;
ConvParameter
*
deconv_param
=
new
ConvParameter
();
lite
::
Context
*
ctx
=
new
lite
::
Context
();
ctx
->
thread
Num
=
1
;
ctx
->
thread
_num_
=
1
;
float
*
correct
;
int
total_size
=
DeConvTestInit1
(
&
inputs_
,
&
outputs_
,
deconv_param
,
&
correct
);
kernel
::
DeConvolutionCPUKernel
*
deconv
=
...
...
@@ -364,7 +364,7 @@ TEST_F(TestDeConvolutionFp32, DeConvTest2) {
float
*
correct
;
int
total_size
=
DeConvTestInit2
(
&
inputs_
,
&
outputs_
,
deconv_param
,
&
correct
);
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
4
;
ctx
->
thread
_num_
=
4
;
kernel
::
DeConvolutionCPUKernel
*
deconv
=
new
kernel
::
DeConvolutionCPUKernel
(
reinterpret_cast
<
OpParameter
*>
(
deconv_param
),
inputs_
,
outputs_
,
ctx
);
...
...
@@ -443,7 +443,7 @@ TEST_F(TestDeConvolutionFp32, DeConvTest3) {
float
*
correct
;
int
total_size
=
DeConvTestInit3
(
&
inputs_
,
&
outputs_
,
deconv_param
,
&
correct
);
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
kernel
::
DeConvolutionCPUKernel
*
deconv
=
new
kernel
::
DeConvolutionCPUKernel
(
reinterpret_cast
<
OpParameter
*>
(
deconv_param
),
inputs_
,
outputs_
,
ctx
);
...
...
@@ -515,7 +515,7 @@ TEST_F(TestDeConvolutionFp32, DeConvTest4) {
float
*
correct
;
int
total_size
=
DeConvTestInit4
(
&
inputs_
,
&
outputs_
,
deconv_param
,
&
correct
);
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
kernel
::
DeConvolutionCPUKernel
*
deconv
=
new
kernel
::
DeConvolutionCPUKernel
(
reinterpret_cast
<
OpParameter
*>
(
deconv_param
),
inputs_
,
outputs_
,
ctx
);
...
...
mindspore/lite/test/ut/src/runtime/kernel/arm/fp32/fullconnection_fp32_tests.cc
浏览文件 @
6139494f
...
...
@@ -77,7 +77,7 @@ TEST_F(TestFcFp32, FcTest1) {
float
*
correct
;
int
total_size
=
FcTestInit1
(
&
inputs_
,
&
outputs_
,
matmul_param
,
&
correct
);
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
kernel
::
FullconnectionCPUKernel
*
fc
=
new
kernel
::
FullconnectionCPUKernel
(
reinterpret_cast
<
OpParameter
*>
(
matmul_param
),
inputs_
,
outputs_
,
ctx
);
...
...
@@ -134,7 +134,7 @@ TEST_F(TestFcFp32, FcTest2) {
float
*
correct
;
int
total_size
=
FcTestInit2
(
&
inputs_
,
&
outputs_
,
matmul_param
,
&
correct
);
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
1
;
ctx
->
thread
_num_
=
1
;
kernel
::
FullconnectionCPUKernel
*
fc
=
new
kernel
::
FullconnectionCPUKernel
(
reinterpret_cast
<
OpParameter
*>
(
matmul_param
),
inputs_
,
outputs_
,
ctx
);
...
...
mindspore/lite/test/ut/src/runtime/kernel/arm/fp32/space_to_depth_fp32_tests.cc
浏览文件 @
6139494f
...
...
@@ -75,7 +75,7 @@ TEST_F(SpaceToDepthTestFp32, SpaceToDepthTest2) {
op_param
.
block_size_
=
2
;
lite
::
Context
ctx
;
ctx
.
thread
Num
=
3
;
ctx
.
thread
_num_
=
3
;
kernel
::
KernelKey
desc
=
{
kernel
::
KERNEL_ARCH
::
kCPU
,
kNumberTypeFloat32
,
schema
::
PrimitiveType_SpaceToDepth
};
auto
creator
=
lite
::
KernelRegistry
::
GetInstance
()
->
GetCreator
(
desc
);
ASSERT_NE
(
creator
,
nullptr
);
...
...
mindspore/lite/test/ut/src/runtime/kernel/arm/int8/arithmetic_self_int8_tests.cc
浏览文件 @
6139494f
...
...
@@ -65,7 +65,7 @@ TEST_F(TestArithmeticSelfInt8, floor_quant0_thread2) {
ArithmeticSelfParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Floor
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
kernel
::
KernelKey
desc
=
{
kernel
::
KERNEL_ARCH
::
kCPU
,
kNumberTypeInt8
,
schema
::
PrimitiveType_Floor
};
auto
creator
=
lite
::
KernelRegistry
::
GetInstance
()
->
GetCreator
(
desc
);
ASSERT_NE
(
creator
,
nullptr
);
...
...
@@ -124,7 +124,7 @@ TEST_F(TestArithmeticSelfInt8, floor_quant1_thread2) {
ArithmeticSelfParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Floor
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
kernel
::
KernelKey
desc
=
{
kernel
::
KERNEL_ARCH
::
kCPU
,
kNumberTypeInt8
,
schema
::
PrimitiveType_Floor
};
auto
creator
=
lite
::
KernelRegistry
::
GetInstance
()
->
GetCreator
(
desc
);
ASSERT_NE
(
creator
,
nullptr
);
...
...
@@ -183,7 +183,7 @@ TEST_F(TestArithmeticSelfInt8, round_quant0_thread2) {
ArithmeticSelfParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Round
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
kernel
::
KernelKey
desc
=
{
kernel
::
KERNEL_ARCH
::
kCPU
,
kNumberTypeInt8
,
schema
::
PrimitiveType_Floor
};
auto
creator
=
lite
::
KernelRegistry
::
GetInstance
()
->
GetCreator
(
desc
);
ASSERT_NE
(
creator
,
nullptr
);
...
...
@@ -242,7 +242,7 @@ TEST_F(TestArithmeticSelfInt8, round_quant1_thread2) {
ArithmeticSelfParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Round
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
kernel
::
KernelKey
desc
=
{
kernel
::
KERNEL_ARCH
::
kCPU
,
kNumberTypeInt8
,
schema
::
PrimitiveType_Floor
};
auto
creator
=
lite
::
KernelRegistry
::
GetInstance
()
->
GetCreator
(
desc
);
ASSERT_NE
(
creator
,
nullptr
);
...
...
@@ -301,7 +301,7 @@ TEST_F(TestArithmeticSelfInt8, ceil_quant0_thread2) {
ArithmeticSelfParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Ceil
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
kernel
::
KernelKey
desc
=
{
kernel
::
KERNEL_ARCH
::
kCPU
,
kNumberTypeInt8
,
schema
::
PrimitiveType_Floor
};
auto
creator
=
lite
::
KernelRegistry
::
GetInstance
()
->
GetCreator
(
desc
);
ASSERT_NE
(
creator
,
nullptr
);
...
...
@@ -360,7 +360,7 @@ TEST_F(TestArithmeticSelfInt8, ceil_quant1_thread2) {
ArithmeticSelfParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Ceil
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
kernel
::
KernelKey
desc
=
{
kernel
::
KERNEL_ARCH
::
kCPU
,
kNumberTypeInt8
,
schema
::
PrimitiveType_Floor
};
auto
creator
=
lite
::
KernelRegistry
::
GetInstance
()
->
GetCreator
(
desc
);
ASSERT_NE
(
creator
,
nullptr
);
...
...
mindspore/lite/test/ut/src/runtime/kernel/arm/int8/crop_int8_tests.cc
浏览文件 @
6139494f
...
...
@@ -66,7 +66,7 @@ TEST_F(TestCropInt8, crop_1d_axis0_offset0_quant0_thread2) {
CropParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Crop
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
op_param
.
axis_
=
0
;
op_param
.
offset_
[
0
]
=
1
;
op_param
.
offset_size_
=
1
;
...
...
@@ -129,7 +129,7 @@ TEST_F(TestCropInt8, crop_2d_axis1_offset0_quant0_thread2) {
CropParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Crop
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
op_param
.
axis_
=
1
;
op_param
.
offset_
[
0
]
=
1
;
op_param
.
offset_size_
=
1
;
...
...
@@ -192,7 +192,7 @@ TEST_F(TestCropInt8, crop_3d_axis1_offset0_quant0_thread0) {
CropParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Crop
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
1
;
ctx
->
thread
_num_
=
1
;
op_param
.
axis_
=
1
;
op_param
.
offset_
[
0
]
=
1
;
op_param
.
offset_size_
=
1
;
...
...
@@ -256,7 +256,7 @@ TEST_F(TestCropInt8, crop_3d_axis1_offset0_quant0_thread2) {
CropParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Crop
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
op_param
.
axis_
=
1
;
op_param
.
offset_
[
0
]
=
1
;
op_param
.
offset_size_
=
1
;
...
...
@@ -319,7 +319,7 @@ TEST_F(TestCropInt8, crop_4d_axis0_offset0_quant0_thread0) {
CropParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Crop
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
1
;
ctx
->
thread
_num_
=
1
;
op_param
.
axis_
=
0
;
op_param
.
offset_
[
0
]
=
1
;
op_param
.
offset_size_
=
1
;
...
...
@@ -382,7 +382,7 @@ TEST_F(TestCropInt8, crop_4d_axis1_offset0_quant0_thread0) {
CropParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Crop
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
1
;
ctx
->
thread
_num_
=
1
;
op_param
.
axis_
=
1
;
op_param
.
offset_
[
0
]
=
1
;
op_param
.
offset_size_
=
1
;
...
...
@@ -445,7 +445,7 @@ TEST_F(TestCropInt8, crop_4d_axis1_offset1_quant0_thread0) {
CropParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Crop
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
1
;
ctx
->
thread
_num_
=
1
;
op_param
.
axis_
=
0
;
op_param
.
offset_
[
0
]
=
1
;
op_param
.
offset_
[
1
]
=
1
;
...
...
@@ -511,7 +511,7 @@ TEST_F(TestCropInt8, crop_4d_axis1_offset1_quant1_thread0) {
CropParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Crop
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
1
;
ctx
->
thread
_num_
=
1
;
op_param
.
axis_
=
0
;
op_param
.
offset_
[
0
]
=
1
;
op_param
.
offset_
[
1
]
=
1
;
...
...
@@ -579,7 +579,7 @@ TEST_F(TestCropInt8, crop_4d_axis0_offset0_quant0_thread2) {
CropParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Crop
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
op_param
.
axis_
=
0
;
op_param
.
offset_
[
0
]
=
1
;
op_param
.
offset_size_
=
1
;
...
...
@@ -644,7 +644,7 @@ TEST_F(TestCropInt8, crop_4d_axis0_offset0_quant0_thread3) {
CropParameter
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_Crop
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
3
;
ctx
->
thread
_num_
=
3
;
op_param
.
axis_
=
0
;
op_param
.
offset_
[
0
]
=
1
;
op_param
.
offset_size_
=
1
;
...
...
mindspore/lite/test/ut/src/runtime/kernel/arm/int8/deconv_int8_tests.cc
浏览文件 @
6139494f
...
...
@@ -247,7 +247,7 @@ TEST_F(TestDeconvInt8, DeConvInt8Test1) {
std
::
vector
<
lite
::
tensor
::
Tensor
*>
outputs_
;
auto
deconv_param
=
new
ConvParameter
();
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
int8_t
*
correct
;
int
total_size
=
DeConvInt8TestInit1
(
&
inputs_
,
&
outputs_
,
deconv_param
,
&
correct
);
mindspore
::
kernel
::
DeConvInt8CPUKernel
*
deconv
=
...
...
mindspore/lite/test/ut/src/runtime/kernel/arm/int8/fullconnection_int8_tests.cc
浏览文件 @
6139494f
...
...
@@ -123,7 +123,7 @@ TEST_F(TestFcInt8, fcint8) {
int
output_zp
;
int
total_size
=
FcInt8TestInit
(
&
inputs_
,
&
outputs_
,
matmul_param
,
&
correct
,
&
output_scale
,
&
output_zp
);
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread
Num
=
2
;
ctx
->
thread
_num_
=
2
;
kernel
::
FullconnectionInt8CPUKernel
*
fc
=
new
kernel
::
FullconnectionInt8CPUKernel
(
reinterpret_cast
<
OpParameter
*>
(
matmul_param
),
inputs_
,
outputs_
,
ctx
);
...
...
mindspore/lite/test/ut/src/runtime/kernel/arm/int8/quant_dtype_cast_tests.cc
浏览文件 @
6139494f
...
...
@@ -62,7 +62,7 @@ TEST_F(QuantDTypeCastTestFp32, QuantDTypeCastTest1) {
outputs_tensor
.
emplace_back
(
&
output_tensor
);
lite
::
Context
ctx
;
ctx
.
thread
Num
=
3
;
ctx
.
thread
_num_
=
3
;
kernel
::
KernelKey
desc
=
{
kernel
::
KERNEL_ARCH
::
kCPU
,
kNumberTypeInt8
,
schema
::
PrimitiveType_QuantDTypeCast
};
auto
creator
=
lite
::
KernelRegistry
::
GetInstance
()
->
GetCreator
(
desc
);
ASSERT_NE
(
creator
,
nullptr
);
...
...
@@ -108,7 +108,7 @@ TEST_F(QuantDTypeCastTestFp32, QuantDTypeCastTest2) {
outputs_tensor
.
emplace_back
(
&
output_tensor
);
lite
::
Context
ctx
;
ctx
.
thread
Num
=
3
;
ctx
.
thread
_num_
=
3
;
kernel
::
KernelKey
desc
=
{
kernel
::
KERNEL_ARCH
::
kCPU
,
kNumberTypeInt8
,
schema
::
PrimitiveType_QuantDTypeCast
};
auto
creator
=
lite
::
KernelRegistry
::
GetInstance
()
->
GetCreator
(
desc
);
ASSERT_NE
(
creator
,
nullptr
);
...
...
mindspore/lite/tools/benchmark/benchmark.cc
浏览文件 @
6139494f
...
...
@@ -350,19 +350,19 @@ int Benchmark::RunBenchmark(const std::string &deviceType) {
auto
model
=
lite
::
Model
::
Import
(
graphBuf
,
size
);
auto
context
=
new
lite
::
Context
;
if
(
_flags
->
device
==
"CPU"
)
{
context
->
device
Ctx
.
type
=
lite
::
DT_CPU
;
context
->
device
_ctx_
.
type
=
lite
::
DT_CPU
;
}
else
{
context
->
device
Ctx
.
type
=
lite
::
DT_NPU
;
context
->
device
_ctx_
.
type
=
lite
::
DT_NPU
;
}
if
(
_flags
->
cpuBindMode
==
-
1
)
{
context
->
cpu
BindMode
=
MID_CPU
;
context
->
cpu
_bind_mode_
=
MID_CPU
;
}
else
if
(
_flags
->
cpuBindMode
==
0
)
{
context
->
cpu
BindMode
=
HIGHER_CPU
;
context
->
cpu
_bind_mode_
=
HIGHER_CPU
;
}
else
{
context
->
cpu
BindMode
=
NO_BIND
;
context
->
cpu
_bind_mode_
=
NO_BIND
;
}
context
->
thread
Num
=
_flags
->
numThreads
;
context
->
thread
_num_
=
_flags
->
numThreads
;
session
=
session
::
LiteSession
::
CreateSession
(
context
);
auto
ret
=
session
->
CompileGraph
(
model
.
get
());
if
(
ret
!=
RET_OK
)
{
...
...
mindspore/lite/tools/converter/quantizer/post_training.cc
浏览文件 @
6139494f
...
...
@@ -898,9 +898,9 @@ STATUS PostTrainingQuantizer::DoQuantize(FuncGraphPtr funcGraph) {
auto
model
=
lite
::
Model
::
Import
(
content
,
size
);
Context
ctx
;
ctx
.
device
Ctx
.
type
=
DT_CPU
;
ctx
.
thread
Num
=
calibrator_
->
GetThreadNum
();
ctx
.
cpu
BindMode
=
MID_CPU
;
ctx
.
device
_ctx_
.
type
=
DT_CPU
;
ctx
.
thread
_num_
=
calibrator_
->
GetThreadNum
();
ctx
.
cpu
_bind_mode_
=
MID_CPU
;
session_
=
dynamic_cast
<
mindspore
::
lite
::
LiteSession
*>
(
session
::
LiteSession
::
CreateSession
(
&
ctx
));
if
(
session_
==
nullptr
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录