shape function refactor:
This commit is contained in:
parent
7a217baae6
commit
0f4901b3ed
|
@ -57,18 +57,6 @@ void UpdateDumpFlagAndDebugInfo(const CNodePtr &node, const std::vector<AnfNodeP
|
|||
}
|
||||
} // namespace
|
||||
|
||||
std::vector<int64_t> Convert2Int(const std::vector<size_t> &v) {
|
||||
std::vector<int64_t> result;
|
||||
(void)std::transform(v.begin(), v.end(), std::back_inserter(result), SizeToInt);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<int64_t> Convert2Long(const std::vector<size_t> &v) {
|
||||
std::vector<int64_t> result;
|
||||
(void)std::transform(v.begin(), v.end(), std::back_inserter(result), SizeToLong);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsDepend(const FuncGraph &graph, const AnfNodePtr &node, const std::vector<AnfNodePtr> &nodes) {
|
||||
mindspore::HashSet<AnfNodePtr> visited_nodes;
|
||||
return IsDepend(graph, node, nodes, &visited_nodes);
|
||||
|
@ -950,7 +938,6 @@ kernel::KernelBuildInfoPtr GenerateKernelBuildInfo(const std::vector<AnfNodePtr>
|
|||
std::vector<std::string> outputs_device_format;
|
||||
std::vector<TypeId> inputs_device_type;
|
||||
std::vector<TypeId> outputs_device_type;
|
||||
std::vector<std::vector<size_t>> outputs_shape;
|
||||
kernel::KernelBuildInfo::KernelBuildInfoBuilder builder;
|
||||
for (size_t idx = 0; idx < node_list.size(); ++idx) {
|
||||
auto cnode = utils::cast<CNodePtr>(node_list[idx]);
|
||||
|
@ -964,7 +951,6 @@ kernel::KernelBuildInfoPtr GenerateKernelBuildInfo(const std::vector<AnfNodePtr>
|
|||
for (size_t output_index = 0; output_index < output_num; ++output_index) {
|
||||
(void)outputs_device_format.emplace_back(kOpFormat_DEFAULT);
|
||||
(void)outputs_device_type.emplace_back(common::AnfAlgo::GetOutputInferDataType(cnode, output_index));
|
||||
(void)outputs_shape.emplace_back(common::AnfAlgo::GetOutputInferShape(cnode, output_index));
|
||||
}
|
||||
}
|
||||
builder.SetInputsFormat(inputs_device_format);
|
||||
|
|
|
@ -127,10 +127,6 @@ enum ConvBn1Output {
|
|||
kMean,
|
||||
};
|
||||
|
||||
std::vector<int64_t> Convert2Int(const std::vector<size_t> &v);
|
||||
|
||||
std::vector<int64_t> Convert2Long(const std::vector<size_t> &v);
|
||||
|
||||
// check whether node depends on either of nodes or not
|
||||
bool IsDepend(const FuncGraph &graph, const AnfNodePtr &node, const std::vector<AnfNodePtr> &nodes);
|
||||
bool IsDepend(const FuncGraph &graph, const AnfNodePtr &node, const std::vector<AnfNodePtr> &nodes,
|
||||
|
|
|
@ -63,7 +63,7 @@ TypeId CacheManager::GetOutputType(const AnfNodePtr &node, size_t index) {
|
|||
return result;
|
||||
}
|
||||
|
||||
std::vector<size_t> CacheManager::GetOutputShape(const AnfNodePtr &node, size_t index) {
|
||||
ShapeVector CacheManager::GetOutputShape(const AnfNodePtr &node, size_t index) {
|
||||
MS_EXCEPTION_IF_NULL(node);
|
||||
auto iter = shape_map_.find(node);
|
||||
if (iter != shape_map_.end()) {
|
||||
|
@ -75,8 +75,8 @@ std::vector<size_t> CacheManager::GetOutputShape(const AnfNodePtr &node, size_t
|
|||
return {};
|
||||
}
|
||||
auto output_nums = common::AnfAlgo::GetOutputTensorNum(node);
|
||||
std::map<size_t, std::vector<size_t>> index_to_shapes;
|
||||
std::vector<size_t> result = {};
|
||||
std::map<size_t, ShapeVector> index_to_shapes;
|
||||
ShapeVector result = {};
|
||||
for (size_t i = 0; i < output_nums; i++) {
|
||||
auto output_shape = common::AnfAlgo::GetOutputInferShape(node, i);
|
||||
(void)index_to_shapes.emplace(i, output_shape);
|
||||
|
|
|
@ -34,11 +34,11 @@ class CacheManager {
|
|||
~CacheManager() = default;
|
||||
void Update(const AnfNodePtr &node);
|
||||
TypeId GetOutputType(const AnfNodePtr &node, size_t index);
|
||||
std::vector<size_t> GetOutputShape(const AnfNodePtr &node, size_t index);
|
||||
ShapeVector GetOutputShape(const AnfNodePtr &node, size_t index);
|
||||
|
||||
private:
|
||||
std::map<AnfNodePtr, std::map<size_t, TypeId>> type_map_;
|
||||
std::map<AnfNodePtr, std::map<size_t, std::vector<size_t>>> shape_map_;
|
||||
std::map<AnfNodePtr, std::map<size_t, ShapeVector>> shape_map_;
|
||||
};
|
||||
|
||||
// @brief For optimization passes management
|
||||
|
|
|
@ -46,7 +46,6 @@ kernel::KernelBuildInfoPtr GenerateKernelBuildInfo(const CommunicationOpInfo &co
|
|||
std::vector<std::string> outputs_device_format;
|
||||
std::vector<TypeId> inputs_device_type;
|
||||
std::vector<TypeId> outputs_device_type;
|
||||
std::vector<std::vector<size_t>> outputs_shape;
|
||||
kernel::KernelBuildInfo::KernelBuildInfoBuilder builder;
|
||||
for (size_t idx = start_index; idx <= end_index; ++idx) {
|
||||
auto cnode = communication_op_info.communication_op_nodes[idx];
|
||||
|
@ -55,8 +54,7 @@ kernel::KernelBuildInfoPtr GenerateKernelBuildInfo(const CommunicationOpInfo &co
|
|||
common::AnfAlgo::GetCNodeName(cnode) == kAllGatherOpName) {
|
||||
rank_size = common::AnfAlgo::GetNodeAttr<int64_t>(cnode, kAttrRankSize);
|
||||
}
|
||||
size_t rank_size_t = LongToSize(rank_size);
|
||||
if (rank_size_t == 0) {
|
||||
if (rank_size == 0) {
|
||||
MS_LOG(EXCEPTION) << "Rank size should not be zero.";
|
||||
}
|
||||
MS_EXCEPTION_IF_NULL(cnode);
|
||||
|
@ -65,16 +63,11 @@ kernel::KernelBuildInfoPtr GenerateKernelBuildInfo(const CommunicationOpInfo &co
|
|||
inputs_device_format.push_back(AnfAlgo::GetInputFormat(cnode, input_index));
|
||||
inputs_device_type.push_back(AnfAlgo::GetInputDeviceDataType(cnode, input_index));
|
||||
}
|
||||
for (size_t rank_index = 0; rank_index < rank_size_t; ++rank_index) {
|
||||
for (int64_t rank_index = 0; rank_index < rank_size; ++rank_index) {
|
||||
size_t output_num = common::AnfAlgo::GetOutputTensorNum(cnode);
|
||||
for (size_t output_index = 0; output_index < output_num; ++output_index) {
|
||||
outputs_device_format.push_back(AnfAlgo::GetOutputFormat(cnode, output_index));
|
||||
outputs_device_type.push_back(AnfAlgo::GetOutputDeviceDataType(cnode, output_index));
|
||||
std::vector<size_t> shape = common::AnfAlgo::GetOutputInferShape(cnode, output_index);
|
||||
if (!shape.empty()) {
|
||||
shape[0] /= rank_size_t;
|
||||
}
|
||||
outputs_shape.push_back(common::AnfAlgo::GetOutputInferShape(cnode, output_index));
|
||||
}
|
||||
}
|
||||
builder.SetFusionType(AnfAlgo::GetFusionType(cnode));
|
||||
|
@ -373,21 +366,21 @@ AnfNodePtr CommunicationOpFusion::CreateFusedCommunicationOp(const FuncGraphPtr
|
|||
common::AnfAlgo::GetCNodeName(final_node) == kAllGatherOpName) {
|
||||
rank_size = common::AnfAlgo::GetNodeAttr<int64_t>(final_node, kAttrRankSize);
|
||||
}
|
||||
size_t rank_size_t = LongToSize(rank_size);
|
||||
if (rank_size_t == 0) {
|
||||
|
||||
if (rank_size == 0) {
|
||||
MS_LOG(EXCEPTION) << "Rank size should not be zero.";
|
||||
}
|
||||
size_t output_num = node_num * rank_size_t;
|
||||
size_t output_num = node_num * LongToSize(rank_size);
|
||||
std::vector<TypeId> dtypes(output_num, common::AnfAlgo::GetOutputInferDataType(final_node, 0));
|
||||
std::vector<std::vector<size_t>> shapes;
|
||||
std::vector<ShapeVector> shapes;
|
||||
int64_t fusion_total_size = 0;
|
||||
for (size_t i = 0; i < rank_size_t; ++i) {
|
||||
for (int64_t i = 0; i < rank_size; ++i) {
|
||||
for (size_t idx = start_index; idx <= end_index; ++idx) {
|
||||
auto input_node = communication_op_info.communication_op_nodes[idx];
|
||||
MS_EXCEPTION_IF_NULL(input_node);
|
||||
std::vector<size_t> shape = common::AnfAlgo::GetOutputInferShape(input_node, 0);
|
||||
auto shape = common::AnfAlgo::GetOutputInferShape(input_node, 0);
|
||||
if (!shape.empty()) {
|
||||
shape[0] /= rank_size_t;
|
||||
shape[0] /= rank_size;
|
||||
}
|
||||
shapes.push_back(shape);
|
||||
size_t tensor_size = AnfAlgo::GetOutputTensorMemSize(input_node, 0);
|
||||
|
|
|
@ -29,7 +29,6 @@ kernel::KernelBuildInfoPtr ReplaceNodeByProxy::GenerateKernelBuildInfo(const CNo
|
|||
std::vector<std::string> outputs_device_format;
|
||||
std::vector<TypeId> inputs_device_type;
|
||||
std::vector<TypeId> outputs_device_type;
|
||||
std::vector<std::vector<size_t>> outputs_shape;
|
||||
kernel::KernelBuildInfo::KernelBuildInfoBuilder builder;
|
||||
size_t input_num = common::AnfAlgo::GetInputTensorNum(cnode);
|
||||
for (size_t input_index = 0; input_index < input_num; ++input_index) {
|
||||
|
@ -40,7 +39,6 @@ kernel::KernelBuildInfoPtr ReplaceNodeByProxy::GenerateKernelBuildInfo(const CNo
|
|||
for (size_t output_index = 0; output_index < output_num; ++output_index) {
|
||||
outputs_device_format.push_back(AnfAlgo::GetOutputFormat(cnode, output_index));
|
||||
outputs_device_type.push_back(AnfAlgo::GetOutputDeviceDataType(cnode, output_index));
|
||||
outputs_shape.push_back(common::AnfAlgo::GetOutputInferShape(cnode, output_index));
|
||||
}
|
||||
builder.SetFusionType(AnfAlgo::GetFusionType(cnode));
|
||||
builder.SetProcessor(AnfAlgo::GetProcessor(cnode));
|
||||
|
|
|
@ -83,7 +83,7 @@ static std::map<std::string, std::pair<std::map<size_t, size_t>, std::map<size_t
|
|||
{prim::kPrimStridedSliceGrad->name(),
|
||||
{{{0, 1}, {1, 2}, {2, 3}, {3, 4}, {4, 0}}, {{1, 0}, {2, 1}, {3, 2}, {4, 3}, {0, 4}}}}};
|
||||
|
||||
std::string PrintKernelFormatAndType(const std::string &fmt, const TypeId &type, const std::vector<size_t> &shape) {
|
||||
std::string PrintKernelFormatAndType(const std::string &fmt, const TypeId &type, const std::vector<int64_t> &shape) {
|
||||
std::ostringstream buffer;
|
||||
buffer << "<" << TypeIdLabel(type);
|
||||
if (!fmt.empty()) {
|
||||
|
@ -170,7 +170,17 @@ size_t AnfRuntimeAlgorithm::GetOutputTensorMemSize(const AnfNodePtr &node, size_
|
|||
output_type_id = common::AnfAlgo::GetOutputInferDataType(node, output_index);
|
||||
}
|
||||
size_t type_size = GetTypeByte(TypeIdToType(output_type_id));
|
||||
std::vector<size_t> shape = AnfAlgo::GetOutputDeviceShape(node, output_index);
|
||||
auto shape = AnfAlgo::GetOutputDeviceShape(node, output_index);
|
||||
if (IsDynamic(shape)) {
|
||||
auto max_shape = common::AnfAlgo::GetOutputMaxShape(node, output_index);
|
||||
if (!max_shape.empty()) {
|
||||
shape = max_shape;
|
||||
MS_LOG(DEBUG) << "shape[" << shape << "] is dynamic, using max_shape[" << max_shape << "] instead.";
|
||||
} else {
|
||||
shape = {1};
|
||||
MS_LOG(DEBUG) << "shape[" << shape << "] is dynamic, set default to {1}";
|
||||
}
|
||||
}
|
||||
auto format = AnfAlgo::GetOutputFormat(node, output_index);
|
||||
auto dtype = AnfAlgo::GetOutputDeviceDataType(node, output_index);
|
||||
if (shape.empty() && format != kOpFormat_DEFAULT) {
|
||||
|
@ -178,7 +188,7 @@ size_t AnfRuntimeAlgorithm::GetOutputTensorMemSize(const AnfNodePtr &node, size_
|
|||
shape = trans::TransShapeToDevice(shape, format, node, output_index, dtype);
|
||||
}
|
||||
// scalar's output shape is a empty vector
|
||||
size_t tensor_size = std::accumulate(shape.begin(), shape.end(), type_size, std::multiplies<size_t>());
|
||||
size_t tensor_size = type_size * SizeOf(shape);
|
||||
return tensor_size;
|
||||
}
|
||||
|
||||
|
@ -331,12 +341,29 @@ std::vector<int64_t> AnfRuntimeAlgorithm::GetOutputDeviceShapeForTbeBuild(const
|
|||
return trans::TransShapeToDevice(infer_shape, format, node, output_idx, dtype);
|
||||
}
|
||||
|
||||
std::vector<size_t> AnfRuntimeAlgorithm::GetOutputDeviceShape(const AnfNodePtr &node, size_t output_idx) {
|
||||
bool AnfRuntimeAlgorithm::IsShapesDynamic(const std::vector<ShapeVector> &shapes) {
|
||||
for (const auto &shape : shapes) {
|
||||
if (IsDynamic(shape)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ShapeVector AnfRuntimeAlgorithm::GetOutputDeviceShape(const AnfNodePtr &node, size_t output_idx) {
|
||||
auto format = GetOutputFormat(node, output_idx);
|
||||
auto infer_shape = common::AnfAlgo::GetOutputInferShape(node, output_idx);
|
||||
if (infer_shape.empty()) {
|
||||
return infer_shape;
|
||||
}
|
||||
|
||||
if (IsDynamic(infer_shape)) {
|
||||
auto max_shape = common::AnfAlgo::GetOutputMaxShape(node, output_idx);
|
||||
if (!max_shape.empty()) {
|
||||
infer_shape = max_shape;
|
||||
}
|
||||
}
|
||||
// if format is default_format or NC1KHKWHWC0,device shape = original shape
|
||||
if (trans::IsNeedPadding(format, infer_shape.size())) {
|
||||
infer_shape = trans::PaddingShape(infer_shape, format, GetOutputReshapeType(node, output_idx), node);
|
||||
|
@ -366,7 +393,7 @@ std::vector<int64_t> AnfRuntimeAlgorithm::GetInputDeviceShapeForTbeBuild(const A
|
|||
return trans::TransShapeToDevice(infer_shape, format, node, input_idx, dtype, false);
|
||||
}
|
||||
|
||||
std::vector<size_t> AnfRuntimeAlgorithm::GetInputDeviceShape(const AnfNodePtr &node, size_t input_idx) {
|
||||
std::vector<int64_t> AnfRuntimeAlgorithm::GetInputDeviceShape(const AnfNodePtr &node, size_t input_idx) {
|
||||
auto format = GetInputFormat(node, input_idx);
|
||||
auto infer_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(node, input_idx);
|
||||
if (infer_shape.empty()) {
|
||||
|
@ -930,9 +957,9 @@ bool AnfRuntimeAlgorithm::IsIndependentNode(const CNodePtr &node) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static inline void GetMaxOrDefaultShape(const std::vector<int64_t> &max_shape, std::vector<size_t> *device_shape) {
|
||||
constexpr size_t kDefaultValueForDynamicDim = 16;
|
||||
auto ConvertNegOneToDefault = [&kDefaultValueForDynamicDim](size_t size) {
|
||||
static inline void GetMaxOrDefaultShape(const std::vector<int64_t> &max_shape, ShapeVector *device_shape) {
|
||||
constexpr int64_t kDefaultValueForDynamicDim = 16;
|
||||
auto ConvertNegOneToDefault = [&kDefaultValueForDynamicDim](int64_t size) {
|
||||
return static_cast<int64_t>(size) < 0 ? kDefaultValueForDynamicDim : size;
|
||||
};
|
||||
if (!max_shape.empty()) {
|
||||
|
@ -940,7 +967,7 @@ static inline void GetMaxOrDefaultShape(const std::vector<int64_t> &max_shape, s
|
|||
(void)std::transform(max_shape.begin(), max_shape.end(), std::back_inserter(*device_shape),
|
||||
ConvertNegOneToDefault);
|
||||
} else {
|
||||
(void)std::transform(max_shape.begin(), max_shape.end(), device_shape->begin(), IntToSize);
|
||||
*device_shape = max_shape;
|
||||
}
|
||||
} else {
|
||||
auto tmp_shape = *device_shape;
|
||||
|
@ -954,10 +981,10 @@ static inline void GetMaxOrDefaultShape(const std::vector<int64_t> &max_shape, s
|
|||
// why do we do this? Because in dynamic shape case, the input shape is unknown when the `init`
|
||||
// function executes at the very first time, but we still need to some helpful shape to make
|
||||
// sure the `init` executes correctly.
|
||||
std::vector<size_t> AnfRuntimeAlgorithm::GetInputDeviceShapeAdaptively(const AnfNodePtr &anf_node, size_t index) {
|
||||
ShapeVector AnfRuntimeAlgorithm::GetInputDeviceShapeAdaptively(const AnfNodePtr &anf_node, size_t index) {
|
||||
auto device_shape = GetInputDeviceShape(anf_node, index);
|
||||
// Initialize GPUKernel with max shape to fit 'InitDynamicOutputKernelRef()' for memory reuse.
|
||||
if (AnfUtils::IsShapeDynamic(device_shape) || device_shape.empty()) {
|
||||
if (IsDynamic(device_shape) || device_shape.empty()) {
|
||||
auto max_shape = common::AnfAlgo::GetInputMaxShape(anf_node, index);
|
||||
GetMaxOrDefaultShape(max_shape, &device_shape);
|
||||
auto format = GetInputFormat(anf_node, index);
|
||||
|
@ -967,11 +994,11 @@ std::vector<size_t> AnfRuntimeAlgorithm::GetInputDeviceShapeAdaptively(const Anf
|
|||
|
||||
if (device_shape.empty()) {
|
||||
KernelWithIndex kernel_with_index = common::AnfAlgo::GetPrevNodeOutput(anf_node, index);
|
||||
auto shape = common::AnfAlgo::GetOutputInferShapeSigned(kernel_with_index.first, kernel_with_index.second);
|
||||
std::vector<size_t> ret_shape;
|
||||
constexpr size_t kDefaultValueForDynamicDim = 1;
|
||||
auto shape = common::AnfAlgo::GetOutputInferShape(kernel_with_index.first, kernel_with_index.second);
|
||||
ShapeVector ret_shape;
|
||||
constexpr int64_t kDefaultValueForDynamicDim = 1;
|
||||
auto ConvertNegOneToDefault = [&kDefaultValueForDynamicDim](int64_t size) {
|
||||
return size < 0 ? kDefaultValueForDynamicDim : LongToSize(size);
|
||||
return size < 0 ? kDefaultValueForDynamicDim : size;
|
||||
};
|
||||
std::transform(shape.begin(), shape.end(), std::back_inserter(ret_shape), ConvertNegOneToDefault);
|
||||
auto format = GetInputFormat(anf_node, index);
|
||||
|
@ -984,10 +1011,10 @@ std::vector<size_t> AnfRuntimeAlgorithm::GetInputDeviceShapeAdaptively(const Anf
|
|||
}
|
||||
|
||||
// The same to GetInputDeviceShapeAdaptively
|
||||
std::vector<size_t> AnfRuntimeAlgorithm::GetOutputDeviceShapeAdaptively(const AnfNodePtr &anf_node, size_t index) {
|
||||
ShapeVector AnfRuntimeAlgorithm::GetOutputDeviceShapeAdaptively(const AnfNodePtr &anf_node, size_t index) {
|
||||
auto device_shape = GetOutputDeviceShape(anf_node, index);
|
||||
// Initialize GPUKernel with max shape to fit 'InitDynamicOutputKernelRef()' for memory reuse.
|
||||
if (AnfUtils::IsShapeDynamic(device_shape) || device_shape.empty()) {
|
||||
if (IsDynamic(device_shape) || device_shape.empty()) {
|
||||
auto max_shape = common::AnfAlgo::GetOutputMaxShape(anf_node, index);
|
||||
GetMaxOrDefaultShape(max_shape, &device_shape);
|
||||
auto format = GetOutputFormat(anf_node, index);
|
||||
|
@ -997,10 +1024,10 @@ std::vector<size_t> AnfRuntimeAlgorithm::GetOutputDeviceShapeAdaptively(const An
|
|||
|
||||
if (device_shape.empty()) {
|
||||
auto shape = common::AnfAlgo::GetOutputInferShapeSigned(anf_node, index);
|
||||
std::vector<size_t> ret_shape;
|
||||
constexpr size_t kDefaultValueForDynamicDim = 1;
|
||||
ShapeVector ret_shape;
|
||||
constexpr int64_t kDefaultValueForDynamicDim = 1;
|
||||
auto ConvertNegOneToOne = [&kDefaultValueForDynamicDim](int64_t size) {
|
||||
return size < 0 ? kDefaultValueForDynamicDim : LongToSize(size);
|
||||
return size < 0 ? kDefaultValueForDynamicDim : size;
|
||||
};
|
||||
std::transform(shape.begin(), shape.end(), std::back_inserter(ret_shape), ConvertNegOneToOne);
|
||||
auto format = GetOutputFormat(anf_node, index);
|
||||
|
@ -1285,7 +1312,7 @@ bool AnfRuntimeAlgorithm::IsDynamicShapeSkipExecute(const CNodePtr &cnode) {
|
|||
MS_EXCEPTION_IF_NULL(axes_abs);
|
||||
auto axes_shape = AnfAlgo::GetInputDeviceShape(cnode, axes_index);
|
||||
if (axes_abs->isa<abstract::AbstractTensor>()) {
|
||||
if (std::any_of(axes_shape.begin(), axes_shape.end(), [](ssize_t shape) { return shape == 0; })) {
|
||||
if (std::any_of(axes_shape.begin(), axes_shape.end(), [](int64_t shape) { return shape == 0; })) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,9 +71,9 @@ class BACKEND_EXPORT AnfRuntimeAlgorithm {
|
|||
// get reshape_type of from the output of input node.
|
||||
static std::string GetPrevNodeOutputReshapeType(const AnfNodePtr &node, size_t input_idx);
|
||||
// get output shapes which will built and run in device
|
||||
static std::vector<size_t> GetOutputDeviceShape(const AnfNodePtr &node, size_t output_idx);
|
||||
static std::vector<int64_t> GetOutputDeviceShape(const AnfNodePtr &node, size_t output_idx);
|
||||
// get input shapes which will built and run in device
|
||||
static std::vector<size_t> GetInputDeviceShape(const AnfNodePtr &node, size_t input_idx);
|
||||
static std::vector<int64_t> GetInputDeviceShape(const AnfNodePtr &node, size_t input_idx);
|
||||
// get output shapes for tbe build
|
||||
static std::vector<int64_t> GetOutputDeviceShapeForTbeBuild(const AnfNodePtr &node, const size_t output_idx,
|
||||
const std::string &format);
|
||||
|
@ -160,8 +160,8 @@ class BACKEND_EXPORT AnfRuntimeAlgorithm {
|
|||
static std::vector<KernelGraphPtr> GetCallSwitchKernelGraph(const CNodePtr &cnode);
|
||||
static bool IsIndependentNode(const CNodePtr &node);
|
||||
static void InferShape(const CNodePtr &node, std::map<uint32_t, tensor::TensorPtr> *depend_tensors = nullptr);
|
||||
static std::vector<size_t> GetInputDeviceShapeAdaptively(const AnfNodePtr &anf_node, size_t index);
|
||||
static std::vector<size_t> GetOutputDeviceShapeAdaptively(const AnfNodePtr &anf_node, size_t index);
|
||||
static ShapeVector GetInputDeviceShapeAdaptively(const AnfNodePtr &anf_node, size_t index);
|
||||
static ShapeVector GetOutputDeviceShapeAdaptively(const AnfNodePtr &anf_node, size_t index);
|
||||
static KernelGraphPtr FetchKernelGraph(const AnfNodePtr &node);
|
||||
static AnfNodePtr FetchFrontNodeByBackendNode(const AnfNodePtr &backend_node, const KernelGraph &graph);
|
||||
static void InsertMakeTupleForOutput(const NotNull<KernelGraphPtr> &root_graph);
|
||||
|
@ -180,6 +180,7 @@ class BACKEND_EXPORT AnfRuntimeAlgorithm {
|
|||
// Update the shape of internal parameter in the sub graph.
|
||||
static void UpdateInternalParameterShape(const std::map<size_t, std::vector<AnfNodeWeakPtr>> &internal_parameters,
|
||||
const CNodePtr &cnode);
|
||||
static bool IsShapesDynamic(const std::vector<ShapeVector> &shapes);
|
||||
};
|
||||
} // namespace session
|
||||
using AnfAlgo = session::AnfRuntimeAlgorithm;
|
||||
|
|
|
@ -147,10 +147,10 @@ bool AscendInferenceSession::CompareInput(const tensor::TensorPtr &input, const
|
|||
|
||||
// compare shape
|
||||
auto input_shape = input->shape();
|
||||
vector<size_t> trans_input;
|
||||
vector<int64_t> trans_input;
|
||||
(void)std::transform(input_shape.begin(), input_shape.end(), std::back_inserter(trans_input),
|
||||
[](const int64_t dim) { return static_cast<size_t>(dim); });
|
||||
auto is_scalar_shape = [](const vector<size_t> &shape) {
|
||||
auto is_scalar_shape = [](const vector<int64_t> &shape) {
|
||||
return shape.empty() || (shape.size() == 1 && shape[0] == 1);
|
||||
};
|
||||
if ((!is_scalar_shape(trans_input) || !is_scalar_shape(parameter_shape)) && (trans_input != parameter_shape)) {
|
||||
|
|
|
@ -338,11 +338,9 @@ void AscendSession::LoadInputData(const std::shared_ptr<KernelGraph> &kernel_gra
|
|||
continue;
|
||||
} else if (input_param->has_dynamic_shape()) {
|
||||
auto tensor_shape = tensor->shape();
|
||||
std::vector<size_t> shape_tmp;
|
||||
(void)std::transform(tensor_shape.begin(), tensor_shape.end(), std::back_inserter(shape_tmp), LongToSize);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({common::AnfAlgo::GetOutputInferDataType(input_node, 0)}, {shape_tmp},
|
||||
input_node.get());
|
||||
size = abstract::ShapeSize(shape_tmp) * abstract::TypeIdSize(tensor->data_type());
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({common::AnfAlgo::GetOutputInferDataType(input_node, 0)},
|
||||
{tensor_shape}, input_node.get());
|
||||
size = abstract::ShapeSize(tensor_shape) * abstract::TypeIdSize(tensor->data_type());
|
||||
}
|
||||
if (AnfAlgo::OutputAddrExist(input_node, 0) &&
|
||||
TensorNeedSync(kernel_graph, input_node, tensor, &device_memcpy_nums)) {
|
||||
|
@ -1768,9 +1766,7 @@ void AscendSession::UpdateOutputTensors(const VectorRef *outputs,
|
|||
|
||||
if (common::AnfAlgo::IsDynamicShape(node)) {
|
||||
const auto &updated_shape = common::AnfAlgo::GetOutputInferShape(node, output_index);
|
||||
ShapeVector int_shape;
|
||||
(void)std::transform(updated_shape.begin(), updated_shape.end(), std::back_inserter(int_shape), SizeToInt);
|
||||
(void)tensor->set_shape(int_shape);
|
||||
(void)tensor->set_shape(updated_shape);
|
||||
}
|
||||
}
|
||||
if (tensor->NeedSyncDeviceToHostImmediately()) {
|
||||
|
|
|
@ -257,10 +257,8 @@ void CPUSession::UpdateDynamicOutputShape(const std::map<tensor::TensorPtr, Kern
|
|||
const auto &kernel = tensor_node.second.first;
|
||||
const auto &output_index = tensor_node.second.second;
|
||||
const auto &shape = common::AnfAlgo::GetOutputInferShape(kernel, output_index);
|
||||
std::vector<int64_t> refresh_shape;
|
||||
(void)std::copy(shape.begin(), shape.end(), std::back_inserter(refresh_shape));
|
||||
MS_EXCEPTION_IF_NULL(tensor_node.first);
|
||||
tensor_node.first->set_shape(refresh_shape);
|
||||
tensor_node.first->set_shape(shape);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,10 +146,10 @@ bool GpuInferenceSession::CompareInput(const tensor::TensorPtr &input, const Par
|
|||
|
||||
// compare shape
|
||||
auto input_shape = input->shape();
|
||||
vector<size_t> trans_input;
|
||||
vector<int64_t> trans_input;
|
||||
(void)std::transform(input_shape.begin(), input_shape.end(), std::back_inserter(trans_input),
|
||||
[](const int64_t dim) { return static_cast<size_t>(dim); });
|
||||
auto is_scalar_shape = [](const vector<size_t> &shape) {
|
||||
auto is_scalar_shape = [](const vector<int64_t> &shape) {
|
||||
return shape.empty() || (shape.size() == 1 && shape[0] == 1);
|
||||
};
|
||||
if ((!is_scalar_shape(trans_input) || !is_scalar_shape(parameter_shape)) && (trans_input != parameter_shape)) {
|
||||
|
|
|
@ -308,11 +308,9 @@ size_t UpdateGraphInputAbstract(const AnfNodePtr input_node, const tensor::Tenso
|
|||
auto input_param = input_node->cast<ParameterPtr>();
|
||||
if (input_param != nullptr && input_param->has_dynamic_shape()) {
|
||||
auto tensor_shape = tensor->shape();
|
||||
std::vector<size_t> shape_tmp;
|
||||
(void)std::transform(tensor_shape.begin(), tensor_shape.end(), std::back_inserter(shape_tmp), LongToSize);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({common::AnfAlgo::GetOutputInferDataType(input_node, 0)}, {shape_tmp},
|
||||
input_node.get());
|
||||
size = abstract::ShapeSize(shape_tmp) * abstract::TypeIdSize(tensor->data_type());
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({common::AnfAlgo::GetOutputInferDataType(input_node, 0)},
|
||||
{tensor_shape}, input_node.get());
|
||||
size = abstract::ShapeSize(tensor_shape) * abstract::TypeIdSize(tensor->data_type());
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
@ -631,9 +629,7 @@ void GPUSession::UpdateOutputTensors(const VectorRef *outputs,
|
|||
|
||||
if (common::AnfAlgo::IsDynamicShape(node)) {
|
||||
const auto &updated_shape = common::AnfAlgo::GetOutputInferShape(node, output_index);
|
||||
ShapeVector int_shape;
|
||||
std::transform(updated_shape.begin(), updated_shape.end(), std::back_inserter(int_shape), SizeToInt);
|
||||
tensor->set_shape(int_shape);
|
||||
tensor->set_shape(updated_shape);
|
||||
}
|
||||
}
|
||||
if (tensor->NeedSyncDeviceToHostImmediately()) {
|
||||
|
|
|
@ -713,7 +713,7 @@ AnfNodePtr KernelGraph::CreatTupleGetItemNode(const AnfNodePtr &node, size_t out
|
|||
AnfNodePtr tuple_getitem = NewCNode({mindspore::NewValueNode(prim::kPrimTupleGetItem), node, idx});
|
||||
MS_EXCEPTION_IF_NULL(tuple_getitem);
|
||||
tuple_getitem->set_scope(node->scope());
|
||||
std::vector<size_t> origin_shape = common::AnfAlgo::GetOutputInferShape(node, output_idx);
|
||||
auto origin_shape = common::AnfAlgo::GetOutputInferShape(node, output_idx);
|
||||
TypeId origin_type = common::AnfAlgo::GetOutputInferDataType(node, output_idx);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({origin_type}, {origin_shape}, tuple_getitem.get());
|
||||
return tuple_getitem;
|
||||
|
@ -722,7 +722,7 @@ AnfNodePtr KernelGraph::CreatTupleGetItemNode(const AnfNodePtr &node, size_t out
|
|||
AnfNodePtr KernelGraph::TransCNodeTuple(const CNodePtr &node) {
|
||||
MS_EXCEPTION_IF_NULL(node);
|
||||
std::vector<TypeId> types;
|
||||
std::vector<std::vector<size_t>> shapes;
|
||||
std::vector<ShapeVector> shapes;
|
||||
std::vector<AnfNodePtr> make_tuple_inputs_list = {mindspore::NewValueNode(prim::kPrimMakeTuple)};
|
||||
size_t output_num = common::AnfAlgo::GetOutputTensorNum(node);
|
||||
for (size_t tuple_out_index = 0; tuple_out_index < output_num; ++tuple_out_index) {
|
||||
|
|
|
@ -80,12 +80,7 @@ MS_REG_SESSION(kSessionBasic, SessionBasic);
|
|||
namespace {
|
||||
const int kSummaryGetItem = 2;
|
||||
const size_t max_depth = 128;
|
||||
bool IsShapeDynamic(const abstract::ShapePtr &shape) {
|
||||
if (shape == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return std::any_of(shape->shape().begin(), shape->shape().end(), [](int64_t s) { return s < 0; });
|
||||
}
|
||||
|
||||
bool RecursiveCheck(const FuncGraphManagerPtr &manager, const std::pair<AnfNodePtr, int64_t> &kernel, size_t *idx) {
|
||||
auto node = kernel.first;
|
||||
MS_EXCEPTION_IF_NULL(manager);
|
||||
|
@ -203,23 +198,24 @@ BaseRef CreateNodeOutputTensor(const session::KernelWithIndex &node_output_pair,
|
|||
if (type_id == kTypeUnknown) {
|
||||
type_id = common::AnfAlgo::GetOutputInferDataType(node, output_index);
|
||||
}
|
||||
std::vector<int64_t> temp_shape;
|
||||
|
||||
auto shape = common::AnfAlgo::GetOutputInferShape(node, output_index);
|
||||
(void)std::copy(shape.begin(), shape.end(), std::back_inserter(temp_shape));
|
||||
if (common::AnfAlgo::IsDynamicShape(node)) {
|
||||
auto max_shape = common::AnfAlgo::GetOutputMaxShape(node, output_index);
|
||||
temp_shape = abstract::ShapeSize(max_shape) > abstract::ShapeSize(temp_shape) ? max_shape : temp_shape;
|
||||
if (abstract::ShapeSize(max_shape) > abstract::ShapeSize(shape)) {
|
||||
shape = max_shape;
|
||||
}
|
||||
}
|
||||
tensor::TensorPtr tensor;
|
||||
bool is_internal_output = graph->IsInternalOutput(node, output_index);
|
||||
if (is_internal_output) {
|
||||
tensor = graph->GetInternalOutputTensor(node, output_index);
|
||||
if (tensor == nullptr) {
|
||||
tensor = std::make_shared<tensor::Tensor>(type_id, temp_shape);
|
||||
tensor = std::make_shared<tensor::Tensor>(type_id, shape);
|
||||
graph->AddInternalOutputTensor(node, output_index, tensor);
|
||||
}
|
||||
} else {
|
||||
tensor = std::make_shared<tensor::Tensor>(type_id, temp_shape);
|
||||
tensor = std::make_shared<tensor::Tensor>(type_id, shape);
|
||||
}
|
||||
MS_EXCEPTION_IF_NULL(tensor);
|
||||
tensor->set_padding_type(AnfAlgo::GetOutputReshapeType(node, output_index));
|
||||
|
@ -477,7 +473,7 @@ void CheckInputTensorShape(const TensorPtr &tensor, const CNodePtr &kernel, size
|
|||
<< "] of kernel: " << common::AnfAlgo::GetCNodeName(kernel) << trace::DumpSourceLines(kernel);
|
||||
}
|
||||
for (size_t i = 0; i < tensor_shape.size(); i++) {
|
||||
if (tensor_shape[i] < 0 || static_cast<size_t>(tensor_shape[i]) != input_shape[i]) {
|
||||
if (tensor_shape[i] < 0 || tensor_shape[i] != input_shape[i]) {
|
||||
MS_LOG(EXCEPTION) << "The input tensor's shape: " << tensor_shape
|
||||
<< " is not equal to expected shape: " << input_shape << " for input[" << input_index
|
||||
<< "] of kernel: " << common::AnfAlgo::GetCNodeName(kernel) << trace::DumpSourceLines(kernel);
|
||||
|
@ -1292,7 +1288,7 @@ void SessionBasic::SetInputNodeUsage(const KernelGraphPtr &graph, const FuncGrap
|
|||
node_ptr->SetNotUsedByRealKernelInGraph(graph->graph_id());
|
||||
}
|
||||
auto shape = node_ptr->Shape();
|
||||
if (IsShapeDynamic(shape->cast<abstract::ShapePtr>())) {
|
||||
if (AnfUtils::IsShapeDynamic(shape->cast<abstract::ShapePtr>())) {
|
||||
node_ptr->set_has_dynamic_shape(true);
|
||||
}
|
||||
}
|
||||
|
@ -1442,8 +1438,8 @@ void SessionBasic::GetParameterIndex(const KernelGraph *graph, const std::vector
|
|||
<< ") are different, input index: " << index << ", parameter: " << param->DebugString();
|
||||
}
|
||||
for (size_t i = 0; i < input_shape.size(); i += 1) {
|
||||
if (input_shape[i] < 0 || (!is_parallel_forward_ms_function &&
|
||||
static_cast<size_t>(input_shape[i]) != param_shape[i] && !is_dynamic)) {
|
||||
if (input_shape[i] < 0 ||
|
||||
(!is_parallel_forward_ms_function && input_shape[i] != param_shape[i] && !is_dynamic)) {
|
||||
MS_LOG(EXCEPTION) << "Input tensor shape(" << input_shape << ") and parameter shape(" << param_shape
|
||||
<< ") are different, input index: " << index << ", parameter: " << param->DebugString();
|
||||
}
|
||||
|
@ -1916,9 +1912,7 @@ void SessionBasic::UpdateOutputs(const std::shared_ptr<KernelGraph> &kernel_grap
|
|||
<< ", device address " << tensor->device_address().get();
|
||||
if (common::AnfAlgo::IsDynamicShape(node)) {
|
||||
const auto &updated_shape = common::AnfAlgo::GetOutputInferShape(node, output_index);
|
||||
ShapeVector int_shape;
|
||||
(void)std::transform(updated_shape.begin(), updated_shape.end(), std::back_inserter(int_shape), SizeToInt);
|
||||
(void)tensor->set_shape(int_shape);
|
||||
(void)tensor->set_shape(updated_shape);
|
||||
}
|
||||
if (ms_context->get_param<int>(MS_CTX_EXECUTION_MODE) != kPynativeMode) {
|
||||
tensor->data_sync(false);
|
||||
|
@ -2011,9 +2005,7 @@ void SessionBasic::UpdateOutputTensors(const VectorRef *outputs,
|
|||
|
||||
if (common::AnfAlgo::IsDynamicShape(node)) {
|
||||
const auto &updated_shape = common::AnfAlgo::GetOutputInferShape(node, output_index);
|
||||
ShapeVector int_shape;
|
||||
(void)std::transform(updated_shape.begin(), updated_shape.end(), std::back_inserter(int_shape), SizeToInt);
|
||||
(void)tensor->set_shape(int_shape);
|
||||
(void)tensor->set_shape(updated_shape);
|
||||
}
|
||||
}
|
||||
if (tensor->NeedSyncDeviceToHostImmediately()) {
|
||||
|
@ -2041,10 +2033,7 @@ void SessionBasic::GetModelInputsInfo(uint32_t graph_id, std::vector<tensor::Ten
|
|||
}
|
||||
auto parameter = kernel_graph_inputs[i]->cast<ParameterPtr>();
|
||||
if (!common::AnfAlgo::IsParameterWeight(parameter)) {
|
||||
vector<int64_t> input_shape;
|
||||
auto parameter_shape = AnfAlgo::GetOutputDeviceShape(parameter, 0);
|
||||
(void)std::transform(parameter_shape.begin(), parameter_shape.end(), std::back_inserter(input_shape),
|
||||
[](const size_t dim) { return SizeToLong(dim); });
|
||||
vector<int64_t> input_shape = AnfAlgo::GetOutputDeviceShape(parameter, 0);
|
||||
auto kernel_build_info = AnfAlgo::GetSelectKernelBuildInfo(parameter);
|
||||
auto data_type = kernel_build_info->GetOutputDeviceType(0);
|
||||
auto ms_tensor = std::make_shared<tensor::Tensor>(data_type, input_shape);
|
||||
|
@ -2168,9 +2157,7 @@ void SessionBasic::Summary(KernelGraph *graph) {
|
|||
auto address = AnfAlgo::GetOutputAddr(node, index, false);
|
||||
auto shape = common::AnfAlgo::GetOutputInferShape(node, index);
|
||||
TypeId type_id = common::AnfAlgo::GetOutputInferDataType(node, index);
|
||||
std::vector<int64_t> temp_shape;
|
||||
(void)std::copy(shape.begin(), shape.end(), std::back_inserter(temp_shape));
|
||||
tensor::TensorPtr tensor = std::make_shared<tensor::Tensor>(type_id, temp_shape);
|
||||
tensor::TensorPtr tensor = std::make_shared<tensor::Tensor>(type_id, shape);
|
||||
MS_EXCEPTION_IF_NULL(address);
|
||||
if (!address->GetPtr()) {
|
||||
continue;
|
||||
|
@ -2435,7 +2422,7 @@ void SessionBasic::CreateOutputNode(const CNodePtr &cnode, const std::shared_ptr
|
|||
idx->set_abstract(std::make_shared<abstract::AbstractScalar>(imm));
|
||||
auto getitem = graph->NewCNode({NewValueNode(prim::kPrimTupleGetItem), cnode, idx});
|
||||
std::vector<TypeId> types = {common::AnfAlgo::GetOutputInferDataType(cnode, output_index)};
|
||||
std::vector<std::vector<size_t>> shapes = {common::AnfAlgo::GetOutputInferShape(cnode, output_index)};
|
||||
auto shapes = {common::AnfAlgo::GetOutputInferShape(cnode, output_index)};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(types, shapes, getitem.get());
|
||||
make_tuple_inputs.push_back(getitem);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace mindspore {
|
|||
namespace session {
|
||||
std::shared_ptr<session::KernelGraph> SingleKernelGraph::ConstructKernelGraphBasedOnSingleOp(
|
||||
const std::string &op_name, const std::vector<TypeId> &input_dtypes, const std::vector<ShapeVector> &input_shapes,
|
||||
const std::vector<TypeId> &output_dtypes, const std::vector<std::vector<size_t>> &output_shapes) {
|
||||
const std::vector<TypeId> &output_dtypes, const std::vector<ShapeVector> &output_shapes) {
|
||||
auto graph = std::make_shared<session::KernelGraph>();
|
||||
MS_EXCEPTION_IF_NULL(graph);
|
||||
std::vector<AnfNodePtr> inputs;
|
||||
|
|
|
@ -31,7 +31,7 @@ class SingleKernelGraph {
|
|||
|
||||
static std::shared_ptr<session::KernelGraph> ConstructKernelGraphBasedOnSingleOp(
|
||||
const std::string &op_name, const std::vector<TypeId> &input_dtypes, const std::vector<ShapeVector> &input_shapes,
|
||||
const std::vector<TypeId> &output_dtypes, const std::vector<std::vector<size_t>> &output_shapes);
|
||||
const std::vector<TypeId> &output_dtypes, const std::vector<ShapeVector> &output_shapes);
|
||||
};
|
||||
} // namespace session
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -308,10 +308,8 @@ TensorPtr CreateOutputTensor(const AnfNodePtr &output_node, size_t output_index)
|
|||
// Create host tensor, the output tensor should use the infer type, it will be handed correctly by tensor data sync
|
||||
// when infer type is not equal to device type.
|
||||
auto type_id = common::AnfAlgo::GetOutputInferDataType(output_node, output_index);
|
||||
std::vector<int64_t> temp_shape;
|
||||
const auto &shape = common::AnfAlgo::GetOutputInferShape(output_node, output_index);
|
||||
(void)std::copy(shape.begin(), shape.end(), std::back_inserter(temp_shape));
|
||||
auto tensor = std::make_shared<tensor::Tensor>(type_id, temp_shape);
|
||||
auto tensor = std::make_shared<tensor::Tensor>(type_id, shape);
|
||||
tensor->set_padding_type(AnfAlgo::GetOutputReshapeType(output_node, output_index));
|
||||
|
||||
// Put device tensor into host tensor.
|
||||
|
|
|
@ -34,31 +34,19 @@
|
|||
namespace mindspore::graphkernel {
|
||||
GRAPH_KERNEL_CALLBACK_REGISTER(CallbackImpl);
|
||||
ShapeVector CallbackImpl::GetInputShape(const AnfNodePtr &node, size_t i) {
|
||||
auto vec = AnfAlgo::GetInputDeviceShape(node, i);
|
||||
ShapeVector ret;
|
||||
(void)std::transform(vec.begin(), vec.end(), std::back_inserter(ret), SizeToLong);
|
||||
return ret;
|
||||
return AnfAlgo::GetInputDeviceShape(node, i);
|
||||
}
|
||||
|
||||
ShapeVector CallbackImpl::GetOutputShape(const AnfNodePtr &node, size_t i) {
|
||||
auto vec = AnfAlgo::GetOutputDeviceShape(node, i);
|
||||
ShapeVector ret;
|
||||
(void)std::transform(vec.begin(), vec.end(), std::back_inserter(ret), SizeToLong);
|
||||
return ret;
|
||||
return AnfAlgo::GetOutputDeviceShape(node, i);
|
||||
}
|
||||
|
||||
ShapeVector CallbackImpl::GetInputInferShape(const AnfNodePtr &node, size_t i) {
|
||||
auto vec = common::AnfAlgo::GetPrevNodeOutputInferShape(node, i);
|
||||
ShapeVector ret;
|
||||
(void)std::transform(vec.begin(), vec.end(), std::back_inserter(ret), SizeToLong);
|
||||
return ret;
|
||||
return common::AnfAlgo::GetPrevNodeOutputInferShape(node, i);
|
||||
}
|
||||
|
||||
ShapeVector CallbackImpl::GetOutputInferShape(const AnfNodePtr &node, size_t i) {
|
||||
auto vec = common::AnfAlgo::GetOutputInferShape(node, i);
|
||||
ShapeVector ret;
|
||||
(void)std::transform(vec.begin(), vec.end(), std::back_inserter(ret), SizeToLong);
|
||||
return ret;
|
||||
return common::AnfAlgo::GetOutputInferShape(node, i);
|
||||
}
|
||||
|
||||
TypeId CallbackImpl::GetInputType(const AnfNodePtr &node, size_t i) { return AnfAlgo::GetInputDeviceDataType(node, i); }
|
||||
|
@ -235,7 +223,7 @@ ShapeVector CallbackImplWithInferShape::GetInputShape(const AnfNodePtr &node, si
|
|||
}
|
||||
|
||||
ShapeVector CallbackImplWithInferShape::GetOutputShape(const AnfNodePtr &node, size_t i) {
|
||||
return CallbackImpl::GetOutputInferShape(node, i);
|
||||
return common::AnfAlgo::GetOutputInferShape(node, i);
|
||||
}
|
||||
|
||||
TypeId CallbackImplWithInferShape::GetInputType(const AnfNodePtr &node, size_t i) {
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
namespace mindspore::graphkernel {
|
||||
// Add CastCNode
|
||||
CNodePtr AddCastCNode(const FuncGraphPtr &func_graph, const AnfNodePtr &input, const std::string &format,
|
||||
const TypeId &input_type, const TypeId &output_type, const std::vector<size_t> &origin_shape,
|
||||
const TypeId &input_type, const TypeId &output_type, const ShapeVector &origin_shape,
|
||||
const TypeId &origin_type) {
|
||||
MS_EXCEPTION_IF_NULL(func_graph);
|
||||
CNodePtr cast = func_graph->NewCNode({NewValueNode(std::make_shared<Primitive>(prim::kPrimCast->name())), input});
|
||||
|
|
|
@ -293,14 +293,8 @@ ShapeVector GetShape(const AnfNodePtr &node) {
|
|||
}
|
||||
|
||||
ShapeVector GetDeviceShape(const AnfNodePtr &node) {
|
||||
ShapeVector res_device_shape;
|
||||
auto device_shape = AnfAlgo::GetOutputDeviceShape(node, 0);
|
||||
if (device_shape.empty()) {
|
||||
res_device_shape.push_back(1);
|
||||
} else {
|
||||
(void)std::transform(device_shape.begin(), device_shape.end(), std::back_inserter(res_device_shape), SizeToLong);
|
||||
}
|
||||
return res_device_shape;
|
||||
ShapeVector res_device_shape = AnfAlgo::GetOutputDeviceShape(node, 0);
|
||||
return res_device_shape.empty() ? ShapeVector({1}) : res_device_shape;
|
||||
}
|
||||
|
||||
std::vector<int64_t> GetReduceAxis(const AnfNodePtr &node) {
|
||||
|
|
|
@ -28,7 +28,7 @@ GVAR_DEF(PrimitivePtr, kPrimPadAkg, std::make_shared<Primitive>("PadAkg"));
|
|||
} // namespace prim
|
||||
namespace graphkernel {
|
||||
namespace {
|
||||
using vec = std::vector<size_t>;
|
||||
using vec = std::vector<int64_t>;
|
||||
constexpr size_t MAX_PER_DIM_SHAPE = 4096;
|
||||
constexpr int64_t MAX_ALL_SHAPE = static_cast<int64_t>(3e10);
|
||||
|
||||
|
|
|
@ -36,28 +36,26 @@ namespace {
|
|||
* after: keep_dims=True, axis=(1) ,out_shape=(a,1,b,c)
|
||||
*/
|
||||
void ResetReduceAttrAndShape(const AnfNodePtr &node, const std::vector<TypeId> &target_output_types,
|
||||
const std::vector<std::vector<size_t>> &target_output_shapes) {
|
||||
const std::vector<ShapeVector> &target_output_shapes) {
|
||||
common::AnfAlgo::SetNodeAttr(kAttrKeepDims, MakeValue(true), node);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(target_output_types, target_output_shapes, node.get());
|
||||
}
|
||||
|
||||
size_t ProcessTupleGetItem(const AnfNodePtr &node, const std::vector<TypeId> &target_output_types,
|
||||
const std::vector<std::vector<size_t>> &target_output_shapes) {
|
||||
const std::vector<ShapeVector> &target_output_shapes) {
|
||||
size_t index = common::AnfAlgo::GetTupleGetItemOutIndex(node->cast<CNodePtr>());
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({target_output_types[index]}, {target_output_shapes[index]}, node.get());
|
||||
return index;
|
||||
}
|
||||
|
||||
void InsertReshape(const FuncGraphPtr &graph, const AnfNodePtr &node, const TypeId &infer_type,
|
||||
const std::vector<size_t> &infer_shape, const TypeId &device_type) {
|
||||
const ShapeVector &infer_shape, const TypeId &device_type) {
|
||||
auto manager = graph->manager();
|
||||
MS_EXCEPTION_IF_NULL(manager);
|
||||
std::vector<AnfNodePtr> inputs = {NewValueNode(std::make_shared<Primitive>(prim::kPrimReshape->name())), node};
|
||||
auto reshape = graph->NewCNode(inputs);
|
||||
MS_EXCEPTION_IF_NULL(reshape);
|
||||
std::vector<int64_t> reshape_size;
|
||||
(void)std::transform(infer_shape.begin(), infer_shape.end(), std::back_inserter(reshape_size), SizeToLong);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrShape, MakeValue(reshape_size), reshape);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrShape, MakeValue(infer_shape), reshape);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({infer_type}, {infer_shape}, reshape.get());
|
||||
auto graph_sel_info =
|
||||
BuildSelectKernelBuildInfo({kOpFormat_DEFAULT}, {device_type}, {kOpFormat_DEFAULT}, {device_type});
|
||||
|
@ -66,8 +64,8 @@ void InsertReshape(const FuncGraphPtr &graph, const AnfNodePtr &node, const Type
|
|||
}
|
||||
|
||||
void InsertReshapeForMultiOutputs(const FuncGraphPtr &graph, const AnfNodePtr &node,
|
||||
const std::vector<std::vector<size_t>> &origin_output_shapes,
|
||||
const std::vector<std::vector<size_t>> &target_output_shapes,
|
||||
const std::vector<ShapeVector> &origin_output_shapes,
|
||||
const std::vector<ShapeVector> &target_output_shapes,
|
||||
const std::vector<TypeId> &target_output_types, const AnfNodePtr &target) {
|
||||
auto used_node_list = opt::GetRealNodeUsedList(graph, node);
|
||||
MS_EXCEPTION_IF_NULL(used_node_list);
|
||||
|
@ -154,12 +152,12 @@ bool ReshapeReduceForCSE::Run(const FuncGraphPtr &graph) {
|
|||
<< target_output_num << ".";
|
||||
}
|
||||
|
||||
std::vector<std::vector<size_t>> origin_output_shapes;
|
||||
std::vector<ShapeVector> origin_output_shapes;
|
||||
for (size_t i = 0; i < output_num; i++) {
|
||||
(void)origin_output_shapes.emplace_back(common::AnfAlgo::GetOutputInferShape(node, i));
|
||||
}
|
||||
|
||||
std::vector<std::vector<size_t>> target_output_shapes;
|
||||
std::vector<ShapeVector> target_output_shapes;
|
||||
std::vector<TypeId> target_output_types;
|
||||
for (size_t i = 0; i < target_output_num; i++) {
|
||||
(void)target_output_shapes.emplace_back(common::AnfAlgo::GetOutputInferShape(target, i));
|
||||
|
|
|
@ -47,8 +47,6 @@ AnfNodePtr DropoutExpanderDeco::Run(const AnfNodePtr &node) {
|
|||
auto func_graph = node->func_graph();
|
||||
CheckCNodeInputSize(cnode, kDropoutInputTensorNum);
|
||||
auto shape = AnfAlgo::GetInputDeviceShape(cnode, 0);
|
||||
ShapeVector shape_i64;
|
||||
(void)std::transform(shape.begin(), shape.end(), std::back_inserter(shape_i64), SizeToLong);
|
||||
// Get seed from original dropout's attrs, rather than set seed by time.
|
||||
// Only seed0 and seed1 are all equal to 0, then set seed = time.
|
||||
auto node_prim = GetCNodePrimitive(node);
|
||||
|
@ -69,7 +67,7 @@ AnfNodePtr DropoutExpanderDeco::Run(const AnfNodePtr &node) {
|
|||
auto uniform_real_node = func_graph->NewCNode(uniform_real_input);
|
||||
SetNodeAttrSafely("seed", MakeValue(seed), uniform_real_node);
|
||||
common::AnfAlgo::SetNodeAttr("seed2", MakeValue(static_cast<int64_t>(0)), uniform_real_node);
|
||||
uniform_real_node->set_abstract(std::make_shared<abstract::AbstractTensor>(kFloat32, shape_i64));
|
||||
uniform_real_node->set_abstract(std::make_shared<abstract::AbstractTensor>(kFloat32, shape));
|
||||
// Set kernel_info for uniform_real node
|
||||
auto uniform_real_kernel_info_builder = std::make_shared<kernel::KernelBuildInfo::KernelBuildInfoBuilder>();
|
||||
uniform_real_kernel_info_builder->SetInputsFormat({kOpFormat_DEFAULT});
|
||||
|
|
|
@ -71,9 +71,8 @@ int64_t MemReuseChecker::CalculOriInput(const KernelGraph *graph) const {
|
|||
ou_type = common::AnfAlgo::GetOutputInferDataType(item, index);
|
||||
}
|
||||
size_t type_size = GetTypeByte(TypeIdToType(ou_type));
|
||||
std::vector<size_t> shape = AnfAlgo::GetOutputDeviceShape(item, index);
|
||||
size_t tensor_size =
|
||||
shape.empty() ? type_size : std::accumulate(shape.begin(), shape.end(), type_size, std::multiplies<size_t>());
|
||||
auto shape = AnfAlgo::GetOutputDeviceShape(item, index);
|
||||
size_t tensor_size = type_size * SizeOf(shape);
|
||||
auto checker_size = SizeToLong(tensor_size);
|
||||
static_input_size += checker_size;
|
||||
}
|
||||
|
|
|
@ -89,9 +89,7 @@ void GetDumpIntShape(const AnfNodePtr &node, size_t index, NotNull<ShapeVector *
|
|||
if (trans_flag) {
|
||||
*int_shapes = trans::GetRuntimePaddingShape(node, index);
|
||||
} else {
|
||||
auto shape = AnfAlgo::GetOutputDeviceShape(node, index);
|
||||
(void)std::transform(shape.begin(), shape.end(), std::back_inserter(*int_shapes),
|
||||
[](size_t inner_item) { return SizeToInt(inner_item); });
|
||||
*int_shapes = AnfAlgo::GetOutputDeviceShape(node, index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class FedAvgKernel : public AggregationKernelMod {
|
|||
return;
|
||||
}
|
||||
cnode_weight_idx_ = kNameToIdxMap.at(cnode_name).at("inputs").at("weight");
|
||||
std::vector<size_t> weight_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, cnode_weight_idx_);
|
||||
auto weight_shape = Convert2SizeT(common::AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, cnode_weight_idx_));
|
||||
size_t weight_size =
|
||||
std::accumulate(weight_shape.begin(), weight_shape.end(), sizeof(T), std::multiplies<size_t>());
|
||||
size_t new_weight_size = weight_size;
|
||||
|
|
|
@ -70,14 +70,20 @@ class OptimizerKernelMod : public DeprecatedNativeCpuKernelMod {
|
|||
size_t input_num = common::AnfAlgo::GetInputTensorNum(kernel_node);
|
||||
size_t type_size = sizeof(float);
|
||||
for (size_t input_index = 0; input_index < input_num; ++input_index) {
|
||||
std::vector<size_t> shape = common::AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, input_index);
|
||||
auto shape = common::AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, input_index);
|
||||
if (IsDynamic(shape)) {
|
||||
MS_LOG(EXCEPTION) << "Shape[" << shape << "] contains negative value and fails to calculate tensor_size";
|
||||
}
|
||||
size_t tensor_size =
|
||||
shape.empty() ? type_size : std::accumulate(shape.begin(), shape.end(), type_size, std::multiplies<size_t>());
|
||||
input_size_list_.emplace_back(tensor_size);
|
||||
}
|
||||
size_t output_num = common::AnfAlgo::GetOutputTensorNum(kernel_node);
|
||||
for (size_t output_index = 0; output_index < output_num; ++output_index) {
|
||||
std::vector<size_t> shape = common::AnfAlgo::GetOutputInferShape(kernel_node, output_index);
|
||||
auto shape = common::AnfAlgo::GetOutputInferShape(kernel_node, output_index);
|
||||
if (IsDynamic(shape)) {
|
||||
MS_LOG(EXCEPTION) << "Shape[" << shape << "] contains negative value and fails to calculate tensor_size";
|
||||
}
|
||||
size_t tensor_size =
|
||||
shape.empty() ? type_size : std::accumulate(shape.begin(), shape.end(), type_size, std::multiplies<size_t>());
|
||||
output_size_list_.emplace_back(tensor_size);
|
||||
|
|
|
@ -79,11 +79,11 @@ CNodePtr CreateOneHot(const FuncGraphPtr &graph, const CNodePtr &sparse_softmax_
|
|||
MS_EXCEPTION_IF_NULL(graph);
|
||||
MS_EXCEPTION_IF_NULL(sparse_softmax_node);
|
||||
|
||||
std::vector<size_t> logits_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(sparse_softmax_node, 0);
|
||||
auto logits_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(sparse_softmax_node, 0);
|
||||
int64_t depth = 0;
|
||||
if (!logits_shape.empty()) {
|
||||
size_t index = logits_shape.size() - 1;
|
||||
depth = SizeToLong(logits_shape[index]);
|
||||
depth = logits_shape[index];
|
||||
} else {
|
||||
MS_LOG(EXCEPTION) << "Logits's shape of node [" << sparse_softmax_node->DebugString() << "] is empty"
|
||||
<< trace::DumpSourceLines(sparse_softmax_node);
|
||||
|
@ -114,18 +114,17 @@ CNodePtr CreateOneHot(const FuncGraphPtr &graph, const CNodePtr &sparse_softmax_
|
|||
auto one_hot_node = graph->NewCNode(one_hot_inputs);
|
||||
MS_EXCEPTION_IF_NULL(one_hot_node);
|
||||
one_hot_node->set_scope(sparse_softmax_node->scope());
|
||||
std::vector<size_t> labels_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(sparse_softmax_node, 1);
|
||||
auto labels_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(sparse_softmax_node, 1);
|
||||
labels_shape.emplace_back(depth);
|
||||
if (AnfUtils::IsShapeDynamic(labels_shape)) {
|
||||
if (IsDynamic(labels_shape)) {
|
||||
auto kernel_info = common::AnfAlgo::GetPrevNodeOutput(sparse_softmax_node, 1);
|
||||
auto min_shape = common::AnfAlgo::GetOutputMinShape(kernel_info.first, kernel_info.second);
|
||||
auto max_shape = common::AnfAlgo::GetOutputMaxShape(kernel_info.first, kernel_info.second);
|
||||
std::vector<int64_t> shape_tmp;
|
||||
std::transform(labels_shape.begin(), labels_shape.end(), std::back_inserter(shape_tmp), SizeToLong);
|
||||
min_shape.emplace_back(depth);
|
||||
max_shape.emplace_back(depth);
|
||||
common::AnfAlgo::SetOutputTypeAndDetailShape(
|
||||
{kNumberTypeFloat32}, {std::make_shared<abstract::Shape>(shape_tmp, min_shape, max_shape)}, one_hot_node.get());
|
||||
{kNumberTypeFloat32}, {std::make_shared<abstract::Shape>(labels_shape, min_shape, max_shape)},
|
||||
one_hot_node.get());
|
||||
} else {
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({kNumberTypeFloat32}, {labels_shape}, one_hot_node.get());
|
||||
}
|
||||
|
@ -144,8 +143,8 @@ CNodePtr CreateSoftmaxCrossEntropyWithLogits(const FuncGraphPtr &graph, const CN
|
|||
MS_EXCEPTION_IF_NULL(softmax_node);
|
||||
softmax_node->set_scope(sparse_softmax_node->scope());
|
||||
|
||||
std::vector<size_t> labels_shape = common::AnfAlgo::GetOutputInferShape(one_hot_node, 0);
|
||||
std::vector<size_t> loss_shape;
|
||||
auto labels_shape = common::AnfAlgo::GetOutputInferShape(one_hot_node, 0);
|
||||
ShapeVector loss_shape;
|
||||
if (!labels_shape.empty()) {
|
||||
loss_shape.emplace_back(labels_shape[0]);
|
||||
} else {
|
||||
|
@ -154,19 +153,18 @@ CNodePtr CreateSoftmaxCrossEntropyWithLogits(const FuncGraphPtr &graph, const CN
|
|||
|
||||
auto data_types = common::AnfAlgo::GetOutputInferDataType(one_hot_node, 0);
|
||||
auto types = {data_types, data_types};
|
||||
if (AnfUtils::IsShapeDynamic(labels_shape)) {
|
||||
ShapeVector shape_tmp = {static_cast<int64_t>(labels_shape[0])};
|
||||
if (IsDynamic(labels_shape)) {
|
||||
auto min_shape = common::AnfAlgo::GetOutputMinShape(one_hot_node, 0);
|
||||
auto max_shape = common::AnfAlgo::GetOutputMaxShape(one_hot_node, 0);
|
||||
std::vector<BaseShapePtr> shapes;
|
||||
if (!min_shape.empty() && !max_shape.empty()) {
|
||||
shapes = {std::make_shared<abstract::Shape>(shape_tmp, ShapeVector(min_shape[0]), ShapeVector(max_shape[0])),
|
||||
shapes = {std::make_shared<abstract::Shape>(ShapeVector({labels_shape[0]}), ShapeVector(min_shape[0]),
|
||||
ShapeVector(max_shape[0])),
|
||||
common::AnfAlgo::GetOutputDetailShape(one_hot_node, 0)};
|
||||
} else {
|
||||
shapes = {std::make_shared<abstract::Shape>(shape_tmp, ShapeVector({}), ShapeVector({})),
|
||||
shapes = {std::make_shared<abstract::Shape>(ShapeVector({labels_shape[0]})),
|
||||
common::AnfAlgo::GetOutputDetailShape(one_hot_node, 0)};
|
||||
}
|
||||
|
||||
common::AnfAlgo::SetOutputTypeAndDetailShape(types, shapes, softmax_node.get());
|
||||
} else {
|
||||
// Loss shape:(N,) labels shape:(N,C)
|
||||
|
@ -201,7 +199,7 @@ void CreateMultiOutputsOfAnfNode(const FuncGraphPtr &func_graph, const AnfNodePt
|
|||
|
||||
std::vector<int64_t> GetAxis(const AnfNodePtr &node) {
|
||||
MS_EXCEPTION_IF_NULL(node);
|
||||
std::vector<size_t> output_shape = common::AnfAlgo::GetOutputInferShape(node, 0);
|
||||
auto output_shape = common::AnfAlgo::GetOutputInferShape(node, 0);
|
||||
if (output_shape.empty()) {
|
||||
MS_LOG(EXCEPTION) << node->fullname_with_scope() << "'s output shape is empty" << trace::DumpSourceLines(node);
|
||||
}
|
||||
|
@ -297,10 +295,7 @@ CNodePtr CreateTile(const FuncGraphPtr &graph, const CNodePtr &sparse_softmax_no
|
|||
CheckCNodeInputSize(sparse_softmax_node, kSparseSoftmaxCrossEntropyWithLogitsInputTensorsNum);
|
||||
CheckCNodeInputSize(mul_node, kMulInputTensorNum);
|
||||
|
||||
auto labels_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(sparse_softmax_node, 1);
|
||||
std::vector<int64_t> multiple_value;
|
||||
std::transform(labels_shape.begin(), labels_shape.end(), std::back_inserter(multiple_value),
|
||||
[](size_t label) { return static_cast<int64_t>(label); });
|
||||
auto multiple_value = common::AnfAlgo::GetPrevNodeOutputInferShape(sparse_softmax_node, 1);
|
||||
if (std::all_of(multiple_value.begin(), multiple_value.end(), [](int64_t value) { return value == 1; })) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -337,7 +332,7 @@ CNodePtr CreateRealDiv(const FuncGraphPtr &graph, const CNodePtr &sparse_softmax
|
|||
MS_EXCEPTION_IF_NULL(sparse_softmax_node);
|
||||
MS_EXCEPTION_IF_NULL(tile_node);
|
||||
CheckCNodeInputSize(sparse_softmax_node, kSparseSoftmaxCrossEntropyWithLogitsInputTensorsNum);
|
||||
std::vector<size_t> labels_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(sparse_softmax_node, 1);
|
||||
auto labels_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(sparse_softmax_node, 1);
|
||||
if (labels_shape.size() != 1) {
|
||||
MS_LOG(EXCEPTION) << "Label's shape should be 1-D, but got " << labels_shape.size()
|
||||
<< trace::DumpSourceLines(sparse_softmax_node);
|
||||
|
@ -388,17 +383,15 @@ CNodePtr CreateExpandDims(const FuncGraphPtr &graph, const CNodePtr &real_div_no
|
|||
MS_EXCEPTION_IF_NULL(expand_dims_node);
|
||||
|
||||
expand_dims_node->set_scope(real_div_node->scope());
|
||||
std::vector<size_t> y_shape = common::AnfAlgo::GetOutputInferShape(real_div_node, 0);
|
||||
auto y_shape = common::AnfAlgo::GetOutputInferShape(real_div_node, 0);
|
||||
y_shape.emplace_back(1);
|
||||
if (AnfUtils::IsShapeDynamic(y_shape)) {
|
||||
if (IsDynamic(y_shape)) {
|
||||
auto min_shape = common::AnfAlgo::GetOutputMinShape(real_div_node, 0);
|
||||
auto max_shape = common::AnfAlgo::GetOutputMaxShape(real_div_node, 0);
|
||||
min_shape.emplace_back(1);
|
||||
max_shape.emplace_back(1);
|
||||
std::vector<int64_t> shape_tmp;
|
||||
std::transform(y_shape.begin(), y_shape.end(), std::back_inserter(shape_tmp), SizeToLong);
|
||||
common::AnfAlgo::SetOutputTypeAndDetailShape({common::AnfAlgo::GetOutputInferDataType(real_div_node, 0)},
|
||||
{std::make_shared<abstract::Shape>(shape_tmp, min_shape, max_shape)},
|
||||
{std::make_shared<abstract::Shape>(y_shape, min_shape, max_shape)},
|
||||
expand_dims_node.get());
|
||||
} else {
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({common::AnfAlgo::GetOutputInferDataType(real_div_node, 0)}, {y_shape},
|
||||
|
|
|
@ -116,7 +116,7 @@ void PsEmbeddingCacheInserter::GetEmbeddingLookupNodes() {
|
|||
int64_t rank_id_attr = GetValue<int64_t>(prim->GetAttr(distributed::kOpLabelRankId));
|
||||
std::string node_role_attr = GetValue<std::string>(prim->GetAttr(distributed::kOpLabelRole));
|
||||
if (rank_id_attr == rank_id_ && node_role_attr == node_role_) {
|
||||
std::vector<size_t> shape = common::AnfAlgo::GetPrevNodeOutputInferShape(node, 0);
|
||||
auto shape = common::AnfAlgo::GetPrevNodeOutputInferShape(node, 0);
|
||||
shapes_to_nodes_[shape] = node;
|
||||
}
|
||||
});
|
||||
|
@ -329,12 +329,12 @@ FuncGraphPtr PsEmbeddingCacheInserter::ConstructUpdateEmbeddingSubGraph(const Pa
|
|||
|
||||
ParameterPtr update_values = graph->add_parameter();
|
||||
MS_EXCEPTION_IF_NULL(update_values);
|
||||
std::vector<size_t> emb_shape = common::AnfAlgo::GetOutputInferShape(param, 0);
|
||||
auto emb_shape = common::AnfAlgo::GetOutputInferShape(param, 0);
|
||||
if (emb_shape.size() != kEmbeddingTableDims) {
|
||||
MS_LOG(EXCEPTION) << "Embedding table should be 2 dims for embedding cache mode, but got: " << emb_shape.size()
|
||||
<< " dims";
|
||||
}
|
||||
int64_t emb_dim = SizeToLong(emb_shape.back());
|
||||
int64_t emb_dim = emb_shape.back();
|
||||
ShapeVector update_values_shape = {-1, emb_dim};
|
||||
ShapeVector update_values_min_shape = {1, emb_dim};
|
||||
ShapeVector update_values_max_shape = {1, emb_dim};
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "ir/anf.h"
|
||||
#include "distributed/constants.h"
|
||||
#include "utils/shape_utils.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace parallel {
|
||||
|
@ -107,7 +108,7 @@ class PsEmbeddingCacheInserter {
|
|||
|
||||
// Record EmbeddingLookup nodes which are executed on server from origin function graph.
|
||||
// Key: shape of EmbeddingLookup node, Value: EmbeddingLookup AnfNodePtr.
|
||||
std::map<std::vector<size_t>, AnfNodePtr> shapes_to_nodes_;
|
||||
std::map<ShapeVector, AnfNodePtr> shapes_to_nodes_;
|
||||
};
|
||||
} // namespace parallel
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <utility>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include "ir/anf.h"
|
||||
#include "ir/func_graph.h"
|
||||
|
@ -111,11 +112,11 @@ class COMMON_EXPORT AnfAlgo {
|
|||
// from std::vector<size_t> to ShapeVector
|
||||
static ShapeVector GetOutputInferShapeSigned(const AnfNodePtr &node, size_t output_idx);
|
||||
// get output shapes inferred by ME from input nodes.
|
||||
static std::vector<size_t> GetOutputInferShape(const AnfNodePtr &node, size_t output_idx);
|
||||
static std::vector<size_t> GetOutputInferShape(const AnfNodePtr &node, const abstract::BaseShapePtr &base_shape,
|
||||
size_t output_idx);
|
||||
static ShapeVector GetOutputInferShape(const AnfNodePtr &node, size_t output_idx);
|
||||
static ShapeVector GetOutputInferShape(const AnfNodePtr &node, const abstract::BaseShapePtr &base_shape,
|
||||
size_t output_idx);
|
||||
// get input shapes inferred by ME from input nodes.
|
||||
static std::vector<size_t> GetPrevNodeOutputInferShape(const AnfNodePtr &node, size_t input_idx);
|
||||
static ShapeVector GetPrevNodeOutputInferShape(const AnfNodePtr &node, size_t input_idx);
|
||||
// get output data type inferred by ME of anf node
|
||||
static TypeId GetOutputInferDataType(const AnfNodePtr &node, size_t output_idx);
|
||||
static TypeId GetOutputInferDataType(const TypePtr &type_ptr, size_t output_idx);
|
||||
|
@ -125,8 +126,8 @@ class COMMON_EXPORT AnfAlgo {
|
|||
// get output original data type from prev node,input_index is the input index of current node related to prev node
|
||||
static TypeId GetPrevNodeOutputInferDataType(const AnfNodePtr &node, size_t input_idx);
|
||||
// set infer shapes and types of anf node
|
||||
static void SetOutputInferTypeAndShape(const std::vector<TypeId> &types,
|
||||
const std::vector<std::vector<size_t>> &shapes, AnfNode *node);
|
||||
static void SetOutputInferTypeAndShape(const std::vector<TypeId> &types, const std::vector<ShapeVector> &shapes,
|
||||
AnfNode *node);
|
||||
// get and set output shape ptr
|
||||
static abstract::BaseShapePtr GetOutputDetailShape(const AnfNodePtr &node, size_t output_idx);
|
||||
static abstract::BaseShapePtr GetPrevNodeOutputDetailShape(const AnfNodePtr &node, size_t input_idx);
|
||||
|
@ -184,15 +185,31 @@ class COMMON_EXPORT AnfAlgo {
|
|||
// Get node real inputs, skip `MakeTuple`, `TupleGetItem`, `Depend`, `Load`, `UpdateState` etc.
|
||||
static void GetRealInputs(const AnfNodePtr &anf_node, std::vector<KernelWithIndex> *inputs);
|
||||
// Check whether tensors need broadcast or not.
|
||||
static bool IsTensorBroadcast(const std::vector<size_t> &lhs, const std::vector<size_t> &rhs);
|
||||
template <typename T>
|
||||
static inline bool IsTensorBroadcast(const std::vector<T> &lhs, const std::vector<T> &rhs) {
|
||||
if (lhs.size() != rhs.size()) {
|
||||
return true;
|
||||
}
|
||||
for (size_t i = 0; i < lhs.size(); i++) {
|
||||
if (lhs[i] != rhs[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Calc tensor size in byte.
|
||||
template <typename T>
|
||||
static size_t TensorSizeInByte(const std::vector<int64_t> &shape) {
|
||||
return sizeof(T) * SizeOf(shape);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static size_t TensorSizeInByte(const std::vector<size_t> &shape) {
|
||||
size_t result = sizeof(T);
|
||||
for (size_t i = 0; i < shape.size(); i++) {
|
||||
result *= shape[i];
|
||||
}
|
||||
return result;
|
||||
size_t res = sizeof(T);
|
||||
res = std::accumulate(shape.begin(), shape.end(), res, std::multiplies<size_t>());
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// Judge a control operator need be compiled into kernel graph rather than be cut into single op and
|
||||
|
|
|
@ -119,7 +119,7 @@ abstract::BaseShapePtr GetValidShapeFromAbstract(const abstract::AbstractBasePtr
|
|||
}
|
||||
|
||||
KernelTensorPtr CreateKernelTensor(const abstract::AbstractBasePtr &cur_abstract, const TypeId &real_type, size_t idx,
|
||||
const std::vector<size_t> &device_shape_adaptively, const std::string &format_str) {
|
||||
const ShapeVector &device_shape_adaptively, const std::string &format_str) {
|
||||
auto tag_abstract = cur_abstract->Clone();
|
||||
if (cur_abstract->isa<abstract::AbstractTuple>()) {
|
||||
auto abs_tuple = cur_abstract->Clone()->cast<abstract::AbstractTuplePtr>();
|
||||
|
@ -130,12 +130,9 @@ KernelTensorPtr CreateKernelTensor(const abstract::AbstractBasePtr &cur_abstract
|
|||
}
|
||||
|
||||
TypePtr tag_type_ptr = TypeIdToType(real_type);
|
||||
ShapeVector tag_shape;
|
||||
(void)std::transform(device_shape_adaptively.begin(), device_shape_adaptively.end(), std::back_inserter(tag_shape),
|
||||
SizeToLong);
|
||||
auto abstract_shape_ptr = GetValidShapeFromAbstract(tag_abstract);
|
||||
auto new_abstract = std::make_shared<abstract::AbstractTensor>(tag_type_ptr, abstract_shape_ptr);
|
||||
TensorInfo tensor_info{GetFormatFromStrToEnum(format_str), new_abstract, tag_shape};
|
||||
TensorInfo tensor_info{GetFormatFromStrToEnum(format_str), new_abstract, device_shape_adaptively};
|
||||
KernelTensorPtr res_tensor = std::make_shared<KernelTensor>();
|
||||
res_tensor->SetTensorInfo(tensor_info);
|
||||
return res_tensor;
|
||||
|
@ -553,19 +550,7 @@ std::string GetProcessor(const AnfNodePtr &anf_node) {
|
|||
return device;
|
||||
}
|
||||
|
||||
bool IsSameShape(const std::vector<size_t> &shape_a, const std::vector<size_t> &shape_b) {
|
||||
if (shape_a.size() != shape_b.size()) {
|
||||
return false;
|
||||
}
|
||||
for (size_t i = 0; i < shape_a.size(); ++i) {
|
||||
if (shape_a[i] != shape_b[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsSameShape(const std::vector<int64_t> &shape_a, const std::vector<int64_t> &shape_b) {
|
||||
bool IsSameShape(const ShapeVector &shape_a, const ShapeVector &shape_b) {
|
||||
if (shape_a.size() != shape_b.size()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -696,11 +681,11 @@ std::vector<int64_t> GetReduceAttrAxis(const CNodePtr &cnode) {
|
|||
}
|
||||
|
||||
void FillEmptyDims(const CNodePtr &kernel_node, std::vector<int64_t> *begin, std::vector<int64_t> *end,
|
||||
std::vector<int64_t> *stride, std::vector<size_t> *input_shape) {
|
||||
std::vector<int64_t> *stride, ShapeVector *input_shape) {
|
||||
std::vector<int64_t> &_begin = *begin;
|
||||
std::vector<int64_t> &_end = *end;
|
||||
std::vector<int64_t> &_stride = *stride;
|
||||
std::vector<size_t> &_input_shape = *input_shape;
|
||||
auto &_input_shape = *input_shape;
|
||||
if (_begin.size() != _end.size() || _begin.size() != _stride.size() || _begin.size() > _input_shape.size()) {
|
||||
MS_LOG(EXCEPTION) << "For '" << common::AnfAlgo::GetCNodeName(kernel_node)
|
||||
<< "', the length of 'begin', 'stride' and 'end' should be equal "
|
||||
|
@ -716,17 +701,17 @@ void FillEmptyDims(const CNodePtr &kernel_node, std::vector<int64_t> *begin, std
|
|||
}
|
||||
|
||||
if (i < _begin.size()) {
|
||||
int64_t dim = SizeToLong(_input_shape[i]);
|
||||
int64_t dim = _input_shape[i];
|
||||
_begin[i] = std::min(_begin[i] < 0 ? std::max(_begin[i] + dim, static_cast<int64_t>(0)) : _begin[i], dim - 1);
|
||||
} else {
|
||||
_begin.push_back(0);
|
||||
}
|
||||
|
||||
if (i < _end.size()) {
|
||||
int64_t dim = SizeToLong(_input_shape[i]);
|
||||
int64_t dim = _input_shape[i];
|
||||
_end[i] = std::max(_end[i] < 0 ? _end[i] + dim : std::min(_end[i], dim), static_cast<int64_t>(-1));
|
||||
} else {
|
||||
_end.push_back(i < _input_shape.size() ? SizeToLong(_input_shape[i]) : 1);
|
||||
_end.push_back(i < _input_shape.size() ? _input_shape[i] : 1);
|
||||
}
|
||||
|
||||
if (i >= _stride.size()) {
|
||||
|
@ -749,31 +734,31 @@ std::vector<bool> Dec2Bin(const int64_t &mask) {
|
|||
}
|
||||
|
||||
void ComputeBeginMask(const CNodePtr &kernel_node, std::vector<int64_t> *begin, const std::vector<int64_t> &stride,
|
||||
const std::vector<size_t> &input_shape) {
|
||||
const ShapeVector &input_shape) {
|
||||
std::vector<int64_t> &_begin = *begin;
|
||||
auto begin_mask_int = common::AnfAlgo::GetNodeAttr<int64_t>(kernel_node, kAttrBeginMask);
|
||||
auto begin_mask = Dec2Bin(begin_mask_int);
|
||||
for (size_t i = 0; i < begin_mask.size(); i++) {
|
||||
if (i < kStridedSliceMaxDims && begin_mask[i]) {
|
||||
_begin[i] = stride[i] < 0 ? SizeToLong(input_shape[i]) - 1 : 0;
|
||||
_begin[i] = stride[i] < 0 ? input_shape[i] - 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ComputeEndMask(const CNodePtr &kernel_node, std::vector<int64_t> *end, const std::vector<int64_t> &stride,
|
||||
const std::vector<size_t> &input_shape) {
|
||||
const ShapeVector &input_shape) {
|
||||
std::vector<int64_t> &_end = *end;
|
||||
auto end_mask_int = common::AnfAlgo::GetNodeAttr<int64_t>(kernel_node, kAttrEndMask);
|
||||
auto end_mask = Dec2Bin(end_mask_int);
|
||||
for (size_t j = 0; j < end_mask.size(); j++) {
|
||||
if (j < kStridedSliceMaxDims && end_mask[j]) {
|
||||
_end[j] = stride[j] < 0 ? -1 : SizeToLong(input_shape[j]);
|
||||
_end[j] = stride[j] < 0 ? -1 : input_shape[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ComputeEllipsisMask(const CNodePtr &kernel_node, std::vector<int64_t> *begin, std::vector<int64_t> *end,
|
||||
std::vector<int64_t> *stride, const std::vector<size_t> &input_shape) {
|
||||
std::vector<int64_t> *stride, const ShapeVector &input_shape) {
|
||||
std::vector<int64_t> &_begin = *begin;
|
||||
std::vector<int64_t> &_end = *end;
|
||||
std::vector<int64_t> &_stride = *stride;
|
||||
|
@ -782,14 +767,14 @@ void ComputeEllipsisMask(const CNodePtr &kernel_node, std::vector<int64_t> *begi
|
|||
for (size_t k = 0; k < ellipsis_mask.size(); k++) {
|
||||
if (k < kStridedSliceMaxDims && ellipsis_mask[k]) {
|
||||
_begin[k] = 0;
|
||||
_end[k] = SizeToLong(input_shape[k]);
|
||||
_end[k] = input_shape[k];
|
||||
_stride[k] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ComputNewAxisMask(const CNodePtr &kernel_node, std::vector<int64_t> *begin, std::vector<int64_t> *end,
|
||||
std::vector<int64_t> *stride, const std::vector<size_t> &input_shape) {
|
||||
std::vector<int64_t> *stride, const ShapeVector &input_shape) {
|
||||
std::vector<int64_t> &_begin = *begin;
|
||||
std::vector<int64_t> &_end = *end;
|
||||
std::vector<int64_t> &_stride = *stride;
|
||||
|
@ -798,7 +783,7 @@ void ComputNewAxisMask(const CNodePtr &kernel_node, std::vector<int64_t> *begin,
|
|||
for (size_t l = 0; l < new_axis_mask.size(); l++) {
|
||||
if (l < kStridedSliceMaxDims && new_axis_mask[l]) {
|
||||
_begin[l] = 0;
|
||||
_end[l] = SizeToLong(input_shape[l]);
|
||||
_end[l] = input_shape[l];
|
||||
_stride[l] = 1;
|
||||
}
|
||||
}
|
||||
|
@ -819,7 +804,7 @@ void ComputShrinkAxisMask(const CNodePtr &kernel_node, const std::vector<int64_t
|
|||
}
|
||||
|
||||
void ParseStrideSliceMasks(const CNodePtr &kernel_node, std::vector<int64_t> *begin, std::vector<int64_t> *end,
|
||||
std::vector<int64_t> *stride, const std::vector<size_t> &input_shape) {
|
||||
std::vector<int64_t> *stride, const ShapeVector &input_shape) {
|
||||
ComputeBeginMask(kernel_node, begin, *stride, input_shape);
|
||||
ComputeEndMask(kernel_node, end, *stride, input_shape);
|
||||
ComputeEllipsisMask(kernel_node, begin, end, stride, input_shape);
|
||||
|
@ -906,24 +891,24 @@ void ComputeInterpolationWeights(const size_t out_size, const size_t in_size, co
|
|||
}
|
||||
}
|
||||
|
||||
bool GetShapeSize(const std::vector<size_t> &shape, const TypePtr &type_ptr, int64_t *size_i) {
|
||||
bool GetShapeSize(const ShapeVector &shape, const TypePtr &type_ptr, int64_t *size_i) {
|
||||
MS_EXCEPTION_IF_NULL(type_ptr);
|
||||
size_t type_byte = GetTypeByte(type_ptr);
|
||||
if (type_byte == 0) {
|
||||
return false;
|
||||
}
|
||||
for (size_t j = 0; j < shape.size(); j++) {
|
||||
size_i[0] = LongMulWithOverflowCheck(size_i[0], static_cast<int64_t>(shape[j]));
|
||||
if (shape[j] <= 0) {
|
||||
MS_LOG(DEBUG) << "shape[" << shape << "] has invalid value(less equal 0), set size to 0";
|
||||
size_i[0] = 0;
|
||||
return true;
|
||||
}
|
||||
size_i[0] = LongMulWithOverflowCheck(size_i[0], shape[j]);
|
||||
}
|
||||
size_i[0] = LongMulWithOverflowCheck(size_i[0], SizeToInt(type_byte));
|
||||
return true;
|
||||
}
|
||||
|
||||
void CastShapeSizeToLong(const std::vector<size_t> &shape, std::vector<int64_t> *long_shape) {
|
||||
MS_EXCEPTION_IF_NULL(long_shape);
|
||||
(void)std::transform(shape.begin(), shape.end(), std::back_inserter(*long_shape), SizeToLong);
|
||||
}
|
||||
|
||||
void CheckSliceValid(const std::vector<int64_t> &start, const std::vector<int64_t> &stop,
|
||||
const std::vector<int64_t> &step, const std::vector<int64_t> &input_shape) {
|
||||
if (start.size() != stop.size() || start.size() != step.size() || start.size() > input_shape.size()) {
|
||||
|
@ -1337,14 +1322,12 @@ void UpdateNodeShape(const CNodePtr &cnode) {
|
|||
return;
|
||||
}
|
||||
std::vector<TypeId> type_ids;
|
||||
std::vector<std::vector<size_t>> shapes;
|
||||
std::vector<ShapeVector> shapes;
|
||||
size_t output_num = output_tensor.size();
|
||||
for (size_t i = 0; i < output_num; ++i) {
|
||||
MS_EXCEPTION_IF_NULL(output_tensor[i]);
|
||||
auto out_shape = output_tensor[i]->GetShapeVector();
|
||||
std::vector<size_t> u_out_shape;
|
||||
std::transform(out_shape.begin(), out_shape.end(), std::back_inserter(u_out_shape), LongToSize);
|
||||
shapes.emplace_back(std::move(u_out_shape));
|
||||
shapes.emplace_back(std::move(out_shape));
|
||||
type_ids.emplace_back(output_tensor[i]->GetDtype());
|
||||
}
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(type_ids, shapes, cnode.get());
|
||||
|
|
|
@ -87,7 +87,7 @@ class KernelMeta {
|
|||
|
||||
class MatrixInfo {
|
||||
public:
|
||||
explicit MatrixInfo(size_t max_index, const std::vector<size_t> &matrix_shapes)
|
||||
explicit MatrixInfo(size_t max_index, const ShapeVector &matrix_shapes)
|
||||
: max_index_(max_index), shapes_(matrix_shapes) {
|
||||
current_indexes_.resize(shapes_.size(), 0);
|
||||
}
|
||||
|
@ -101,8 +101,8 @@ class MatrixInfo {
|
|||
int last_rank = SizeToInt(current_indexes_.size()) - 1;
|
||||
for (int i = last_rank; i >= 0; --i) {
|
||||
size_t position = IntToSize(i);
|
||||
current_indexes_[position] = start % shapes_.at(position);
|
||||
start = start / shapes_.at(position);
|
||||
current_indexes_[position] = start % LongToSize(shapes_.at(position));
|
||||
start = start / LongToSize(shapes_.at(position));
|
||||
if (start == 0) {
|
||||
break;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ class MatrixInfo {
|
|||
}
|
||||
size_t last_rank = current_indexes_.size() - 1;
|
||||
current_indexes_[last_rank]++;
|
||||
for (size_t i = last_rank; current_indexes_.at(i) >= shapes_.at(i) && i > 0; --i) {
|
||||
for (size_t i = last_rank; current_indexes_.at(i) >= LongToSize(shapes_.at(i)) && i > 0; --i) {
|
||||
current_indexes_[i] = 0;
|
||||
current_indexes_[i - 1] += 1;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class MatrixInfo {
|
|||
bool is_first_iterator_{true};
|
||||
size_t min_index{0};
|
||||
size_t max_index_{1};
|
||||
std::vector<size_t> shapes_;
|
||||
ShapeVector shapes_;
|
||||
std::vector<size_t> current_indexes_;
|
||||
};
|
||||
using MatrixInfoPtr = std::shared_ptr<MatrixInfo>;
|
||||
|
@ -143,14 +143,13 @@ KernelPackPtr InsertCache(const std::string &kernel_name, const std::string &pro
|
|||
TypeId DtypeToTypeId(const std::string &dtypes);
|
||||
std::string Dtype2ShortType(const std::string &dtypes);
|
||||
size_t GetDtypeNbyte(const std::string &dtypes);
|
||||
bool GetShapeSize(const std::vector<size_t> &shape, const TypePtr &type_ptr, int64_t *size_i);
|
||||
bool GetShapeSize(const ShapeVector &shape, const TypePtr &type_ptr, int64_t *size_i);
|
||||
bool ParseMetadata(const CNodePtr &kernel_node, const std::shared_ptr<const OpInfo> &op_info_ptr, Processor processor,
|
||||
std::vector<std::shared_ptr<KernelBuildInfo>> *const kernel_info_list);
|
||||
void SaveJsonInfo(const std::string &json_name, const std::string &info, const std::string &base_path);
|
||||
std::string GetProcessor(const AnfNodePtr &anf_node);
|
||||
Processor GetProcessor(const string &processor);
|
||||
bool IsSameShape(const std::vector<size_t> &shape_a, const std::vector<size_t> &shape_b);
|
||||
bool IsSameShape(const std::vector<int64_t> &shape_a, const std::vector<int64_t> &shape_b);
|
||||
bool IsSameShape(const ShapeVector &shape_a, const ShapeVector &shape_b);
|
||||
std::vector<std::pair<AnfNodePtr, size_t>> GetOutputIndex(const std::vector<AnfNodePtr> &node_list,
|
||||
const std::vector<AnfNodePtr> &input_list,
|
||||
const std::vector<AnfNodePtr> &output_list);
|
||||
|
@ -170,9 +169,9 @@ FusionType GetFusionTypeByName(const std::string &name);
|
|||
std::string GetFusionNameByType(const kernel::FusionType &type);
|
||||
std::vector<bool> Dec2Bin(const int64_t &mask);
|
||||
void FillEmptyDims(const CNodePtr &kernel_node, std::vector<int64_t> *begin, std::vector<int64_t> *end,
|
||||
std::vector<int64_t> *stride, std::vector<size_t> *input_shape);
|
||||
std::vector<int64_t> *stride, ShapeVector *input_shape);
|
||||
void ParseStrideSliceMasks(const CNodePtr &kernel_node, std::vector<int64_t> *begin, std::vector<int64_t> *end,
|
||||
std::vector<int64_t> *stride, const std::vector<size_t> &input_shape);
|
||||
std::vector<int64_t> *stride, const ShapeVector &input_shape);
|
||||
struct CachedInterpolation {
|
||||
size_t lower;
|
||||
size_t upper;
|
||||
|
@ -246,7 +245,6 @@ inline T ComputeLerp(T top_left, T top_right, T bottom_left, T bottom_right, T x
|
|||
return top + (bottom - top) * y_lerp;
|
||||
}
|
||||
|
||||
void CastShapeSizeToLong(const std::vector<size_t> &shape, std::vector<int64_t> *long_shape);
|
||||
void CheckSliceValid(const std::vector<int64_t> &start, const std::vector<int64_t> &stop,
|
||||
const std::vector<int64_t> &step, const std::vector<int64_t> &input_shape);
|
||||
size_t CalOffset(const std::vector<int64_t> &start, const std::vector<int64_t> &stop,
|
||||
|
|
|
@ -100,7 +100,7 @@ bool EnvironMgr::CheckEnvInput(const CNodePtr &kernel_node) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool EnvironMgr::IsScalarTensor(TypeId type, const std::vector<size_t> &shape) const {
|
||||
bool EnvironMgr::IsScalarTensor(TypeId type, const std::vector<int64_t> &shape) const {
|
||||
if (type == kObjectTypeTensorType) {
|
||||
MS_LOG(ERROR) << "The type is invalid: " << type;
|
||||
return false;
|
||||
|
|
|
@ -43,7 +43,7 @@ class EnvironMgr {
|
|||
// Check whether the inputs of EnvironGet kernel or EnvironSet kernel are valid.
|
||||
bool CheckEnvInput(const CNodePtr &kernel_node) const;
|
||||
// Check whether is scalar tensor. Environ handle and env key only support scalar tensor currently.
|
||||
bool IsScalarTensor(TypeId type, const std::vector<size_t> &shape) const;
|
||||
bool IsScalarTensor(TypeId type, const std::vector<int64_t> &shape) const;
|
||||
|
||||
private:
|
||||
EnvironMgr() = default;
|
||||
|
|
|
@ -200,13 +200,13 @@ class KernelTensor {
|
|||
// If real type is not a list or tuple tensor, it will return kTypeUnknown.
|
||||
std::vector<TypeId> GetListOrTupleDtype() const;
|
||||
// If real type is not a single shape vector, it will return empty.
|
||||
std::vector<int64_t> GetShapeVector() const;
|
||||
ShapeVector GetShapeVector() const;
|
||||
// If real type is not a list or tuple shape vector, it will return empty.
|
||||
std::vector<std::vector<int64_t>> GetListOrTupleShapeVector() const;
|
||||
std::vector<ShapeVector> GetListOrTupleShapeVector() const;
|
||||
void SetData(const AddressPtr &data) { data_ = data; }
|
||||
void SetDtype(const TypePtr &dtype);
|
||||
void SetFormat(mindspore::Format format) { tensor_info_.format = format; }
|
||||
void SetShapeVector(const std::vector<int64_t> &shape);
|
||||
void SetShapeVector(const ShapeVector &shape);
|
||||
|
||||
abstract::BaseShapePtr GetBaseShape() const;
|
||||
// If the shape need to be List or Tuple, `SetBaseShape` should be called.
|
||||
|
@ -215,8 +215,8 @@ class KernelTensor {
|
|||
void SetTensorInfo(const TensorInfo &tensor_info) { tensor_info_ = tensor_info; }
|
||||
|
||||
// deprecated field for dynamic shape
|
||||
const std::vector<int64_t> &GetDeviceShapeAdaptively() const;
|
||||
void SetDeviceShapeAdaptively(const std::vector<int64_t> &device_shape_adaptively);
|
||||
const ShapeVector &GetDeviceShapeAdaptively() const;
|
||||
void SetDeviceShapeAdaptively(const ShapeVector &device_shape_adaptively);
|
||||
|
||||
private:
|
||||
TensorInfo tensor_info_;
|
||||
|
@ -293,7 +293,7 @@ class KernelMod {
|
|||
protected:
|
||||
virtual void SyncData() {}
|
||||
virtual std::vector<KernelTensorPtr> GetOutputs() { return {}; }
|
||||
bool IsValidShape(const std::vector<int64_t> &shape) {
|
||||
bool IsValidShape(const ShapeVector &shape) {
|
||||
if (std::any_of(shape.begin(), shape.end(), [](int64_t dim) { return dim < 0; })) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ ShapeVector AscendDeviceAddress::GetDeviceShape(ShapeVector *host_shape) const {
|
|||
return device_shape;
|
||||
}
|
||||
|
||||
std::shared_ptr<LaunchKernel> AscendDeviceAddress::CreateLaunchTransData(const std::vector<size_t> &host_shape,
|
||||
std::shared_ptr<LaunchKernel> AscendDeviceAddress::CreateLaunchTransData(const ShapeVector &host_shape,
|
||||
const std::string &ori_format,
|
||||
const std::string &dst_format) const {
|
||||
auto runtime_instance = device::KernelRuntimeManager::Instance().GetCurrentKernelRuntime();
|
||||
|
@ -300,8 +300,8 @@ std::shared_ptr<LaunchKernel> AscendDeviceAddress::CreateLaunchTransData(const s
|
|||
return launch_trans_data;
|
||||
}
|
||||
|
||||
bool AscendDeviceAddress::SyncDeviceToHostAndConvertFormatBasedOnTransData(const std::vector<size_t> &host_shape,
|
||||
size_t size, mindspore::TypeId type,
|
||||
bool AscendDeviceAddress::SyncDeviceToHostAndConvertFormatBasedOnTransData(const ShapeVector &host_shape, size_t size,
|
||||
mindspore::TypeId type,
|
||||
void *host_ptr) const {
|
||||
bool sync_ok = true;
|
||||
const std::string dst_format = kOpFormat_NCHW;
|
||||
|
@ -325,7 +325,7 @@ bool AscendDeviceAddress::SyncDeviceToHostAndConvertFormatBasedOnTransData(const
|
|||
auto host = std::vector<uint8_t>(size);
|
||||
SyncMemory(host.data(), output_addr_vec[0], size, ACL_MEMCPY_DEVICE_TO_HOST);
|
||||
auto shape_size = abstract::ShapeSize(host_shape);
|
||||
const trans::TypeIdArgs type_args{host.data(), SizeToLong(shape_size), type_id_, type, size};
|
||||
const trans::TypeIdArgs type_args{host.data(), shape_size, type_id_, type, size};
|
||||
sync_ok = trans::TransDataType(type_args, host_ptr);
|
||||
if (!sync_ok) {
|
||||
MS_LOG(ERROR) << "Trans data type failed.";
|
||||
|
@ -353,9 +353,7 @@ bool AscendDeviceAddress::SyncDeviceToHostAndConvertFormat(const ShapeVector &sh
|
|||
type_id_name_map.find(type_id_) != type_id_name_map.end()) {
|
||||
std::pair<std::string, std::string> type_format = std::make_pair(type_id_name_map.at(type_id_), format_);
|
||||
if (use_trans_data.find(type_format) != use_trans_data.end()) {
|
||||
std::vector<size_t> st_shape;
|
||||
(void)std::transform(host_shape.begin(), host_shape.end(), std::back_inserter(st_shape), LongToSize);
|
||||
sync_ok = SyncDeviceToHostAndConvertFormatBasedOnTransData(st_shape, size, type, host_ptr);
|
||||
sync_ok = SyncDeviceToHostAndConvertFormatBasedOnTransData(host_shape, size, type, host_ptr);
|
||||
return sync_ok;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,15 +74,14 @@ class AscendDeviceAddress : public DeviceAddress {
|
|||
private:
|
||||
bool SyncDeviceToHostAndConvertFormat(const ShapeVector &shape, size_t size, TypeId type, void *host_ptr) const;
|
||||
bool ConvertFormatAndSyncHostToDevice(const ShapeVector &shape, size_t size, TypeId type, const void *host_ptr) const;
|
||||
bool SyncDeviceToHostAndConvertFormatBasedOnTransData(const std::vector<size_t> &host_shape, size_t size,
|
||||
bool SyncDeviceToHostAndConvertFormatBasedOnTransData(const ShapeVector &host_shape, size_t size,
|
||||
mindspore::TypeId type, void *host_ptr) const;
|
||||
bool SyncDeviceToDeviceWithSameFormatType(const ShapeVector &shape, size_t size, TypeId type, const void *src_ptr,
|
||||
const std::string &format) const;
|
||||
bool SyncDeviceToDeviceWithDiffFormatType(const DeviceSync *src_device_addr) const;
|
||||
void SyncStream() const;
|
||||
ShapeVector GetDeviceShape(ShapeVector *host_shape) const;
|
||||
std::shared_ptr<LaunchKernel> CreateLaunchTransData(const std::vector<size_t> &host_shape,
|
||||
const std::string &ori_format,
|
||||
std::shared_ptr<LaunchKernel> CreateLaunchTransData(const ShapeVector &host_shape, const std::string &ori_format,
|
||||
const std::string &dst_format) const;
|
||||
mutable std::shared_ptr<LaunchKernel> launch_transdata_{nullptr};
|
||||
void BindDevice() const;
|
||||
|
|
|
@ -85,7 +85,7 @@ std::shared_ptr<session::KernelGraph> AscendLaunchAtomicClean::ObtainAtomicClean
|
|||
}
|
||||
auto shape = total_size_ / dtype_size;
|
||||
std::vector<std::vector<int64_t>> input_shapes = {{static_cast<int64_t>(shape)}};
|
||||
std::vector<std::vector<size_t>> output_shapes = {};
|
||||
std::vector<ShapeVector> output_shapes = {};
|
||||
auto atomic_clean_graph = session::SingleKernelGraph::ConstructKernelGraphBasedOnSingleOp(
|
||||
kAtomicAddrCleanOpName, input_dtypes, input_shapes, output_dtypes, output_shapes);
|
||||
MS_EXCEPTION_IF_NULL(atomic_clean_graph);
|
||||
|
|
|
@ -81,10 +81,8 @@ std::shared_ptr<session::KernelGraph> AscendLaunchTransData::ObtainTransDataKern
|
|||
std::vector<TypeId> input_dtypes = {dtype_};
|
||||
std::vector<TypeId> output_dtypes = {dtype_};
|
||||
// obtain input & output shape
|
||||
std::vector<int64_t> input_shape;
|
||||
std::transform(shape_.begin(), shape_.end(), std::back_inserter(input_shape), SizeToLong);
|
||||
std::vector<std::vector<int64_t>> input_shapes = {{input_shape}};
|
||||
std::vector<std::vector<size_t>> output_shapes = {{shape_}};
|
||||
std::vector<ShapeVector> input_shapes = {{shape_}};
|
||||
std::vector<ShapeVector> output_shapes = {{shape_}};
|
||||
auto transdata_graph = session::SingleKernelGraph::ConstructKernelGraphBasedOnSingleOp(
|
||||
kTransDataOpName, input_dtypes, input_shapes, output_dtypes, output_shapes);
|
||||
MS_EXCEPTION_IF_NULL(transdata_graph);
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace mindspore::device::ascend {
|
|||
class AscendLaunchTransData : public AscendLaunchKernel {
|
||||
public:
|
||||
AscendLaunchTransData(void *stream, TypeId dtype, size_t total_size, std::string src_format, std::string dst_format,
|
||||
std::vector<size_t> host_shape, int64_t groups)
|
||||
ShapeVector host_shape, int64_t groups)
|
||||
: AscendLaunchKernel(stream),
|
||||
dtype_(dtype),
|
||||
total_size_(total_size),
|
||||
|
@ -57,7 +57,7 @@ class AscendLaunchTransData : public AscendLaunchKernel {
|
|||
uint8_t *input_addr_;
|
||||
std::string src_format_;
|
||||
std::string dst_format_;
|
||||
std::vector<size_t> shape_;
|
||||
ShapeVector shape_;
|
||||
int64_t groups_;
|
||||
|
||||
private:
|
||||
|
|
|
@ -409,7 +409,7 @@ void DataDumper::RtLoadDumpData(const aicpu::dump::OpMappingInfo &dump_info, voi
|
|||
}
|
||||
}
|
||||
|
||||
void SetDumpShape(const std::vector<size_t> &ms_shape, NotNull<aicpu::dump::Shape *> dump_shape) {
|
||||
void SetDumpShape(const ShapeVector &ms_shape, NotNull<aicpu::dump::Shape *> dump_shape) {
|
||||
for (auto &dim : ms_shape) {
|
||||
dump_shape->add_dim(dim);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ void UpdateKernelInfo(const std::vector<AnfNodePtr> &node_list) {
|
|||
}
|
||||
}
|
||||
|
||||
bool CanConvertDefaultShapeToNZ(const std::vector<size_t> &shape) {
|
||||
bool CanConvertDefaultShapeToNZ(const ShapeVector &shape) {
|
||||
for (size_t i = 1; i <= shape.size(); ++i) {
|
||||
if (i > 2) {
|
||||
break;
|
||||
|
@ -115,7 +115,7 @@ bool CanConvertDefaultShapeToNZ(const std::vector<size_t> &shape) {
|
|||
return true;
|
||||
}
|
||||
|
||||
std::vector<int64_t> DefaultToFracNZAxis(const std::vector<size_t> &ori_shape, const std::vector<int64_t> &axis) {
|
||||
std::vector<int64_t> DefaultToFracNZAxis(const ShapeVector &ori_shape, const std::vector<int64_t> &axis) {
|
||||
std::vector<int64_t> frac_nz_axis = axis;
|
||||
auto shape_len = ori_shape.size();
|
||||
for (size_t i = 0; i < axis.size(); ++i) {
|
||||
|
@ -133,23 +133,6 @@ std::vector<int64_t> DefaultToFracNZAxis(const std::vector<size_t> &ori_shape, c
|
|||
return frac_nz_axis;
|
||||
}
|
||||
|
||||
std::vector<size_t> GetReducedFracNZShape(const std::vector<size_t> &ori_shape, const std::vector<int64_t> &axis,
|
||||
bool keep_dims) {
|
||||
std::vector<size_t> result;
|
||||
std::set<size_t> positive_idx;
|
||||
for (const auto &a : axis) {
|
||||
(void)positive_idx.insert(a >= 0 ? LongToSize(a) : ori_shape.size() + LongToSize(a));
|
||||
}
|
||||
for (size_t i = 0; i < ori_shape.size(); ++i) {
|
||||
if (positive_idx.count(i) == 0) {
|
||||
result.push_back(ori_shape[i]);
|
||||
} else if (keep_dims) {
|
||||
result.push_back(1);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void UpdateFracNZReduceOp(const CNodePtr &cnode) {
|
||||
MS_EXCEPTION_IF_NULL(cnode);
|
||||
auto input_format = AnfAlgo::GetPrevNodeOutputFormat(cnode, 0);
|
||||
|
|
|
@ -261,7 +261,7 @@ void ProfilingReporter::BuildTensorData(MsprofGeTensorData *tensor_data, const C
|
|||
uint32_t tensor_type) {
|
||||
MS_EXCEPTION_IF_NULL(tensor_data);
|
||||
tensor_data->tensorType = tensor_type;
|
||||
std::vector<size_t> shape;
|
||||
std::vector<int64_t> shape;
|
||||
string data_format;
|
||||
uint32_t vm_data_type;
|
||||
if (tensor_type == MSPROF_GE_TENSOR_TYPE_INPUT) {
|
||||
|
|
|
@ -302,10 +302,10 @@ void ReorderInputsAsFrontGraph(const KernelGraphPtr &kernel_graph, const FuncGra
|
|||
}
|
||||
|
||||
void UpdateOutputNodeShape(const std::vector<KernelWithIndex> &outputs, const std::vector<TypeId> &outputs_type,
|
||||
const std::vector<std::vector<size_t>> &shapes) {
|
||||
const std::vector<ShapeVector> &shapes) {
|
||||
AnfNodePtr cur_node = nullptr;
|
||||
std::vector<TypeId> cur_types = {};
|
||||
std::vector<std::vector<size_t>> cur_shapes = {};
|
||||
std::vector<ShapeVector> cur_shapes = {};
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
const auto &node = outputs[i].first;
|
||||
if (node != cur_node && cur_node != nullptr) {
|
||||
|
@ -349,7 +349,7 @@ void GeGraphExecutor::AllocInputHostMemory(const KernelGraphPtr &kernel_graph) c
|
|||
continue;
|
||||
}
|
||||
TypeId output_type_id = common::AnfAlgo::GetOutputInferDataType(input_node, 0);
|
||||
std::vector<size_t> shape = common::AnfAlgo::GetOutputInferShape(input_node, 0);
|
||||
std::vector<size_t> shape = Convert2SizeT(common::AnfAlgo::GetOutputInferShape(input_node, 0));
|
||||
size_t type_size = GetTypeByte(TypeIdToType(output_type_id));
|
||||
size_t tensor_size = std::accumulate(shape.begin(), shape.end(), type_size, std::multiplies<size_t>());
|
||||
auto device_address_ptr =
|
||||
|
@ -364,7 +364,7 @@ void GeGraphExecutor::AllocOutputHostMemory(const KernelGraphPtr &kernel_graph)
|
|||
auto outputs = common::AnfAlgo::GetAllOutputWithIndex(kernel_graph->output());
|
||||
for (const auto &[output_node, i] : outputs) {
|
||||
TypeId output_type_id = common::AnfAlgo::GetOutputInferDataType(output_node, i);
|
||||
std::vector<size_t> shape = common::AnfAlgo::GetOutputInferShape(output_node, i);
|
||||
std::vector<size_t> shape = Convert2SizeT(common::AnfAlgo::GetOutputInferShape(output_node, i));
|
||||
size_t type_size = GetTypeByte(TypeIdToType(output_type_id));
|
||||
size_t tensor_size = std::accumulate(shape.begin(), shape.end(), type_size, std::multiplies<size_t>());
|
||||
auto device_address_ptr =
|
||||
|
@ -446,7 +446,7 @@ bool GeGraphExecutor::RunGraph(const FuncGraphPtr &graph, const std::vector<tens
|
|||
MS_LOG(EXCEPTION) << "Invalid output size, graph's size " << outputs.size() << " tensor size " << ge_outputs.size();
|
||||
}
|
||||
|
||||
std::vector<std::vector<size_t>> output_shapes;
|
||||
std::vector<ShapeVector> output_shapes;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
const auto &[output_node, idx] = outputs[i];
|
||||
const auto &tensor = ge_outputs[i];
|
||||
|
@ -462,9 +462,7 @@ bool GeGraphExecutor::RunGraph(const FuncGraphPtr &graph, const std::vector<tens
|
|||
// memcpy_s does not support data that more than 2GB
|
||||
(void)memcpy(output_addr->GetMutablePtr(), tensor->GetData(), tensor->GetSize());
|
||||
auto actual_shapes = tensor->GetTensorDesc().GetShape().GetDims();
|
||||
std::vector<size_t> u_out_shape;
|
||||
std::transform(actual_shapes.begin(), actual_shapes.end(), std::back_inserter(u_out_shape), LongToSize);
|
||||
output_shapes.emplace_back(std::move(u_out_shape));
|
||||
output_shapes.emplace_back(std::move(actual_shapes));
|
||||
}
|
||||
UpdateOutputNodeShape(outputs, me_types, output_shapes);
|
||||
MS_LOG(INFO) << "GE run graph end.";
|
||||
|
|
|
@ -65,7 +65,7 @@ void AllToAllvCalcParam::CalcOpParam() {
|
|||
if (type_size == 0) {
|
||||
MS_LOG(EXCEPTION) << "Invalid type_size 0 of node: " << cnode->fullname_with_scope();
|
||||
}
|
||||
size_t origin_mem_size = std::accumulate(ms_shape.begin(), ms_shape.end(), type_size, std::multiplies<size_t>());
|
||||
size_t origin_mem_size = type_size * SizeOf(ms_shape);
|
||||
size_t aligned_mem_size = device::MemoryManager::GetCommonAlignSize(origin_mem_size);
|
||||
input_aligned_mem_size[i] = aligned_mem_size / type_size;
|
||||
input_real_mem_size[i] = origin_mem_size / type_size;
|
||||
|
@ -76,7 +76,7 @@ void AllToAllvCalcParam::CalcOpParam() {
|
|||
if (type_size == 0) {
|
||||
MS_LOG(EXCEPTION) << "Invalid type_size 0 of node: " << cnode->fullname_with_scope();
|
||||
}
|
||||
size_t origin_mem_size = std::accumulate(ms_shape.begin(), ms_shape.end(), type_size, std::multiplies<size_t>());
|
||||
size_t origin_mem_size = type_size * SizeOf(ms_shape);
|
||||
size_t aligned_mem_size = device::MemoryManager::GetCommonAlignSize(origin_mem_size);
|
||||
output_aligned_mem_size[i] = aligned_mem_size / type_size;
|
||||
output_real_mem_size[i] = origin_mem_size / type_size;
|
||||
|
|
|
@ -176,18 +176,12 @@ std::tuple<ge::NodePtr, ge::ComputeGraphPtr> GenerateStubGeNode(const AnfNodePtr
|
|||
size_t input_num = common::AnfAlgo::GetInputTensorNum(cnode);
|
||||
size_t output_num = common::AnfAlgo::GetOutputTensorNum(cnode);
|
||||
for (size_t i = 0; i < input_num; ++i) {
|
||||
std::vector<int64_t> ge_shape;
|
||||
auto ms_shape = AnfAlgo::GetInputDeviceShape(cnode, i);
|
||||
std::transform(ms_shape.begin(), ms_shape.end(), std::back_inserter(ge_shape),
|
||||
[](size_t in) { return static_cast<int64_t>(in); });
|
||||
auto ge_shape = AnfAlgo::GetInputDeviceShape(cnode, i);
|
||||
op_desc->AddInputDesc(ge::GeTensorDesc(ge::GeShape(ge_shape), ge::Format::FORMAT_NCHW,
|
||||
transform::ConvertDataType(AnfAlgo::GetInputDeviceDataType(cnode, i))));
|
||||
}
|
||||
for (size_t i = 0; i < output_num; ++i) {
|
||||
std::vector<int64_t> ge_shape;
|
||||
auto ms_shape = AnfAlgo::GetOutputDeviceShape(cnode, i);
|
||||
std::transform(ms_shape.begin(), ms_shape.end(), std::back_inserter(ge_shape),
|
||||
[](size_t in) { return static_cast<int64_t>(in); });
|
||||
auto ge_shape = AnfAlgo::GetOutputDeviceShape(cnode, i);
|
||||
op_desc->AddOutputDesc(ge::GeTensorDesc(ge::GeShape(ge_shape), ge::Format::FORMAT_NCHW,
|
||||
transform::ConvertDataType(AnfAlgo::GetOutputDeviceDataType(cnode, i))));
|
||||
}
|
||||
|
|
|
@ -154,18 +154,16 @@ bool AicpuExtInfoHandler::UpdateInputShapeAndType(uint32_t input_index, const No
|
|||
}
|
||||
|
||||
auto input_shape = AnfAlgo::GetInputDeviceShape(anf_node, input_index);
|
||||
std::vector<int64_t> tmp_shape;
|
||||
(void)std::transform(input_shape.begin(), input_shape.end(), std::back_inserter(tmp_shape), SizeToLong);
|
||||
if (input_index >= input_shape_and_type_.size()) {
|
||||
MS_LOG(ERROR) << "Invalid input_index: " << input_index
|
||||
<< " the size of input_shape_and_type_ is: " << input_shape_and_type_.size();
|
||||
return false;
|
||||
}
|
||||
if (tmp_shape.empty()) {
|
||||
tmp_shape = {1};
|
||||
if (input_shape.empty()) {
|
||||
input_shape = {1};
|
||||
}
|
||||
|
||||
return UpdateShapeAndType(tmp_shape, NOT_NULL(input_shape_and_type_[input_index]));
|
||||
return UpdateShapeAndType(input_shape, NOT_NULL(input_shape_and_type_[input_index]));
|
||||
}
|
||||
|
||||
bool AicpuExtInfoHandler::UpdateOutputShapeAndType(uint32_t output_index, const NotNull<AnfNodePtr> &anf_node) {
|
||||
|
@ -177,23 +175,21 @@ bool AicpuExtInfoHandler::UpdateOutputShapeAndType(uint32_t output_index, const
|
|||
auto shape = AnfAlgo::GetOutputDeviceShape(anf_node, output_index);
|
||||
auto max_shape = common::AnfAlgo::GetOutputMaxShape(anf_node, output_index);
|
||||
for (size_t i = 0; i < shape.size(); ++i) {
|
||||
if (i < max_shape.size() && shape[i] == SIZE_MAX) {
|
||||
MS_LOG(INFO) << "Node:" << node_name_ << " update shape from SIZE_MAX to " << max_shape[i];
|
||||
shape[i] = LongToSize(max_shape[i]);
|
||||
if (i < max_shape.size() && shape[i] == abstract::Shape::SHP_ANY) {
|
||||
MS_LOG(INFO) << "Node:" << node_name_ << " update shape from SHP_ANY to " << max_shape[i];
|
||||
shape[i] = max_shape[i];
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int64_t> tmp_shape;
|
||||
(void)std::transform(shape.begin(), shape.end(), std::back_inserter(tmp_shape), SizeToLong);
|
||||
if (output_index >= output_shape_and_type_.size()) {
|
||||
MS_LOG(ERROR) << "Invalid output_index: " << output_index
|
||||
<< " the size of output_shape_and_type_ is: " << output_shape_and_type_.size();
|
||||
return false;
|
||||
}
|
||||
if (tmp_shape.empty()) {
|
||||
tmp_shape = {1};
|
||||
if (shape.empty()) {
|
||||
shape = {1};
|
||||
}
|
||||
return UpdateShapeAndType(tmp_shape, NOT_NULL(output_shape_and_type_[output_index]));
|
||||
return UpdateShapeAndType(shape, NOT_NULL(output_shape_and_type_[output_index]));
|
||||
}
|
||||
|
||||
bool AicpuExtInfoHandler::GetOutputShapeAndType(uint32_t output_index, NotNull<std::vector<int64_t> *> shape,
|
||||
|
|
|
@ -47,7 +47,7 @@ bool SetIOIputSize(const std::shared_ptr<AnfNode> &anf_node, const size_t &input
|
|||
MS_EXCEPTION_IF_NULL(anf_node);
|
||||
MS_EXCEPTION_IF_NULL(input_size_list);
|
||||
for (size_t i = 0; i < input_num; i++) {
|
||||
std::vector<size_t> shape_i = AnfAlgo::GetInputDeviceShape(anf_node, i);
|
||||
auto shape_i = AnfAlgo::GetInputDeviceShape(anf_node, i);
|
||||
if (AnfAlgo::GetInputDeviceDataType(anf_node, i) == kObjectTypeString) {
|
||||
if (!anf_node->isa<CNode>()) {
|
||||
MS_LOG(EXCEPTION) << "anf_node is not CNode.";
|
||||
|
@ -93,7 +93,7 @@ bool SetIOSize(const std::shared_ptr<AnfNode> &anf_node, const std::shared_ptr<A
|
|||
output_num = 0;
|
||||
}
|
||||
for (size_t i = 0; i < output_num; i++) {
|
||||
std::vector<size_t> shape_i = AnfAlgo::GetOutputDeviceShape(anf_node, i);
|
||||
auto shape_i = AnfAlgo::GetOutputDeviceShape(anf_node, i);
|
||||
TypePtr type_ptr = TypeIdToType(AnfAlgo::GetOutputDeviceDataType(anf_node, i));
|
||||
int64_t size_i = 1;
|
||||
if (!GetShapeSize(shape_i, type_ptr, &size_i)) {
|
||||
|
@ -222,7 +222,7 @@ void SetNodeInputs(const std::shared_ptr<AnfNode> &anf_node, mindspore::NodeDef
|
|||
::mindspore::Tensor *node_inputs = proto->add_inputs();
|
||||
MS_EXCEPTION_IF_NULL(node_inputs);
|
||||
TypeId input_type = AnfAlgo::GetInputDeviceDataType(anf_node, input_index);
|
||||
std::vector<size_t> input_shape;
|
||||
std::vector<int64_t> input_shape;
|
||||
int32_t input_data_type;
|
||||
if (input_type == kObjectTypeString) {
|
||||
auto cnode = anf_node->cast<CNodePtr>();
|
||||
|
@ -232,7 +232,7 @@ void SetNodeInputs(const std::shared_ptr<AnfNode> &anf_node, mindspore::NodeDef
|
|||
MS_EXCEPTION_IF_NULL(value_ptr);
|
||||
auto value = GetValue<std::string>(value_ptr);
|
||||
input_shape.push_back(1);
|
||||
input_shape.push_back(value.size());
|
||||
input_shape.push_back(static_cast<int64_t>(value.size()));
|
||||
input_data_type = AicpuOpUtil::MsTypeToProtoType(kTypeUnknown);
|
||||
} else {
|
||||
input_shape = AnfAlgo::GetInputDeviceShape(anf_node, input_index);
|
||||
|
@ -266,7 +266,7 @@ void SetNodeOutputs(const std::shared_ptr<AnfNode> &anf_node, mindspore::NodeDef
|
|||
for (size_t output_index = 0; output_index < output_num; output_index++) {
|
||||
::mindspore::Tensor *node_outputs = proto->add_outputs();
|
||||
MS_EXCEPTION_IF_NULL(node_outputs);
|
||||
std::vector<size_t> output_shape = AnfAlgo::GetOutputDeviceShape(anf_node, output_index);
|
||||
auto output_shape = AnfAlgo::GetOutputDeviceShape(anf_node, output_index);
|
||||
mindspore::TensorShape *tensorShape = node_outputs->mutable_tensor_shape();
|
||||
MS_EXCEPTION_IF_NULL(tensorShape);
|
||||
for (auto item : output_shape) {
|
||||
|
@ -350,7 +350,7 @@ uint64_t SetExtInfoInputShapeType(char *ext_info_buf, uint64_t ext_info_offset,
|
|||
auto *inputs = reinterpret_cast<ShapeAndType *>(ext_info_buf + ext_info_offset);
|
||||
for (size_t input_index = 0; input_index < input_num; input_index++) {
|
||||
TypeId input_type = AnfAlgo::GetInputDeviceDataType(anf_node, input_index);
|
||||
std::vector<size_t> input_shape;
|
||||
std::vector<int64_t> input_shape;
|
||||
int32_t input_data_type;
|
||||
if (input_type == kObjectTypeString) {
|
||||
auto cnode = anf_node->cast<CNodePtr>();
|
||||
|
@ -359,7 +359,7 @@ uint64_t SetExtInfoInputShapeType(char *ext_info_buf, uint64_t ext_info_offset,
|
|||
auto value_ptr = GetValueNode(input_node);
|
||||
auto value = GetValue<std::string>(value_ptr);
|
||||
input_shape.push_back(1);
|
||||
input_shape.push_back(value.size());
|
||||
input_shape.push_back(static_cast<int64_t>(value.size()));
|
||||
input_data_type = AicpuOpUtil::MsTypeToProtoType(kTypeUnknown);
|
||||
} else {
|
||||
input_shape = AnfAlgo::GetInputDeviceShape(anf_node, input_index);
|
||||
|
@ -369,7 +369,7 @@ uint64_t SetExtInfoInputShapeType(char *ext_info_buf, uint64_t ext_info_offset,
|
|||
|
||||
size_t input_shape_index = 0;
|
||||
for (; input_shape_index < input_shape.size(); input_shape_index++) {
|
||||
inputs[input_index].dims[input_shape_index] = SizeToLong(input_shape[input_shape_index]);
|
||||
inputs[input_index].dims[input_shape_index] = input_shape[input_shape_index];
|
||||
}
|
||||
if (input_shape.size() < kMaxShapeDims) {
|
||||
inputs[input_index].dims[input_shape_index] = LLONG_MIN;
|
||||
|
@ -389,14 +389,14 @@ uint64_t SetExtInfoOutputShapeType(char *ext_info_buf, uint64_t ext_info_offset,
|
|||
|
||||
auto *outputs = reinterpret_cast<ShapeAndType *>(ext_info_buf + ext_info_offset);
|
||||
for (size_t output_index = 0; output_index < output_num; output_index++) {
|
||||
std::vector<size_t> output_shape = AnfAlgo::GetOutputDeviceShape(anf_node, output_index);
|
||||
auto output_shape = AnfAlgo::GetOutputDeviceShape(anf_node, output_index);
|
||||
TypeId output_type = AnfAlgo::GetOutputDeviceDataType(anf_node, output_index);
|
||||
int32_t output_data_type = AicpuOpUtil::MsTypeToProtoType(output_type);
|
||||
outputs[output_index].type = output_data_type;
|
||||
|
||||
size_t output_shape_index = 0;
|
||||
for (; output_shape_index < output_shape.size(); output_shape_index++) {
|
||||
outputs[output_index].dims[output_shape_index] = SizeToLong(output_shape[output_shape_index]);
|
||||
outputs[output_index].dims[output_shape_index] = output_shape[output_shape_index];
|
||||
}
|
||||
if (output_shape_index < kMaxShapeDims) {
|
||||
outputs[output_index].dims[output_shape_index] = LLONG_MIN;
|
||||
|
|
|
@ -212,16 +212,14 @@ bool DynamicAicpuOpKernelMod::UpdateOutputShapeFromExtInfo(const CNodePtr &cnode
|
|||
MS_EXCEPTION_IF_NULL(ext_info_handler_);
|
||||
|
||||
std::vector<TypeId> type_ids;
|
||||
std::vector<std::vector<size_t>> shapes;
|
||||
std::vector<ShapeVector> shapes;
|
||||
auto output_num = common::AnfAlgo::GetOutputTensorNum(cnode);
|
||||
for (size_t i = 0; i < output_num; ++i) {
|
||||
std::vector<int64_t> shape;
|
||||
TypeId type_id;
|
||||
(void)ext_info_handler_->GetOutputShapeAndType(SizeToUint(i), NOT_NULL(&shape), NOT_NULL(&type_id));
|
||||
type_ids.emplace_back(type_id);
|
||||
std::vector<size_t> size_t_shape;
|
||||
std::transform(shape.begin(), shape.end(), std::back_inserter(size_t_shape), LongToSize);
|
||||
shapes.emplace_back(size_t_shape);
|
||||
shapes.emplace_back(shape);
|
||||
}
|
||||
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(type_ids, shapes, cnode.get());
|
||||
|
|
|
@ -361,7 +361,7 @@ int HcclKernel::Resize(const BaseOperatorPtr &base_operator, const std::vector<K
|
|||
|
||||
MS_LOG(INFO) << "Start to InitOp. Node info: " << cnode->DebugString();
|
||||
|
||||
std::vector<std::vector<size_t>> hccl_kernel_input_shape_list;
|
||||
std::vector<ShapeVector> hccl_kernel_input_shape_list;
|
||||
if (!HcomUtil::GetKernelInputShape(cnode, &hccl_kernel_input_shape_list)) {
|
||||
MS_LOG(EXCEPTION) << "GetKernelInputShape fail! Node info: " << cnode->DebugString();
|
||||
}
|
||||
|
|
|
@ -56,8 +56,8 @@ class HcclKernel : public AscendKernelMod {
|
|||
const std::map<uint32_t, tensor::TensorPtr> &inputsOnHost = std::map<uint32_t, tensor::TensorPtr>()) override;
|
||||
|
||||
protected:
|
||||
std::vector<std::vector<size_t>> hccl_kernel_input_shape_list_;
|
||||
std::vector<std::vector<size_t>> hccl_kernel_output_shape_list_;
|
||||
std::vector<std::vector<int64_t>> hccl_kernel_input_shape_list_;
|
||||
std::vector<std::vector<int64_t>> hccl_kernel_output_shape_list_;
|
||||
std::vector<HcclDataType> hccl_data_type_list_;
|
||||
std::vector<std::string> hccl_format_list_;
|
||||
uint64_t hccl_count_;
|
||||
|
|
|
@ -32,24 +32,24 @@ bool IsPyNativeMode() {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
bool HcomUtil::GetKernelInputShape(const AnfNodePtr &anf_node, vector<vector<size_t>> *hccl_kernel_intput_shape_list) {
|
||||
bool HcomUtil::GetKernelInputShape(const AnfNodePtr &anf_node, vector<ShapeVector> *hccl_kernel_intput_shape_list) {
|
||||
MS_EXCEPTION_IF_NULL(anf_node);
|
||||
MS_EXCEPTION_IF_NULL(hccl_kernel_intput_shape_list);
|
||||
size_t input_num = common::AnfAlgo::GetInputTensorNum(anf_node);
|
||||
for (size_t i = 0; i < input_num; ++i) {
|
||||
std::vector<size_t> shape_i = AnfAlgo::GetInputDeviceShape(anf_node, i);
|
||||
auto shape_i = AnfAlgo::GetInputDeviceShape(anf_node, i);
|
||||
hccl_kernel_intput_shape_list->emplace_back(shape_i);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HcomUtil::GetKernelOutputShape(const AnfNodePtr &anf_node, vector<vector<size_t>> *hccl_kernel_output_shape_list) {
|
||||
bool HcomUtil::GetKernelOutputShape(const AnfNodePtr &anf_node, vector<ShapeVector> *hccl_kernel_output_shape_list) {
|
||||
MS_EXCEPTION_IF_NULL(anf_node);
|
||||
MS_EXCEPTION_IF_NULL(hccl_kernel_output_shape_list);
|
||||
size_t output_num = common::AnfAlgo::GetOutputTensorNum(anf_node);
|
||||
for (size_t i = 0; i < output_num; ++i) {
|
||||
std::vector<size_t> shape_i = AnfAlgo::GetOutputDeviceShape(anf_node, i);
|
||||
auto shape_i = AnfAlgo::GetOutputDeviceShape(anf_node, i);
|
||||
(void)hccl_kernel_output_shape_list->emplace_back(shape_i);
|
||||
}
|
||||
|
||||
|
@ -91,19 +91,19 @@ bool HcomUtil::GetHcomDataType(const AnfNodePtr &anf_node, vector<HcclDataType>
|
|||
return true;
|
||||
}
|
||||
|
||||
bool HcomUtil::GetHcclOpSize(const HcclDataType &data_type, const vector<size_t> &shape, size_t *size) {
|
||||
bool HcomUtil::GetHcclOpSize(const HcclDataType &data_type, const ShapeVector &shape, size_t *size) {
|
||||
MS_EXCEPTION_IF_NULL(size);
|
||||
size_t tmp_size = 1;
|
||||
int64_t tmp_size = 1;
|
||||
uint32_t type_size = 4;
|
||||
for (size_t i = 0; i < shape.size(); i++) {
|
||||
tmp_size = SizetMulWithOverflowCheck(tmp_size, shape[i]);
|
||||
tmp_size = LongMulWithOverflowCheck(tmp_size, shape[i]);
|
||||
}
|
||||
|
||||
if (!GetHcomTypeSize(data_type, &type_size)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*size = SizetMulWithOverflowCheck(tmp_size, type_size);
|
||||
*size = SizetMulWithOverflowCheck(LongToSize(tmp_size), type_size);
|
||||
|
||||
MS_LOG(DEBUG) << "size[" << *size << "]";
|
||||
return true;
|
||||
|
@ -121,7 +121,7 @@ bool HcomUtil::GetHcomTypeSize(const HcclDataType &data_type, uint32_t *size) {
|
|||
}
|
||||
|
||||
bool HcomUtil::GetHcomCount(const AnfNodePtr &anf_node, const vector<HcclDataType> &data_type_list,
|
||||
const vector<vector<size_t>> &shape_list, uint64_t *total_count) {
|
||||
const vector<ShapeVector> &shape_list, uint64_t *total_count) {
|
||||
MS_EXCEPTION_IF_NULL(anf_node);
|
||||
MS_EXCEPTION_IF_NULL(total_count);
|
||||
const uint32_t align_size = 512;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "hccl/base.h"
|
||||
#include "include/common/utils/contract.h"
|
||||
#include "hccl/hccl_types.h"
|
||||
#include "utils/shape_utils.h"
|
||||
|
||||
namespace mindspore {
|
||||
using std::map;
|
||||
|
@ -57,14 +58,14 @@ static map<HcclDataType, uint32_t> kConstOpHcomDataTypeSizeMap = {
|
|||
|
||||
class HcomUtil {
|
||||
public:
|
||||
static bool GetKernelInputShape(const AnfNodePtr &anf_node, vector<vector<size_t>> *hccl_kernel_shape_list);
|
||||
static bool GetKernelOutputShape(const AnfNodePtr &anf_node, vector<vector<size_t>> *hccl_kernel_shape_list);
|
||||
static bool GetKernelInputShape(const AnfNodePtr &anf_node, vector<ShapeVector> *hccl_kernel_shape_list);
|
||||
static bool GetKernelOutputShape(const AnfNodePtr &anf_node, vector<ShapeVector> *hccl_kernel_shape_list);
|
||||
static ::HcclDataType ConvertHcclType(TypeId type_id);
|
||||
static bool GetHcomDataType(const AnfNodePtr &anf_node, vector<HcclDataType> *data_type_list);
|
||||
static bool GetHcclOpSize(const HcclDataType &data_type, const vector<size_t> &shape, size_t *size);
|
||||
static bool GetHcclOpSize(const HcclDataType &data_type, const ShapeVector &shape, size_t *size);
|
||||
static bool GetHcomTypeSize(const HcclDataType &data_type, uint32_t *size);
|
||||
static bool GetHcomCount(const AnfNodePtr &anf_node, const vector<HcclDataType> &data_type_list,
|
||||
const vector<vector<size_t>> &shape_list, uint64_t *total_count);
|
||||
const vector<ShapeVector> &shape_list, uint64_t *total_count);
|
||||
static bool GetHcomOperationType(const AnfNodePtr &anf_node, HcclReduceOp *op_type);
|
||||
static bool GetHcomRootId(const AnfNodePtr &anf_node, uint32_t *root_id);
|
||||
static bool GetHcomSrcRank(const AnfNodePtr &anf_node, uint32_t *src_rank);
|
||||
|
|
|
@ -134,8 +134,8 @@ std::vector<int64_t> GetInputShape(const CNodePtr &cnode, size_t index) {
|
|||
<< trace::DumpSourceLines(cnode);
|
||||
}
|
||||
|
||||
size_t x_num = shape_x[0];
|
||||
std::vector<int64_t> x{SizeToLong(x_num)};
|
||||
auto x_num = shape_x[0];
|
||||
std::vector<int64_t> x{x_num};
|
||||
|
||||
auto x_shape_value = std::make_shared<tensor::Tensor>(type_x, x);
|
||||
// The second parameter must be false, otherwise the device address cannot be released and allocated, and the
|
||||
|
@ -208,8 +208,8 @@ void DynamicBroadcastGradientArgsKernelMod::Execute() {
|
|||
auto r0_size = SetOutputValue(cnode, grad_reduce_idx, 0, input_shapes[0].size());
|
||||
auto r1_size = SetOutputValue(cnode, grad_reduce_idx, 1, input_shapes[1].size());
|
||||
|
||||
std::vector<size_t> r0_shp{r0_size};
|
||||
std::vector<size_t> r1_shp{r1_size};
|
||||
ShapeVector r0_shp{SizeToLong(r0_size)};
|
||||
ShapeVector r1_shp{SizeToLong(r1_size)};
|
||||
auto output_type = TypeId::kNumberTypeInt64;
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({output_type, output_type}, {r0_shp, r1_shp}, cnode.get());
|
||||
MS_LOG(INFO) << "Execute DynamicBroadcastGradientArgsKernel End";
|
||||
|
|
|
@ -45,7 +45,7 @@ void TensorShapeKernelMod::Execute() {
|
|||
auto data_ptr = static_cast<int64_t *>(output_tensor_for_sync->data_c());
|
||||
for (size_t i = 0; i < prev_output_shape.size(); ++i) {
|
||||
MS_LOG(INFO) << "DEBUG prev_output_shape[" << i << "]:" << prev_output_shape[i];
|
||||
*(data_ptr + i) = SizeToLong(prev_output_shape[i]);
|
||||
*(data_ptr + i) = prev_output_shape[i];
|
||||
}
|
||||
|
||||
auto output_addr = AnfAlgo::GetOutputAddr(cnode, 0);
|
||||
|
@ -94,7 +94,7 @@ void TensorShapeKernelMod::Execute(const std::vector<AddressPtr> &inputs, const
|
|||
auto data_ptr = static_cast<int64_t *>(output_tensor_for_sync->data_c());
|
||||
for (size_t i = 0; i < prev_output_shape.size(); ++i) {
|
||||
MS_LOG(INFO) << "DEBUG prev_output_shape[" << i << "]:" << prev_output_shape[i];
|
||||
*(data_ptr + i) = SizeToLong(prev_output_shape[i]);
|
||||
*(data_ptr + i) = prev_output_shape[i];
|
||||
}
|
||||
|
||||
if (outputs.empty()) {
|
||||
|
|
|
@ -50,7 +50,7 @@ bool HostKernelMod::Init(const AnfNodePtr &anf_node) {
|
|||
size_t output_num = common::AnfAlgo::GetOutputTensorNum(anf_node);
|
||||
|
||||
for (size_t i = 0; i < input_num; i++) {
|
||||
std::vector<size_t> shape_i = AnfAlgo::GetInputDeviceShape(anf_node, i);
|
||||
auto shape_i = AnfAlgo::GetInputDeviceShape(anf_node, i);
|
||||
TypePtr type_ptr = TypeIdToType(AnfAlgo::GetInputDeviceDataType(anf_node, i));
|
||||
int64_t size_i = 1;
|
||||
if (!GetShapeSize(shape_i, type_ptr, &size_i)) {
|
||||
|
@ -60,7 +60,7 @@ bool HostKernelMod::Init(const AnfNodePtr &anf_node) {
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < output_num; i++) {
|
||||
std::vector<size_t> shape_i = AnfAlgo::GetOutputDeviceShape(anf_node, i);
|
||||
auto shape_i = AnfAlgo::GetOutputDeviceShape(anf_node, i);
|
||||
TypePtr type_ptr = TypeIdToType(AnfAlgo::GetOutputDeviceDataType(anf_node, i));
|
||||
MS_EXCEPTION_IF_NULL(type_ptr);
|
||||
int64_t size_i = 1;
|
||||
|
|
|
@ -45,7 +45,7 @@ std::vector<int64_t> GetInputValue(const CNodePtr &cnode, size_t index) {
|
|||
<< trace::DumpSourceLines(cnode);
|
||||
}
|
||||
|
||||
size_t x_num = shape_x[0];
|
||||
auto x_num = shape_x[0];
|
||||
std::vector<int64_t> x{SizeToLong(x_num)};
|
||||
|
||||
auto x_shape_value = std::make_shared<tensor::Tensor>(type_x, x);
|
||||
|
@ -60,7 +60,7 @@ std::vector<int64_t> GetInputValue(const CNodePtr &cnode, size_t index) {
|
|||
} else {
|
||||
auto x_value = reinterpret_cast<int *>(x_shape_value->data_c());
|
||||
MS_EXCEPTION_IF_NULL(x_value);
|
||||
for (size_t i = 0; i < x_num; i++) {
|
||||
for (int64_t i = 0; i < x_num; i++) {
|
||||
input_shape.push_back(static_cast<int64_t>(*x_value));
|
||||
++x_value;
|
||||
}
|
||||
|
|
|
@ -92,10 +92,10 @@ void MemCpyAsyncKernel::GetInputOutputTotalCount(const AnfNodePtr &anf_node) {
|
|||
MS_LOG(EXCEPTION) << "MemCpyAsync input size is not 1, got " << input_size;
|
||||
}
|
||||
size_t type_size = abstract::TypeIdSize(input_type_id_);
|
||||
std::vector<size_t> shape_i = AnfAlgo::GetInputDeviceShape(anf_node, 0);
|
||||
auto shape_i = AnfAlgo::GetInputDeviceShape(anf_node, 0);
|
||||
size_t total_size = 1;
|
||||
for (size_t i = 0; i < shape_i.size(); i++) {
|
||||
total_size = SizetMulWithOverflowCheck(total_size, shape_i[i]);
|
||||
total_size = SizetMulWithOverflowCheck(total_size, static_cast<size_t>(shape_i[i]));
|
||||
}
|
||||
total_size = SizetMulWithOverflowCheck(total_size, type_size);
|
||||
MS_LOG(INFO) << "MemCpyAsync size[" << total_size << "]";
|
||||
|
|
|
@ -99,12 +99,9 @@ void TensorCopySlices::GetInputOutputInfo(const AnfNodePtr &anf_node) {
|
|||
<< " output_type_id_:" << output_type_id_;
|
||||
}
|
||||
|
||||
auto input_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(anf_node, 0);
|
||||
auto update_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(anf_node, 1);
|
||||
auto output_shape = AnfAlgo::GetOutputDeviceShape(anf_node, 0);
|
||||
CastShapeSizeToLong(input_shape, &input_shape_);
|
||||
CastShapeSizeToLong(update_shape, &update_shape_);
|
||||
CastShapeSizeToLong(output_shape, &output_shape_);
|
||||
input_shape_ = common::AnfAlgo::GetPrevNodeOutputInferShape(anf_node, 0);
|
||||
update_shape_ = common::AnfAlgo::GetPrevNodeOutputInferShape(anf_node, 1);
|
||||
output_shape_ = AnfAlgo::GetOutputDeviceShape(anf_node, 0);
|
||||
}
|
||||
|
||||
void *TensorCopySlices::VoidPointerOffset(void *ptr, size_t offset) const {
|
||||
|
|
|
@ -121,6 +121,7 @@ RangePair TbeDynamicShapeUtil::GetInputDynamicRange(const AnfNodePtr &anf_node,
|
|||
std::string reshape_type = AnfAlgo::GetInputReshapeType(anf_node, index);
|
||||
trans::ShapeRangeTransfer shapeRangeTransfer;
|
||||
RangePair ret;
|
||||
|
||||
if (input_range_min.empty() && input_range_max.empty()) {
|
||||
auto prev_node = common::AnfAlgo::GetPrevNodeOutput(anf_node, index);
|
||||
MS_EXCEPTION_IF_NULL(prev_node.first);
|
||||
|
|
|
@ -103,9 +103,9 @@ bool TbeKernelBroadCastSelecter::IsBroadCastSupport5HD(SupportFormat *support_fo
|
|||
}
|
||||
}
|
||||
auto shape_tmp = input_shapes_[0];
|
||||
auto broadcast_c_axis = std::any_of(
|
||||
input_shapes_.begin(), input_shapes_.end(),
|
||||
[&shape_tmp](const std::vector<size_t> &elem) { return shape_tmp.at(kChannelC) != elem.at(kChannelC); });
|
||||
auto broadcast_c_axis =
|
||||
std::any_of(input_shapes_.begin(), input_shapes_.end(),
|
||||
[&shape_tmp](const ShapeVector &elem) { return shape_tmp.at(kChannelC) != elem.at(kChannelC); });
|
||||
if (broadcast_c_axis) {
|
||||
MS_LOG(INFO) << "This node broadcast c channel.";
|
||||
return false;
|
||||
|
@ -186,7 +186,7 @@ bool TbeKernelBroadCastSelecter::IsBroadCastSupportC1HWNCoC0(SupportFormat *supp
|
|||
}
|
||||
auto shape_tmp = input_shapes_[0];
|
||||
auto broadcast_nc_axis =
|
||||
std::any_of(input_shapes_.begin(), input_shapes_.end(), [&shape_tmp](const std::vector<size_t> &elem) {
|
||||
std::any_of(input_shapes_.begin(), input_shapes_.end(), [&shape_tmp](const ShapeVector &elem) {
|
||||
return (shape_tmp.at(kChannelC) != elem.at(kChannelC) || shape_tmp.at(kChannelN) != elem.at(kChannelN));
|
||||
});
|
||||
if (broadcast_nc_axis) {
|
||||
|
@ -230,7 +230,7 @@ bool TbeKernelBroadCastSelecter::IsBroadCastSupportFracNZ(SupportFormat *support
|
|||
}
|
||||
} else {
|
||||
auto less_2dims = std::any_of(input_shapes_.begin(), input_shapes_.end(),
|
||||
[](const std::vector<size_t> &elem) { return elem.size() < kShape2dDims; });
|
||||
[](const ShapeVector &elem) { return elem.size() < kShape2dDims; });
|
||||
if (less_2dims) {
|
||||
MS_LOG(INFO) << "This node dim less 2.";
|
||||
return false;
|
||||
|
@ -238,7 +238,7 @@ bool TbeKernelBroadCastSelecter::IsBroadCastSupportFracNZ(SupportFormat *support
|
|||
|
||||
auto shape_tmp = input_shapes_[0];
|
||||
auto broadcast_last_dim =
|
||||
std::any_of(input_shapes_.begin(), input_shapes_.end(), [&shape_tmp](const std::vector<size_t> &elem) {
|
||||
std::any_of(input_shapes_.begin(), input_shapes_.end(), [&shape_tmp](const ShapeVector &elem) {
|
||||
return (shape_tmp.at(shape_tmp.size() - 1) != elem.at(elem.size() - 1)) ||
|
||||
(shape_tmp.at(shape_tmp.size() - 2) != elem.at(elem.size() - 2));
|
||||
});
|
||||
|
@ -285,9 +285,9 @@ bool TbeKernelBroadCastSelecter::IsBroadCastSupportNDC1HWC0(SupportFormat *suppo
|
|||
}
|
||||
}
|
||||
auto shape_tmp = input_shapes_[0];
|
||||
auto broadcast_c_axis = std::any_of(
|
||||
input_shapes_.begin(), input_shapes_.end(),
|
||||
[&shape_tmp](const std::vector<size_t> &elem) { return shape_tmp.at(kChannelC) != elem.at(kChannelC); });
|
||||
auto broadcast_c_axis =
|
||||
std::any_of(input_shapes_.begin(), input_shapes_.end(),
|
||||
[&shape_tmp](const ShapeVector &elem) { return shape_tmp.at(kChannelC) != elem.at(kChannelC); });
|
||||
if (broadcast_c_axis) {
|
||||
MS_LOG(INFO) << "This node broadcast c channel.";
|
||||
return false;
|
||||
|
@ -300,13 +300,9 @@ bool TbeKernelBroadCastSelecter::IsBroadCastSupportNDC1HWC0(SupportFormat *suppo
|
|||
return true;
|
||||
}
|
||||
|
||||
bool TbeKernelBroadCastSelecter::Is4DShape(const std::vector<size_t> &shape) const {
|
||||
return shape.size() == kShape4dDims;
|
||||
}
|
||||
bool TbeKernelBroadCastSelecter::Is4DShape(const ShapeVector &shape) const { return shape.size() == kShape4dDims; }
|
||||
|
||||
bool TbeKernelBroadCastSelecter::Is5DShape(const std::vector<size_t> &shape) const {
|
||||
return shape.size() == kShape5dDims;
|
||||
}
|
||||
bool TbeKernelBroadCastSelecter::Is5DShape(const ShapeVector &shape) const { return shape.size() == kShape5dDims; }
|
||||
|
||||
bool TbeKernelBroadCastSelecter::IsSameShape() const {
|
||||
auto shape = input_shapes_.begin();
|
||||
|
@ -323,14 +319,14 @@ bool TbeKernelBroadCastSelecter::IsSameShape() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
void TbeKernelBroadCastSelecter::PadScalarShape(std::vector<size_t> *shape) const {
|
||||
void TbeKernelBroadCastSelecter::PadScalarShape(ShapeVector *shape) const {
|
||||
MS_EXCEPTION_IF_NULL(shape);
|
||||
if (shape->empty()) {
|
||||
shape->emplace_back(1);
|
||||
}
|
||||
}
|
||||
|
||||
bool TbeKernelBroadCastSelecter::IsScalarShape(const std::vector<size_t> &shape) const {
|
||||
bool TbeKernelBroadCastSelecter::IsScalarShape(const ShapeVector &shape) const {
|
||||
return (shape.size() == 1 && shape[0] == 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,10 +38,10 @@ class TbeKernelBroadCastSelecter {
|
|||
|
||||
private:
|
||||
bool IsSameShape() const;
|
||||
void PadScalarShape(std::vector<size_t> *shape) const;
|
||||
bool Is4DShape(const std::vector<size_t> &shape) const;
|
||||
bool Is5DShape(const std::vector<size_t> &shape) const;
|
||||
bool IsScalarShape(const std::vector<size_t> &shape) const;
|
||||
void PadScalarShape(ShapeVector *shape) const;
|
||||
bool Is4DShape(const ShapeVector &shape) const;
|
||||
bool Is5DShape(const ShapeVector &shape) const;
|
||||
bool IsScalarShape(const ShapeVector &shape) const;
|
||||
bool HasScalarInput() const;
|
||||
void GenOutputSupportFormat(const std::string &support_format, SupportFormatItem *output_support_item) const;
|
||||
void AssignSupportFormat(const std::string &support_format_str, SupportFormat *support_format) const;
|
||||
|
@ -49,8 +49,8 @@ class TbeKernelBroadCastSelecter {
|
|||
CNodePtr cnode_ptr_;
|
||||
size_t input_num_{};
|
||||
size_t output_num_{};
|
||||
std::vector<std::vector<size_t>> input_shapes_;
|
||||
std::vector<std::vector<size_t>> output_shapes_;
|
||||
std::vector<ShapeVector> input_shapes_;
|
||||
std::vector<ShapeVector> output_shapes_;
|
||||
};
|
||||
} // namespace kernel
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -153,11 +153,11 @@ void TbeKernelReduceSelecter::AssignSupportFormat(const std::string &support_for
|
|||
(void)support_format->output_format.emplace_back(output_support_format);
|
||||
}
|
||||
|
||||
bool TbeKernelReduceSelecter::Is4DShape(const std::vector<size_t> &shape) const { return shape.size() == kShape4dDims; }
|
||||
bool TbeKernelReduceSelecter::Is4DShape(const ShapeVector &shape) const { return shape.size() == kShape4dDims; }
|
||||
|
||||
bool TbeKernelReduceSelecter::Is5DShape(const std::vector<size_t> &shape) const { return shape.size() == kShape5dDims; }
|
||||
bool TbeKernelReduceSelecter::Is5DShape(const ShapeVector &shape) const { return shape.size() == kShape5dDims; }
|
||||
|
||||
void TbeKernelReduceSelecter::PadScalarShape(std::vector<size_t> *shape) const {
|
||||
void TbeKernelReduceSelecter::PadScalarShape(ShapeVector *shape) const {
|
||||
MS_EXCEPTION_IF_NULL(shape);
|
||||
if (shape->empty()) {
|
||||
(void)shape->emplace_back(1);
|
||||
|
|
|
@ -38,12 +38,12 @@ class TbeKernelReduceSelecter {
|
|||
bool IsFracZAndC1HWNCoC0Common(const std::string &format, SupportFormat *support_format) const;
|
||||
void GetReduceAttrKeepDim();
|
||||
void AssignSupportFormat(const std::string &support_format_str, SupportFormat *support_format) const;
|
||||
bool Is4DShape(const std::vector<size_t> &shape) const;
|
||||
bool Is5DShape(const std::vector<size_t> &shape) const;
|
||||
void PadScalarShape(std::vector<size_t> *shape) const;
|
||||
bool Is4DShape(const ShapeVector &shape) const;
|
||||
bool Is5DShape(const ShapeVector &shape) const;
|
||||
void PadScalarShape(ShapeVector *shape) const;
|
||||
CNodePtr cnode_ptr_;
|
||||
std::vector<size_t> input_shape_{};
|
||||
std::vector<size_t> output_shape_{};
|
||||
ShapeVector input_shape_{};
|
||||
ShapeVector output_shape_{};
|
||||
std::vector<int64_t> axis_{};
|
||||
bool keep_dims_ = false;
|
||||
};
|
||||
|
|
|
@ -337,7 +337,7 @@ bool TbeKernelSelect::FilterInVaildShape(const KernelBuildInfoIter &kernel_build
|
|||
return true;
|
||||
}
|
||||
|
||||
bool TbeKernelSelect::IsShapeMatchFormat(const std::vector<size_t> &shape, const std::string &format) {
|
||||
bool TbeKernelSelect::IsShapeMatchFormat(const ShapeVector &shape, const std::string &format) {
|
||||
if (format == kOpFormat_DEFAULT) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ class TbeKernelSelect {
|
|||
void GetReducePatternKernelInfo(const OpInfo &op_info);
|
||||
void FilterInVaildKernelInfo(const OpInfo &op_info);
|
||||
bool FilterInVaildShape(const KernelBuildInfoIter &kernel_build_info_iter, bool is_dynamic_input);
|
||||
static bool IsShapeMatchFormat(const std::vector<size_t> &shape, const std::string &format);
|
||||
static bool IsShapeMatchFormat(const ShapeVector &shape, const std::string &format);
|
||||
bool TbeCheckSupported(const KernelBuildInfoIter &kernel_build_info_iter);
|
||||
static void SetTbeBuildCommonInfo(const OpInfo &op_info, KernelBuildInfo::KernelBuildInfoBuilder *builder);
|
||||
std::vector<int64_t> GetNodeDynamicInputs();
|
||||
|
|
|
@ -108,21 +108,15 @@ void OpTilingCalculateAdapter::ConvertInputShapeAndType(const CNodePtr &node, ::
|
|||
auto ms_dtype = AnfAlgo::GetOutputDeviceDataType(input_node, input_index);
|
||||
|
||||
// ge info
|
||||
std::vector<int64_t> ge_shape;
|
||||
std::vector<int64_t> ge_ori_shape;
|
||||
::ge::DataType ge_dtype = ascend::GeTypesConvert::TransTypeIdToGeDataType(ms_dtype);
|
||||
::ge::Format ge_format = ascend::GeTypesConvert::GetGeFormat(ms_format, ms_shape.size());
|
||||
std::transform(ms_shape.begin(), ms_shape.end(), std::back_inserter(ge_shape),
|
||||
[](size_t s) { return static_cast<int64_t>(s); });
|
||||
std::transform(ms_ori_shape.begin(), ms_ori_shape.end(), std::back_inserter(ge_ori_shape),
|
||||
[](size_t s) { return static_cast<int64_t>(s); });
|
||||
|
||||
auto input_name = GetInputName(node, real_index);
|
||||
::ge::GeTensorDesc ge_tensor_desc;
|
||||
ge_tensor_desc.SetFormat(ge_format);
|
||||
ge_tensor_desc.SetDataType(ge_dtype);
|
||||
ge_tensor_desc.SetShape(::ge::GeShape(ge_shape));
|
||||
ge_tensor_desc.SetOriginShape(::ge::GeShape(ge_ori_shape));
|
||||
ge_tensor_desc.SetShape(::ge::GeShape(ms_shape));
|
||||
ge_tensor_desc.SetOriginShape(::ge::GeShape(ms_ori_shape));
|
||||
ge_tensor_desc.SetName(input_name);
|
||||
(void)(*op_desc)->AddInputDesc(input_name, ge_tensor_desc);
|
||||
}
|
||||
|
@ -138,20 +132,15 @@ void OpTilingCalculateAdapter::ConvertOutputShapeAndType(const CNodePtr &node, :
|
|||
auto ms_format = AnfAlgo::GetOutputFormat(node, i);
|
||||
auto ms_dtype = AnfAlgo::GetOutputDeviceDataType(node, i);
|
||||
|
||||
std::vector<int64_t> ge_shape;
|
||||
std::vector<int64_t> ge_ori_shape;
|
||||
::ge::DataType ge_dtype = ascend::GeTypesConvert::TransTypeIdToGeDataType(ms_dtype);
|
||||
::ge::Format ge_format = ascend::GeTypesConvert::GetGeFormat(ms_format, ms_shape.size());
|
||||
std::transform(ms_shape.begin(), ms_shape.end(), std::back_inserter(ge_shape),
|
||||
[](size_t s) { return static_cast<int64_t>(s); });
|
||||
std::transform(ms_ori_shape.begin(), ms_ori_shape.end(), std::back_inserter(ge_ori_shape),
|
||||
[](size_t s) { return static_cast<int64_t>(s); });
|
||||
|
||||
auto output_name = GetOutputName(node, i);
|
||||
::ge::GeTensorDesc ge_tensor_desc;
|
||||
ge_tensor_desc.SetFormat(ge_format);
|
||||
ge_tensor_desc.SetDataType(ge_dtype);
|
||||
ge_tensor_desc.SetShape(::ge::GeShape(ge_shape));
|
||||
ge_tensor_desc.SetOriginShape(::ge::GeShape(ge_ori_shape));
|
||||
ge_tensor_desc.SetShape(::ge::GeShape(ms_shape));
|
||||
ge_tensor_desc.SetOriginShape(::ge::GeShape(ms_ori_shape));
|
||||
ge_tensor_desc.SetName(output_name);
|
||||
(void)(*op_desc)->AddOutputDesc(output_name, ge_tensor_desc);
|
||||
}
|
||||
|
@ -224,18 +213,12 @@ void OpTilingCalculateAdapter::ConvertAtomicCompileInfo(const CNodePtr &node, ::
|
|||
MS_EXCEPTION_IF_NULL(tensor_data);
|
||||
::ge::OpDescPtr op_desc = std::make_shared<::ge::OpDesc>(name, CONSTANTOP);
|
||||
auto ms_format = AnfAlgo::GetPrevNodeOutputFormat(node, index);
|
||||
auto ms_ori_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(node, index);
|
||||
auto ge_ori_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(node, index);
|
||||
auto ms_dtype = AnfAlgo::GetPrevNodeOutputDeviceDataType(node, index);
|
||||
auto ms_shape = AnfAlgo::GetInputDeviceShape(node, index);
|
||||
auto ge_shape = AnfAlgo::GetInputDeviceShape(node, index);
|
||||
|
||||
std::vector<int64_t> ge_shape;
|
||||
std::vector<int64_t> ge_ori_shape;
|
||||
std::transform(ms_shape.begin(), ms_shape.end(), std::back_inserter(ge_shape),
|
||||
[](size_t s) { return static_cast<int64_t>(s); });
|
||||
std::transform(ms_ori_shape.begin(), ms_ori_shape.end(), std::back_inserter(ge_ori_shape),
|
||||
[](size_t s) { return static_cast<int64_t>(s); });
|
||||
::ge::DataType ge_dtype = ascend::GeTypesConvert::TransTypeIdToGeDataType(ms_dtype);
|
||||
::ge::Format ge_format = ascend::GeTypesConvert::GetGeFormat(ms_format, ms_shape.size());
|
||||
::ge::Format ge_format = ascend::GeTypesConvert::GetGeFormat(ms_format, ge_shape.size());
|
||||
::ge::GeTensorDesc ge_tensor_desc;
|
||||
ge_tensor_desc.SetFormat(ge_format);
|
||||
ge_tensor_desc.SetDataType(ge_dtype);
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace mindspore {
|
|||
namespace opt {
|
||||
using KernelBuildInfoBuilder = kernel::KernelBuildInfo::KernelBuildInfoBuilder;
|
||||
namespace {
|
||||
bool NeedInsertTransData(const std::vector<size_t> &origin_shape, const std::string &format) {
|
||||
bool NeedInsertTransData(const ShapeVector &origin_shape, const std::string &format) {
|
||||
bool shape_check = origin_shape.size() > 1 || (origin_shape.size() == 1 && origin_shape[0] % kCubeSize != 0);
|
||||
return kCommonFormatSet.find(format) == kCommonFormatSet.end() && (shape_check || format == kOpFormat_ND_RNN_BIAS);
|
||||
}
|
||||
|
@ -72,10 +72,8 @@ CNodePtr CreateReshapeNode(const FuncGraphPtr &func_graph, const AnfNodePtr &inp
|
|||
common::AnfAlgo::SetNodeAttr(kAttrReshapePaddingAxis, MakeValue(padding_axis), reshape);
|
||||
}
|
||||
} else {
|
||||
std::vector<size_t> shape_size_t;
|
||||
std::transform(dst_shape->shape().begin(), dst_shape->shape().end(), std::back_inserter(shape_size_t), LongToSize);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({common::AnfAlgo::GetOutputInferDataType(input_node, 0)},
|
||||
{shape_size_t}, reshape.get());
|
||||
{dst_shape->shape()}, reshape.get());
|
||||
}
|
||||
|
||||
common::AnfAlgo::SetNodeAttr(kAttrVisited, MakeValue(true), reshape);
|
||||
|
@ -157,7 +155,7 @@ AnfNodePtr GetTransInputNodePtr(const FuncGraphPtr &func_graph, const CNodePtr &
|
|||
MS_EXCEPTION_IF_NULL(input_node);
|
||||
common::AnfAlgo::SetNodeInput(node, input_node, index);
|
||||
}
|
||||
std::vector<size_t> origin_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(node, index);
|
||||
ShapeVector origin_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(node, index);
|
||||
std::string dest_format = AnfAlgo::GetInputFormat(node, index);
|
||||
if (NeedInsertTransData(origin_shape, dest_format)) {
|
||||
MS_LOG(DEBUG) << node->DebugString() << "Insert transdata " << AnfAlgo::GetInputFormat(node, index)
|
||||
|
@ -176,7 +174,7 @@ AnfNodePtr InsertTransOpForSingleOutput(const FuncGraphPtr &func_graph, const An
|
|||
MS_EXCEPTION_IF_NULL(node);
|
||||
MS_EXCEPTION_IF_NULL(func_graph);
|
||||
std::string output_format = AnfAlgo::GetOutputFormat(node, 0);
|
||||
std::vector<size_t> origin_shape = common::AnfAlgo::GetOutputInferShape(node, 0);
|
||||
auto origin_shape = common::AnfAlgo::GetOutputInferShape(node, 0);
|
||||
if (output_format == kOpFormat_NC1KHKWHWC0) {
|
||||
MS_LOG(EXCEPTION) << "Got the hw format " << output_format << "when insert the transdata node "
|
||||
<< node->DebugString() << trace::DumpSourceLines(node);
|
||||
|
@ -211,7 +209,7 @@ AnfNodePtr InsertTransOpForMultipleOutput(const FuncGraphPtr &func_graph, const
|
|||
<< node->DebugString() << trace::DumpSourceLines(node);
|
||||
}
|
||||
auto tuple_getitem = CreatTupleGetItemNode(func_graph, node, output_idx);
|
||||
std::vector<size_t> origin_shape = common::AnfAlgo::GetOutputInferShape(node, output_idx);
|
||||
auto origin_shape = common::AnfAlgo::GetOutputInferShape(node, output_idx);
|
||||
if (NeedInsertTransData(origin_shape, output_format)) {
|
||||
auto trans_op = AddTransOpNodeToGraph(func_graph, tuple_getitem, kernel_select, 0, false);
|
||||
if (kernel_graph != nullptr && kernel_graph->IsInternalOutput(node, output_idx)) {
|
||||
|
|
|
@ -25,9 +25,9 @@ namespace {
|
|||
OutputInfo GetNodeOutputInfo(const AnfNodePtr &node) {
|
||||
MS_EXCEPTION_IF_NULL(node);
|
||||
std::vector<TypeId> output_infer_dtype;
|
||||
std::vector<std::vector<size_t>> output_infer_shape;
|
||||
std::vector<std::vector<int64_t>> output_max_shape;
|
||||
std::vector<std::vector<int64_t>> output_min_shape;
|
||||
std::vector<ShapeVector> output_infer_shape;
|
||||
std::vector<ShapeVector> output_max_shape;
|
||||
std::vector<ShapeVector> output_min_shape;
|
||||
std::vector<std::string> output_format;
|
||||
std::vector<TypeId> output_device_dtype;
|
||||
auto type_ptr = node->Type();
|
||||
|
@ -109,18 +109,15 @@ AnfNodePtr ConcatOutputsForAllGather::InsertConcatForOutput(const FuncGraphPtr &
|
|||
MS_EXCEPTION_IF_NULL(new_tuple_getitems[i]);
|
||||
const std::vector<TypeId> &dtypes = {std::get<0>(output_info)[i]};
|
||||
auto shape = std::get<1>(output_info)[i];
|
||||
shape[0] *= LongToSize(rank_size);
|
||||
if (AnfUtils::IsShapeDynamic(shape)) {
|
||||
ShapeVector tensor_shape;
|
||||
shape[0] *= rank_size;
|
||||
if (IsDynamic(shape)) {
|
||||
auto min_shape = std::get<kIndex2>(output_info)[i];
|
||||
auto max_shape = std::get<kIndex3>(output_info)[i];
|
||||
if (!min_shape.empty() && !max_shape.empty()) {
|
||||
max_shape[0] *= rank_size;
|
||||
min_shape[0] *= rank_size;
|
||||
}
|
||||
|
||||
(void)std::transform(shape.begin(), shape.end(), std::back_inserter(tensor_shape), SizeToLong);
|
||||
BaseShapePtr base_shape = std::make_shared<abstract::Shape>(tensor_shape, min_shape, max_shape);
|
||||
BaseShapePtr base_shape = std::make_shared<abstract::Shape>(shape, min_shape, max_shape);
|
||||
common::AnfAlgo::SetOutputTypeAndDetailShape(dtypes, {base_shape}, concat.get());
|
||||
} else {
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(dtypes, {shape}, concat.get());
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
namespace mindspore {
|
||||
namespace opt {
|
||||
using OutputInfo = std::tuple<std::vector<TypeId>, std::vector<std::vector<size_t>>, std::vector<std::vector<int64_t>>,
|
||||
using OutputInfo = std::tuple<std::vector<TypeId>, std::vector<ShapeVector>, std::vector<std::vector<int64_t>>,
|
||||
std::vector<std::vector<int64_t>>, std::vector<std::string>, std::vector<TypeId>>;
|
||||
|
||||
class ConcatOutputsForAllGather : public PatternProcessPass {
|
||||
|
|
|
@ -132,7 +132,7 @@ AnfNodePtr InsertForOutput(const FuncGraphPtr &func_graph, const CNodePtr &orig_
|
|||
return make_tuple;
|
||||
}
|
||||
|
||||
AnfNodePtr InsertTranspose(const FuncGraphPtr &func_graph, const CNodePtr &node, const std::vector<size_t> &in_shape,
|
||||
AnfNodePtr InsertTranspose(const FuncGraphPtr &func_graph, const CNodePtr &node, const ShapeVector &in_shape,
|
||||
int64_t axis) {
|
||||
MS_EXCEPTION_IF_NULL(func_graph);
|
||||
MS_EXCEPTION_IF_NULL(node);
|
||||
|
|
|
@ -28,7 +28,7 @@ std::vector<AnfNodePtr> SplitInputsForReduceScatter::InsertSplitForInput(const F
|
|||
size_t inputs_size = common::AnfAlgo::GetInputTensorNum(node);
|
||||
std::vector<AnfNodePtr> split_outputs;
|
||||
size_t rank_size_t = LongToSize(rank_size);
|
||||
if (rank_size_t == 0) {
|
||||
if (rank_size == 0) {
|
||||
MS_LOG(EXCEPTION) << "The rank size can not be zero.";
|
||||
}
|
||||
for (size_t i = 0; i < inputs_size; i++) {
|
||||
|
@ -39,23 +39,20 @@ std::vector<AnfNodePtr> SplitInputsForReduceScatter::InsertSplitForInput(const F
|
|||
std::vector<TypeId> dtypes(rank_size, common::AnfAlgo::GetPrevNodeOutputInferDataType(node, i));
|
||||
|
||||
std::vector<int> size_splits;
|
||||
std::vector<size_t> output_node_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(node, i);
|
||||
output_node_shape[0] /= rank_size_t;
|
||||
if (AnfUtils::IsShapeDynamic(output_node_shape)) {
|
||||
auto output_node_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(node, i);
|
||||
output_node_shape[0] /= rank_size;
|
||||
if (IsDynamic(output_node_shape)) {
|
||||
auto min_shape = common::AnfAlgo::GetInputMinShape(node, i);
|
||||
auto max_shape = common::AnfAlgo::GetInputMaxShape(node, i);
|
||||
if (!min_shape.empty() && !max_shape.empty()) {
|
||||
min_shape[0] /= static_cast<int64_t>(rank_size_t);
|
||||
max_shape[0] /= static_cast<int64_t>(rank_size_t);
|
||||
min_shape[0] /= rank_size;
|
||||
max_shape[0] /= rank_size;
|
||||
}
|
||||
|
||||
ShapeVector shape_tmp;
|
||||
(void)std::transform(output_node_shape.begin(), output_node_shape.end(), std::back_inserter(shape_tmp),
|
||||
SizeToLong);
|
||||
std::vector<BaseShapePtr> shapes(rank_size_t, std::make_shared<abstract::Shape>(shape_tmp, min_shape, max_shape));
|
||||
std::vector<BaseShapePtr> shapes(rank_size_t,
|
||||
std::make_shared<abstract::Shape>(output_node_shape, min_shape, max_shape));
|
||||
common::AnfAlgo::SetOutputTypeAndDetailShape(dtypes, shapes, split.get());
|
||||
} else {
|
||||
std::vector<std::vector<size_t>> shapes(rank_size_t, output_node_shape);
|
||||
std::vector<ShapeVector> shapes(rank_size_t, output_node_shape);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(dtypes, shapes, split.get());
|
||||
}
|
||||
|
||||
|
|
|
@ -47,13 +47,13 @@ CNodePtr Insert(const FuncGraphPtr &func_graph, const CNodePtr &cnode, const std
|
|||
auto origin_type = common::AnfAlgo::GetPrevNodeOutputInferDataType(cnode, 1);
|
||||
auto origin_shape = common::AnfAlgo::GetPrevNodeOutputInferShape(cnode, 1);
|
||||
auto dst_shape = {origin_shape[1], origin_shape[0]};
|
||||
auto is_dynamic = AnfUtils::IsShapeDynamic(dst_shape);
|
||||
auto is_dynamic = IsDynamic(dst_shape);
|
||||
|
||||
transpose_inputs.push_back(common::AnfAlgo::GetInputNode(cnode, 1));
|
||||
CNodePtr transpose = func_graph->NewCNode(transpose_inputs);
|
||||
MS_EXCEPTION_IF_NULL(transpose);
|
||||
if (is_dynamic) {
|
||||
auto shape = {SizeToLong(origin_shape[1]), SizeToLong(origin_shape[0])};
|
||||
auto shape = {origin_shape[1], origin_shape[0]};
|
||||
auto max_shape = common::AnfAlgo::GetInputMaxShape(cnode, 1);
|
||||
auto min_shape = common::AnfAlgo::GetInputMinShape(cnode, 1);
|
||||
auto min_shape_tmp = min_shape;
|
||||
|
@ -86,8 +86,8 @@ CNodePtr Insert(const FuncGraphPtr &func_graph, const CNodePtr &cnode, const std
|
|||
transpose_inputs.push_back(tuple_getitem);
|
||||
CNodePtr transpose = func_graph->NewCNode(transpose_inputs);
|
||||
MS_EXCEPTION_IF_NULL(transpose);
|
||||
if (AnfUtils::IsShapeDynamic(origin_shape)) {
|
||||
auto dst_shape = {SizeToLong(origin_shape[0]), SizeToLong(origin_shape[1])};
|
||||
if (IsDynamic(origin_shape)) {
|
||||
auto dst_shape = {origin_shape[0], origin_shape[1]};
|
||||
auto min_shape = common::AnfAlgo::GetOutputMinShape(cnode, output_idx);
|
||||
auto max_shape = common::AnfAlgo::GetOutputMaxShape(cnode, output_idx);
|
||||
auto min_shape_tmp = min_shape;
|
||||
|
|
|
@ -60,10 +60,8 @@ CNodePtr AddBroadCastToNode(const FuncGraphPtr &func_graph, const CNodePtr &inpu
|
|||
CNodePtr broadcastto_node = NewCNode(broadcastto_inputs, func_graph);
|
||||
broadcastto_node->set_scope(input_node->scope());
|
||||
broadcastto_node->set_abstract(input_node->abstract());
|
||||
std::vector<size_t> out_shape;
|
||||
std::transform(broad_shape.begin(), broad_shape.end(), std::back_inserter(out_shape), SizeToLong);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrShape, MakeValue<std::vector<int64_t>>(broad_shape), broadcastto_node);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({input_type}, {out_shape}, broadcastto_node.get());
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({input_type}, {broad_shape}, broadcastto_node.get());
|
||||
return broadcastto_node;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ constexpr size_t kCdistGradInputNum = 4;
|
|||
constexpr int64_t kInputXDimP = -1;
|
||||
constexpr int64_t kInputYDimR = -2;
|
||||
|
||||
std::vector<size_t> CalCdistBroadCastShape(std::vector<size_t> x_shape, std::vector<size_t> y_shape) {
|
||||
ShapeVector CalCdistBroadCastShape(ShapeVector x_shape, ShapeVector y_shape) {
|
||||
(void)x_shape.insert(x_shape.end() + kInputXDimP, 1);
|
||||
(void)y_shape.insert(y_shape.end() + kInputYDimR, 1);
|
||||
if (x_shape.size() != y_shape.size()) {
|
||||
|
@ -38,7 +38,7 @@ std::vector<size_t> CalCdistBroadCastShape(std::vector<size_t> x_shape, std::vec
|
|||
return x_shape;
|
||||
}
|
||||
auto length = x_shape.size();
|
||||
std::vector<size_t> broadcast_shape;
|
||||
ShapeVector broadcast_shape;
|
||||
(void)std::copy(x_shape.begin(), x_shape.end() - SizeToLong(length), std::back_inserter(broadcast_shape));
|
||||
for (size_t i = length; i > 0; --i) {
|
||||
if (x_shape[length - i] == 1) {
|
||||
|
@ -56,7 +56,7 @@ std::vector<size_t> CalCdistBroadCastShape(std::vector<size_t> x_shape, std::vec
|
|||
}
|
||||
|
||||
AnfNodePtr AddBroadCastToNode(const FuncGraphPtr &func_graph, const AnfNodePtr &input_node, int64_t dim,
|
||||
const std::vector<size_t> &need_shape, const PatternProcessPass &pass) {
|
||||
const ShapeVector &need_shape, const PatternProcessPass &pass) {
|
||||
MS_EXCEPTION_IF_NULL(func_graph);
|
||||
MS_EXCEPTION_IF_NULL(input_node);
|
||||
// Add ExpandDims Node
|
||||
|
@ -74,9 +74,7 @@ AnfNodePtr AddBroadCastToNode(const FuncGraphPtr &func_graph, const AnfNodePtr &
|
|||
NewValueNode(std::make_shared<Primitive>(prim::kPrimBroadcastTo->name())), expand_dims};
|
||||
auto broadcast_to = pass.NewCNode(broadcast_to_inputs, func_graph);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({dtype}, {need_shape}, broadcast_to.get());
|
||||
std::vector<int64_t> shape;
|
||||
(void)std::transform(need_shape.begin(), need_shape.end(), std::back_inserter(shape), LongToSize);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrShape, MakeValue(shape), broadcast_to);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrShape, MakeValue(need_shape), broadcast_to);
|
||||
common::AnfAlgo::SetNodeAttr("is_backend_insert", MakeValue(true), broadcast_to);
|
||||
return broadcast_to;
|
||||
}
|
||||
|
|
|
@ -33,32 +33,30 @@ namespace {
|
|||
constexpr int64_t kGroupsDefaultValue = 1;
|
||||
|
||||
template <typename T>
|
||||
void SetAssistTensorData(void *data, const T &value, size_t dims_size) {
|
||||
void SetAssistTensorData(void *data, const T &value, int64_t dims_size) {
|
||||
MS_EXCEPTION_IF_NULL(data);
|
||||
auto tensor_data = static_cast<T *>(data);
|
||||
for (size_t i = 0; i < dims_size; ++i) {
|
||||
for (size_t i = 0; i < static_cast<size_t>(dims_size); ++i) {
|
||||
tensor_data[i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
ValueNodePtr CreateAssistNode(const FuncGraphPtr &func_graph, const AnfNodePtr &node, const std::vector<size_t> &shape,
|
||||
size_t matrix_size) {
|
||||
ValueNodePtr CreateAssistNode(const FuncGraphPtr &func_graph, const AnfNodePtr &node, const ShapeVector &shape,
|
||||
int64_t matrix_size) {
|
||||
MS_EXCEPTION_IF_NULL(func_graph);
|
||||
MS_EXCEPTION_IF_NULL(node);
|
||||
auto type = common::AnfAlgo::GetOutputInferDataType(node, 0);
|
||||
std::vector<int64_t> assist_shape;
|
||||
std::transform(shape.begin(), shape.end(), std::back_inserter(assist_shape), SizeToLong);
|
||||
tensor::TensorPtr tensor = std::make_shared<tensor::Tensor>(type, assist_shape);
|
||||
tensor::TensorPtr tensor = std::make_shared<tensor::Tensor>(type, shape);
|
||||
AbstractBasePtr x_abstract;
|
||||
if (type == kNumberTypeInt32) {
|
||||
SetAssistTensorData<int32_t>(tensor->data_c(), 1, matrix_size);
|
||||
x_abstract = std::make_shared<abstract::AbstractTensor>(kInt32, assist_shape);
|
||||
x_abstract = std::make_shared<abstract::AbstractTensor>(kInt32, shape);
|
||||
} else if (type == kNumberTypeFloat16) {
|
||||
SetAssistTensorData<float16>(tensor->data_c(), float16(static_cast<float>(1)), matrix_size);
|
||||
x_abstract = std::make_shared<abstract::AbstractTensor>(kFloat16, assist_shape);
|
||||
x_abstract = std::make_shared<abstract::AbstractTensor>(kFloat16, shape);
|
||||
} else if (type == kNumberTypeFloat32) {
|
||||
SetAssistTensorData<float>(tensor->data_c(), static_cast<float>(1), matrix_size);
|
||||
x_abstract = std::make_shared<abstract::AbstractTensor>(kFloat, assist_shape);
|
||||
x_abstract = std::make_shared<abstract::AbstractTensor>(kFloat, shape);
|
||||
} else {
|
||||
MS_EXCEPTION(TypeError) << "The type of node [" << node->DebugString()
|
||||
<< "] should be int32, float16 or float32, but got" << node->Type()->ToString();
|
||||
|
|
|
@ -28,39 +28,37 @@ constexpr size_t kDiagInputNum = 1;
|
|||
constexpr size_t kDiagInputMaxDim = 4;
|
||||
|
||||
template <typename T>
|
||||
void SetAssistTensorData(void *data, const T &value, size_t dims_size) {
|
||||
void SetAssistTensorData(void *data, const T &value, int64_t dims_size) {
|
||||
MS_EXCEPTION_IF_NULL(data);
|
||||
auto tensor_data = reinterpret_cast<T *>(data);
|
||||
for (size_t i = 0; i < dims_size; ++i) {
|
||||
tensor_data[(1 + dims_size) * i] = value;
|
||||
for (size_t i = 0; i < static_cast<size_t>(dims_size); ++i) {
|
||||
tensor_data[(1 + static_cast<size_t>(dims_size)) * i] = value;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
ValueNodePtr DiagFission::CreateAssistNode(const FuncGraphPtr &func_graph, const AnfNodePtr &node,
|
||||
const std::vector<size_t> &ori_shape) const {
|
||||
const ShapeVector &ori_shape) const {
|
||||
MS_EXCEPTION_IF_NULL(func_graph);
|
||||
MS_EXCEPTION_IF_NULL(node);
|
||||
std::vector<size_t> output_shape(ori_shape);
|
||||
size_t dims = 1;
|
||||
ShapeVector output_shape(ori_shape);
|
||||
ShapeValueDType dims = 1;
|
||||
for (size_t i = 0; i < ori_shape.size(); i++) {
|
||||
dims = dims * ori_shape[i];
|
||||
}
|
||||
(void)output_shape.insert(output_shape.end(), ori_shape.begin(), ori_shape.end());
|
||||
auto type = common::AnfAlgo::GetOutputInferDataType(node, 0);
|
||||
std::vector<int64_t> assist_shape;
|
||||
std::transform(output_shape.begin(), output_shape.end(), std::back_inserter(assist_shape), SizeToLong);
|
||||
tensor::TensorPtr tensor = std::make_shared<tensor::Tensor>(type, assist_shape);
|
||||
tensor::TensorPtr tensor = std::make_shared<tensor::Tensor>(type, output_shape);
|
||||
AbstractBasePtr x_abstract;
|
||||
if (type == kNumberTypeInt32) {
|
||||
SetAssistTensorData<int32_t>(tensor->data_c(), 1, dims);
|
||||
x_abstract = std::make_shared<abstract::AbstractTensor>(kInt32, assist_shape);
|
||||
x_abstract = std::make_shared<abstract::AbstractTensor>(kInt32, output_shape);
|
||||
} else if (type == kNumberTypeFloat16) {
|
||||
SetAssistTensorData<float16>(tensor->data_c(), float16(static_cast<float>(1)), dims);
|
||||
x_abstract = std::make_shared<abstract::AbstractTensor>(kFloat16, assist_shape);
|
||||
x_abstract = std::make_shared<abstract::AbstractTensor>(kFloat16, output_shape);
|
||||
} else if (type == kNumberTypeFloat32) {
|
||||
SetAssistTensorData<float>(tensor->data_c(), static_cast<float>(1), dims);
|
||||
x_abstract = std::make_shared<abstract::AbstractTensor>(kFloat, assist_shape);
|
||||
x_abstract = std::make_shared<abstract::AbstractTensor>(kFloat, output_shape);
|
||||
} else {
|
||||
MS_EXCEPTION(TypeError) << "The type of node [" << node->DebugString()
|
||||
<< "] should be int32, float16 or float32, but got" << node->Type()->ToString();
|
||||
|
|
|
@ -32,7 +32,7 @@ class DiagFission : public PatternProcessPass {
|
|||
|
||||
protected:
|
||||
ValueNodePtr CreateAssistNode(const FuncGraphPtr &func_graph, const AnfNodePtr &node,
|
||||
const std::vector<size_t> &ori_shape) const;
|
||||
const ShapeVector &ori_shape) const;
|
||||
};
|
||||
} // namespace opt
|
||||
} // namespace mindspore
|
||||
|
|
|
@ -100,10 +100,9 @@ AnfNodePtr DynamicGRUV2GradFission::CreateGRUV2HiddenGradCellNode(const FuncGrap
|
|||
(void)gru_v2_hidden_grad_cell_inputs.emplace_back(dynamic_gru_v2_grad_inputs[input_index["hidden_new"]]);
|
||||
auto gru_v2_hidden_grad_cell_op = NewCNode(gru_v2_hidden_grad_cell_inputs, func_graph);
|
||||
|
||||
std::vector<size_t> dh_prev_shape =
|
||||
common::AnfAlgo::GetOutputInferShape(dynamic_gru_grad_outputs[output_index["dh_prev"]], 0);
|
||||
std::vector<size_t> dgate_h_shape = {1, batch_size, kGateNum * hidden_size};
|
||||
std::vector<size_t> dnt_x_shape = {1, batch_size, hidden_size};
|
||||
auto dh_prev_shape = common::AnfAlgo::GetOutputInferShape(dynamic_gru_grad_outputs[output_index["dh_prev"]], 0);
|
||||
ShapeVector dgate_h_shape = {1, SizeToLong(batch_size), SizeToLong(kGateNum * hidden_size)};
|
||||
ShapeVector dnt_x_shape = {1, SizeToLong(batch_size), SizeToLong(hidden_size)};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(
|
||||
{dh_dtype, dh_dtype, dh_dtype}, {dh_prev_shape, dgate_h_shape, dnt_x_shape}, gru_v2_hidden_grad_cell_op.get());
|
||||
common::AnfAlgo::SetNodeAttr("t_state", MakeValue(SizeToLong(cur_t)), gru_v2_hidden_grad_cell_op);
|
||||
|
@ -142,13 +141,13 @@ void DynamicGRUV2GradFission::AddTLoopNode(const FuncGraphPtr &func_graph, const
|
|||
weight_hidden};
|
||||
auto reshape = NewCNode(reshape_inputs, func_graph);
|
||||
auto weight_hidden_dtype = common::AnfAlgo::GetOutputInferDataType(weight_hidden, input_index["weight_hidden"]);
|
||||
auto reshape_out_shape = {IntToSize(1), common::AnfAlgo::GetOutputInferShape(weight_hidden, 0)[0],
|
||||
common::AnfAlgo::GetOutputInferShape(weight_hidden, 0)[1]};
|
||||
ShapeVector reshape_out_shape = {1, common::AnfAlgo::GetOutputInferShape(weight_hidden, 0)[0],
|
||||
common::AnfAlgo::GetOutputInferShape(weight_hidden, 0)[1]};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({weight_hidden_dtype}, {reshape_out_shape}, reshape.get());
|
||||
(void)matmul_inputs.emplace_back(reshape);
|
||||
auto matmul_node = NewCNode(matmul_inputs, func_graph);
|
||||
MS_EXCEPTION_IF_NULL(matmul_node);
|
||||
std::vector<size_t> out_shape = {1, batch_size, hidden_size};
|
||||
ShapeVector out_shape = {1, SizeToLong(batch_size), SizeToLong(hidden_size)};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({weight_hidden_dtype}, {out_shape}, matmul_node.get());
|
||||
common::AnfAlgo::SetNodeAttr("transpose_x1", MakeValue(false), matmul_node);
|
||||
common::AnfAlgo::SetNodeAttr("transpose_x2", MakeValue(true), matmul_node);
|
||||
|
@ -181,7 +180,7 @@ AnfNodePtr DynamicGRUV2GradFission::AddTConcatNode(const FuncGraphPtr &func_grap
|
|||
}
|
||||
auto concat_t_node = NewCNode(concat_inputs, func_graph);
|
||||
auto out_dims = common::AnfAlgo::GetOutputInferShape(gru_hidden_grad_nodes[kIndex0], concat_output_index);
|
||||
std::vector<size_t> concat_output_shape = {t_size, out_dims[kDim1], out_dims[kDim2]};
|
||||
ShapeVector concat_output_shape = {SizeToLong(t_size), out_dims[kDim1], out_dims[kDim2]};
|
||||
auto out_type = common::AnfAlgo::GetOutputInferDataType(gru_hidden_grad_nodes[kIndex0], concat_output_index);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({out_type}, {concat_output_shape}, concat_t_node.get());
|
||||
common::AnfAlgo::SetNodeAttr(kAttrN, MakeValue(SizeToLong(t_size)), concat_t_node);
|
||||
|
@ -232,7 +231,7 @@ AnfNodePtr DynamicGRUV2GradFission::AddHSplitNode(const FuncGraphPtr &func_graph
|
|||
std::vector<size_t> output1_shape = {t_size - 1, batch_size, hidden_size};
|
||||
std::vector<size_t> output2_shape = {1, batch_size, hidden_size};
|
||||
std::vector<int64_t> split_list = {SizeToLong(t_size - 1), 1};
|
||||
std::vector<std::vector<size_t>> shapes = {output1_shape, output2_shape};
|
||||
std::vector<ShapeVector> shapes = {Convert2Long(output1_shape), Convert2Long(output2_shape)};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(dtypes, shapes, split_v.get());
|
||||
// Set attr
|
||||
common::AnfAlgo::SetNodeAttr(kAttrSplitDim, MakeValue(SizeToLong(0)), split_v);
|
||||
|
@ -246,17 +245,17 @@ AnfNodePtr DynamicGRUV2GradFission::CreateHReshape(const FuncGraphPtr &graph, co
|
|||
MS_EXCEPTION_IF_NULL(graph);
|
||||
MS_EXCEPTION_IF_NULL(node);
|
||||
auto ori_shape = common::AnfAlgo::GetOutputInferShape(node, 0);
|
||||
std::vector<std::vector<size_t>> shape_tmp;
|
||||
ShapeVector shape_tmp;
|
||||
if (ori_shape.size() == k3Dims) {
|
||||
shape_tmp = {ori_shape};
|
||||
} else {
|
||||
shape_tmp = {{IntToSize(1), ori_shape[kDim0], ori_shape[kDim1]}};
|
||||
shape_tmp = {{1, ori_shape[kDim0], ori_shape[kDim1]}};
|
||||
}
|
||||
auto ori_dtype = {common::AnfAlgo::GetOutputInferDataType(node, 0)};
|
||||
// reshape
|
||||
std::vector<AnfNodePtr> reshape_input = {NewValueNode(std::make_shared<Primitive>(prim::kPrimReshape->name())), node};
|
||||
auto reshape = NewCNode(reshape_input, graph);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(ori_dtype, shape_tmp, reshape.get());
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(ori_dtype, {shape_tmp}, reshape.get());
|
||||
common::AnfAlgo::SetNodeAttr("is_backend_insert", MakeValue(true), reshape);
|
||||
return reshape;
|
||||
}
|
||||
|
@ -280,7 +279,7 @@ AnfNodePtr DynamicGRUV2GradFission::AddHConcatNode(const FuncGraphPtr &func_grap
|
|||
(void)concat_inputs.emplace_back(splitv_outputs[kIndex0]);
|
||||
auto concat = NewCNode(concat_inputs, func_graph);
|
||||
// Set infer data type and shape
|
||||
std::vector<size_t> output_shape = {t_size, batch_size, hidden_size};
|
||||
ShapeVector output_shape = Convert2Long({t_size, batch_size, hidden_size});
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({common::AnfAlgo::GetOutputInferDataType(init_h_reshape, 0)},
|
||||
{output_shape}, concat.get());
|
||||
// Set attr
|
||||
|
@ -307,7 +306,7 @@ AnfNodePtr DynamicGRUV2GradFission::AddDwhMatmulNode(const FuncGraphPtr &func_gr
|
|||
(void)matmul_inputs.emplace_back(dgate_h);
|
||||
}
|
||||
auto batch_matmul = NewCNode(matmul_inputs, func_graph);
|
||||
std::vector<size_t> shape = {t_size, hidden_size, kGateNum * hidden_size};
|
||||
ShapeVector shape = Convert2Long({t_size, hidden_size, kGateNum * hidden_size});
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({kNumberTypeFloat16}, {shape}, batch_matmul.get());
|
||||
common::AnfAlgo::SetNodeAttr("transpose_x1", MakeValue(true), batch_matmul);
|
||||
common::AnfAlgo::SetNodeAttr("transpose_x2", MakeValue(false), batch_matmul);
|
||||
|
@ -330,9 +329,9 @@ AnfNodePtr DynamicGRUV2GradFission::CreateDgateHSplitVDNode(const FuncGraphPtr &
|
|||
auto split_vd = NewCNode(splitvd_input, func_graph);
|
||||
auto dtypes = {common::AnfAlgo::GetOutputInferDataType(dgate_h, 0),
|
||||
common::AnfAlgo::GetOutputInferDataType(dgate_h, 0)};
|
||||
std::vector<size_t> shape = {t_size, batch_size, hidden_size << 1};
|
||||
std::vector<size_t> shape2 = {t_size, batch_size, hidden_size};
|
||||
std::vector<std::vector<size_t>> shapes = {shape, shape2};
|
||||
auto shape = Convert2Long({t_size, batch_size, hidden_size << 1});
|
||||
auto shape2 = Convert2Long({t_size, batch_size, hidden_size});
|
||||
std::vector<ShapeVector> shapes = {shape, shape2};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(dtypes, shapes, split_vd.get());
|
||||
common::AnfAlgo::SetNodeAttr("split_dim", MakeValue(SizeToLong(kDim2)), split_vd);
|
||||
common::AnfAlgo::SetNodeAttr("num_split", MakeValue(SizeToLong(kSplitVOutputNum)), split_vd);
|
||||
|
@ -359,7 +358,7 @@ AnfNodePtr DynamicGRUV2GradFission::CreateDgateXConcatDNode(const FuncGraphPtr &
|
|||
(void)concat_inputs.emplace_back(dnt_x);
|
||||
}
|
||||
auto concat_op = NewCNode(concat_inputs, func_graph);
|
||||
std::vector<size_t> shape = {t_size, batch_size, kGateNum * hidden_size};
|
||||
auto shape = Convert2Long({t_size, batch_size, kGateNum * hidden_size});
|
||||
auto types = {common::AnfAlgo::GetOutputInferDataType(dnt_x, 0)};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(types, {shape}, concat_op.get());
|
||||
common::AnfAlgo::SetNodeAttr(kAttrN, MakeValue(SizeToLong(kConcatNum)), concat_op);
|
||||
|
@ -379,7 +378,7 @@ AnfNodePtr DynamicGRUV2GradFission::CreateDwxBatchMatMul(const FuncGraphPtr &gra
|
|||
node1, node2};
|
||||
auto batch_matmul = NewCNode(matmul_inputs, graph);
|
||||
MS_EXCEPTION_IF_NULL(batch_matmul);
|
||||
std::vector<size_t> shape = {t_size, input_size, kGateNum * hidden_size};
|
||||
auto shape = Convert2Long({t_size, input_size, kGateNum * hidden_size});
|
||||
auto x_dtype = common::AnfAlgo::GetOutputInferDataType(node1, input_index["x"]);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({x_dtype}, {shape}, batch_matmul.get());
|
||||
common::AnfAlgo::SetNodeAttr("transpose_x1", MakeValue(true), batch_matmul);
|
||||
|
@ -412,7 +411,7 @@ AnfNodePtr DynamicGRUV2GradFission::CreateWBroadcastToDNode(const FuncGraphPtr &
|
|||
// BroadcastTo
|
||||
std::vector<AnfNodePtr> braodcast_to_input = {NewValueNode(std::make_shared<Primitive>(kBroadcastToOpName)), node};
|
||||
auto broadcast_to_d = NewCNode(braodcast_to_input, graph);
|
||||
std::vector<size_t> shape = {t_size, input_size, kGateNum * hidden_size};
|
||||
auto shape = Convert2Long({t_size, input_size, kGateNum * hidden_size});
|
||||
auto type = {common::AnfAlgo::GetOutputInferDataType(node, 0)};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(type, {shape}, broadcast_to_d.get());
|
||||
std::vector<int64_t> attr_shape = {SizeToLong(t_size), SizeToLong(input_size), SizeToLong(kGateNum * hidden_size)};
|
||||
|
@ -449,7 +448,7 @@ AnfNodePtr DynamicGRUV2GradFission::CreateDbReduceSumDNode(const FuncGraphPtr &g
|
|||
node};
|
||||
auto reduce_sumd = NewCNode(reducesum_inputs, graph);
|
||||
MS_EXCEPTION_IF_NULL(reduce_sumd);
|
||||
std::vector<size_t> shape = {kGateNum * hidden_size};
|
||||
auto shape = Convert2Long({kGateNum * hidden_size});
|
||||
auto types = {common::AnfAlgo::GetOutputInferDataType(node2, 0)};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(types, {shape}, reduce_sumd.get());
|
||||
common::AnfAlgo::SetNodeAttr(kAttrAxis, MakeValue(std::vector<int64_t>{0, 1}), reduce_sumd);
|
||||
|
@ -485,10 +484,10 @@ const AnfNodePtr DynamicGRUV2GradFission::Process(const FuncGraphPtr &func_graph
|
|||
CreateMultipleOutputsOfAnfNode(func_graph, dynamic_gru_v2_grad_cnode, kDynamicGRUV2GradOutputNum, &gru_grad_outputs);
|
||||
auto input_h = ori_inputs[input_index["h"]];
|
||||
auto input_x = ori_inputs[input_index["x"]];
|
||||
t_size = common::AnfAlgo::GetOutputInferShape(input_h, 0)[kDim0];
|
||||
batch_size = common::AnfAlgo::GetOutputInferShape(input_h, 0)[kDim1];
|
||||
hidden_size = common::AnfAlgo::GetOutputInferShape(input_h, 0)[kDim2];
|
||||
input_size = common::AnfAlgo::GetOutputInferShape(input_x, 0)[kDim2];
|
||||
t_size = LongToSize(common::AnfAlgo::GetOutputInferShape(input_h, 0)[kDim0]);
|
||||
batch_size = LongToSize(common::AnfAlgo::GetOutputInferShape(input_h, 0)[kDim1]);
|
||||
hidden_size = LongToSize(common::AnfAlgo::GetOutputInferShape(input_h, 0)[kDim2]);
|
||||
input_size = LongToSize(common::AnfAlgo::GetOutputInferShape(input_x, 0)[kDim2]);
|
||||
MS_LOG(INFO) << "For DynamicGRUV2Grad op, t_size: " << t_size << ", batch_size: " << batch_size
|
||||
<< ", hidden_size: " << hidden_size << ", input_size: " << input_size;
|
||||
// add GRUHiddenGrad {dhPrevNode, dgateHConcatTNode, dntXConcatTNode}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include "backend/common/session/kernel_graph.h"
|
||||
#include "backend/common/session/anf_runtime_algorithm.h"
|
||||
#include "include/common/utils/anfalgo.h"
|
||||
|
@ -87,9 +88,9 @@ void DynamicRnnGradFissionV2::CreateTLoopNode(const FuncGraphPtr &func_graph, co
|
|||
NewValueNode(std::make_shared<Primitive>(kBasicLSTMCellCStateGradV2OpName))};
|
||||
auto basic_lstm_cell_c_state_grad = NewCNode(basic_lstm_cell_c_state_grad_inputs, func_graph);
|
||||
|
||||
std::vector<size_t> output0_dims{specs.batch_size, kDimMultiNum * specs.hidden_nz_size * kCubeSize};
|
||||
ShapeVector output0_dims{SizeToLong(specs.batch_size), SizeToLong(kDimMultiNum * specs.hidden_nz_size * kCubeSize)};
|
||||
// batch_size, hidden_size
|
||||
std::vector<size_t> output1_dims{input_i_shape[kDim1], input_i_shape[kDim2]};
|
||||
ShapeVector output1_dims{input_i_shape[kDim1], input_i_shape[kDim2]};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({kNumberTypeFloat16, kNumberTypeFloat32}, {output0_dims, output1_dims},
|
||||
basic_lstm_cell_c_state_grad.get());
|
||||
common::AnfAlgo::SetNodeAttr("forget_bias", MakeValue(1.0f), basic_lstm_cell_c_state_grad);
|
||||
|
@ -104,7 +105,8 @@ void DynamicRnnGradFissionV2::CreateTLoopNode(const FuncGraphPtr &func_graph, co
|
|||
}
|
||||
auto matmul = NewCNode(matmul_inputs, func_graph);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(
|
||||
{kNumberTypeFloat32}, {{IntToSize(1), specs.batch_size, specs.input_size + specs.hidden_size}}, matmul.get());
|
||||
{kNumberTypeFloat32}, {{1, SizeToLong(specs.batch_size), SizeToLong(specs.input_size + specs.hidden_size)}},
|
||||
matmul.get());
|
||||
common::AnfAlgo::SetNodeAttr("transpose_x1", MakeValue(false), matmul);
|
||||
common::AnfAlgo::SetNodeAttr("transpose_x2", MakeValue(true), matmul);
|
||||
if (specs.shape_need_align) {
|
||||
|
@ -122,8 +124,8 @@ void DynamicRnnGradFissionV2::CreateTLoopNode(const FuncGraphPtr &func_graph, co
|
|||
// Create split
|
||||
std::vector<AnfNodePtr> splitv_input = {NewValueNode(std::make_shared<Primitive>(prim::kPrimSplitV->name()))};
|
||||
auto split_v = NewCNode(splitv_input, func_graph);
|
||||
std::vector<size_t> split_v_output0_shape{IntToSize(1), specs.batch_size, specs.input_size};
|
||||
std::vector<size_t> split_v_output1_shape{IntToSize(1), specs.batch_size, specs.hidden_size};
|
||||
auto split_v_output0_shape = Convert2Long({IntToSize(1), specs.batch_size, specs.input_size});
|
||||
auto split_v_output1_shape = Convert2Long({IntToSize(1), specs.batch_size, specs.hidden_size});
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({kNumberTypeFloat32, kNumberTypeFloat32},
|
||||
{split_v_output0_shape, split_v_output1_shape}, split_v.get());
|
||||
common::AnfAlgo::SetNodeAttr(kAttrSizeSplits,
|
||||
|
@ -152,7 +154,7 @@ void DynamicRnnGradFissionV2::CreateTLoopNode(const FuncGraphPtr &func_graph, co
|
|||
}
|
||||
|
||||
AnfNodePtr DynamicRnnGradFissionV2::CreateLSTMSPlitV(const FuncGraphPtr &func_graph, const AnfNodePtr &input,
|
||||
const std::vector<std::vector<size_t>> &split_shapes,
|
||||
const std::vector<ShapeVector> &split_shapes,
|
||||
const std::vector<TypeId> &split_types,
|
||||
const std::vector<int64_t> &size_split, size_t num_split_x) const {
|
||||
std::vector<AnfNodePtr> lstm_split_input = {NewValueNode(std::make_shared<Primitive>(prim::kPrimSplitV->name())),
|
||||
|
@ -195,9 +197,9 @@ void DynamicRnnGradFissionV2::CreateTLoopNodeWithEdge(const FuncGraphPtr &func_g
|
|||
std::vector<AnfNodePtr> reshape_inputs = {NewValueNode(std::make_shared<Primitive>(kReshapeOpName)),
|
||||
dynamic_rnn_grad_cnode->input(kIndex6)};
|
||||
auto reshape = NewCNode(reshape_inputs, func_graph);
|
||||
auto reshape_out_shape = {IntToSize(1),
|
||||
common::AnfAlgo::GetOutputInferShape(dynamic_rnn_grad_cnode->input(kIndex6), 0)[0],
|
||||
common::AnfAlgo::GetOutputInferShape(dynamic_rnn_grad_cnode->input(kIndex6), 0)[1]};
|
||||
ShapeVector reshape_out_shape = {
|
||||
1, common::AnfAlgo::GetOutputInferShape(dynamic_rnn_grad_cnode->input(kIndex6), 0)[0],
|
||||
common::AnfAlgo::GetOutputInferShape(dynamic_rnn_grad_cnode->input(kIndex6), 0)[1]};
|
||||
auto reshape_out_dtype = common::AnfAlgo::GetOutputInferDataType(dynamic_rnn_grad_cnode->input(kIndex6), 0);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({reshape_out_dtype}, {reshape_out_shape}, reshape.get());
|
||||
(void)basic_lstm_cell_c_state_grad_inputs.emplace_back(reshape);
|
||||
|
@ -253,7 +255,7 @@ void DynamicRnnGradFissionV2::CreateTLoopNodeWithEdge(const FuncGraphPtr &func_g
|
|||
} else {
|
||||
auto basic_lstm_cell_output_0_shape =
|
||||
common::AnfAlgo::GetOutputInferShape(basic_lstm_cell_c_state_grad_outputs[0], 0);
|
||||
std::vector<size_t> temp_shape;
|
||||
ShapeVector temp_shape;
|
||||
if (basic_lstm_cell_output_0_shape.size() == kBasicLstmCStateGradOutput0DimNum) {
|
||||
temp_shape = basic_lstm_cell_output_0_shape;
|
||||
} else {
|
||||
|
@ -282,11 +284,11 @@ AnfNodePtr DynamicRnnGradFissionV2::AddLSTMInputGradNode(const FuncGraphPtr &fun
|
|||
CreateTLoopNode(func_graph, dynamic_rnn_grad_cnode, specs, &result_nodes);
|
||||
|
||||
auto origin_input5_shape = common::AnfAlgo::GetOutputInferShape(dynamic_rnn_grad_cnode->input(kIndex6), 0);
|
||||
std::vector<size_t> split_c_dims{IntToSize(1), origin_input5_shape[0], origin_input5_shape[1]};
|
||||
ShapeVector split_c_dims{1, origin_input5_shape[0], origin_input5_shape[1]};
|
||||
|
||||
auto origin_input7 = dynamic_rnn_grad_cnode->input(kIndex8);
|
||||
size_t num_split_x = common::AnfAlgo::GetOutputInferShape(origin_input7, 0)[0];
|
||||
std::vector<std::vector<size_t>> split_shapes;
|
||||
size_t num_split_x = LongToSize(common::AnfAlgo::GetOutputInferShape(origin_input7, 0)[0]);
|
||||
std::vector<ShapeVector> split_shapes;
|
||||
std::vector<TypeId> split_types;
|
||||
std::vector<int64_t> size_split;
|
||||
for (size_t i = 0; i < num_split_x; ++i) {
|
||||
|
@ -376,7 +378,8 @@ AnfNodePtr DynamicRnnGradFissionV2::AddLSTMInputGradNode(const FuncGraphPtr &fun
|
|||
} else {
|
||||
gage_concat_shape = {specs.t_size, specs.batch_size, kDimMultiNum * specs.hidden_nz_size * kCubeSize};
|
||||
}
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({kNumberTypeFloat16}, {gage_concat_shape}, lstm_gage_concat.get());
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({kNumberTypeFloat16}, {Convert2Long(gage_concat_shape)},
|
||||
lstm_gage_concat.get());
|
||||
common::AnfAlgo::SetNodeAttr(kAttrN, MakeValue(SizeToLong(num_split_x)), lstm_gage_concat);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrDynInputSizes, MakeValue(std::vector<int64_t>{SizeToLong(num_split_x)}),
|
||||
lstm_gage_concat);
|
||||
|
@ -406,7 +409,7 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateSplitV(const FuncGraphPtr &func_graph,
|
|||
if (specs.batch_size % kCubeSize == 0 && !specs.shape_need_align) {
|
||||
std::vector<AnfNodePtr> reshape_input = {NewValueNode(std::make_shared<Primitive>(kReshapeOpName)), origin_input6};
|
||||
auto reshape = NewCNode(reshape_input, func_graph);
|
||||
std::vector<size_t> shape = {origin_input6_shape[kDim0] * origin_input6_shape[kDim1], origin_input6_shape[kDim2]};
|
||||
ShapeVector shape = {origin_input6_shape[kDim0] * origin_input6_shape[kDim1], origin_input6_shape[kDim2]};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({origin_input6_dtype}, {shape}, reshape.get());
|
||||
splitv_input.push_back(reshape);
|
||||
} else {
|
||||
|
@ -414,7 +417,7 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateSplitV(const FuncGraphPtr &func_graph,
|
|||
}
|
||||
auto split_v = NewCNode(splitv_input, func_graph);
|
||||
// Set infer data type and shape
|
||||
std::vector<size_t> shape1, shape2;
|
||||
ShapeVector shape1, shape2;
|
||||
if (specs.batch_size % kCubeSize == 0 && !specs.shape_need_align) {
|
||||
shape1 = {(origin_input6_shape[kDim0] - 1) * origin_input6_shape[kDim1], origin_input6_shape[kDim2]};
|
||||
shape2 = {origin_input6_shape[kDim1], origin_input6_shape[kDim2]};
|
||||
|
@ -423,7 +426,7 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateSplitV(const FuncGraphPtr &func_graph,
|
|||
shape2 = {1, origin_input6_shape[kDim1], origin_input6_shape[kDim2]};
|
||||
}
|
||||
auto dtypes = {origin_input6_dtype, origin_input6_dtype};
|
||||
std::vector<std::vector<size_t>> shapes = {shape1, shape2};
|
||||
std::vector<ShapeVector> shapes = {shape1, shape2};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(dtypes, shapes, split_v.get());
|
||||
// Set attr
|
||||
common::AnfAlgo::SetNodeAttr(kAttrSplitDim, MakeValue(SizeToLong(0)), split_v);
|
||||
|
@ -456,7 +459,7 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateHConcat(const FuncGraphPtr &func_graph
|
|||
auto origin_input4 = dynamic_rnn_grad_cnode->input(kIndex5);
|
||||
auto origin_input4_shape = common::AnfAlgo::GetOutputInferShape(origin_input4, 0);
|
||||
// Create reshape to change shape
|
||||
std::vector<size_t> shape_tmp;
|
||||
ShapeVector shape_tmp;
|
||||
if (specs.batch_size % kCubeSize == 0 && !specs.shape_need_align) {
|
||||
shape_tmp = {origin_input4_shape[0], origin_input4_shape[1]};
|
||||
} else {
|
||||
|
@ -477,7 +480,7 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateHConcat(const FuncGraphPtr &func_graph
|
|||
auto concat = NewCNode(concat_inputs, func_graph);
|
||||
// Set infer data type and shape
|
||||
auto splitv_output0_shape = common::AnfAlgo::GetOutputInferShape(splitv, 0);
|
||||
std::vector<size_t> shape;
|
||||
ShapeVector shape;
|
||||
if (specs.batch_size % kCubeSize == 0 && !specs.shape_need_align) {
|
||||
shape = {splitv_output0_shape[0] + origin_input4_shape[0], origin_input4_shape[1]};
|
||||
} else {
|
||||
|
@ -506,7 +509,7 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateConcat(const FuncGraphPtr &func_graph,
|
|||
if (specs.batch_size % kCubeSize == 0 && !specs.shape_need_align) {
|
||||
std::vector<AnfNodePtr> reshape_input = {NewValueNode(std::make_shared<Primitive>(kReshapeOpName)), origin_input0};
|
||||
auto reshape = NewCNode(reshape_input, func_graph);
|
||||
std::vector<size_t> shape = {origin_input0_shape[kDim0] * origin_input0_shape[kDim1], origin_input0_shape[kDim2]};
|
||||
ShapeVector shape = {origin_input0_shape[kDim0] * origin_input0_shape[kDim1], origin_input0_shape[kDim2]};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({origin_input0_dtype}, {shape}, reshape.get());
|
||||
// t_size * batch_size, input_size
|
||||
concat_inputs.push_back(reshape);
|
||||
|
@ -518,7 +521,7 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateConcat(const FuncGraphPtr &func_graph,
|
|||
auto concat = NewCNode(concat_inputs, func_graph);
|
||||
// Set infer data type and shape
|
||||
auto h_concat_output_shape = common::AnfAlgo::GetOutputInferShape(h_concat, 0);
|
||||
std::vector<size_t> shape;
|
||||
ShapeVector shape;
|
||||
if (specs.batch_size % kCubeSize == 0 && !specs.shape_need_align) {
|
||||
shape = {origin_input0_shape[kDim0] * origin_input0_shape[kDim1],
|
||||
origin_input0_shape[kDim2] + h_concat_output_shape[kDim1]};
|
||||
|
@ -562,7 +565,7 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateConcatNodeT1(const FuncGraphPtr &func_
|
|||
if (specs.batch_size % kCubeSize == 0 && !specs.shape_need_align) {
|
||||
std::vector<AnfNodePtr> reshape_inputs = {NewValueNode(std::make_shared<Primitive>(kReshapeOpName)), origin_input0};
|
||||
auto reshape_in0 = NewCNode(reshape_inputs, func_graph);
|
||||
std::vector<size_t> shape = {origin_input0_shape[kDim0] * origin_input0_shape[kDim1], origin_input0_shape[kDim2]};
|
||||
ShapeVector shape = {origin_input0_shape[kDim0] * origin_input0_shape[kDim1], origin_input0_shape[kDim2]};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({origin_input0_dtype}, {shape}, reshape_in0.get());
|
||||
(void)concat_inputs.emplace_back(reshape_in0);
|
||||
} else {
|
||||
|
@ -571,7 +574,7 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateConcatNodeT1(const FuncGraphPtr &func_
|
|||
|
||||
auto origin_input4 = dynamic_rnn_grad_cnode->input(kIndex5);
|
||||
auto origin_input4_shape = common::AnfAlgo::GetOutputInferShape(origin_input4, 0);
|
||||
std::vector<size_t> shape_tmp;
|
||||
ShapeVector shape_tmp;
|
||||
if (specs.batch_size % kCubeSize == 0 && !specs.shape_need_align) {
|
||||
shape_tmp = {origin_input4_shape[0], origin_input4_shape[1]};
|
||||
} else {
|
||||
|
@ -590,7 +593,7 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateConcatNodeT1(const FuncGraphPtr &func_
|
|||
concat_inputs.push_back(reshape_in4);
|
||||
auto concat = NewCNode(concat_inputs, func_graph);
|
||||
// Set infer data type and shape
|
||||
std::vector<size_t> shape;
|
||||
ShapeVector shape;
|
||||
if (specs.batch_size % kCubeSize == 0 && !specs.shape_need_align) {
|
||||
shape = {origin_input0_shape[kDim0] * origin_input0_shape[kDim1], origin_input0_shape[kDim2] + shape_tmp[kDim1]};
|
||||
} else {
|
||||
|
@ -631,7 +634,7 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateMatMulNode(const FuncGraphPtr &func_gr
|
|||
// Set infer data type and shape
|
||||
auto concat_shape = common::AnfAlgo::GetOutputInferShape(concat, 0);
|
||||
auto lstm_input_grad_shape = common::AnfAlgo::GetOutputInferShape(lstm_input_grad, 0);
|
||||
std::vector<size_t> shape;
|
||||
ShapeVector shape;
|
||||
if (specs.batch_size % kCubeSize == 0 && !specs.shape_need_align) {
|
||||
// t_size * (input_size + hidden_size), 4 * hidden_size
|
||||
shape = {concat_shape[kDim1], lstm_input_grad_shape[kDim1]};
|
||||
|
@ -674,11 +677,11 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateMatMulNode2(const FuncGraphPtr &func_g
|
|||
auto matmul = NewCNode(matmul_inputs, func_graph);
|
||||
// Set infer data type and shape
|
||||
auto lstm_input_grad_shape = common::AnfAlgo::GetOutputInferShape(lstm_input_grad, 0);
|
||||
std::vector<size_t> out_shape;
|
||||
ShapeVector out_shape;
|
||||
if (specs.batch_size % kCubeSize == 0 && !specs.shape_need_align) {
|
||||
out_shape = {IntToSize(1), lstm_input_grad_shape[kDim1]};
|
||||
out_shape = {1, lstm_input_grad_shape[kDim1]};
|
||||
} else {
|
||||
out_shape = {lstm_input_grad_shape[kDim0], IntToSize(1), lstm_input_grad_shape[kDim2]};
|
||||
out_shape = {lstm_input_grad_shape[kDim0], 1, lstm_input_grad_shape[kDim2]};
|
||||
}
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({kNumberTypeFloat16}, {out_shape}, matmul.get());
|
||||
// Set attr
|
||||
|
@ -694,7 +697,7 @@ CNodePtr DynamicRnnGradFissionV2::CreateTranspose(const FuncGraphPtr &func_graph
|
|||
std::vector<AnfNodePtr> transpose_inputs = {NewValueNode(std::make_shared<Primitive>(prim::kPrimTranspose->name())),
|
||||
dw_reduce_sum};
|
||||
auto transpose = NewCNode(transpose_inputs, func_graph);
|
||||
std::vector<size_t> out_shape = {specs.input_size + specs.hidden_size, kDimMultiNum * specs.hidden_size};
|
||||
auto out_shape = Convert2Long({specs.input_size + specs.hidden_size, kDimMultiNum * specs.hidden_size});
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({common::AnfAlgo::GetOutputInferDataType(dw_reduce_sum, 0)}, {out_shape},
|
||||
transpose.get());
|
||||
common::AnfAlgo::SetNodeAttr(kAttrPerm, MakeValue(std::vector<int64_t>{1, 0, 2, 3}), transpose);
|
||||
|
@ -718,8 +721,8 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateDwReduceSum(const FuncGraphPtr &func_g
|
|||
// if matmul output is too large, need to insert cast to enable BatchMatmul&ReduceSum ub fusion later
|
||||
const size_t max_out_shape_size = 1 << 10;
|
||||
auto matmul_out_shape = common::AnfAlgo::GetOutputInferShape(matmul, 0);
|
||||
auto matmul_out_shape_size = std::accumulate(matmul_out_shape.begin(), matmul_out_shape.end(), static_cast<size_t>(1),
|
||||
std::multiplies<size_t>());
|
||||
auto matmul_out_shape_size = LongToSize(std::accumulate(matmul_out_shape.begin(), matmul_out_shape.end(),
|
||||
static_cast<int64_t>(1), std::multiplies<int64_t>()));
|
||||
bool size_exceed_limit = matmul_out_shape_size > max_out_shape_size;
|
||||
if (size_exceed_limit) {
|
||||
std::vector<AnfNodePtr> cast_inputs = {NewValueNode(std::make_shared<Primitive>(prim::kPrimCast->name())), matmul};
|
||||
|
@ -732,8 +735,8 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateDwReduceSum(const FuncGraphPtr &func_g
|
|||
input_node};
|
||||
auto reduce_sum = NewCNode(reduce_sum_inputs, func_graph);
|
||||
// Set infer data type and shape
|
||||
std::vector<size_t> reduce_sum_shape = {specs.input_size + specs.hidden_size,
|
||||
kDimMultiNum * specs.hidden_nz_size * kCubeSize};
|
||||
auto reduce_sum_shape =
|
||||
Convert2Long({specs.input_size + specs.hidden_size, kDimMultiNum * specs.hidden_nz_size * kCubeSize});
|
||||
auto reduce_sum_type =
|
||||
size_exceed_limit ? kNumberTypeFloat32 : common::AnfAlgo::GetOutputInferDataType(dynamic_rnn_grad_cnode, 0);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({reduce_sum_type}, {reduce_sum_shape}, reduce_sum.get());
|
||||
|
@ -778,8 +781,8 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateDwReshape(const FuncGraphPtr &func_gra
|
|||
matmul};
|
||||
auto reshape = NewCNode(reshape_inputs, func_graph);
|
||||
// Set infer data type and shape
|
||||
std::vector<size_t> out_shape = {specs.input_size + specs.hidden_size,
|
||||
kDimMultiNum * specs.hidden_nz_size * kCubeSize};
|
||||
auto out_shape =
|
||||
Convert2Long({specs.input_size + specs.hidden_size, kDimMultiNum * specs.hidden_nz_size * kCubeSize});
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({common::AnfAlgo::GetOutputInferDataType(dynamic_rnn_grad_cnode, 0)},
|
||||
{out_shape}, reshape.get());
|
||||
common::AnfAlgo::SetNodeAttr("is_backend_insert", MakeValue(true), reshape);
|
||||
|
@ -807,7 +810,7 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateValueNode(const FuncGraphPtr &func_gra
|
|||
auto kernel_graph = func_graph->cast<KernelGraphPtr>();
|
||||
auto value_node = kernel_graph->NewValueNode(x_abstract, tensor);
|
||||
kernel_graph->AddValueNodeToGraph(value_node);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({kNumberTypeFloat32}, {shape}, value_node.get());
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({kNumberTypeFloat32}, {output_shape}, value_node.get());
|
||||
return value_node;
|
||||
}
|
||||
|
||||
|
@ -821,7 +824,7 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateDbReduceSum(const FuncGraphPtr &func_g
|
|||
std::vector<AnfNodePtr> reshape_inputs = {NewValueNode(std::make_shared<Primitive>(prim::kPrimReshape->name())),
|
||||
matmul};
|
||||
auto reshape = NewCNode(reshape_inputs, func_graph);
|
||||
std::vector<size_t> out_shape = {kDimMultiNum * specs.hidden_size};
|
||||
ShapeVector out_shape = {SizeToLong(kDimMultiNum * specs.hidden_size)};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({kNumberTypeFloat16}, {out_shape}, reshape.get());
|
||||
common::AnfAlgo::SetNodeAttr("is_backend_insert", MakeValue(true), reshape);
|
||||
return reshape;
|
||||
|
@ -830,7 +833,7 @@ AnfNodePtr DynamicRnnGradFissionV2::CreateDbReduceSum(const FuncGraphPtr &func_g
|
|||
NewValueNode(std::make_shared<Primitive>(prim::kPrimReduceSum->name())), matmul};
|
||||
auto reduce_sum = NewCNode(reduce_sum_inputs, func_graph);
|
||||
// Set infer data type and shape
|
||||
std::vector<size_t> out_shape = {kDimMultiNum * specs.hidden_size};
|
||||
ShapeVector out_shape = {SizeToLong(kDimMultiNum * specs.hidden_size)};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({kNumberTypeFloat16}, {out_shape}, reduce_sum.get());
|
||||
// Set attr
|
||||
common::AnfAlgo::SetNodeAttr(kAttrAxis, MakeValue(std::vector<int64_t>{0}), reduce_sum);
|
||||
|
@ -870,10 +873,11 @@ const AnfNodePtr DynamicRnnGradFissionV2::Process(const FuncGraphPtr &func_graph
|
|||
}
|
||||
auto input0_shape = common::AnfAlgo::GetOutputInferShape(dynamic_rnn_grad_cnode->input(kIndex1), 0);
|
||||
RNNShapeSpecs specs;
|
||||
specs.t_size = input0_shape[0];
|
||||
specs.batch_size = input0_shape[1];
|
||||
specs.input_size = input0_shape[kDim2];
|
||||
specs.hidden_size = common::AnfAlgo::GetOutputInferShape(dynamic_rnn_grad_cnode->input(kIndex7), 0)[kDim2];
|
||||
specs.t_size = LongToSize(input0_shape[0]);
|
||||
specs.batch_size = LongToSize(input0_shape[1]);
|
||||
specs.input_size = LongToSize(input0_shape[kDim2]);
|
||||
specs.hidden_size =
|
||||
LongToSize(common::AnfAlgo::GetOutputInferShape(dynamic_rnn_grad_cnode->input(kIndex7), 0)[kDim2]);
|
||||
if (specs.input_size % kCubeSize != 0 || specs.hidden_size % kCubeSize != 0) {
|
||||
specs.shape_need_align = true;
|
||||
SetAttrInputAndHiddenSize(func_graph, dynamic_rnn_grad_cnode, SizeToLong(specs.input_size),
|
||||
|
|
|
@ -45,9 +45,8 @@ class DynamicRnnGradFissionV2 : public PatternProcessPass {
|
|||
void CreateTLoopNode(const FuncGraphPtr &func_graph, const CNodePtr &dynamic_rnn_grad_cnode,
|
||||
const RNNShapeSpecs &specs, std::vector<std::vector<AnfNodePtr>> *result_nodes) const;
|
||||
AnfNodePtr CreateLSTMSPlitV(const FuncGraphPtr &func_graph, const AnfNodePtr &input,
|
||||
const std::vector<std::vector<size_t>> &split_shapes,
|
||||
const std::vector<TypeId> &split_types, const std::vector<int64_t> &size_split,
|
||||
size_t num_split_x) const;
|
||||
const std::vector<ShapeVector> &split_shapes, const std::vector<TypeId> &split_types,
|
||||
const std::vector<int64_t> &size_split, size_t num_split_x) const;
|
||||
void CreateTLoopNodeWithEdge(const FuncGraphPtr &func_graph, const CNodePtr &dynamic_rnn_grad_cnode,
|
||||
const std::vector<std::vector<AnfNodePtr>> &result_nodes, size_t num_split_x,
|
||||
const RNNShapeSpecs &specs,
|
||||
|
|
|
@ -132,9 +132,8 @@ CNodePtr GatherV2DsFission::CreateGatherV2Ds(const FuncGraphPtr &graph, const CN
|
|||
gather_v2->set_scope(origin_node->scope());
|
||||
|
||||
auto shape = common::AnfAlgo::GetOutputInferShape(origin_node, 0);
|
||||
shape[shape.size() - 1] = pad_dim_size;
|
||||
if (AnfUtils::IsShapeDynamic(shape)) {
|
||||
ShapeVector shape_tmp;
|
||||
shape[shape.size() - 1] = SizeToLong(pad_dim_size);
|
||||
if (IsDynamic(shape)) {
|
||||
auto min_shape = common::AnfAlgo::GetOutputMinShape(origin_node, 0);
|
||||
auto max_shape = common::AnfAlgo::GetOutputMaxShape(origin_node, 0);
|
||||
if (!min_shape.empty() && !max_shape.empty()) {
|
||||
|
@ -142,8 +141,7 @@ CNodePtr GatherV2DsFission::CreateGatherV2Ds(const FuncGraphPtr &graph, const CN
|
|||
max_shape[max_shape.size() - 1] = SizeToLong(pad_dim_size);
|
||||
}
|
||||
|
||||
std::transform(shape.begin(), shape.end(), std::back_inserter(shape_tmp), SizeToLong);
|
||||
std::vector<BaseShapePtr> shapes = {std::make_shared<abstract::Shape>(shape_tmp, min_shape, max_shape)};
|
||||
std::vector<BaseShapePtr> shapes = {std::make_shared<abstract::Shape>(shape, min_shape, max_shape)};
|
||||
common::AnfAlgo::SetOutputTypeAndDetailShape({common::AnfAlgo::GetOutputInferDataType(origin_node, 0)}, shapes,
|
||||
gather_v2.get());
|
||||
} else {
|
||||
|
@ -172,7 +170,7 @@ CNodePtr GatherV2DsFission::CreateSlice(const FuncGraphPtr &graph, const CNodePt
|
|||
auto gather_v2_shape = common::AnfAlgo::GetOutputInferShape(gather_v2, 0);
|
||||
std::vector<size_t> offsets(gather_v2_shape.size(), 0);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrBegin, MakeValue(Convert2Long(offsets)), slice);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrSize, MakeValue(Convert2Long(gather_v2_shape)), slice);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrSize, MakeValue(gather_v2_shape), slice);
|
||||
return slice;
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ AnfNodePtr CreateLayerNormNode(const FuncGraphPtr &graph, const AnfNodePtr &inpu
|
|||
square_sum_node->set_abstract(input_node->abstract());
|
||||
|
||||
auto types = {common::AnfAlgo::GetOutputInferDataType(input_node, 0)};
|
||||
std::vector<size_t> shape = {1};
|
||||
ShapeVector shape = {1};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(types, {shape}, square_sum_node.get());
|
||||
|
||||
// Calc sqrt of the sum of square
|
||||
|
|
|
@ -43,7 +43,7 @@ void LarsV2Fission::CreateOutputsOfSquareSumAll(const FuncGraphPtr &graph, const
|
|||
square_sum_all->set_scope(lars_v2->scope());
|
||||
|
||||
auto types = {kNumberTypeFloat32, kNumberTypeFloat32};
|
||||
std::vector<size_t> shape;
|
||||
ShapeVector shape;
|
||||
auto shapes = {shape, shape};
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(types, shapes, square_sum_all.get());
|
||||
CreateMultipleOutputsOfAnfNode(graph, square_sum_all, kSquareSumOutputNum, square_sum_all_outputs);
|
||||
|
|
|
@ -83,10 +83,8 @@ void LayerNormGradSplit::CreateOutputsOfLayerNormBetaGammaBackpropV2(
|
|||
common::AnfAlgo::SetOutputTypeAndDetailShape(types, shapes, layer_norm_beta_gamma_backprop.get());
|
||||
|
||||
// get device shape of LayerNormGrad's 5th Input, and convert it to attr
|
||||
std::vector<size_t> shape_gamma =
|
||||
common::AnfAlgo::GetPrevNodeOutputInferShape(layer_norm_grad, kLayerNormGradInputGammaIndex);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrShapeGamma, MakeValue(opt::Convert2Long(shape_gamma)),
|
||||
layer_norm_beta_gamma_backprop);
|
||||
auto shape_gamma = common::AnfAlgo::GetPrevNodeOutputInferShape(layer_norm_grad, kLayerNormGradInputGammaIndex);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrShapeGamma, MakeValue(shape_gamma), layer_norm_beta_gamma_backprop);
|
||||
|
||||
CreateMultipleOutputsOfAnfNode(graph, layer_norm_beta_gamma_backprop, kLayerNormBetaGammaBackpropOutputNum,
|
||||
layer_norm_beta_gamma_backprop_outputs);
|
||||
|
|
|
@ -52,6 +52,7 @@ AnfNodePtr PackFission::CreateNewPack(const FuncGraphPtr &func_graph, const CNod
|
|||
MS_LOG(EXCEPTION) << "The concat_dim value " << axis << "is out of range"
|
||||
<< trace::DumpSourceLines(origin_pack_cnode);
|
||||
}
|
||||
|
||||
ShapeVector new_shape = output_shape->shape();
|
||||
ShapeVector new_shape_min = output_shape->min_shape();
|
||||
ShapeVector new_shape_max = output_shape->max_shape();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
namespace mindspore {
|
||||
namespace opt {
|
||||
namespace {
|
||||
bool NeedOptimize(const TypeId &dtype, const std::vector<size_t> &shape, const std::vector<int64_t> &axis) {
|
||||
bool NeedOptimize(const TypeId &dtype, const ShapeVector &shape, const std::vector<int64_t> &axis) {
|
||||
if (dtype != kNumberTypeFloat32) {
|
||||
MS_LOG(INFO) << "ReduceMin's input Dtype is not float32, no need to optimize!";
|
||||
return false;
|
||||
|
@ -44,7 +44,7 @@ bool NeedOptimize(const TypeId &dtype, const std::vector<size_t> &shape, const s
|
|||
return true;
|
||||
}
|
||||
|
||||
std::vector<int64_t> CalFirstAxis(const std::vector<size_t> &shape, const std::vector<int64_t> &axis) {
|
||||
std::vector<int64_t> CalFirstAxis(const ShapeVector &shape, const std::vector<int64_t> &axis) {
|
||||
std::vector<int64_t> axis_fisrt;
|
||||
int64_t last_dim = SizeToLong(shape.size() - 1);
|
||||
std::copy_if(axis.begin(), axis.end(), std::back_inserter(axis_fisrt),
|
||||
|
@ -68,9 +68,8 @@ std::vector<int64_t> CalFirstAxis(const std::vector<size_t> &shape, const std::v
|
|||
return axis_fisrt;
|
||||
}
|
||||
|
||||
std::vector<size_t> GetInferShape(const std::vector<size_t> &shape, const std::vector<int64_t> &axis_first,
|
||||
bool keep_dims) {
|
||||
std::vector<size_t> shape_first;
|
||||
ShapeVector GetInferShape(const ShapeVector &shape, const std::vector<int64_t> &axis_first, bool keep_dims) {
|
||||
ShapeVector shape_first;
|
||||
for (size_t item = 0; item < shape.size(); ++item) {
|
||||
if (axis_first.end() != std::find(axis_first.begin(), axis_first.end(), item)) {
|
||||
if (keep_dims) {
|
||||
|
@ -138,7 +137,7 @@ const AnfNodePtr ReduceMinFission::Process(const FuncGraphPtr &graph, const AnfN
|
|||
// Create reduce_min1
|
||||
CNodePtr reduce_min1 = CreateReduceMin(graph, cnode->input(1), cnode);
|
||||
std::vector<int64_t> axis_first = CalFirstAxis(shape, axis);
|
||||
std::vector<size_t> shape_first = GetInferShape(shape, axis_first, keep_dims);
|
||||
auto shape_first = GetInferShape(shape, axis_first, keep_dims);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({dtype}, {shape_first}, reduce_min1.get());
|
||||
common::AnfAlgo::SetNodeAttr(kAttrAxis, MakeValue(axis_first), reduce_min1);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
namespace mindspore {
|
||||
namespace opt {
|
||||
namespace {
|
||||
void FreshRenormInferShape(const CNodePtr &node, std::vector<size_t> in_shape, const TypeId &type) {
|
||||
void FreshRenormInferShape(const CNodePtr &node, ShapeVector in_shape, const TypeId &type) {
|
||||
MS_EXCEPTION_IF_NULL(node);
|
||||
auto dim = common::AnfAlgo::GetNodeAttr<int64_t>(node, "dim");
|
||||
if (dim < 0) {
|
||||
|
@ -37,10 +37,8 @@ void FreshRenormInferShape(const CNodePtr &node, std::vector<size_t> in_shape, c
|
|||
if (common::AnfAlgo::IsDynamicShape(node)) {
|
||||
auto max_shape = common::AnfAlgo::GetOutputMaxShape(node, 0);
|
||||
auto min_shape = common::AnfAlgo::GetOutputMinShape(node, 0);
|
||||
std::vector<int64_t> shape_tmp;
|
||||
std::transform(in_shape.begin(), in_shape.end(), std::back_inserter(shape_tmp), SizeToLong);
|
||||
common::AnfAlgo::SetOutputTypeAndDetailShape(
|
||||
{type}, {std::make_shared<abstract::Shape>(shape_tmp, min_shape, max_shape)}, node.get());
|
||||
{type}, {std::make_shared<abstract::Shape>(in_shape, min_shape, max_shape)}, node.get());
|
||||
return;
|
||||
}
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({type}, {in_shape}, node.get());
|
||||
|
@ -83,9 +81,7 @@ const AnfNodePtr RenormSplit::Process(const FuncGraphPtr &func_graph, const AnfN
|
|||
node};
|
||||
auto broadcast_node = NewCNode(broadcast_inputs, func_graph);
|
||||
MS_EXCEPTION_IF_NULL(broadcast_node);
|
||||
std::vector<int64_t> shape;
|
||||
(void)std::transform(in_shape.begin(), in_shape.end(), std::back_inserter(shape), SizeToLong);
|
||||
common::AnfAlgo::SetNodeAttr("shape", MakeValue(shape), broadcast_node);
|
||||
common::AnfAlgo::SetNodeAttr("shape", MakeValue(in_shape), broadcast_node);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({type}, {in_shape}, broadcast_node.get());
|
||||
|
||||
std::vector<AnfNodePtr> mul_inputs = {NewValueNode(std::make_shared<Primitive>(prim::kPrimMul->name())),
|
||||
|
|
|
@ -35,9 +35,9 @@ tensor::TensorPtr CreateTensor(const AnfNodePtr &node) {
|
|||
MS_EXCEPTION_IF_NULL(cnode);
|
||||
auto input_x = cnode->input(kSpaceToDepthInputNum);
|
||||
int64_t block_size = common::AnfAlgo::GetNodeAttr<int64_t>(cnode, "block_size");
|
||||
std::vector<size_t> x_shape = common::AnfAlgo::GetOutputInferShape(input_x, 0);
|
||||
int64_t input_channel = SizeToLong(x_shape[kDim1]);
|
||||
int64_t assist_input_channel = SizeToLong(x_shape[kDim1]) * block_size * block_size;
|
||||
auto x_shape = common::AnfAlgo::GetOutputInferShape(input_x, 0);
|
||||
int64_t input_channel = x_shape[kDim1];
|
||||
int64_t assist_input_channel = x_shape[kDim1] * block_size * block_size;
|
||||
std::vector<int64_t> assist_input_shape = {assist_input_channel, input_channel, block_size, block_size};
|
||||
int64_t dest_size = assist_input_channel * input_channel * block_size * block_size;
|
||||
MS_LOG(DEBUG) << "For SpaceToDepth op, assist input shape is: (" << assist_input_channel << ", " << input_channel
|
||||
|
|
|
@ -51,7 +51,7 @@ AnfNodePtr CreateTupleGetItem(const FuncGraphPtr &func_graph, const AnfNodePtr &
|
|||
|
||||
void CreateOutputShapeAndTypeId(const CNodePtr &origin_cnode, int64_t split_dim,
|
||||
const std::vector<int64_t> &size_splits_new, std::vector<TypeId> *new_type_ids,
|
||||
std::vector<std::vector<size_t>> *new_output_shapes) {
|
||||
std::vector<ShapeVector> *new_output_shapes) {
|
||||
MS_EXCEPTION_IF_NULL(new_type_ids);
|
||||
MS_EXCEPTION_IF_NULL(new_output_shapes);
|
||||
auto output_shape = common::AnfAlgo::GetOutputInferShape(origin_cnode, 0);
|
||||
|
@ -65,7 +65,7 @@ void CreateOutputShapeAndTypeId(const CNodePtr &origin_cnode, int64_t split_dim,
|
|||
TypeId type_id = common::AnfAlgo::GetOutputInferDataType(origin_cnode, 0);
|
||||
for (size_t i = 0; i < size_splits_new.size(); ++i) {
|
||||
(void)new_type_ids->emplace_back(type_id);
|
||||
output_shape[split_dim_unsigned] = LongToSize(size_splits_new[i]);
|
||||
output_shape[split_dim_unsigned] = size_splits_new[i];
|
||||
(void)new_output_shapes->emplace_back(output_shape);
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ void SetAttrAndAbstractForBaseSplitv(const CNodePtr &origin_cnode, const CNodePt
|
|||
auto output_shape = common::AnfAlgo::GetOutputInferShape(origin_cnode, 0);
|
||||
TypeId type_id = common::AnfAlgo::GetOutputInferDataType(origin_cnode, 0);
|
||||
std::vector<TypeId> base_type_ids(num_split, type_id);
|
||||
std::vector<std::vector<size_t>> base_output_shapes_base;
|
||||
std::vector<ShapeVector> base_output_shapes_base;
|
||||
if (split_dim < 0) {
|
||||
split_dim += SizeToLong(output_shape.size());
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ void SetAttrAndAbstractForBaseSplitv(const CNodePtr &origin_cnode, const CNodePt
|
|||
auto split_dim_l = LongToSize(split_dim);
|
||||
auto num_split_l = LongToSize(num_split);
|
||||
for (size_t i = 0; i < num_split_l; ++i) {
|
||||
output_shape[split_dim_l] = LongToSize(size_splits_base[i]);
|
||||
output_shape[split_dim_l] = size_splits_base[i];
|
||||
(void)base_output_shapes_base.emplace_back(output_shape);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({type_id}, {output_shape}, base_splitv_outputs[i].get());
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ AnfNodePtr SplitFission::DoFission(const FuncGraphPtr &func_graph, const CNodePt
|
|||
SetAttrForSplitVNode(new_splitv, size_splits_new, split_dim, divisor);
|
||||
// Create new output shape and new output type id for each new Splitv node which has full inputs.
|
||||
std::vector<TypeId> new_type_ids;
|
||||
std::vector<std::vector<size_t>> new_output_shapes;
|
||||
std::vector<ShapeVector> new_output_shapes;
|
||||
CreateOutputShapeAndTypeId(cnode, split_dim, size_splits_new, &new_type_ids, &new_output_shapes);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(new_type_ids, new_output_shapes, new_splitv.get());
|
||||
AddNewOutputs(func_graph, new_splitv, divisor, &make_tuple_inputs);
|
||||
|
@ -160,7 +160,7 @@ AnfNodePtr SplitFission::DoFission(const FuncGraphPtr &func_graph, const CNodePt
|
|||
SetAttrForSplitVNode(new_splitv, size_splits_new_last, split_dim, last_node_num_split);
|
||||
// Create new output shape and new output type id for the last Splitv node
|
||||
std::vector<TypeId> last_new_type_ids;
|
||||
std::vector<std::vector<size_t>> last_new_output_shapes;
|
||||
std::vector<ShapeVector> last_new_output_shapes;
|
||||
CreateOutputShapeAndTypeId(cnode, split_dim, size_splits_new_last, &last_new_type_ids, &last_new_output_shapes);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape(last_new_type_ids, last_new_output_shapes, new_splitv.get());
|
||||
AddNewOutputs(func_graph, new_splitv, last_node_num_split, &make_tuple_inputs);
|
||||
|
|
|
@ -111,7 +111,7 @@ bool CheckOutputShape(const AnfNodePtr &node) {
|
|||
return false;
|
||||
}
|
||||
auto last_dim = shape[shape.size() - 1];
|
||||
const size_t kMaxFloat16 = 65500;
|
||||
const int64_t kMaxFloat16 = 65500;
|
||||
if (last_dim > kMaxFloat16) {
|
||||
MS_LOG(INFO) << "The last dim is more than " << kMaxFloat16 << ", switch to aicpu ops.";
|
||||
return false;
|
||||
|
|
|
@ -56,17 +56,15 @@ CNodePtr UnsortSegmentSumFission::CreatePadding(const FuncGraphPtr &graph, const
|
|||
MS_EXCEPTION_IF_NULL(padding);
|
||||
padding->set_scope(origin_node->scope());
|
||||
auto shape = common::AnfAlgo::GetPrevNodeOutputInferShape(origin_node, 0);
|
||||
shape[shape.size() - 1] = pad_dim_size;
|
||||
if (AnfUtils::IsShapeDynamic(shape)) {
|
||||
shape[shape.size() - 1] = SizeToLong(pad_dim_size);
|
||||
if (IsDynamic(shape)) {
|
||||
auto min_shape = common::AnfAlgo::GetInputMinShape(origin_node, 0);
|
||||
auto max_shape = common::AnfAlgo::GetInputMaxShape(origin_node, 0);
|
||||
if (!min_shape.empty() && !max_shape.empty()) {
|
||||
min_shape[shape.size() - 1] = SizeToLong(pad_dim_size);
|
||||
max_shape[shape.size() - 1] = SizeToLong(pad_dim_size);
|
||||
}
|
||||
ShapeVector shape_tmp;
|
||||
std::transform(shape.begin(), shape.end(), std::back_inserter(shape_tmp), SizeToLong);
|
||||
BaseShapePtr base_shape = std::make_shared<abstract::Shape>(shape_tmp, min_shape, max_shape);
|
||||
BaseShapePtr base_shape = std::make_shared<abstract::Shape>(shape, min_shape, max_shape);
|
||||
common::AnfAlgo::SetOutputTypeAndDetailShape({common::AnfAlgo::GetPrevNodeOutputInferDataType(origin_node, 0)},
|
||||
{base_shape}, padding.get());
|
||||
} else {
|
||||
|
@ -89,17 +87,16 @@ CNodePtr UnsortSegmentSumFission::CreateUnsortedSegmentSum(const FuncGraphPtr &g
|
|||
MS_EXCEPTION_IF_NULL(unsorted_segment_sum);
|
||||
unsorted_segment_sum->set_scope(origin_node->scope());
|
||||
auto shape = common::AnfAlgo::GetOutputInferShape(origin_node, 0);
|
||||
shape[shape.size() - 1] = pad_dim_size;
|
||||
if (AnfUtils::IsShapeDynamic(shape)) {
|
||||
shape[shape.size() - 1] = SizeToLong(pad_dim_size);
|
||||
if (IsDynamic(shape)) {
|
||||
auto min_shape = common::AnfAlgo::GetOutputMinShape(origin_node, 0);
|
||||
auto max_shape = common::AnfAlgo::GetInputMaxShape(origin_node, 0);
|
||||
if (!min_shape.empty() && !max_shape.empty()) {
|
||||
min_shape[shape.size() - 1] = SizeToLong(pad_dim_size);
|
||||
max_shape[shape.size() - 1] = SizeToLong(pad_dim_size);
|
||||
}
|
||||
ShapeVector shape_tmp;
|
||||
std::transform(shape.begin(), shape.end(), std::back_inserter(shape_tmp), SizeToLong);
|
||||
BaseShapePtr base_shape = std::make_shared<abstract::Shape>(shape_tmp, min_shape, max_shape);
|
||||
|
||||
BaseShapePtr base_shape = std::make_shared<abstract::Shape>(shape, min_shape, max_shape);
|
||||
common::AnfAlgo::SetOutputTypeAndDetailShape({common::AnfAlgo::GetOutputInferDataType(origin_node, 0)},
|
||||
{base_shape}, unsorted_segment_sum.get());
|
||||
} else {
|
||||
|
@ -107,7 +104,7 @@ CNodePtr UnsortSegmentSumFission::CreateUnsortedSegmentSum(const FuncGraphPtr &g
|
|||
unsorted_segment_sum.get());
|
||||
}
|
||||
|
||||
common::AnfAlgo::SetNodeAttr(kAttrNumSegments, MakeValue(SizeToLong(shape[0])), unsorted_segment_sum);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrNumSegments, MakeValue(shape[0]), unsorted_segment_sum);
|
||||
return unsorted_segment_sum;
|
||||
}
|
||||
|
||||
|
@ -125,7 +122,7 @@ CNodePtr UnsortSegmentSumFission::CreateSlice(const FuncGraphPtr &graph, const C
|
|||
auto unsort_segment_sum_shape = common::AnfAlgo::GetOutputInferShape(unsort_segment_sum, 0);
|
||||
std::vector<size_t> offsets(unsort_segment_sum_shape.size(), 0);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrBegin, MakeValue(Convert2Long(offsets)), slice);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrSize, MakeValue(Convert2Long(unsort_segment_sum_shape)), slice);
|
||||
common::AnfAlgo::SetNodeAttr(kAttrSize, MakeValue(unsort_segment_sum_shape), slice);
|
||||
return slice;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,8 +140,8 @@ AnfNodePtr ConstructFilter(const FuncGraphPtr &func_graph, const std::vector<int
|
|||
MS_EXCEPTION_IF_NULL(func_graph);
|
||||
// assist tensor 1
|
||||
int64_t c1 = (fc + kC0 - 1) / kC0;
|
||||
std::vector<int64_t> assist_shape = {c1 * kd * kh * kw, 1, kC0, kC0}; // frac_z_3d
|
||||
std::vector<size_t> infer_shape = {IntToSize(1), LongToSize(fc), LongToSize(kd), LongToSize(kh), LongToSize(kw)};
|
||||
ShapeVector assist_shape = {c1 * kd * kh * kw, 1, kC0, kC0}; // frac_z_3d
|
||||
ShapeVector infer_shape = {1, fc, kd, kh, kw};
|
||||
float val = 1.0 / (kd * kh * kw);
|
||||
if (divisor_override != 0) {
|
||||
val = 1.0 / divisor_override;
|
||||
|
@ -160,7 +160,6 @@ AnfNodePtr ConstructMultiplier(const FuncGraphPtr &func_graph, int64_t fn, int64
|
|||
MS_EXCEPTION_IF_NULL(func_graph);
|
||||
// assist tensor 2
|
||||
std::vector<int64_t> assist_shape = {fn, fc, dd, dh, dw}; // NCDHW
|
||||
auto infer_shape = {LongToSize(fn), LongToSize(fc), LongToSize(dd), LongToSize(dh), LongToSize(dw)};
|
||||
tensor::TensorPtr tensor = std::make_shared<tensor::Tensor>(kNumberTypeFloat16, assist_shape);
|
||||
MS_EXCEPTION_IF_NULL(tensor);
|
||||
auto tensor_data = reinterpret_cast<float16 *>(tensor->data_c());
|
||||
|
@ -206,13 +205,13 @@ AnfNodePtr ConstructMultiplier(const FuncGraphPtr &func_graph, int64_t fn, int64
|
|||
MS_EXCEPTION_IF_NULL(kernel_graph);
|
||||
auto value_node = kernel_graph->NewValueNode(x_abstract, tensor);
|
||||
kernel_graph->AddValueNodeToGraph(value_node);
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({kNumberTypeFloat16}, {infer_shape}, value_node.get());
|
||||
common::AnfAlgo::SetOutputInferTypeAndShape({kNumberTypeFloat16}, {assist_shape}, value_node.get());
|
||||
return value_node;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
AnfNodePtr ConstructFilterValueNode(const FuncGraphPtr &func_graph, float val, const std::vector<int64_t> &assist_shape,
|
||||
const std::vector<size_t> &infer_shape, int64_t cnt) {
|
||||
AnfNodePtr ConstructFilterValueNode(const FuncGraphPtr &func_graph, float val, const ShapeVector &assist_shape,
|
||||
const ShapeVector &infer_shape, int64_t cnt) {
|
||||
tensor::TensorPtr assist_tensor = std::make_shared<tensor::Tensor>(kNumberTypeFloat16, assist_shape);
|
||||
MS_EXCEPTION_IF_NULL(assist_tensor);
|
||||
TensorTypePtr tensor_type = std::make_shared<TensorType>(kFloat16);
|
||||
|
@ -265,14 +264,14 @@ const AnfNodePtr AvgPool3DFusion::Process(const FuncGraphPtr &func_graph, const
|
|||
<< ", but got in_shape is " << dims_in.size() << "-D, out_shape is " << dims_out.size()
|
||||
<< trace::DumpSourceLines(node);
|
||||
}
|
||||
auto fn = SizeToLong(dims_in[kDim0]);
|
||||
auto fc = SizeToLong(dims_in[kDim1]);
|
||||
auto fd = SizeToLong(dims_in[kDim2]);
|
||||
auto fh = SizeToLong(dims_in[kDim3]);
|
||||
auto fw = SizeToLong(dims_in[kDim4]);
|
||||
auto dout = SizeToLong(dims_out[kDim2]);
|
||||
auto dh = SizeToLong(dims_out[kDim3]);
|
||||
auto dw = SizeToLong(dims_out[kDim4]);
|
||||
auto fn = dims_in[kDim0];
|
||||
auto fc = dims_in[kDim1];
|
||||
auto fd = dims_in[kDim2];
|
||||
auto fh = dims_in[kDim3];
|
||||
auto fw = dims_in[kDim4];
|
||||
auto dout = dims_out[kDim2];
|
||||
auto dh = dims_out[kDim3];
|
||||
auto dw = dims_out[kDim4];
|
||||
// kernel size
|
||||
int64_t kd;
|
||||
int64_t kh;
|
||||
|
|
|
@ -32,8 +32,8 @@ class AvgPool3DFusion : public PatternProcessPass {
|
|||
const AnfNodePtr Process(const FuncGraphPtr &, const AnfNodePtr &, const EquivPtr &) const override;
|
||||
};
|
||||
|
||||
AnfNodePtr ConstructFilterValueNode(const FuncGraphPtr &func_graph, float val, const std::vector<int64_t> &assist_shape,
|
||||
const std::vector<size_t> &infer_shape, int64_t cnt);
|
||||
AnfNodePtr ConstructFilterValueNode(const FuncGraphPtr &func_graph, float val, const ShapeVector &assist_shape,
|
||||
const ShapeVector &infer_shape, int64_t cnt);
|
||||
} // namespace opt
|
||||
} // namespace mindspore
|
||||
|
||||
|
|
|
@ -97,8 +97,8 @@ AnfNodePtr ConstructFilter(const FuncGraphPtr &func_graph, const std::vector<int
|
|||
MS_EXCEPTION_IF_NULL(func_graph);
|
||||
// assist tensor 1
|
||||
int64_t c1 = (fc + kC0 - 1) / kC0;
|
||||
std::vector<int64_t> assist_shape = {c1 * kd * kh * kw, 1, kC0, kC0}; // frac_z_3d
|
||||
std::vector<size_t> infer_shape = {IntToSize(1), LongToSize(fc), LongToSize(kd), LongToSize(kh), LongToSize(kw)};
|
||||
ShapeVector assist_shape = {c1 * kd * kh * kw, 1, kC0, kC0}; // frac_z_3d
|
||||
ShapeVector infer_shape = {1, fc, kd, kh, kw};
|
||||
float val = 1.0;
|
||||
if (divisor_override != 0) {
|
||||
val = 1.0 / divisor_override;
|
||||
|
@ -110,15 +110,13 @@ AnfNodePtr ConstructFilter(const FuncGraphPtr &func_graph, const std::vector<int
|
|||
return ConstructFilterValueNode(func_graph, val, assist_shape, infer_shape, cnt);
|
||||
}
|
||||
|
||||
AnfNodePtr ConstructMultiplier(const FuncGraphPtr &func_graph, const std::vector<size_t> &ori_shape,
|
||||
AnfNodePtr ConstructMultiplier(const FuncGraphPtr &func_graph, const ShapeVector &ori_shape,
|
||||
const std::vector<int64_t> &ori_input_shape, const std::vector<int64_t> &kernel_size,
|
||||
const std::vector<int64_t> &strides, const std::vector<int64_t> &pad_list,
|
||||
bool count_include_pad) {
|
||||
MS_EXCEPTION_IF_NULL(func_graph);
|
||||
// assist tensor 2
|
||||
std::vector<int64_t> grad_shape;
|
||||
(void)std::transform(ori_shape.begin(), ori_shape.end(), std::back_inserter(grad_shape), SizeToLong);
|
||||
std::vector<int64_t> assist_shape = grad_shape; // NCDHW
|
||||
std::vector<int64_t> assist_shape = ori_shape; // NCDHW
|
||||
tensor::TensorPtr tensor = std::make_shared<tensor::Tensor>(kNumberTypeFloat16, assist_shape);
|
||||
MS_EXCEPTION_IF_NULL(tensor);
|
||||
auto tensor_data = reinterpret_cast<float16 *>(tensor->data_c());
|
||||
|
@ -128,14 +126,14 @@ AnfNodePtr ConstructMultiplier(const FuncGraphPtr &func_graph, const std::vector
|
|||
auto len_d = ori_input_shape[kDim2] + pad_d;
|
||||
auto len_h = ori_input_shape[kDim3] + pad_h;
|
||||
auto len_w = ori_input_shape[kDim4] + pad_w;
|
||||
for (int64_t nn = 0; nn < grad_shape[kDim0]; nn++) {
|
||||
for (int64_t cc = 0; cc < grad_shape[kDim1]; cc++) {
|
||||
for (int64_t nn = 0; nn < ori_shape[kDim0]; nn++) {
|
||||
for (int64_t cc = 0; cc < ori_shape[kDim1]; cc++) {
|
||||
int64_t start_d = 0;
|
||||
for (int64_t di = 0; di < grad_shape[kDim2]; di++) {
|
||||
for (int64_t di = 0; di < ori_shape[kDim2]; di++) {
|
||||
int64_t start_h = 0;
|
||||
for (int64_t hi = 0; hi < grad_shape[kDim3]; hi++) {
|
||||
for (int64_t hi = 0; hi < ori_shape[kDim3]; hi++) {
|
||||
int64_t start_w = 0;
|
||||
for (int64_t wi = 0; wi < grad_shape[kDim4]; wi++) {
|
||||
for (int64_t wi = 0; wi < ori_shape[kDim4]; wi++) {
|
||||
int64_t valid_d = 0;
|
||||
int64_t valid_h = 0;
|
||||
int64_t valid_w = 0;
|
||||
|
|
|
@ -44,19 +44,19 @@ bool CheckSupported(const CNodePtr &conv_back_filter) {
|
|||
<< y_shape.size() << "-D, x_shape is " << x_shape.size() << "-D, out_shape is "
|
||||
<< out_shape.size() << trace::DumpSourceLines(conv_back_filter);
|
||||
}
|
||||
const std::set<size_t> kSupportedBatchSize = {32, 256};
|
||||
const std::set<int64_t> kSupportedBatchSize = {32, 256};
|
||||
if (kSupportedBatchSize.find(x_shape[0]) == kSupportedBatchSize.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::vector<size_t>> supported_cases = {
|
||||
std::vector<ShapeVector> supported_cases = {
|
||||
// c_in, c_out, x_h, x_w, y_h, y_w, k_h, k_w
|
||||
{64, 256, 56, 56, 56, 56, 1, 1}, {256, 64, 56, 56, 56, 56, 1, 1}, {3, 64, 224, 224, 112, 112, 7, 7},
|
||||
{512, 128, 28, 28, 28, 28, 1, 1}, {64, 64, 56, 56, 56, 56, 3, 3}, {256, 512, 56, 56, 28, 28, 1, 1},
|
||||
{128, 512, 28, 28, 28, 28, 1, 1}, {256, 128, 56, 56, 56, 56, 1, 1}, {64, 64, 56, 56, 56, 56, 1, 1},
|
||||
};
|
||||
return std::any_of(
|
||||
supported_cases.begin(), supported_cases.end(), [&x_shape, &y_shape, &out_shape](const std::vector<size_t> &c) {
|
||||
supported_cases.begin(), supported_cases.end(), [&x_shape, &y_shape, &out_shape](const ShapeVector &c) {
|
||||
return (c[kIndex0] == x_shape[kIndex1] && c[kIndex1] == y_shape[kIndex1] && c[kIndex2] == x_shape[kIndex2] &&
|
||||
c[kIndex3] == x_shape[kIndex3] && c[kIndex4] == y_shape[kIndex2] && c[kIndex5] == y_shape[kIndex3] &&
|
||||
c[kIndex6] == out_shape[kIndex2] && c[kIndex7] == out_shape[kIndex3]);
|
||||
|
|
|
@ -61,8 +61,8 @@ bool QuitFusion(const FuncGraphPtr &graph, const AnfNodePtr &mul0_anf, const Anf
|
|||
MS_EXCEPTION_IF_NULL(input2);
|
||||
auto addn = input2->cast<CNodePtr>();
|
||||
constexpr size_t kInferShapeIndex = 2;
|
||||
constexpr size_t kShape2Dim1 = 1024;
|
||||
constexpr size_t kShape2Dim2 = 768;
|
||||
constexpr ShapeValueDType kShape2Dim1 = 1024;
|
||||
constexpr ShapeValueDType kShape2Dim2 = 768;
|
||||
if (addn == nullptr || common::AnfAlgo::GetCNodeName(addn) != prim::kPrimAddN->name()) {
|
||||
MS_LOG(INFO) << "Mul's second input is not Addn, quit fusion";
|
||||
return true;
|
||||
|
@ -70,7 +70,7 @@ bool QuitFusion(const FuncGraphPtr &graph, const AnfNodePtr &mul0_anf, const Anf
|
|||
if (common::AnfAlgo::IsDynamicShape(addn)) {
|
||||
return true;
|
||||
}
|
||||
std::vector<size_t> shape = common::AnfAlgo::GetOutputInferShape(addn, 0);
|
||||
auto shape = common::AnfAlgo::GetOutputInferShape(addn, 0);
|
||||
if (shape.size() != kInferShapeIndex || !(shape[1] == kShape2Dim1 || shape[1] == kShape2Dim2)) {
|
||||
MS_LOG(INFO) << "Addn's infer shape is not equal to [x,1024] or [x,768], quit fusion";
|
||||
return true;
|
||||
|
|
|
@ -71,7 +71,7 @@ bool NeedFusion(const AnfNodePtr &sum_anf, const AnfNodePtr &input0, const AnfNo
|
|||
return false;
|
||||
}
|
||||
|
||||
const size_t last_dim_limit = 30000;
|
||||
const ShapeValueDType last_dim_limit = 30000;
|
||||
auto input0_shape = common::AnfAlgo::GetOutputInferShape(input0, 0);
|
||||
if (!input0_shape.empty() && input0_shape[input0_shape.size() - 1] > last_dim_limit) {
|
||||
MS_LOG(INFO) << "Input shape is too large to optimize, quit fusion, shape: " << input0_shape;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue