Compare commits
7 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
cdd3e50e98 | |
|
|
33b5741627 | |
|
|
dea43db54e | |
|
|
bbef4447f0 | |
|
|
00c8628b9b | |
|
|
b728e941d8 | |
|
|
eb89dacd3c |
3
build.sh
3
build.sh
|
|
@ -14,6 +14,7 @@
|
|||
# limitations under the License.
|
||||
# ============================================================================
|
||||
|
||||
# MindSpore build script
|
||||
set -e
|
||||
BASEPATH=$(cd "$(dirname $0)"; pwd)
|
||||
export CUDA_PATH=""
|
||||
|
|
@ -39,6 +40,7 @@ check_on_off()
|
|||
fi
|
||||
}
|
||||
|
||||
# check value of input is 'on' or 'off' or 'debug'
|
||||
update_submodule()
|
||||
{
|
||||
git submodule update --init graphengine
|
||||
|
|
@ -54,6 +56,7 @@ update_submodule()
|
|||
fi
|
||||
}
|
||||
|
||||
# check value of input is 'on' or 'off'
|
||||
build_exit()
|
||||
{
|
||||
echo "$@" >&2
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ message(STATUS "Compiling GraphEngine")
|
|||
if(NOT(BUILD_LITE))
|
||||
set(GE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/graphengine)
|
||||
else()
|
||||
set(GE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/../../graphengine)
|
||||
set(GE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/../../graphengine)
|
||||
endif()
|
||||
|
||||
message(STATUS "[ME] build_path: ${BUILD_PATH}")
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#include <memory>
|
||||
#include "include/api/status.h"
|
||||
#include "include/api/types.h"
|
||||
#include "include/api/graph.h"
|
||||
#include "include/api/graph.h" // for MSTensor
|
||||
|
||||
namespace mindspore {
|
||||
class InputAndOutput;
|
||||
|
|
@ -29,7 +29,8 @@ class Context;
|
|||
using Input = InputAndOutput;
|
||||
using Output = InputAndOutput;
|
||||
|
||||
class MS_API CellBase {
|
||||
|
||||
class MS_API CellBase { // for CellCreator
|
||||
public:
|
||||
CellBase() = default;
|
||||
virtual ~CellBase() = default;
|
||||
|
|
@ -50,7 +51,7 @@ class MS_API GraphCell final : public Cell<GraphCell> {
|
|||
public:
|
||||
class GraphImpl;
|
||||
|
||||
GraphCell() = default;
|
||||
GraphCell() = default; // for CellCreator
|
||||
~GraphCell() override = default;
|
||||
|
||||
explicit GraphCell(const Graph &);
|
||||
|
|
@ -58,7 +59,7 @@ class MS_API GraphCell final : public Cell<GraphCell> {
|
|||
explicit GraphCell(const std::shared_ptr<Graph> &);
|
||||
|
||||
void SetContext(const std::shared_ptr<Context> &context);
|
||||
const std::shared_ptr<Graph> &GetGraph() const { return graph_; }
|
||||
const std::shared_ptr<Graph> &GetGraph() const { return graph_; } // for CellCreator
|
||||
Status Run(const std::vector<MSTensor> &inputs, std::vector<MSTensor> *outputs) override;
|
||||
std::vector<MSTensor> GetInputs();
|
||||
std::vector<MSTensor> GetOutputs();
|
||||
|
|
@ -71,7 +72,8 @@ class MS_API GraphCell final : public Cell<GraphCell> {
|
|||
std::shared_ptr<GraphImpl> executor_;
|
||||
};
|
||||
|
||||
class MS_API InputAndOutput {
|
||||
class MS_API InputAndOutput { // for CellCreator
|
||||
|
||||
public:
|
||||
InputAndOutput();
|
||||
~InputAndOutput() = default;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ typedef struct MSTensorHandleArray {
|
|||
} MSTensorHandleArray;
|
||||
|
||||
#define MS_MAX_SHAPE_NUM 32
|
||||
|
||||
typedef struct MSShapeInfo {
|
||||
size_t shape_num;
|
||||
int64_t shape[MS_MAX_SHAPE_NUM];
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum MSCompCode {
|
||||
enum MSCompCode { // 4 bytes
|
||||
kMSCompCodeCore = 0x00000000u,
|
||||
kMSCompCodeMD = 0x10000000u,
|
||||
kMSCompCodeME = 0x20000000u,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace mindspore {
|
|||
namespace opt {
|
||||
void BackendCommonOptimization(const std::shared_ptr<session::KernelGraph> &kernel_graph);
|
||||
void CommonFinalOptimization(const std::shared_ptr<session::KernelGraph> &kernel_graph);
|
||||
void CommonUnifyMindIR(const std::shared_ptr<session::KernelGraph> &kernel_graph);
|
||||
void CommonUnifyMindIR(const std::shared_ptr<session::KernelGraph> &kernel_graph); // for debug
|
||||
void AddDynamicShapeAttrPass(const std::shared_ptr<session::KernelGraph> &kernel_graph);
|
||||
void EliminateIllegalDataTypePass(const std::shared_ptr<session::KernelGraph> &kernel_graph);
|
||||
void DynamicShapeConvertPass(const std::shared_ptr<session::KernelGraph> &kernel_graph);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class AscendSession : public SessionBasic {
|
|||
|
||||
static void BatchBuildKernel(const std::vector<std::shared_ptr<SessionTask>> &build_tasks);
|
||||
|
||||
protected:
|
||||
protected: // load graph to device related
|
||||
void UnifyMindIR(const KernelGraphPtr &graph) override;
|
||||
GraphId CompileGraphImpl(const AnfNodePtrList &lst, const AnfNodePtrList &outputs) override;
|
||||
GraphId CompileGraphImpl(NotNull<FuncGraphPtr> func_graph) override;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class CPUSession : public SessionBasic {
|
|||
~CPUSession() override = default;
|
||||
void Init(uint32_t device_id) override;
|
||||
|
||||
protected:
|
||||
protected: // load graph
|
||||
void UnifyMindIR(const KernelGraphPtr &graph) override { SessionBasic::UnifyMindIR(graph); }
|
||||
void CreateOutputTensors(const GraphId &graph_id, const std::vector<tensor::TensorPtr> &input_tensors, VectorRef *,
|
||||
std::map<tensor::TensorPtr, session::KernelWithIndex> *tensor_to_node,
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ class BACKEND_EXPORT SessionBasic : public std::enable_shared_from_this<SessionB
|
|||
// When the device address of the node is used as the output of the graph, the device address will be passed
|
||||
// to the output tensor, and the output node will recreate a new device address. This third parameter records
|
||||
// the relationship between the new and old device address.
|
||||
virtual void UpdateOutputTensors(const VectorRef *outputs,
|
||||
virtual void UpdateOutputTensors(const VectorRef *outputs, // the output of graph
|
||||
const std::map<tensor::TensorPtr, session::KernelWithIndex> &tensor_to_node,
|
||||
std::map<DeviceAddressPtr, DeviceAddressPtr> *);
|
||||
virtual void UnifyMindIR(const KernelGraphPtr &graph);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace py = pybind11;
|
|||
|
||||
enum RunOpArgsEnum { PY_PRIM = 0, PY_NAME, PY_INPUTS, PY_ARGS_NUM };
|
||||
|
||||
struct OpExecInfo {
|
||||
struct OpExecInfo { // for runop build
|
||||
bool is_nop_prim = false;
|
||||
bool is_dynamic_shape = false;
|
||||
bool is_mixed_precision_cast = false;
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ namespace opt {
|
|||
namespace {
|
||||
constexpr char kDisablePrebuildEnv[] = "MS_DEV_DISABLE_PREBUILD";
|
||||
|
||||
// The following passes are used to optimize the graph before fusion.
|
||||
void AddAscendIRFusionRulesPass(PassManager *ir_fusion_pm) {
|
||||
MS_EXCEPTION_IF_NULL(ir_fusion_pm);
|
||||
ir_fusion_pm->AddPass(std::make_shared<LambUpdateWithLRRuleFusion>());
|
||||
|
|
@ -360,6 +361,7 @@ void AscendBackendIRFusionOptimization(const std::shared_ptr<session::KernelGrap
|
|||
MS_LOG(INFO) << "Status record: end ascend ir fusion pass. graph id: " << kernel_graph->graph_id();
|
||||
}
|
||||
|
||||
// The following passes are used to optimize the graph after fusion.
|
||||
void RunOpAscendBackendIRFusionOptimization(const std::shared_ptr<session::KernelGraph> &kernel_graph) {
|
||||
auto context_ptr = MsContext::GetInstance();
|
||||
MS_EXCEPTION_IF_NULL(context_ptr);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ constexpr size_t kDependInputNum = 3;
|
|||
constexpr size_t kDependFirstInputIdx = 1;
|
||||
constexpr size_t kTupleGetItemFirstInputIdx = 1;
|
||||
} // namespace
|
||||
STATUS MindsporeImporter::Mindir2AnfAdjust(const FuncGraphPtr &func_graph, const converter::Flags &flag) {
|
||||
STATUS MindsporeImporter::Mindir2AnfAdjust(const FuncGraphPtr &func_graph, const converter::Flags &flag) { // fmk: Ms
|
||||
MS_ASSERT(func_graph != nullptr);
|
||||
auto primitive_adjust_pass = std::make_shared<PrimitiveAdjust>();
|
||||
MS_CHECK_TRUE_MSG(primitive_adjust_pass != nullptr, RET_NULL_PTR, "primitive_adjust_pass is nullptr.");
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ void CodeMSModelBuild(std::ofstream &ofs, const Configurator *config) {
|
|||
" return kMSStatusLiteNotSupport;\n"
|
||||
" }\n";
|
||||
ofs << " int ret = RET_OK;\n";
|
||||
if (config->target() != kARM32M) {
|
||||
if (config->target() != kARM32M) { // only support ARM32M
|
||||
ofs << " ret = Init((void*)model_data, data_size);\n";
|
||||
}
|
||||
if (config->support_parallel()) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ from .adasum import AdaSum
|
|||
from .dim_reduce import DimReduce
|
||||
|
||||
|
||||
|
||||
__all__ = ['AutoBoost',
|
||||
'OptimizerProcess', 'ParameterProcess',
|
||||
'BoostTrainOneStepCell', 'BoostTrainOneStepWithLossScaleCell',
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ from mindspore.parallel._auto_parallel_context import auto_parallel_context
|
|||
from .less_batch_normalization import CommonHeadLastFN
|
||||
|
||||
|
||||
|
||||
__all__ = ["OptimizerProcess", "ParameterProcess"]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ def _get_delta_weight_process(rho, dn, grad_res_momentum):
|
|||
return delta_weight
|
||||
|
||||
|
||||
|
||||
class DimReduce(Cell):
|
||||
r"""
|
||||
The dimension reduce training, is a novel algorithm for accelerating convergence of Deep Learning models.
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ Descriptions of common dataset terms are as follows:
|
|||
- Iterator, the base class of dataset iterator for enumerating elements.
|
||||
"""
|
||||
|
||||
# pylint: disable=unused-import
|
||||
from .core import config
|
||||
from .engine import *
|
||||
from .engine.cache_client import DatasetCache
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ from mindspore._c_expression import typing
|
|||
import mindspore.common.dtype as mstype
|
||||
|
||||
|
||||
def mstype_to_detype(type_):
|
||||
def mstype_to_detype(type_): # pylint: disable=too-many-return-statements
|
||||
"""
|
||||
Get de data type corresponding to mindspore dtype.
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ grad = GradOperation(get_all=False, get_by_list=False, sens_param=False)
|
|||
_eps_net = ops.Eps()
|
||||
|
||||
|
||||
def _convert_64_to_32(tensor):
|
||||
def _convert_64_to_32(tensor):
|
||||
"""Convert Tensor with float64/int64 types to float32/int32."""
|
||||
if tensor.dtype == mstype.float64:
|
||||
return tensor.astype("float32")
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ from mindspore.common.dtype import dtype_to_nptype, pytype_to_dtype
|
|||
from mindspore.common import dtype as mstype
|
||||
from mindspore import log as logger
|
||||
from mindspore.common.api import _cell_graph_executor
|
||||
from mindspore.train.mind_ir_pb2 import ModelProto as mindir_model
|
||||
from mindspore.train.mind_ir_pb2 import ModelProto as mindir_model
|
||||
from mindspore.train.checkpoint_pb2 import Checkpoint
|
||||
from mindspore.train.node_strategy_pb2 import ParallelStrategyMap as ckpt_strategy
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ def _convert_type(types):
|
|||
Returns:
|
||||
list, list of element in dataset.
|
||||
"""
|
||||
ms_types = []
|
||||
ms_types = []
|
||||
for np_type in types:
|
||||
ms_type = pytype_to_dtype(np_type)
|
||||
ms_types.append(ms_type)
|
||||
|
|
|
|||
15
setup.py
15
setup.py
|
|
@ -19,6 +19,7 @@ import os
|
|||
import stat
|
||||
import platform
|
||||
|
||||
# pylint: disable=import-error
|
||||
from setuptools import setup, find_packages
|
||||
from setuptools.command.egg_info import egg_info
|
||||
from setuptools.command.build_py import build_py
|
||||
|
|
@ -33,35 +34,35 @@ pwd = os.path.dirname(os.path.realpath(__file__))
|
|||
pkg_dir = os.path.join(build_path, 'package')
|
||||
|
||||
|
||||
def _read_file(filename):
|
||||
def _read_file(filename): # pylint: disable=invalid-name
|
||||
with open(os.path.join(pwd, filename), encoding='UTF-8') as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
version = _read_file('version.txt').replace("\n", "")
|
||||
version = _read_file('version.txt').replace("\n", "") # pylint: disable=invalid-name
|
||||
readme = _read_file('README.md')
|
||||
|
||||
|
||||
def _write_version(file):
|
||||
def _write_version(file): # pylint: disable=invalid-name
|
||||
file.write("__version__ = '{}'\n".format(version))
|
||||
|
||||
|
||||
def _write_config(file):
|
||||
def _write_config(file): # pylint: disable=invalid-name
|
||||
file.write("__backend__ = '{}'\n".format(backend_policy))
|
||||
|
||||
|
||||
def _write_commit_file(file):
|
||||
def _write_commit_file(file): # pylint: disable=invalid-name
|
||||
file.write("__commit_id__ = '{}'\n".format(commit_id))
|
||||
|
||||
|
||||
def _write_package_name(file):
|
||||
def _write_package_name(file): # pylint: disable=invalid-name
|
||||
file.write("__package_name__ = '{}'\n".format(package_name))
|
||||
|
||||
|
||||
def _write_device_target(file):
|
||||
file.write("__device_target__ = '{}'\n".format(device_target))
|
||||
|
||||
|
||||
#
|
||||
def build_dependencies():
|
||||
"""generate python file"""
|
||||
version_file = os.path.join(pkg_dir, 'mindspore', 'version.py')
|
||||
|
|
|
|||
Loading…
Reference in New Issue