回退 'Pull Request !3103 : change type of Shape from int32 to int64'

This commit is contained in:
suteng 2020-08-03 22:06:37 +08:00 committed by Gitee
parent 42594daf80
commit 19e45ccdb1
94 changed files with 1162 additions and 1200 deletions

View File

@ -402,36 +402,31 @@ AbstractBasePtr InferImplDropoutGenMask(const AnalysisEnginePtr &, const Primiti
for (std::size_t i = 0; i < x_shape->size(); ++i) {
auto value_track = x_shape_data[i]->GetValueTrack();
MS_EXCEPTION_IF_NULL(value_track);
int64_t e_value = 0;
if (value_track->isa<Int64Imm>()) {
e_value = GetValue<int64_t>(value_track);
} else if (value_track->isa<Int32Imm>()) {
e_value = static_cast<int64_t>(GetValue<int>(value_track));
} else {
MS_LOG(EXCEPTION) << "DropOutGenMask input x_shape elements is not int64 or int32, but "
<< value_track->ToString() << ".";
if (!value_track->isa<Int32Imm>()) {
MS_LOG(EXCEPTION) << "DropOutGenMask input x_shape elements is not int32, but " << value_track->ToString() << ".";
}
int e_value = GetValue<int>(value_track);
if (e_value <= 0) {
MS_LOG(EXCEPTION) << "DropOutGenMask product of x_shape should be > 0";
}
if (std::numeric_limits<int64_t>::max() / count / e_value < 1) {
if (std::numeric_limits<int>::max() / count / e_value < 1) {
MS_LOG(EXCEPTION) << "integer multiply integer overflow";
}
count = count * e_value;
}
// convert to bytes(8 bits) mask, using round up
int64_t n128s = count / 128;
int n128s = count / 128;
if ((count % 128) != 0) {
n128s++;
}
int64_t bytes_count = n128s * 16;
std::vector<int64_t> shape_y{bytes_count};
int bytes_count = n128s * 16;
std::vector<int> shape_y{bytes_count};
primitive->set_attr("T", kInt32);
return std::make_shared<AbstractTensor>(std::make_shared<AbstractScalar>(kAnyValue, kUInt8),
std::make_shared<Shape>(std::vector<int64_t>{shape_y}));
std::make_shared<Shape>(std::vector<int>{shape_y}));
}
} // namespace abstract
} // namespace mindspore

View File

@ -1580,7 +1580,7 @@ Status CostGraph::InitSelectedStrategy() {
if (stra.empty()) {
MS_LOG(EXCEPTION) << "Infer strategy by tensor_info failed";
}
Strategys stra_inputs = {stra};
std::vector<Dimensions> stra_inputs = {stra};
StrategyPtr reshape_stra =
std::make_shared<Strategy>((*pre_iter)->prev_operator()->strategy()->GetInputStage(), stra_inputs);
reshape_info->set_strategy(reshape_stra);

View File

@ -45,9 +45,10 @@ void GenerateStrategy(const std::shared_ptr<Graph> &graph, const std::vector<std
GenerateRemainingOperatorStrategy(graph, ops, input_tensor_names, index_list, no_stra_op_list);
}
Strategys PrepareMatMul(const std::shared_ptr<Graph> &graph, const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops) {
Strategys strategies;
std::vector<std::vector<int32_t>> PrepareMatMul(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops) {
std::vector<std::vector<int32_t>> strategies;
auto attrs = ops[iter_ops]->attrs();
bool transpose_a = attrs[TRANSPOSE_A]->cast<BoolImmPtr>()->value();
bool transpose_b = attrs[TRANSPOSE_B]->cast<BoolImmPtr>()->value();
@ -104,40 +105,41 @@ Strategys PrepareMatMul(const std::shared_ptr<Graph> &graph, const std::vector<s
}
for (size_t iter_op_inputs = 0; iter_op_inputs < ops[iter_ops]->inputs_tensor_info().size(); iter_op_inputs++) {
Dimensions s;
std::vector<int32_t> s;
if (transpose_a && (iter_op_inputs == 0)) {
s.push_back(
static_cast<int64_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_w));
static_cast<int32_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_w));
s.push_back(
static_cast<int64_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_h));
static_cast<int32_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_h));
} else if (transpose_b && (iter_op_inputs == 1)) {
s.push_back(
static_cast<int64_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_w));
static_cast<int32_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_w));
s.push_back(
static_cast<int64_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_h));
static_cast<int32_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_h));
} else {
s.push_back(
static_cast<int64_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_h));
static_cast<int32_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_h));
s.push_back(
static_cast<int64_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_w));
static_cast<int32_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_w));
}
strategies.push_back(s);
}
return strategies;
}
Strategys PrepareBiasAdd(const std::shared_ptr<Dimensions> &s) {
Strategys strategies;
std::vector<std::vector<int32_t>> PrepareBiasAdd(const std::shared_ptr<std::vector<int32_t>> &s) {
std::vector<std::vector<int32_t>> strategies;
strategies.push_back(*s);
Dimensions s_biasadd;
std::vector<int32_t> s_biasadd;
s_biasadd.push_back(s->at(1));
strategies.push_back(s_biasadd);
return strategies;
}
Strategys PrepareOneHot(const std::shared_ptr<Graph> &graph, const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops) {
Strategys strategies = MakeRecSearchStrategy(graph, ops, iter_graph, iter_ops);
std::vector<std::vector<int32_t>> PrepareOneHot(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops) {
std::vector<std::vector<int32_t>> strategies = MakeRecSearchStrategy(graph, ops, iter_graph, iter_ops);
int32_t axis = -1;
auto iter = ops[iter_ops]->attrs().find(AXIS);
@ -156,14 +158,15 @@ Strategys PrepareOneHot(const std::shared_ptr<Graph> &graph, const std::vector<s
graph->nodes[iter_graph].tensor_parm.tensor_str.str_w = 1.0;
}
Dimensions s_empty = {};
std::vector<int32_t> s_empty = {};
strategies.push_back(s_empty);
strategies.push_back(s_empty);
return strategies;
}
Strategys PrepareGatherV2(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops, Dimensions s) {
Strategys strategies;
std::vector<std::vector<int32_t>> PrepareGatherV2(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, std::vector<int32_t> s) {
std::vector<std::vector<int32_t>> strategies;
auto axis_input = GetValue<int>(ops[iter_ops]->input_value().at(2));
if (axis_input < 0) {
@ -182,7 +185,7 @@ Strategys PrepareGatherV2(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
return strategies;
}
Dimensions s_indices;
std::vector<int32_t> s_indices;
for (size_t i = 0; i < ops[iter_ops]->inputs_tensor_info()[1].shape().size(); i++) {
s_indices.push_back(1);
}
@ -191,8 +194,8 @@ Strategys PrepareGatherV2(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
return strategies;
}
Strategys PrepareL2Normalize(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops,
Dimensions s) {
std::vector<std::vector<int32_t>> PrepareL2Normalize(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, std::vector<int32_t> s) {
int32_t axis = 0;
auto iter = ops[iter_ops]->attrs().find(AXIS);
if (iter != ops[iter_ops]->attrs().end()) {
@ -212,14 +215,14 @@ Strategys PrepareL2Normalize(const std::vector<std::shared_ptr<OperatorInfo>> &o
s[IntToSize(axis_index)] = 1;
Strategys strategies;
std::vector<std::vector<int32_t>> strategies;
strategies.push_back(s);
return strategies;
}
Strategys MakeRecSearchStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_graph,
const size_t iter_ops) {
std::vector<std::vector<int32_t>> MakeRecSearchStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops) {
if (ops.empty()) {
MS_LOG(EXCEPTION) << "Failure: Operators is empty.";
}
@ -228,31 +231,31 @@ Strategys MakeRecSearchStrategy(const std::shared_ptr<Graph> &graph,
}
StrategyPtr origin_strategy = ops[iter_ops]->strategy();
Strategys strategies;
std::vector<std::vector<int32_t>> strategies;
for (size_t iter_op_inputs = 0; iter_op_inputs < ops[iter_ops]->inputs_tensor_info().size(); iter_op_inputs++) {
if (iter_op_inputs >= origin_strategy->GetInputDim().size()) {
MS_LOG(EXCEPTION) << "Failure: Strategy's InputDim out of range.";
}
size_t output_size = origin_strategy->GetInputDim()[iter_op_inputs].size();
Dimensions s;
std::vector<int32_t> s;
if (output_size == 4) {
s.push_back(
static_cast<int64_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_n));
static_cast<int32_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_n));
s.push_back(
static_cast<int64_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_c));
static_cast<int32_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_c));
s.push_back(
static_cast<int64_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_h));
static_cast<int32_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_h));
s.push_back(
static_cast<int64_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_w));
static_cast<int32_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_w));
} else if (output_size == 2) {
s.push_back(
static_cast<int64_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_h));
static_cast<int32_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_h));
s.push_back(
static_cast<int64_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_w));
static_cast<int32_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_w));
} else if (output_size == 1) {
s.push_back(
static_cast<int64_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_w));
static_cast<int32_t>(1.0 / graph->nodes[iter_graph].apply.arguments[iter_op_inputs].tensor_str.str_w));
} else if (output_size == 0) {
s = {};
} else {
@ -263,9 +266,9 @@ Strategys MakeRecSearchStrategy(const std::shared_ptr<Graph> &graph,
return strategies;
}
Strategys MakeDataParallelStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_graph,
const size_t iter_ops) {
std::vector<std::vector<int32_t>> MakeDataParallelStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops) {
if (ops.empty()) {
MS_LOG(EXCEPTION) << "Failure: Operators is empty.";
}
@ -274,7 +277,7 @@ Strategys MakeDataParallelStrategy(const std::shared_ptr<Graph> &graph,
}
StrategyPtr origin_strategy = ops[iter_ops]->strategy();
Strategys strategies;
std::vector<std::vector<int32_t>> strategies;
size_t max_device_num = g_device_manager->DeviceNum();
size_t target_tensor_batch = ops[iter_ops]->inputs_tensor_info()[0].shape()[0];
for (size_t iter_op_inputs = 0; iter_op_inputs < ops[iter_ops]->inputs_tensor_info().size(); iter_op_inputs++) {
@ -282,7 +285,7 @@ Strategys MakeDataParallelStrategy(const std::shared_ptr<Graph> &graph,
MS_LOG(EXCEPTION) << "Failure: Strategy's InputDim out of range.";
}
Dimensions s;
std::vector<int32_t> s;
size_t input_size = origin_strategy->GetInputDim()[iter_op_inputs].size();
for (size_t dim = 0; dim < input_size; dim++) {
if (input_size == 1 || input_size == 2 || input_size == 4) {
@ -315,8 +318,9 @@ Strategys MakeDataParallelStrategy(const std::shared_ptr<Graph> &graph,
return strategies;
}
Strategys PrepareStrategy(const std::shared_ptr<Graph> &graph, const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops) {
std::vector<std::vector<int32_t>> PrepareStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops) {
if (ops.empty()) {
MS_LOG(EXCEPTION) << "Failure: Operators is empty.";
}
@ -344,7 +348,7 @@ void GeneratePartitionedOperatorStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const std::shared_ptr<std::vector<size_t>> &index_list) {
for (size_t iter_ops = 0; iter_ops < (size_t)index_list->size(); iter_ops++) {
Strategys strategies;
std::vector<std::vector<int32_t>> strategies;
size_t iter_graph = index_list->at(iter_ops);
if (iter_graph != SIZE_MAX && ops[iter_ops]->type() != GET_NEXT) {
strategies = PrepareStrategy(graph, ops, iter_graph, iter_ops);
@ -371,10 +375,10 @@ size_t FindIndexOfOperatorIncoming(const std::vector<std::vector<std::string>> &
return incoming_op_index;
}
Dimensions CopyIncomingOperatorOutputStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, const size_t iter_graph) {
Dimensions s;
std::vector<int32_t> CopyIncomingOperatorOutputStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, const size_t iter_graph) {
std::vector<int32_t> s;
for (auto input : ops[iter_ops]->inputs_tensor_info()) {
auto input_stra_dim = input.shape().size();
if (input_stra_dim == 0) {
@ -398,9 +402,9 @@ Dimensions CopyIncomingOperatorOutputStrategy(const std::shared_ptr<Graph> &grap
return s;
}
Dimensions PrepareIncomingOperatorInputStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index) {
Dimensions s;
std::vector<int32_t> PrepareIncomingOperatorInputStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index) {
std::vector<int32_t> s;
if (ops[incoming_op_index]->type() == RESHAPE || ops[incoming_op_index]->type() == GATHERV2 ||
ops[incoming_op_index]->type() == TRANSPOSE) {
return s;
@ -422,8 +426,8 @@ Dimensions PrepareIncomingOperatorInputStrategy(const std::vector<std::shared_pt
return s;
}
Dimensions GetAxisList(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const int iter_ops) {
Dimensions axis_list;
std::vector<int32_t> GetAxisList(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const int iter_ops) {
std::vector<int32_t> axis_list;
auto axis_param = ops[iter_ops]->attrs().find(AXIS)->second;
std::vector<ValuePtr> elements;
if (axis_param->isa<ValueTuple>()) {
@ -444,10 +448,10 @@ Dimensions GetAxisList(const std::vector<std::shared_ptr<OperatorInfo>> &ops, co
return axis_list;
}
Dimensions ModifyStrategyIfSqueezeIncoming(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index, Dimensions s) {
Dimensions s_Squeeze;
Dimensions stra_dim_list;
std::vector<int32_t> ModifyStrategyIfSqueezeIncoming(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index, std::vector<int32_t> s) {
std::vector<int32_t> s_Squeeze;
std::vector<int32_t> stra_dim_list;
for (size_t i = 0; i < s.size(); i++) {
stra_dim_list.push_back(i);
}
@ -484,8 +488,8 @@ bool GetKeepDims(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const si
return keepdims;
}
Dimensions GetDimList(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops) {
Dimensions dim_list;
std::vector<int32_t> GetDimList(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops) {
std::vector<int32_t> dim_list;
bool keep_dims = GetKeepDims(ops, iter_ops);
if (keep_dims != false) {
return dim_list;
@ -509,10 +513,10 @@ Dimensions GetDimList(const std::vector<std::shared_ptr<OperatorInfo>> &ops, con
return dim_list;
}
Dimensions ModifyStrategyIfReduceIncoming(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index, Dimensions s) {
Dimensions s_Reduce;
Dimensions axis_list;
std::vector<int32_t> ModifyStrategyIfReduceIncoming(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index, std::vector<int32_t> s) {
std::vector<int32_t> s_Reduce;
std::vector<int32_t> axis_list;
for (size_t i = 0; i < s.size(); i++) {
axis_list.push_back(i);
}
@ -532,8 +536,8 @@ Dimensions ModifyStrategyIfReduceIncoming(const std::vector<std::shared_ptr<Oper
return s_Reduce;
}
Dimensions GetDimListFromAttrs(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops) {
Dimensions dim_list;
std::vector<int32_t> GetDimListFromAttrs(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops) {
std::vector<int32_t> dim_list;
auto iter = ops[iter_ops]->attrs().find(AXIS);
if (iter == ops[iter_ops]->attrs().end()) {
MS_LOG(EXCEPTION) << ops[iter_ops]->name() << ": Don't have attr axis.";
@ -560,15 +564,15 @@ Dimensions GetDimListFromAttrs(const std::vector<std::shared_ptr<OperatorInfo>>
return dim_list;
}
Dimensions ModifyStrategyIfArgIncoming(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index, Dimensions s) {
std::vector<int32_t> ModifyStrategyIfArgIncoming(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index, std::vector<int32_t> s) {
bool keepdims = GetKeepDims(ops, incoming_op_index);
if (keepdims) {
return s;
}
Dimensions s_Arg;
Dimensions axis_list;
std::vector<int32_t> s_Arg;
std::vector<int32_t> axis_list;
for (size_t i = 0; i < s.size(); i++) {
axis_list.push_back(i);
}
@ -588,9 +592,9 @@ Dimensions ModifyStrategyIfArgIncoming(const std::vector<std::shared_ptr<Operato
return s_Arg;
}
Dimensions CopyIncomingOperatorInputStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, const size_t incoming_op_index) {
Dimensions s;
std::vector<int32_t> CopyIncomingOperatorInputStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, const size_t incoming_op_index) {
std::vector<int32_t> s;
s = PrepareIncomingOperatorInputStrategy(ops, incoming_op_index);
if (s.size() != 0) {
if (ops[incoming_op_index]->type() == SQUEEZE) {
@ -607,9 +611,10 @@ Dimensions CopyIncomingOperatorInputStrategy(const std::vector<std::shared_ptr<O
return s;
}
Strategys GenerateStrategiesFromStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops,
Dimensions basic_stra) {
Strategys stra;
std::vector<std::vector<int32_t>> GenerateStrategiesFromStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops,
std::vector<int32_t> basic_stra) {
std::vector<std::vector<int32_t>> stra;
MS_EXCEPTION_IF_NULL(ops[iter_ops]);
if (basic_stra.size() == 0) {
@ -620,7 +625,7 @@ Strategys GenerateStrategiesFromStrategy(const std::vector<std::shared_ptr<Opera
return stra;
}
auto s_ptr = std::make_shared<Dimensions>(basic_stra);
auto s_ptr = std::make_shared<std::vector<int32_t>>(basic_stra);
if (ops[iter_ops]->type() == BIAS_ADD) {
return PrepareBiasAdd(s_ptr);
}
@ -639,8 +644,9 @@ Strategys GenerateStrategiesFromStrategy(const std::vector<std::shared_ptr<Opera
}
// Function to deal with ops with broadcasting, like TensorAdd/Sub/Mul/Div etc.
Strategys CheckBroadcast(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops, Dimensions s) {
Strategys stra;
std::vector<std::vector<int32_t>> CheckBroadcast(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, std::vector<int32_t> s) {
std::vector<std::vector<int32_t>> stra;
size_t first_tensor_dim = ops[iter_ops]->inputs_tensor_info()[0].shape().size();
size_t second_tensor_dim = ops[iter_ops]->inputs_tensor_info()[1].shape().size();
@ -665,10 +671,11 @@ Strategys CheckBroadcast(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
return stra;
}
Dimensions ApplyBroadcast(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops, Dimensions s,
size_t target_tensor_dim, size_t refer_tensor_dim, bool braoadcast_first_tensor) {
Dimensions s_empty = {};
Dimensions s_broadcast;
std::vector<int32_t> ApplyBroadcast(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops,
std::vector<int32_t> s, size_t target_tensor_dim, size_t refer_tensor_dim,
bool braoadcast_first_tensor) {
std::vector<int32_t> s_empty = {};
std::vector<int32_t> s_broadcast;
int target_tensor_index = 0;
int refer_tensor_index = 0;
@ -712,10 +719,10 @@ Dimensions ApplyBroadcast(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
}
// Check whether the operator can be divided by the current strategy.
Strategys CheckDivisible(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops,
Dimensions basic_stra) {
Dimensions s_empty = {};
Strategys stra;
std::vector<std::vector<int32_t>> CheckDivisible(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, std::vector<int32_t> basic_stra) {
std::vector<int32_t> s_empty = {};
std::vector<std::vector<int32_t>> stra;
// For all the input tensors.
for (size_t iter_op_inputs = 0; iter_op_inputs < (size_t)ops[iter_ops]->inputs_tensor_info().size();
@ -726,7 +733,7 @@ Strategys CheckDivisible(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
continue;
}
Dimensions tmp_stra = basic_stra;
std::vector<int32_t> tmp_stra = basic_stra;
bool modified = false;
// Make sure each tensor's dim shape is greater than 1. If not, push back strategy as 1 instead.
@ -758,8 +765,8 @@ void GenerateEliminatedOperatorStrategyForward(const std::shared_ptr<Graph> &gra
for (size_t iter_list = no_stra_op_list->size(); iter_list > 0; iter_list--) {
size_t iter_ops = no_stra_op_list->at(iter_list - 1);
Strategys stra;
Dimensions s;
std::vector<std::vector<int32_t>> stra;
std::vector<int32_t> s;
size_t incoming_op_index = FindIndexOfOperatorIncoming(input_tensor_names, iter_ops);
if (incoming_op_index != SIZE_MAX) {
auto iter_graph = index_list->at(incoming_op_index);
@ -786,9 +793,9 @@ void GenerateEliminatedOperatorStrategyForward(const std::shared_ptr<Graph> &gra
}
}
Dimensions ModifyStrategyIfSqueezeOutgoing(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops,
Dimensions s) {
Dimensions s_Squeeze;
std::vector<int32_t> ModifyStrategyIfSqueezeOutgoing(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, std::vector<int32_t> s) {
std::vector<int32_t> s_Squeeze;
auto axis_list = GetAxisList(ops, iter_ops);
size_t s_index = 0;
size_t axis_list_index = 0;
@ -813,10 +820,10 @@ Dimensions ModifyStrategyIfSqueezeOutgoing(const std::vector<std::shared_ptr<Ope
return s_Squeeze;
}
Dimensions CopyOutgoingOperatorInputStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const std::vector<std::vector<std::string>> &input_tensor_names,
const size_t iter_ops) {
Dimensions s;
std::vector<int32_t> CopyOutgoingOperatorInputStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const std::vector<std::vector<std::string>> &input_tensor_names,
const size_t iter_ops) {
std::vector<int32_t> s;
if (ops[iter_ops]->type() == REDUCE_MAX || ops[iter_ops]->type() == REDUCE_MIN ||
ops[iter_ops]->type() == REDUCE_SUM || ops[iter_ops]->type() == REDUCE_MEAN || ops[iter_ops]->type() == RESHAPE ||
ops[iter_ops]->type() == GATHERV2 || ops[iter_ops]->type() == TRANSPOSE ||
@ -860,8 +867,8 @@ void GenerateEliminatedOperatorStrategyBackward(const std::vector<std::shared_pt
for (size_t iter_list = no_stra_op_list->size(); iter_list > 0; iter_list--) {
auto iter_ops = no_stra_op_list->at(iter_list - 1);
Strategys stra;
Dimensions s = CopyOutgoingOperatorInputStrategy(ops, input_tensor_names, iter_ops);
std::vector<std::vector<int32_t>> stra;
std::vector<int32_t> s = CopyOutgoingOperatorInputStrategy(ops, input_tensor_names, iter_ops);
if (s.size() != 0 && ops[iter_ops]->type() == SQUEEZE) {
s = ModifyStrategyIfSqueezeOutgoing(ops, iter_ops, s);
@ -900,8 +907,8 @@ void GenerateRemainingOperatorStrategy(const std::shared_ptr<Graph> &graph,
for (size_t iter_list = 0; iter_list < no_stra_op_list->size(); iter_list++) {
auto iter_ops = no_stra_op_list->at(iter_list);
Strategys stra;
Dimensions s;
std::vector<std::vector<int32_t>> stra;
std::vector<int32_t> s;
size_t max_dim_num = 0;
for (size_t iter_op_inputs = 0; iter_op_inputs < ops[iter_ops]->inputs_tensor_info().size(); iter_op_inputs++) {

View File

@ -31,60 +31,68 @@ void GenerateStrategy(const std::shared_ptr<Graph> &graph, const std::vector<std
const std::shared_ptr<std::vector<std::vector<size_t>>> &eli_list,
const std::vector<std::vector<std::string>> &input_tensor_names,
const std::shared_ptr<std::vector<size_t>> &index_list);
Strategys PrepareMatMul(const std::shared_ptr<Graph> &graph, const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops);
Strategys PrepareBiasAdd(const std::shared_ptr<Dimensions> &s);
Strategys PrepareOneHot(const std::shared_ptr<Graph> &graph, const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops);
Strategys PrepareGatherV2(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops, Dimensions s);
Strategys PrepareL2Normalize(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops,
Dimensions s);
Strategys MakeRecSearchStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_graph,
const size_t iter_ops);
Strategys CheckBroadcast(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops, Dimensions s);
Dimensions ApplyBroadcast(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops, Dimensions s,
size_t target_tensor_dim, size_t refer_tensor_dim, bool braoadcast_first_tensor);
Strategys CheckDivisible(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops, Dimensions s);
Strategys MakeDataParallelStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_graph,
const size_t iter_ops);
Strategys PrepareStrategy(const std::shared_ptr<Graph> &graph, const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops);
std::vector<std::vector<int32_t>> PrepareMatMul(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops);
std::vector<std::vector<int32_t>> PrepareBiasAdd(const std::shared_ptr<std::vector<int32_t>> &s);
std::vector<std::vector<int32_t>> PrepareOneHot(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops);
std::vector<std::vector<int32_t>> PrepareGatherV2(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, std::vector<int32_t> s);
std::vector<std::vector<int32_t>> PrepareL2Normalize(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, std::vector<int32_t> s);
std::vector<std::vector<int32_t>> CheckBroadcast(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, std::vector<int32_t> s);
std::vector<int32_t> ApplyBroadcast(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops,
std::vector<int32_t> s, size_t target_tensor_dim, size_t refer_tensor_dim,
bool braoadcast_first_tensor);
std::vector<std::vector<int32_t>> CheckDivisible(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, std::vector<int32_t> s);
std::vector<std::vector<int32_t>> MakeRecSearchStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops);
std::vector<std::vector<int32_t>> MakeDataParallelStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops);
std::vector<std::vector<int32_t>> PrepareStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_graph, const size_t iter_ops);
void GeneratePartitionedOperatorStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const std::shared_ptr<std::vector<size_t>> &index_list);
size_t FindIndexOfOperatorIncoming(const std::vector<std::vector<std::string>> &input_tensor_names,
const size_t iter_ops);
Dimensions CopyIncomingOperatorOutputStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, const size_t iter_graph);
Dimensions PrepareIncomingOperatorInputStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index);
Dimensions GetAxisList(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const int iter_ops);
Dimensions ModifyStrategyIfSqueezeIncoming(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index, Dimensions s);
std::vector<int32_t> CopyIncomingOperatorOutputStrategy(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, const size_t iter_graph);
std::vector<int32_t> PrepareIncomingOperatorInputStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index);
std::vector<int32_t> GetAxisList(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const int iter_ops);
std::vector<int32_t> ModifyStrategyIfSqueezeIncoming(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index, std::vector<int32_t> s);
bool GetKeepDims(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops);
Dimensions GetDimList(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops);
Dimensions ModifyStrategyIfReduceIncoming(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index, Dimensions s);
Dimensions GetDimListFromAttrs(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops);
Dimensions ModifyStrategyIfArgIncoming(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index, Dimensions s);
Dimensions CopyIncomingOperatorInputStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, const size_t incoming_op_index);
Strategys GenerateStrategiesFromStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops,
Dimensions basic_stra);
std::vector<int32_t> GetDimList(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops);
std::vector<int32_t> ModifyStrategyIfReduceIncoming(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index, std::vector<int32_t> s);
std::vector<int32_t> GetDimListFromAttrs(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops);
std::vector<int32_t> ModifyStrategyIfArgIncoming(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t incoming_op_index, std::vector<int32_t> s);
std::vector<int32_t> CopyIncomingOperatorInputStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, const size_t incoming_op_index);
std::vector<std::vector<int32_t>> GenerateStrategiesFromStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops,
std::vector<int32_t> basic_stra);
void GenerateEliminatedOperatorStrategyForward(const std::shared_ptr<Graph> &graph,
const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const std::vector<std::vector<std::string>> &input_tensor_names,
const std::shared_ptr<std::vector<size_t>> &index_list,
const std::shared_ptr<std::vector<size_t>> &no_stra_op_list);
Dimensions ModifyStrategyIfSqueezeOutgoing(const std::vector<std::shared_ptr<OperatorInfo>> &ops, const size_t iter_ops,
Dimensions s);
Dimensions CopyOutgoingOperatorInputStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const std::vector<std::vector<std::string>> &input_tensor_names,
const size_t iter_ops);
std::vector<int32_t> ModifyStrategyIfSqueezeOutgoing(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const size_t iter_ops, std::vector<int32_t> s);
std::vector<int32_t> CopyOutgoingOperatorInputStrategy(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const std::vector<std::vector<std::string>> &input_tensor_names,
const size_t iter_ops);
void GenerateEliminatedOperatorStrategyBackward(const std::vector<std::shared_ptr<OperatorInfo>> &ops,
const std::vector<std::vector<std::string>> &input_tensor_names,
const std::shared_ptr<std::vector<size_t>> &no_stra_op_list);

View File

@ -29,7 +29,7 @@
namespace mindspore {
namespace parallel {
static std::map<std::string, Shape> param_shapes;
static std::map<std::string, std::vector<int>> param_shapes;
std::vector<std::string> PARALLEL_MODE_LIST = {STAND_ALONE, DATA_PARALLEL, HYBRID_PARALLEL, SEMI_AUTO_PARALLEL,
AUTO_PARALLEL};
@ -173,7 +173,7 @@ void ParallelParameterContextRestoreInNoTraining(const FuncGraphPtr &func_graph,
MS_LOG(WARNING) << "Can not found the shape for parameter " << param_node->name();
return;
}
Shape shape = iter->second;
std::vector<int> shape = iter->second;
std::shared_ptr<abstract::BaseShape> base_shape = std::make_shared<abstract::Shape>(shape);
ptr->set_shape(base_shape);
MS_LOG(DEBUG) << "The parameter name is " << param_node->name() << ", the shape is " << shape;
@ -189,10 +189,7 @@ void ParallelParameterContextCkptInTraining(const FuncGraphPtr &func_graph, cons
return;
}
std::vector<int> shape_int = dyn_cast<abstract::Shape>(ptr->GetShapeTrack())->shape();
Shape shape;
(void)std::transform(shape_int.begin(), shape_int.end(), std::back_inserter(shape),
[](const int &value) { return static_cast<int64_t>(value); });
std::vector<int> shape = dyn_cast<abstract::Shape>(ptr->GetShapeTrack())->shape();
auto ret = param_shapes.try_emplace(param_node->name(), shape);
if (!ret.second) {
MS_LOG(EXCEPTION) << "The shape for parameter name " << param_node->name() << " is existed";

View File

@ -159,7 +159,7 @@ std::string ShapeToString(const Shape &shape) {
return str + "]";
}
std::string ListToString(const RankList &list) {
std::string ListToString(const std::vector<int32_t> &list) {
std::string str = "[";
for (auto &element : list) {
str += std::to_string(element) + ", ";

View File

@ -27,7 +27,7 @@
namespace mindspore {
namespace parallel {
using RankList = std::vector<int32_t>;
using Shape = std::vector<int64_t>;
using Shape = std::vector<int32_t>;
class DeviceMatrix {
public:
@ -48,7 +48,7 @@ class DeviceMatrix {
};
std::string ShapeToString(const Shape &shape);
std::string ListToString(const RankList &list);
std::string ListToString(const std::vector<int32_t> &list);
} // namespace parallel
} // namespace mindspore

View File

@ -45,13 +45,13 @@ py::dict GetParameterLayout(const FuncGraphPtr &graph) {
auto tensor_map = tensor_layout->tensor_map().array();
auto slice_shape = tensor_layout->slice_shape().array();
int32_t _field_size = tensor_layout->get_field_size();
Shape field_size;
std::vector<int32_t> field_size;
if (_field_size != 0) {
field_size.push_back(_field_size);
} else {
field_size = {0};
}
std::vector<Shape> layout = {device_arrangement, tensor_map, slice_shape, field_size};
std::vector<std::vector<int32_t>> layout = {device_arrangement, tensor_map, slice_shape, field_size};
dict[py::str(name)] = layout;
MS_LOG(INFO) << "GetParameterLayout name = " << name << ", layout " << tensor_layout->ToString();
}

View File

@ -130,7 +130,7 @@ Status Softmax::CheckStrategy(const StrategyPtr &strategy) {
return FAILED;
}
Strategys stra = strategy->GetInputDim();
std::vector<Dimensions> stra = strategy->GetInputDim();
Dimensions input_strategy = stra.at(0);
for (auto &element : axis_) {
@ -181,7 +181,7 @@ Status Softmax::GetAttrs() {
MS_LOG(ERROR) << name_ << " : The axis tuple is empty.";
return FAILED;
}
MS_LOG(INFO) << name_ << " : The axis is tuple, value is " << ListToString(axis_);
MS_LOG(INFO) << name_ << " : The axis is tuple, value is " << ShapeToString(axis_);
} else {
MS_LOG(ERROR) << name_ << " : The value of axis is not int or tuple int.";
return FAILED;
@ -258,7 +258,7 @@ Status Softmax::GenerateStrategies(int32_t stage_id) {
}
Status ActivationBase::InferDevMatrixShape() {
Strategys stra = strategy_->GetInputDim();
std::vector<Dimensions> stra = strategy_->GetInputDim();
Dimensions input_strategy = stra.at(0);
dev_matrix_shape_ = input_strategy;
@ -296,11 +296,11 @@ Status ActivationBase::InferForwardCommunication() {
}
Status ActivationBase::InferTensorMap() {
Shape tensor_map_index;
std::vector<int32_t> tensor_map_index;
size_t size = inputs_shape_.at(0).size();
// such as 4: tensor_map_index [3,2,1,0]
for (size_t i = 0; i < size; ++i) {
tensor_map_index.push_back((int64_t)(size - i - 1));
tensor_map_index.push_back((int32_t)(size - i - 1));
}
inputs_tensor_map_.push_back(tensor_map_index);
@ -425,7 +425,7 @@ Status ExpandDimsInfo::InferTensorMap() {
// for example: if the dimension of input is 3, and the axis is 2,
// then the input_tensor_map is [2, 1, 0], the output_tensor_map is [2, 1, -1, 0]
Shape input_tensor_map, output_tensor_map;
std::vector<int32_t> input_tensor_map, output_tensor_map;
size_t size = inputs_shape_[0].size();
for (size_t i = 0; i < size; ++i) {
input_tensor_map.push_back(SizeToInt(size - i - 1));
@ -607,7 +607,7 @@ Status SqueezeInfo::InferReplaceOps(const StrategyPtr &strategy) {
Status SqueezeInfo::InferTensorMap() {
// for example: if the shape of input is [32, 32, 1], and the axis is (2, ),
// then the input_tensor_map is [2, 1, 0], the output_tensor_map is [2, 1]
Shape input_tensor_map, output_tensor_map;
std::vector<int32_t> input_tensor_map, output_tensor_map;
if (inputs_shape_.empty()) {
MS_LOG(ERROR) << name_ << ": The inputs shape is empty";
return FAILED;

View File

@ -54,9 +54,9 @@ Shapes ArithmeticBase::InferExpendShape() {
return input_shapes;
}
Strategys ExpendStrategy(const StrategyPtr &strategy) {
Strategys expend_strategy;
Strategys stra = strategy->GetInputDim();
std::vector<Dimensions> ExpendStrategy(const StrategyPtr &strategy) {
std::vector<Dimensions> expend_strategy;
std::vector<Dimensions> stra = strategy->GetInputDim();
Dimensions sub_a_strategy = stra.at(0);
Dimensions sub_b_strategy = stra.at(1);
size_t input_a_size = sub_a_strategy.size();
@ -83,7 +83,7 @@ Status ArithmeticBase::CheckStrategy(const StrategyPtr &strategy) {
return FAILED;
}
Shapes input_shapes = InferExpendShape();
Strategys expend_strategy = ExpendStrategy(strategy);
std::vector<Dimensions> expend_strategy = ExpendStrategy(strategy);
Dimensions sub_a_strategy = expend_strategy.at(0);
Dimensions sub_b_strategy = expend_strategy.at(1);
Shape input_a_shape = input_shapes.at(0);
@ -103,7 +103,7 @@ Status ArithmeticBase::CheckStrategy(const StrategyPtr &strategy) {
}
Status ArithmeticBase::InferDevMatrixShape() {
Strategys expend_strategy = ExpendStrategy(strategy_);
std::vector<Dimensions> expend_strategy = ExpendStrategy(strategy_);
Dimensions sub_a_strategy = expend_strategy.at(0);
Dimensions sub_b_strategy = expend_strategy.at(1);
Shape dev_shape;
@ -123,7 +123,7 @@ TensorMap SetExpendTensorMap(const Shape &strategy, const Shape &dev_matrix_shap
TensorMap tensor_map_index;
for (size_t i = 0; i < strategy.size(); ++i) {
if (strategy[i] == dev_matrix_shape[i]) {
tensor_map_index.push_back((int64_t)(LAST_INDEX(strategy.size()) - i));
tensor_map_index.push_back((int32_t)(LAST_INDEX(SizeToUint(strategy.size())) - i));
} else {
tensor_map_index.push_back(-1);
}
@ -159,15 +159,15 @@ void ArithmeticBase::ReComputeBatchSplitFlagList() {
}
Status ArithmeticBase::InferTensorMap() {
Shape tensor_map_index;
Strategys expend_strategy = ExpendStrategy(strategy_);
std::vector<int32_t> tensor_map_index;
std::vector<Dimensions> expend_strategy = ExpendStrategy(strategy_);
Dimensions sub_a_expend_strategy = expend_strategy.at(0);
Dimensions sub_b_expend_strategy = expend_strategy.at(1);
Strategys stra = strategy_->GetInputDim();
Dimensions sub_a_strategy = stra.at(0);
Dimensions sub_b_strategy = stra.at(1);
for (size_t i = 0; i < sub_a_expend_strategy.size(); ++i) {
tensor_map_index.push_back((int64_t)(LAST_INDEX(sub_a_expend_strategy.size()) - i));
tensor_map_index.push_back((int32_t)(LAST_INDEX(SizeToUint(sub_a_expend_strategy.size())) - i));
}
Shape dev_shape;
@ -261,7 +261,7 @@ Status ArithmeticBase::InferTensorInfo() {
// infer slice shape
Shapes inputs_slice_shape, outputs_slice_shape;
Strategys expend_strategy = ExpendStrategy(strategy_);
std::vector<Dimensions> expend_strategy = ExpendStrategy(strategy_);
Dimensions sub_a_expend_strategy = expend_strategy.at(0);
Dimensions sub_b_expend_strategy = expend_strategy.at(1);
Strategys inputs_strategy = strategy_->GetInputDim();

View File

@ -43,13 +43,13 @@ Status BatchParallelInfo::CheckStrategy(const StrategyPtr &strategy) {
dev_num_ = dev_num;
size_t strategy_size = strategy->GetInputNumber();
Strategys stra = strategy->GetInputDim();
std::vector<Dimensions> stra = strategy->GetInputDim();
for (size_t i = 0; i < strategy_size; ++i) {
Shape sub_strategy = stra.at(i);
size_t strategy_len = sub_strategy.size();
bool flag = false;
for (size_t j = 0; j < strategy_len; ++j) {
int64_t strategy_value = sub_strategy.at(j);
int32_t strategy_value = sub_strategy.at(j);
if (strategy_value > 1) {
if (flag || strategy_value != dev_num_) {
if (is_auto_parallel_) {
@ -95,7 +95,7 @@ Status BatchParallelInfo::InferTensorMap() {
return FAILED;
}
for (size_t i = 0; i < inputs_shape_.size(); i++) {
Shape tensor_map_index;
std::vector<int32_t> tensor_map_index;
for (size_t j = 0; j < inputs_shape_[i].size(); ++j) {
if (strategy_->GetInputDim()[i][j] == dev_num_ && j == 0) {
tensor_map_index.push_back(0);
@ -106,7 +106,7 @@ Status BatchParallelInfo::InferTensorMap() {
inputs_tensor_map_.push_back(tensor_map_index);
}
for (size_t i = 0; i < outputs_shape_.size(); i++) {
Shape tensor_map_index;
std::vector<int32_t> tensor_map_index;
for (size_t j = 0; j < outputs_shape_[i].size(); ++j) {
if (i == 0 && j == 0) {
tensor_map_index.push_back(0);
@ -123,7 +123,7 @@ Strategys BatchParallelInfo::GetOutputsStrategy() {
Strategys outputs_strategy;
for (size_t i = 0; i < outputs_shape_.size(); ++i) {
Dimensions strategy;
std::vector<int32_t> strategy;
for (size_t j = 0; j < outputs_shape_[i].size(); ++j) {
if (i == 0 && j == 0) {
strategy.push_back(dev_num_);
@ -201,7 +201,7 @@ Status BatchParallelInfo::GenerateStrategies(int32_t stage_id) {
is_auto_parallel_ = true;
size_t total_dev_num = g_device_manager->GetDeviceListByStageId(stage_id).size();
StrategyPtr sp;
Strategys strategy;
std::vector<Dimensions> strategy;
for (size_t i = 0; i < inputs_shape_.size(); i++) {
Shape temp(inputs_shape_[i].size(), 1);
if (split_flag_list_[i]) {

View File

@ -36,11 +36,11 @@ Status BiasAddInfo::CheckStrategy(const StrategyPtr &strategy) {
}
return FAILED;
}
Strategys stra = strategy->GetInputDim();
std::vector<Dimensions> stra = strategy->GetInputDim();
Dimensions sub_a_strategy = stra.at(0);
Dimensions sub_b_strategy = stra.at(1);
int64_t channel_a_strategy = sub_a_strategy.at(1);
int64_t channel_b_strategy = sub_b_strategy.at(0);
int32_t channel_a_strategy = sub_a_strategy.at(1);
int32_t channel_b_strategy = sub_b_strategy.at(0);
if (channel_a_strategy != channel_b_strategy) {
if (is_auto_parallel_) {
MS_LOG(DEBUG) << name_ << " : Invalid strategy.";
@ -53,7 +53,7 @@ Status BiasAddInfo::CheckStrategy(const StrategyPtr &strategy) {
}
Status BiasAddInfo::InferDevMatrixShape() {
Strategys stra = strategy_->GetInputDim();
std::vector<Dimensions> stra = strategy_->GetInputDim();
Dimensions sub_a_strategy = stra.at(0);
dev_matrix_shape_ = sub_a_strategy;
return SUCCESS;
@ -67,13 +67,13 @@ void BiasAddInfo::ReComputeBatchSplitFlagList() {
Status BiasAddInfo::InferTensorMap() {
TensorMap sub_a_tensor_map;
TensorMap sub_b_tensor_map;
Strategys stra = strategy_->GetInputDim();
std::vector<Dimensions> stra = strategy_->GetInputDim();
Dimensions sub_a_strategy = stra.at(0);
size_t sub_a_strategy_size = sub_a_strategy.size();
for (size_t i = 0; i < sub_a_strategy_size; ++i) {
sub_a_tensor_map.push_back((int32_t)(LAST_INDEX(sub_a_strategy_size) - i));
sub_a_tensor_map.push_back((int32_t)(LAST_INDEX(SizeToUint(sub_a_strategy_size)) - i));
}
sub_b_tensor_map.push_back((int32_t)(LAST_INDEX(sub_a_strategy_size) - 1));
sub_b_tensor_map.push_back((int32_t)(LAST_INDEX(SizeToUint(sub_a_strategy_size)) - 1));
inputs_tensor_map_.push_back(sub_a_tensor_map);
inputs_tensor_map_.push_back(sub_b_tensor_map);
@ -213,7 +213,7 @@ Status BiasAddInfo::GenerateStrategies(int32_t stage_id) {
MS_LOG(INFO) << name_ << " : Generate strategies with broadcast success.";
for (auto &sp : sp_vector) {
Strategys tmp_strategy;
std::vector<Dimensions> tmp_strategy;
Dimensions input0_strategy = sp->GetInputDim()[0];
tmp_strategy.push_back(input0_strategy); // input0

View File

@ -38,7 +38,7 @@ Status DropoutDoMaskInfo::CheckStrategy(const StrategyPtr &strategy) {
return FAILED;
}
Strategys stra = strategy->GetInputDim();
std::vector<Dimensions> stra = strategy->GetInputDim();
if (stra.size() != 1) {
MS_LOG(ERROR) << name_ << ": Invalid strategy size " << stra.size() << ", it must be 1";
return FAILED;
@ -68,7 +68,7 @@ Status DropoutDoMaskInfo::InferDevMatrixShape() {
return FAILED;
}
Strategys strategy = strategy_->GetInputDim();
std::vector<Dimensions> strategy = strategy_->GetInputDim();
if (strategy.empty()) {
MS_LOG(ERROR) << name_ << ": The strategy is empty";
return FAILED;
@ -84,7 +84,7 @@ Status DropoutDoMaskInfo::InferTensorMap() {
return FAILED;
}
Shape tensor_map_index;
std::vector<int32_t> tensor_map_index;
size_t size = inputs_shape_[0].size();
// if the dimension of input is 4, and tensor_map_index is [3, 2, 1, 0]
for (size_t i = 0; i < size; ++i) {
@ -169,13 +169,13 @@ Status DropoutDoMaskInfo::GenerateStrategies(int32_t stage_id) {
return SUCCESS;
}
std::shared_ptr<Strategys> DropoutDoMaskInfo::GenerateBatchStrategies() {
std::shared_ptr<std::vector<std::vector<int32_t>>> DropoutDoMaskInfo::GenerateBatchStrategies() {
CheckGlobalDeviceManager();
size_t dev_num = g_device_manager->GetDeviceListByStageId(0).size();
Dimensions strategy(inputs_shape_[0].size() - 1, 1);
(void)strategy.insert(strategy.begin(), SizeToInt(dev_num));
Strategys strategy_v = {strategy};
return std::make_shared<Strategys>(strategy_v);
std::vector<Dimensions> strategy_v = {strategy};
return std::make_shared<std::vector<std::vector<int32_t>>>(strategy_v);
}
Status DropoutDoMaskInfo::Init(const StrategyPtr &strategy) {

View File

@ -40,7 +40,7 @@ class DropoutDoMaskInfo : public OperatorInfo {
Status GenerateStrategies(int32_t stage_id) override;
Status SetCostUnderStrategy(const StrategyPtr &strategy) override;
Status InitForCostModel(const StrategyPtr &strategy) override;
std::shared_ptr<Strategys> GenerateBatchStrategies() override;
std::shared_ptr<std::vector<std::vector<int32_t>>> GenerateBatchStrategies() override;
std::vector<Operator> GetDropoutGenMaskReplaceOp(const CNodePtr &cnode);
protected:

View File

@ -109,7 +109,7 @@ Status GatherV2Info::CheckStrategy(const StrategyPtr &strategy) {
}
Status GatherV2Info::InferDevMatrixShape() {
Strategys stra = strategy_->GetInputDim();
std::vector<Dimensions> stra = strategy_->GetInputDim();
dev_matrix_shape_ = stra.at(0);
return SUCCESS;
}
@ -129,8 +129,8 @@ Status GatherV2Info::InferTensorMap() {
<< outputs_shape_.size();
return FAILED;
}
Shape tensor_map_in;
Shape tensor_map_out;
std::vector<int32_t> tensor_map_in;
std::vector<int32_t> tensor_map_out;
size_t size = inputs_shape_.at(0).size();
// such as 4: tensor_map_index [3,2,1,0]
for (size_t i = 0; i < size; ++i) {
@ -149,7 +149,7 @@ Status GatherV2Info::InferTensorMap() {
return FAILED;
}
Shape tensor_map_in_index;
std::vector<int32_t> tensor_map_in_index;
if (index_size_ >= 1) {
tensor_map_in_index.push_back(SizeToInt(size - axis_ - 1));
}
@ -323,7 +323,7 @@ Status GatherV2Info::SetCostUnderStrategy(const StrategyPtr &strategy) {
return SUCCESS;
}
std::shared_ptr<Strategys> GatherV2Info::GenerateBatchStrategies() {
std::shared_ptr<std::vector<std::vector<int32_t>>> GatherV2Info::GenerateBatchStrategies() {
if (inputs_shape_.size() != GATHER_V2_INPUTS_SIZE) {
MS_LOG(EXCEPTION) << name_ << ": inputs shape size must be " << GATHER_V2_INPUTS_SIZE << ", but is "
<< inputs_shape_.size();
@ -343,8 +343,8 @@ std::shared_ptr<Strategys> GatherV2Info::GenerateBatchStrategies() {
for (size_t i = 1; i < inputs_shape_[0].size(); i++) {
strategy.push_back(1);
}
Strategys strategy_v = {strategy};
return std::make_shared<Strategys>(strategy_v);
std::vector<Dimensions> strategy_v = {strategy};
return std::make_shared<std::vector<std::vector<int32_t>>>(strategy_v);
}
} // namespace parallel
} // namespace mindspore

View File

@ -50,7 +50,7 @@ class GatherV2Info : public OperatorInfo {
Status GenerateStrategies(int32_t stage_id) override;
Status SetCostUnderStrategy(const StrategyPtr &strategy) override;
std::shared_ptr<Strategys> GenerateBatchStrategies() override;
std::shared_ptr<std::vector<std::vector<int32_t>>> GenerateBatchStrategies() override;
protected:
Status CheckStrategy(const StrategyPtr &strategy) override;

View File

@ -73,8 +73,8 @@ Status GatherV2PInfo::GetAttrs() {
MS_LOG(ERROR) << "Failure: Size of manual_split element must be 2.";
return FAILED;
}
param_split_shapes_.push_back(static_cast<int64_t>(GetValue<int>(value_vector[0])));
index_offsets_.push_back(static_cast<int64_t>(GetValue<int>(value_vector[1])));
param_split_shapes_.push_back(static_cast<int32_t>(GetValue<int>(value_vector[0])));
index_offsets_.push_back(static_cast<int32_t>(GetValue<int>(value_vector[1])));
} else {
MS_LOG(ERROR) << "Failure: Manual split strategy's format is wrong! Need ValueSequeue";
return FAILED;
@ -93,14 +93,14 @@ Status GatherV2PInfo::GetAttrs() {
Status GatherV2PInfo::CheckManualSplit() {
auto param_shape = inputs_shape_.at(0);
int64_t split_shape_sum = std::accumulate(param_split_shapes_.begin(), param_split_shapes_.end(), 0,
[](int64_t s, int64_t shape) { return s + shape; });
int32_t split_shape_sum = std::accumulate(param_split_shapes_.begin(), param_split_shapes_.end(), 0,
[](int32_t s, int32_t shape) { return s + shape; });
if (split_shape_sum < param_shape.at(0)) {
MS_LOG(ERROR) << "Failure: Sum of splited shapes should not be smaller than param_shape.";
return FAILED;
}
if (std::any_of(index_offsets_.begin(), index_offsets_.end(), [](const int64_t &offset) { return offset < 0; })) {
if (std::any_of(index_offsets_.begin(), index_offsets_.end(), [](const int32_t &offset) { return offset < 0; })) {
MS_LOG(ERROR) << "Failure: Index offset must not less than 0.";
return FAILED;
}
@ -269,8 +269,8 @@ Status GatherV2PInfo::InferTensorMap() {
size_t param_size = inputs_shape_.at(0).size();
size_t index_size = inputs_shape_.at(1).size();
size_t total_size = param_size + index_size;
Shape tensor_map_index;
Shape tensor_map_params;
std::vector<int32_t> tensor_map_index;
std::vector<int32_t> tensor_map_params;
auto param_strategy = strategy_->GetInputDim().at(0);
if (param_strategy.at(IntToSize(axis_)) != 1) {
tensor_map_index.insert(tensor_map_index.begin(), index_size, -1);
@ -288,7 +288,7 @@ Status GatherV2PInfo::InferTensorMap() {
}
// infer output tensor map
Shape tensor_map_out;
std::vector<int32_t> tensor_map_out;
if (param_strategy.at(IntToSize(axis_)) == 1) {
// param_strategy(axis) == 1
for (size_t i = 0; i < param_size; ++i) {
@ -427,8 +427,8 @@ Status GatherV2PInfo::InferGroup() {
return SUCCESS;
}
RankList GetRankFromGroup(const Group &group) {
RankList rank_list;
std::vector<int32_t> GetRankFromGroup(const Group &group) {
std::vector<int32_t> rank_list;
auto device_list = group.GetDevicesList();
for (auto &device : device_list) {
rank_list.insert(rank_list.end(), device.rank() % 8);
@ -634,7 +634,7 @@ Status GatherV2PInfo::GenerateStrategies(int32_t stage_id) {
return SUCCESS;
}
std::shared_ptr<Strategys> GatherV2PInfo::GenerateBatchStrategies() {
std::shared_ptr<std::vector<std::vector<int32_t>>> GatherV2PInfo::GenerateBatchStrategies() {
CheckGlobalDeviceManager();
size_t dev_num = g_device_manager->GetDeviceListByStageId(0).size();
Dimensions param_strategy(inputs_shape_[0].size(), 1);
@ -643,8 +643,8 @@ std::shared_ptr<Strategys> GatherV2PInfo::GenerateBatchStrategies() {
for (size_t i = 1; i < inputs_shape_[1].size(); i++) {
index_strategy.push_back(1);
}
Strategys strategy_v = {param_strategy, index_strategy};
return std::make_shared<Strategys>(strategy_v);
std::vector<Dimensions> strategy_v = {param_strategy, index_strategy};
return std::make_shared<std::vector<std::vector<int32_t>>>(strategy_v);
}
} // namespace parallel
} // namespace mindspore

View File

@ -45,7 +45,7 @@ class GatherV2PInfo : public OperatorInfo {
Status GenerateStrategies(int32_t stage_id) override;
Status SetCostUnderStrategy(const StrategyPtr &strategy) override;
ReplaceGraphPtr replace_graph(const CNodePtr &cnode) override;
std::shared_ptr<Strategys> GenerateBatchStrategies() override;
std::shared_ptr<std::vector<std::vector<int32_t>>> GenerateBatchStrategies() override;
protected:
Status CheckStrategy(const StrategyPtr &strategy) override;
@ -67,13 +67,13 @@ class GatherV2PInfo : public OperatorInfo {
std::string target_ = DEVICE;
std::string replace_op_name_ = GATHERV2;
int32_t bias_;
int64_t index_offset_;
int32_t index_offset_;
int32_t slice_size_;
Shape out_dev_matrix_shape_;
Group group_;
bool manual_split_ = false;
std::vector<int64_t> param_split_shapes_;
std::vector<int64_t> index_offsets_;
std::vector<int32_t> param_split_shapes_;
std::vector<int32_t> index_offsets_;
};
class SparseGatherV2Info : public GatherV2PInfo {

View File

@ -118,7 +118,7 @@ Status GetNextInfo::Init(const StrategyPtr &strategy) {
}
Status GetNextInfo::CheckStrategy(const StrategyPtr &strategy) {
Strategys stras = strategy->GetInputDim();
std::vector<Dimensions> stras = strategy->GetInputDim();
for (Dimensions stra : stras) {
if (stra.size() != 0) {
if (is_auto_parallel_) {
@ -254,7 +254,7 @@ Status GetNextInfo::SetCostUnderStrategy(const StrategyPtr &strategy) {
Status GetNextInfo::GenerateStrategies(int32_t stage_id) {
is_auto_parallel_ = true;
Strategys stra;
std::vector<Dimensions> stra;
StrategyPtr sp = std::make_shared<Strategy>(stage_id, stra);
if (SetCostUnderStrategy(sp) == SUCCESS) {
MS_LOG(INFO) << name_ << " : Successfully generated strategy.";

View File

@ -37,7 +37,7 @@ Status L2NormalizeInfo::CheckStrategy(const StrategyPtr &strategy) {
return FAILED;
}
Strategys stra = strategy->GetInputDim();
std::vector<Dimensions> stra = strategy->GetInputDim();
Dimensions input_strategy = stra.at(0);
int32_t axis_index = axis_;
if (axis_ < 0) {

View File

@ -49,7 +49,7 @@ Status LayerNormInfo::GetAttrs() {
Status LayerNormInfo::CheckStrategy(const StrategyPtr &strategy) {
MS_EXCEPTION_IF_NULL(strategy);
Strategys stra = strategy->GetInputDim();
std::vector<Dimensions> stra = strategy->GetInputDim();
if (stra.size() != LAYER_NORM_INPUT_SIZE) {
MS_LOG(ERROR) << name_ << ": Invalid strategy size " << stra.size();
return FAILED;
@ -104,7 +104,7 @@ Status LayerNormInfo::InferDevMatrixShape() {
MS_LOG(ERROR) << name_ << ": The strategy is null";
return FAILED;
}
Strategys stra = strategy_->GetInputDim();
std::vector<Dimensions> stra = strategy_->GetInputDim();
if (stra.empty()) {
MS_LOG(ERROR) << name_ << ": The strategy is empty";
return FAILED;
@ -228,7 +228,7 @@ Status LayerNormInfo::GenerateGammaAndBetaStrategies(const std::vector<StrategyP
MS_LOG(ERROR) << name_ << ": Invalid strategy";
return FAILED;
}
Strategys tmp_strategy;
std::vector<Dimensions> tmp_strategy;
Dimensions input_strategy = sp->GetInputDim()[0];
Dimensions gamma_strategy = input_strategy;
(void)gamma_strategy.erase(gamma_strategy.begin(),

View File

@ -38,7 +38,7 @@ Status SoftmaxCrossEntropyWithLogitsInfo::CheckStrategy(const mindspore::paralle
return FAILED;
}
Strategys stra = strategy->GetInputDim();
std::vector<Dimensions> stra = strategy->GetInputDim();
Dimensions input_strategy = stra.at(0);
Dimensions label_strategy = stra.at(1);
if (input_strategy != label_strategy) {
@ -52,8 +52,8 @@ Status SoftmaxCrossEntropyWithLogitsInfo::CheckStrategy(const mindspore::paralle
axis_index = static_cast<int32_t>(input_dim) + axis_;
}
int64_t input_axis_strategy = input_strategy.at(IntToSize(axis_index));
int64_t label_axis_strategy = label_strategy.at(IntToSize(axis_index));
int32_t input_axis_strategy = input_strategy.at(IntToSize(axis_index));
int32_t label_axis_strategy = label_strategy.at(IntToSize(axis_index));
// Dimension corresponding to axis is un-splittable
if ((input_axis_strategy != MIN_SLICE_NUM) && (label_axis_strategy != MIN_SLICE_NUM)) {
if (is_auto_parallel_) {
@ -82,21 +82,21 @@ Status SoftmaxCrossEntropyWithLogitsInfo::GetAttrs() {
}
Status SoftmaxCrossEntropyWithLogitsInfo::InferDevMatrixShape() {
Strategys stra = strategy_->GetInputDim();
std::vector<Dimensions> stra = strategy_->GetInputDim();
Dimensions input_strategy = stra.at(0);
dev_matrix_shape_ = input_strategy;
return SUCCESS;
}
Status SoftmaxCrossEntropyWithLogitsInfo::InferTensorMap() {
Shape tensor_map_index;
std::vector<int32_t> tensor_map_index;
size_t size = inputs_shape_[0].size();
// such as 4: tensor_map_index [3,2,1,0]
for (size_t i = 0; i < size; ++i) {
tensor_map_index.push_back((int64_t)(size - i - 1));
tensor_map_index.push_back((int32_t)(size - i - 1));
}
Shape first_output_tensor_map = {tensor_map_index[0]};
std::vector<int32_t> first_output_tensor_map = {tensor_map_index[0]};
inputs_tensor_map_.push_back(tensor_map_index); // input
inputs_tensor_map_.push_back(tensor_map_index); // label
outputs_tensor_map_.push_back(first_output_tensor_map); // output-0

View File

@ -158,7 +158,7 @@ Status MatMul::CheckStrategy(const StrategyPtr &strategy) {
return FAILED;
}
Strategys stra = strategy->GetInputDim();
std::vector<Dimensions> stra = strategy->GetInputDim();
Dimensions mat_a_strategy = stra.at(0);
Dimensions mat_b_strategy = stra.at(1);
@ -207,7 +207,7 @@ Status MatMul::CheckStrategy(const StrategyPtr &strategy) {
}
Status MatMulBase::InferDevMatrixShape() {
Strategys stra = strategy_->GetInputDim();
std::vector<Dimensions> stra = strategy_->GetInputDim();
Dimensions mat_a_strategy = stra.at(0);
Dimensions mat_b_strategy = stra.at(1);
@ -279,10 +279,10 @@ Status MatMulBase::InferTensorMap() {
size = dev_matrix_shape_.size() - 1;
}
Shape tensor_map_index;
std::vector<int32_t> tensor_map_index;
// such as 5: tensor_map_index [4,3,2,1,0]
for (size_t i = 0; i < size; ++i) {
tensor_map_index.push_back((int64_t)(LAST_INDEX(size) - i));
tensor_map_index.push_back((int32_t)(LAST_INDEX(size) - i));
}
// infer output tensor map: [4,3,2,0], delete the second-from-end element
@ -309,7 +309,7 @@ Status MatMulBase::InferTensorMap() {
mat_b_tensor_map.begin() + static_cast<different_type>(LAST_INDEX(size) - mat_b_dimension_));
if (transpose_b_) {
// swap the last two elements
int64_t last_value = mat_b_tensor_map.back();
int32_t last_value = mat_b_tensor_map.back();
mat_b_tensor_map.pop_back();
(void)mat_b_tensor_map.insert(
mat_b_tensor_map.begin() + static_cast<different_type>(LAST_INDEX(mat_b_tensor_map.size())), last_value);
@ -436,7 +436,7 @@ Status MatMulBase::GenerateStrategies(int32_t stage_id) {
return FAILED;
}
CheckGlobalDeviceManager();
RankList dev_list = g_device_manager->GetDeviceListByStageId(stage_id);
std::vector<int32_t> dev_list = g_device_manager->GetDeviceListByStageId(stage_id);
size_t dev_num = dev_list.size();
Shape input0_shape = inputs_shape_[0], input1_shape = inputs_shape_[1];
if (transpose_a_) {
@ -503,14 +503,13 @@ Status MatMulBase::GenerateStrategies(int32_t stage_id) {
Status MatMulBase::PrepareStrategy(int32_t stage_id, size_t dev_num,
mindspore::parallel::Dimensions combined_partitions, size_t input0_shape_size,
size_t input1_shape_size, mindspore::parallel::StrategyPtr *const sp) {
int64_t product =
std::accumulate(combined_partitions.begin(), combined_partitions.end(), 1, std::multiplies<int64_t>());
int32_t product = std::accumulate(combined_partitions.begin(), combined_partitions.end(), 1, std::multiplies<int>());
if (!FULLY_USE_DEVICES) {
if (LongToSize(product) > dev_num) {
if (IntToSize(product) > dev_num) {
return FAILED;
}
} else {
if (LongToSize(product) != dev_num) {
if (IntToSize(product) != dev_num) {
return FAILED;
}
}
@ -551,7 +550,7 @@ Status MatMulBase::PrepareStrategy(int32_t stage_id, size_t dev_num,
MS_LOG(ERROR) << name_ << " : Swap last two elements failed.";
}
}
Strategys stras;
std::vector<Dimensions> stras;
stras.push_back(input0_partitions);
stras.push_back(input1_partitions);
(*sp) = std::make_shared<Strategy>(stage_id, stras);

View File

@ -77,7 +77,7 @@ Status OneHotInfo::CheckStrategy(const StrategyPtr &strategy) {
}
Status OneHotInfo::InferDevMatrixShape() {
Strategys stra = strategy_->GetInputDim();
std::vector<Dimensions> stra = strategy_->GetInputDim();
Dimensions input_strategy = stra.at(0);
// Now input only support 1-D tensor, so the output is a 2-D tensor
@ -96,16 +96,16 @@ Status OneHotInfo::InferDevMatrixShape() {
}
Status OneHotInfo::InferTensorMap() {
Shape input_tensor_map_index, output_tensor_map_index;
std::vector<int32_t> input_tensor_map_index, output_tensor_map_index;
size_t size = outputs_shape_[0].size();
// such as 2: tensor_map_index [1,0]
if (axis_ == 0) {
for (size_t i = 0; i < size; ++i) {
output_tensor_map_index.push_back((int64_t)(i));
output_tensor_map_index.push_back((int32_t)(i));
}
} else {
for (size_t i = 0; i < size; ++i) {
output_tensor_map_index.push_back((int64_t)(LAST_INDEX(size) - i));
output_tensor_map_index.push_back((int32_t)(LAST_INDEX(size) - i));
}
}
outputs_tensor_map_.push_back(output_tensor_map_index);
@ -299,13 +299,13 @@ Status OneHotInfo::SetCostUnderStrategy(const StrategyPtr &strategy) {
return SUCCESS;
}
std::shared_ptr<Strategys> OneHotInfo::GenerateBatchStrategies() {
std::shared_ptr<std::vector<std::vector<int32_t>>> OneHotInfo::GenerateBatchStrategies() {
CheckGlobalDeviceManager();
size_t dev_num = g_device_manager->GetDeviceListByStageId(0).size();
Dimensions strategy = {SizeToInt(dev_num), 1};
Dimensions empty_strategy;
Strategys strategy_v = {strategy, empty_strategy, empty_strategy};
return std::make_shared<Strategys>(strategy_v);
std::vector<Dimensions> strategy_v = {strategy, empty_strategy, empty_strategy};
return std::make_shared<std::vector<std::vector<int32_t>>>(strategy_v);
}
} // namespace parallel
} // namespace mindspore

View File

@ -41,7 +41,7 @@ class OneHotInfo : public OperatorInfo {
Status GenerateStrategies(int32_t stage_id) override;
Status SetCostUnderStrategy(const StrategyPtr &strategy) override;
ReplaceGraphPtr replace_graph(const CNodePtr &cnode) override;
std::shared_ptr<Strategys> GenerateBatchStrategies() override;
std::shared_ptr<std::vector<std::vector<int32_t>>> GenerateBatchStrategies() override;
protected:
Status CheckStrategy(const StrategyPtr &strategy) override;

View File

@ -52,7 +52,7 @@ Status CheckStrategyValue(const StrategyPtr &strategy, const Shapes &inputs_shap
return FAILED;
}
Strategys stra = strategy->GetInputDim();
std::vector<Dimensions> stra = strategy->GetInputDim();
for (size_t i = 0; i < strategy_size; ++i) {
Shape sub_strategy = stra.at(i);
Shape sub_input_shape = inputs_shape.at(i);
@ -70,7 +70,7 @@ Status CheckStrategyValue(const StrategyPtr &strategy, const Shapes &inputs_shap
}
for (size_t j = 0; j < strategy_len; ++j) {
int64_t strategy_value = sub_strategy.at(j);
int32_t strategy_value = sub_strategy.at(j);
if (strategy_value < MIN_SLICE_NUM) {
if (is_auto_parallel) {
MS_LOG(DEBUG) << "Invalid strategy value: " << strategy_value;
@ -89,7 +89,7 @@ Status CheckStrategyValue(const StrategyPtr &strategy, const Shapes &inputs_shap
return FAILED;
}
int64_t shape_value = sub_input_shape.at(j);
int32_t shape_value = sub_input_shape.at(j);
if ((shape_value % strategy_value) != 0) {
if (is_auto_parallel) {
MS_LOG(DEBUG) << "Shape " << shape_value << " cannot be divisible by strategy " << strategy_value;
@ -138,9 +138,9 @@ void OperatorInfo::SetDeviceListByStrategy() {
}
Status OperatorInfo::InferRepeatedCalcInfo() {
int64_t g_dev_list_size = SizeToLong(global_device_list_.size());
int64_t dev_matrix_size =
std::accumulate(dev_matrix_shape_.begin(), dev_matrix_shape_.end(), 1, std::multiplies<int64_t>());
int32_t g_dev_list_size = SizeToInt(global_device_list_.size());
int32_t dev_matrix_size =
std::accumulate(dev_matrix_shape_.begin(), dev_matrix_shape_.end(), 1, std::multiplies<int>());
if (dev_matrix_size == 0) {
MS_LOG(ERROR) << name_ << ": The dev matrix size is 0";
return FAILED;
@ -149,7 +149,7 @@ Status OperatorInfo::InferRepeatedCalcInfo() {
if (g_dev_list_size == dev_matrix_size) {
repeated_calc_num_ = 1;
} else if (g_dev_list_size % dev_matrix_size == 0) {
repeated_calc_num_ = ((int32_t)(g_dev_list_size / dev_matrix_size));
repeated_calc_num_ = g_dev_list_size / dev_matrix_size;
} else {
MS_LOG(ERROR) << name_ << ": Dev list size " << g_dev_list_size << " can not be divisible by dev matrix size "
<< dev_matrix_size;
@ -326,7 +326,7 @@ Status OperatorInfo::CreateGroupByDim(size_t axis, std::vector<Group> *group) {
Shape GetSliceShape(const Shape &tensor_shape, const Dimensions &strategy) {
Shape slice_shape;
if (std::any_of(strategy.begin(), strategy.end(), [](int64_t value) { return value <= 0; })) {
if (std::any_of(strategy.begin(), strategy.end(), [](int32_t value) { return value <= 0; })) {
MS_LOG(ERROR) << "Invalid strategy: " << ShapeToString(strategy) << ", the element is less than or equal to 0";
return slice_shape;
}
@ -430,8 +430,7 @@ Status OperatorInfo::InitForCostModelWithAutoRepeatCalc(const StrategyPtr &strat
return FAILED;
}
used_devices_ =
((int32_t)(std::accumulate(dev_matrix_shape_.begin(), dev_matrix_shape_.end(), 1, std::multiplies<int64_t>())));
used_devices_ = std::accumulate(dev_matrix_shape_.begin(), dev_matrix_shape_.end(), 1, std::multiplies<int32_t>());
// must be after InferDevMatrixShape
if (InferRepeatedCalcInfo() != SUCCESS) {
@ -647,8 +646,8 @@ void OperatorInfo::ReplaceSuccEdges(const std::shared_ptr<OperatorInfo> &op, con
succ_edges_ = new_succ_edges;
}
std::shared_ptr<Strategys> GenerateBatchStrategiesBySplitFlag(const Shapes &shapes,
const std::vector<bool> &split_flag_list) {
std::shared_ptr<std::vector<std::vector<int32_t>>> GenerateBatchStrategiesBySplitFlag(
const Shapes &shapes, const std::vector<bool> &split_flag_list) {
if (shapes.size() != split_flag_list.size()) {
MS_LOG(ERROR) << "Split_flag_list do not have the same size as inputs shape, " << split_flag_list.size() << " : "
<< shapes.size();
@ -656,21 +655,21 @@ std::shared_ptr<Strategys> GenerateBatchStrategiesBySplitFlag(const Shapes &shap
}
CheckGlobalDeviceManager();
int32_t dev_num = SizeToInt(g_device_manager->GetDeviceListByStageId(0).size());
Strategys strategy_v;
std::vector<std::vector<int32_t>> strategy_v;
for (size_t i = 0; i != shapes.size(); i++) {
if (shapes[i].empty()) {
MS_LOG(INFO) << "Elements of shapes is empty.";
Dimensions empty_element;
std::vector<int32_t> empty_element;
strategy_v.push_back(empty_element);
} else {
Dimensions element(shapes[i].size(), 1);
std::vector<int32_t> element(shapes[i].size(), 1);
if (split_flag_list[i]) {
element[0] = dev_num;
}
strategy_v.push_back(element);
}
}
return std::make_shared<Strategys>(strategy_v);
return std::make_shared<std::vector<std::vector<int32_t>>>(strategy_v);
}
void OperatorInfo::ReComputeBatchSplitFlagList() {
@ -693,26 +692,26 @@ Status PrepareStrategyBase(int32_t stage_id, size_t dev_num, const Shapes &input
MS_LOG(ERROR) << "The strategy is null.";
return FAILED;
}
int64_t product = 1;
int32_t product = 1;
for (auto &input_partition : inputs_partitions) {
product *= std::accumulate(input_partition.begin(), input_partition.end(), 1, std::multiplies<int64_t>());
product *= std::accumulate(input_partition.begin(), input_partition.end(), 1, std::multiplies<int>());
}
if (!FULLY_USE_DEVICES) {
if (LongToSize(product) > dev_num) {
if (IntToSize(product) > dev_num) {
return FAILED;
}
} else {
if ((product != 1) && (LongToSize(product) != dev_num)) {
if ((product != 1) && (IntToSize(product) != dev_num)) {
return FAILED;
}
}
Strategys stras(inputs_partitions);
std::vector<Dimensions> stras(inputs_partitions);
(*sp) = std::make_shared<Strategy>(stage_id, stras);
return SUCCESS;
}
std::shared_ptr<Strategys> OperatorInfo::GenerateBatchStrategies() {
std::shared_ptr<std::vector<std::vector<int32_t>>> OperatorInfo::GenerateBatchStrategies() {
ComputeBatchSplitFlagList();
return GenerateBatchStrategiesBySplitFlag(inputs_shape_, split_flag_list_);
}
@ -794,7 +793,7 @@ Status GenerateStrategiesForBroadcastLeft(int32_t stage_id, const Shapes &inputs
// second, get the correct strategy for input0
for (auto &sp : *sp_vector) {
Strategys tmp_strategy;
std::vector<Dimensions> tmp_strategy;
Dimensions input0_strategy = sp->GetInputDim()[0];
size_t size_diff = inputs_shape[1].size() - inputs_shape[0].size();
@ -843,7 +842,7 @@ Status GenerateStrategiesForBroadcastRight(int32_t stage_id, const Shapes &input
// second, get the correct strategy for input1
for (auto &sp : *sp_vector) {
Strategys tmp_strategy;
std::vector<Dimensions> tmp_strategy;
tmp_strategy.push_back(sp->GetInputDim()[0]); // input0
Dimensions input1_strategy = sp->GetInputDim()[1];
@ -1176,7 +1175,7 @@ int32_t ComputeRepeatDeviceNumByTensorMap(const Shape &dev_matrix_shape, const S
// The number of repetitions is equal to the number of all devices divided by the number of devices use for
// tensor map.
int64_t device_num = std::accumulate(dev_matrix_shape.begin(), dev_matrix_shape.end(), 1, std::multiplies<int64_t>());
int32_t device_num = std::accumulate(dev_matrix_shape.begin(), dev_matrix_shape.end(), 1, std::multiplies<int>());
for (auto &element : tensor_map) {
// -1 means the corresponding dimension is not split.
if (element == MAP_NONE) {
@ -1195,7 +1194,7 @@ int32_t ComputeRepeatDeviceNumByTensorMap(const Shape &dev_matrix_shape, const S
}
}
return (int32_t)device_num;
return device_num;
}
Status OperatorInfo::InferAsLossDivisor() {

View File

@ -43,10 +43,11 @@ using ForwardOp = OperatorVector;
using MirrorOps = std::vector<OperatorVector>;
using Ops = std::vector<OperatorVector>;
using VirtualDivOp = OperatorVector;
using TensorMaps = std::vector<Shape>;
using TensorMaps = std::vector<std::vector<int32_t>>;
using TensorLayouts = std::vector<TensorLayout>;
using different_type = std::vector<int32_t>::difference_type;
using PrimitiveAttrs = std::unordered_map<std::string, ValuePtr>;
using Strategys = std::vector<Dimensions>;
using ReplaceGraphPtr = std::shared_ptr<std::pair<std::vector<std::pair<AnfNodePtr, int>>, AnfNodePtr>>;
class Edge;
@ -87,7 +88,7 @@ class OperatorInfo {
void set_cost(const OperatorCostPtr &cost) { operator_cost_ = cost; }
virtual Status SetCostUnderStrategy(const StrategyPtr &strategy) = 0;
virtual std::shared_ptr<Strategys> GenerateBatchStrategies();
virtual std::shared_ptr<std::vector<std::vector<int32_t>>> GenerateBatchStrategies();
virtual void ReComputeBatchSplitFlagList();
void ComputeBatchSplitFlagList();
@ -270,8 +271,8 @@ Operator CreateReduceScatterOp(const std::string &reduce_op, const std::string &
Operator CreateGetTensorSliceOp(const TensorLayout &tensor_layout);
OperatorVector CreateMirrorOps(const std::string &group_name, size_t dev_num);
int32_t ComputeRepeatDeviceNumByTensorMap(const Shape &dev_matrix_shape, const Shape &tensor_map);
std::shared_ptr<Strategys> GenerateBatchStrategiesBySplitFlag(const Shapes &shapes,
const std::vector<bool> &split_flag_list);
std::shared_ptr<std::vector<std::vector<int32_t>>> GenerateBatchStrategiesBySplitFlag(
const Shapes &shapes, const std::vector<bool> &split_flag_list);
void PrintStrategy(const StrategyPtr &strategy);
// generate strategies for that all inputs' dimensions are independent, such as: ([a, b, c, d])

View File

@ -43,7 +43,7 @@ Status PReLUInfo::CheckStrategy(const StrategyPtr &strategy) {
}
return FAILED;
}
Strategys stra = strategy->GetInputDim();
std::vector<Dimensions> stra = strategy->GetInputDim();
if (stra[1].size() != PRELU_SECOND_INPUT_SIZE) {
if (is_auto_parallel_) {
MS_LOG(DEBUG) << name_ << ": Invalid strategy size.";
@ -67,7 +67,7 @@ Status PReLUInfo::CheckStrategy(const StrategyPtr &strategy) {
* device matrix is same with the strategy matrix
*/
Status PReLUInfo::InferDevMatrixShape() {
Strategys stra = strategy_->GetInputDim();
std::vector<Dimensions> stra = strategy_->GetInputDim();
Dimensions input_strategy = stra.at(0);
input_strategy_ = input_strategy;
dev_matrix_shape_ = input_strategy;
@ -103,7 +103,7 @@ Status PReLUInfo::InferTensorMap() {
TensorMap input_tensor_map;
// such as 4: input_tensor_map [3,2,1,0]
for (size_t i = 0; i < inputs_shape_[0].size(); ++i) {
input_tensor_map.push_back((int64_t)(inputs_shape_[0].size() - i - 1));
input_tensor_map.push_back((int32_t)(inputs_shape_[0].size() - i - 1));
}
TensorMap param_tensor_map;

View File

@ -43,7 +43,7 @@ Status ReduceMethod::CheckStrategy(const StrategyPtr &strategy) {
}
Status ReduceMethod::InferDevMatrixShape() {
Strategys stra = strategy_->GetInputDim();
std::vector<Dimensions> stra = strategy_->GetInputDim();
Dimensions input_strategy = stra.at(0);
dev_matrix_shape_ = input_strategy;
@ -119,12 +119,11 @@ Status ReduceMethod::GetAttrs() {
}
Status ReduceMethod::InferTensorMap() {
Shape tensor_map_index, output_tensor_map;
std::vector<int32_t> dim_list;
std::vector<int32_t> tensor_map_index, dim_list, output_tensor_map;
size_t size = inputs_shape_.at(0).size();
// such as 4: tensor_map_index [3,2,1,0]
for (size_t i = 0; i < size; ++i) {
tensor_map_index.push_back((int64_t)(size - 1 - i));
tensor_map_index.push_back((int32_t)(size - 1 - i));
}
dim_list = reduce_dim();
for (size_t i = 0; i < size; ++i) {
@ -463,7 +462,7 @@ Status ArgMaxWithValueInfo::CheckStrategy(const StrategyPtr &strategy) {
std::vector<int32_t> dim_list = reduce_dim();
MS_ASSERT(dim_list.size() == 1);
Strategys stra = strategy->GetInputDim();
std::vector<Dimensions> stra = strategy->GetInputDim();
MS_ASSERT(stra.size() == 1);
Shape input_strategy = stra.at(0);
MS_ASSERT(dim_list.at(0) < input_strategy.size());

View File

@ -57,7 +57,7 @@ Status ReshapeInfo::CheckStrategy(const StrategyPtr &strategy) {
* only support batch parallel reshape operator in ReID (batch parallel degree can be smaller than device number)
*/
Status ReshapeInfo::InferDevMatrixShape() {
Strategys stra = strategy_->GetInputDim();
std::vector<Dimensions> stra = strategy_->GetInputDim();
input_strategy_ = stra.at(0);
dev_matrix_shape_.push_back(input_strategy_[0]);
return SUCCESS;
@ -181,7 +181,7 @@ Status ReshapeInfo::InferTensorMap() {
return FAILED;
}
Shape tensor_map_index_input;
std::vector<int32_t> tensor_map_index_input;
tensor_map_index_input.push_back(0);
for (size_t j = 1; j < inputs_shape_[0].size(); ++j) {
@ -189,7 +189,7 @@ Status ReshapeInfo::InferTensorMap() {
}
inputs_tensor_map_.push_back(tensor_map_index_input);
Shape tensor_map_index_output;
std::vector<int32_t> tensor_map_index_output;
tensor_map_index_output.push_back(0);
for (size_t j = 1; j < outputs_shape_[0].size(); ++j) {
@ -205,7 +205,7 @@ Status ReshapeInfo::InferTensorMap() {
*/
Strategys ReshapeInfo::GetOutputsStrategy() {
Strategys outputs_strategy;
Dimensions strategy;
std::vector<int32_t> strategy;
strategy.push_back(input_strategy_[0]);
for (size_t j = 1; j < outputs_shape_[0].size(); ++j) {
strategy.push_back(1);
@ -325,7 +325,7 @@ void ReshapeInfo::device_number(const StrategyPtr &strategy) {
}
Status ReshapeInfo::InferDefaultLayout(const Shape &shape, TensorLayout *const layout) {
Shape tensor_map_index;
std::vector<int32_t> tensor_map_index;
for (size_t i = 0; i < shape.size(); i++) {
tensor_map_index.push_back(MAP_NONE);
}
@ -504,7 +504,7 @@ Status ReshapeInfo::GenetateStrategyCosts(const std::vector<std::shared_ptr<Stra
MS_LOG(ERROR) << "Infer strategy by tensor_info failed";
return FAILED;
}
Strategys stra_inputs = {stra};
std::vector<Dimensions> stra_inputs = {stra};
StrategyPtr reshape_stra = std::make_shared<Strategy>(pre_stra_cost->strategy_ptr->GetInputStage(), stra_inputs);
if (next_stra_costs.empty()) {
if (Init(nullptr) == FAILED) {

View File

@ -227,7 +227,7 @@ Status StridedSliceInfo::InferTensorInfo() {
}
// Note: if the batch dimension is not fully fetched, the batch strategy may not work.
std::shared_ptr<Strategys> StridedSliceInfo::GenerateBatchStrategies() {
std::shared_ptr<std::vector<std::vector<int32_t>>> StridedSliceInfo::GenerateBatchStrategies() {
split_flag_list_ = {true};
return GenerateBatchStrategiesBySplitFlag(inputs_shape_, split_flag_list_);
}

View File

@ -41,7 +41,7 @@ class StridedSliceInfo : public OperatorInfo {
Status InitForCostModel(const StrategyPtr &strategy) override;
Status GenerateStrategies(int32_t) override;
Status SetCostUnderStrategy(const StrategyPtr &) override;
std::shared_ptr<Strategys> GenerateBatchStrategies() override;
std::shared_ptr<std::vector<std::vector<int32_t>>> GenerateBatchStrategies() override;
protected:
Status GetAttrs() override;

View File

@ -54,7 +54,7 @@ Status TileInfo::GetAttrs() {
for (auto &element : elements) {
MS_EXCEPTION_IF_NULL(element);
if (element->isa<Int32Imm>()) {
int64_t axis = static_cast<int64_t>(element->cast<Int32ImmPtr>()->value());
int32_t axis = element->cast<Int32ImmPtr>()->value();
full_multiples_.push_back(axis);
} else {
MS_LOG(ERROR) << name_ << ": The value of axis must be int32.";
@ -180,15 +180,12 @@ void TileInfo::UpdateMultiples(const CNodePtr &cnode) {
auto manager = func_graph->manager();
MS_EXCEPTION_IF_NULL(manager);
std::vector<int32_t> slice_multiples_int;
(void)std::transform(slice_multiples_.begin(), slice_multiples_.end(), std::back_inserter(slice_multiples_int),
[](const int64_t &value) { return static_cast<int32_t>(value); });
ValuePtr new_multiples = MakeValue(slice_multiples_int);
ValuePtr new_multiples = MakeValue(slice_multiples_);
AnfNodePtr val = NewValueNode(new_multiples);
(void)manager->Replace(cnode->input(2), val);
}
std::shared_ptr<Strategys> TileInfo::GenerateBatchStrategies() {
std::shared_ptr<std::vector<std::vector<int32_t>>> TileInfo::GenerateBatchStrategies() {
if (InferAttrs() != SUCCESS) {
MS_LOG(EXCEPTION) << name_ << ": Infer attrs failed";
}

View File

@ -41,7 +41,7 @@ class TileInfo : public OperatorInfo {
Status InitForCostModel(const StrategyPtr &strategy) override;
Status GenerateStrategies(int32_t) override;
Status SetCostUnderStrategy(const StrategyPtr &) override;
std::shared_ptr<Strategys> GenerateBatchStrategies() override;
std::shared_ptr<std::vector<std::vector<int32_t>>> GenerateBatchStrategies() override;
void UpdateMultiples(const CNodePtr &cnode);
protected:
@ -54,8 +54,8 @@ class TileInfo : public OperatorInfo {
Status InferTensorMap() override;
private:
std::vector<int64_t> full_multiples_;
std::vector<int64_t> slice_multiples_;
std::vector<int32_t> full_multiples_;
std::vector<int32_t> slice_multiples_;
};
using TileInfoPtr = std::shared_ptr<TileInfo>;

View File

@ -37,18 +37,18 @@ Status TmpIdentityInfo::CheckStrategy(const mindspore::parallel::StrategyPtr &st
}
Status TmpIdentityInfo::InferDevMatrixShape() {
Strategys stra = strategy_->GetInputDim();
std::vector<Dimensions> stra = strategy_->GetInputDim();
Dimensions input_strategy = stra.at(0);
dev_matrix_shape_ = input_strategy;
return SUCCESS;
}
Status TmpIdentityInfo::InferTensorMap() {
Shape tensor_map_index;
std::vector<int32_t> tensor_map_index;
size_t size = inputs_shape_[0].size();
// such as 4: tensor_map_index [3,2,1,0]
for (size_t i = 0; i < size; ++i) {
tensor_map_index.push_back((int64_t)(size - 1 - i));
tensor_map_index.push_back((int32_t)(size - 1 - i));
}
inputs_tensor_map_.push_back(tensor_map_index);

View File

@ -41,7 +41,7 @@ Status TransposeInfo::CheckStrategy(const StrategyPtr &strategy) {
}
Status TransposeInfo::InferDevMatrixShape() {
Strategys stra = strategy_->GetInputDim();
std::vector<Dimensions> stra = strategy_->GetInputDim();
input_strategy_ = stra.at(0);
for (auto &iter : input_strategy_) {
dev_matrix_shape_.push_back(iter);
@ -105,13 +105,13 @@ Status TransposeInfo::InferTensorMap() {
return FAILED;
}
Shape tensor_map_index_input;
std::vector<int32_t> tensor_map_index_input;
for (size_t j = 0; j < inputs_shape_[0].size(); ++j) {
tensor_map_index_input.push_back(SizeToInt(inputs_shape_[0].size() - j - 1));
}
inputs_tensor_map_.push_back(tensor_map_index_input);
Shape tensor_map_index_output = tensor_map_index_input;
std::vector<int32_t> tensor_map_index_output = tensor_map_index_input;
for (uint32_t i = 0; i < tensor_map_index_output.size(); i++) {
tensor_map_index_output[i] = tensor_map_index_input[IntToUint(axis_v_[i])];
}
@ -122,7 +122,7 @@ Status TransposeInfo::InferTensorMap() {
// the output tensor strategy is the permutation of input tensor strategy, the permutation is axis_v
Strategys TransposeInfo::GetOutputsStrategy() {
Strategys outputs_strategy;
Dimensions strategy = input_strategy_;
std::vector<int32_t> strategy = input_strategy_;
for (uint32_t i = 0; i < strategy.size(); i++) {
strategy[i] = input_strategy_[IntToUint(axis_v_[i])];
}

View File

@ -38,7 +38,7 @@ Status VirtualDatasetInfo::CheckStrategy(const StrategyPtr &strategy) {
return FAILED;
}
Strategys stra = strategy->GetInputDim();
std::vector<Dimensions> stra = strategy->GetInputDim();
if (stra.size() < 1) {
if (is_auto_parallel_) {
MS_LOG(DEBUG) << name_ << ": Strategy size must be larger than 1.";
@ -80,12 +80,12 @@ Status VirtualDatasetInfo::CheckStrategy(const StrategyPtr &strategy) {
}
Status VirtualDatasetInfo::InferDevMatrixShape() {
Strategys stra = strategy_->GetInputDim();
std::vector<Dimensions> stra = strategy_->GetInputDim();
Dimensions strategy_first = stra.at(0);
int32_t stage = strategy_->GetInputStage();
CheckGlobalDeviceManager();
int32_t dev_num = SizeToInt(g_device_manager->GetDeviceListByStageId(stage).size());
int32_t batch_split_num = ((int32_t)(strategy_first.at(0)));
int32_t batch_split_num = strategy_first.at(0);
dev_matrix_shape_.push_back(batch_split_num);
if (dev_num > batch_split_num) {
dev_matrix_shape_.push_back(dev_num / batch_split_num);
@ -103,11 +103,11 @@ Status VirtualDatasetInfo::InferTensorMap() {
bool full_batch = ParallelContext::GetInstance()->full_batch();
for (size_t i = 0; i < strategy_->GetInputNumber(); i++) {
Shape tensor_map_index;
std::vector<int32_t> tensor_map_index;
if (full_batch) {
tensor_map_index.push_back(MAP_NONE);
} else {
tensor_map_index.push_back((int64_t)(LAST_INDEX(dev_matrix_shape_.size())));
tensor_map_index.push_back((int32_t)(LAST_INDEX(SizeToUint(dev_matrix_shape_.size()))));
}
for (size_t j = 1; j < strategy_->GetInputDim()[i].size(); ++j) {
tensor_map_index.push_back(MAP_NONE);
@ -193,7 +193,7 @@ Status VirtualDatasetInfo::GenerateStrategies(int32_t stage_id) {
total_dev_num = g_device_manager->GetDeviceListByStageId(stage_id).size();
}
StrategyPtr sp;
Strategys strategy;
std::vector<Dimensions> strategy;
for (auto &shape : inputs_shape_) {
Shape temp;
temp.emplace_back(SizeToInt(total_dev_num));

View File

@ -1019,16 +1019,14 @@ StrategyPtr ExtractStrategy(std::unordered_map<std::string, ValuePtr> attrs) {
}
if (var->size() > 0) {
std::vector<ValuePtr> elements = var->value();
Strategys strategy;
std::vector<Dimensions> strategy;
for (uint32_t index = 0; index < elements.size(); ++index) {
Dimensions dim;
if (elements[index]->isa<ValueSequeue>()) {
ValueTuplePtr value_tuple = elements[index]->cast<ValueTuplePtr>();
std::vector<ValuePtr> value_vector = value_tuple->value();
(void)std::transform(
value_vector.begin(), value_vector.end(), std::back_inserter(dim), [](const ValuePtr &value) {
return value->isa<Int64Imm>() ? GetValue<int64_t>(value) : static_cast<int64_t>(GetValue<int>(value));
});
(void)std::transform(value_vector.begin(), value_vector.end(), std::back_inserter(dim),
[](const ValuePtr &value) { return static_cast<int32_t>(GetValue<int>(value)); });
strategy.push_back(dim);
} else {
MS_LOG(EXCEPTION) << "Failure:Strategy's format is wrong! Need ValueSequeue";
@ -1077,20 +1075,12 @@ Shapes GetNodeShape(const AnfNodePtr &node) {
for (auto &shape : tuple_shape) {
auto each_shape = dyn_cast<abstract::Shape>(shape);
MS_EXCEPTION_IF_NULL(each_shape);
std::vector<int> shape_int = each_shape->shape();
Shape new_shape;
(void)std::transform(shape_int.begin(), shape_int.end(), std::back_inserter(new_shape),
[](const int &value) { return static_cast<int64_t>(value); });
shapes.push_back(new_shape);
shapes.push_back(each_shape->shape());
}
} else {
auto shape_ptr = dyn_cast<abstract::Shape>(base_shape_ptr);
MS_EXCEPTION_IF_NULL(shape_ptr);
std::vector<int> shape_int = shape_ptr->shape();
Shape new_shape;
(void)std::transform(shape_int.begin(), shape_int.end(), std::back_inserter(new_shape),
[](const int &value) { return static_cast<int64_t>(value); });
shapes.push_back(new_shape);
shapes.push_back(shape_ptr->shape());
}
return shapes;
}
@ -1422,7 +1412,7 @@ void SetVirtualDatasetStrategy(const CNodePtr &node) {
if (shape_list[0][i].empty()) {
MS_LOG(EXCEPTION) << "shape_list[ " << i << " ].size() is zero";
}
Dimensions input_strategy = {dev_num};
std::vector<int32_t> input_strategy = {dev_num};
for (size_t j = 1; j < shape_list[0][i].size(); j++) {
input_strategy.push_back(1);
}
@ -1486,7 +1476,7 @@ void ExtractInformation(const std::vector<AnfNodePtr> &all_nodes) {
if (!StrategyFound(attrs) && !load_strategy_from_ckpt) {
MS_LOG(INFO) << "ExtractInformation: the strategy of node " << node->ToString() << " prim " << prim->name()
<< " is empty, using batch parallel";
std::shared_ptr<Strategys> strategy_v_ptr = operator_->GenerateBatchStrategies();
std::shared_ptr<std::vector<Dimensions>> strategy_v_ptr = operator_->GenerateBatchStrategies();
if (strategy_v_ptr == nullptr) {
MS_LOG(EXCEPTION) << "Failure:Generate batch parallel strategy failed";
}

View File

@ -24,20 +24,19 @@
#include <vector>
#include "frontend/parallel/status.h"
#include "frontend/parallel/device_matrix.h"
namespace mindspore {
namespace parallel {
#define MIN_SLICE_NUM 1
using Dimensions = Shape;
using Strategys = std::vector<Dimensions>;
using Dimensions = std::vector<int32_t>;
class Strategy;
using StrategyPtr = std::shared_ptr<Strategy>;
class Strategy {
public:
Strategy(int32_t stage, Strategys inputs)
Strategy(int32_t stage, std::vector<Dimensions> inputs)
: stage_(stage), inputs_(std::move(inputs)), internal_size_(0), internal_stragies_() {}
Strategy(const Strategy &another_stra) : stage_(another_stra.GetInputStage()) {
@ -52,14 +51,14 @@ class Strategy {
~Strategy() = default;
size_t GetInputNumber() const { return inputs_.size(); }
Strategys GetInputDim() const { return inputs_; }
std::vector<Dimensions> GetInputDim() const { return inputs_; }
int32_t GetInputStage() const { return stage_; }
void ExpandInputDimFromOneToTwo() {
if (inputs_.size() == 1) {
inputs_.push_back(inputs_[0]);
}
}
void ResetInputs(const Strategys &input) { inputs_ = input; }
void ResetInputs(const std::vector<Dimensions> &input) { inputs_ = input; }
std::vector<StrategyPtr> GetInternalStrategies() const { return internal_stragies_; }
size_t GetInternalSize() const { return internal_size_; }
@ -84,12 +83,12 @@ class Strategy {
const int32_t stage_;
// The size of Dimensions must equal to inputs_ tensor dimension.
Strategys inputs_;
std::vector<Dimensions> inputs_;
size_t internal_size_ = 0;
std::vector<StrategyPtr> internal_stragies_;
};
inline StrategyPtr NewStrategy(const int32_t stage, const Strategys &inputs) {
inline StrategyPtr NewStrategy(const int32_t stage, const std::vector<Dimensions> &inputs) {
return std::make_shared<Strategy>(stage, inputs);
}
} // namespace parallel

View File

@ -66,10 +66,10 @@ Status StrategyCheckpoint::Load(StrategyMap *strategy_map) {
straspb::ParallelStrategys parallel_strategys = parallel_strategy_item.parallel_strategys();
auto stage = (int32_t)parallel_strategys.stage();
size_t strategys_num = IntToSize(parallel_strategys.parallel_strategy_size());
Strategys strategy_inputs;
std::vector<std::vector<int32_t>> strategy_inputs;
for (size_t j = 0; j < strategys_num; j++) {
straspb::ParallelStrategy parallel_strategy = parallel_strategys.parallel_strategy(SizeToInt(j));
Dimensions dimension;
std::vector<int32_t> dimension;
size_t dim_num = IntToSize(parallel_strategy.dim_size());
for (size_t k = 0; k < dim_num; k++) {
dimension.push_back(parallel_strategy.dim(SizeToInt(k)));

View File

@ -26,7 +26,7 @@
namespace mindspore {
namespace parallel {
Status Arrangement::Init(const Shape &array) {
Status Arrangement::Init(const std::vector<int32_t> &array) {
Status status = Array::Init(array);
if (status != Status::SUCCESS) {
return Status::FAILED;
@ -40,7 +40,7 @@ Status Arrangement::Init(const Shape &array) {
}
bool Arrangement::IsValidArrangement() {
return !std::any_of(array_.begin(), array_.end(), [](int64_t value) { return value <= 0; });
return !std::any_of(array_.begin(), array_.end(), [](int32_t value) { return value <= 0; });
}
void Arrangement::ComputeSize() {
@ -57,14 +57,14 @@ void Arrangement::ComputeSize() {
* where size_[i-1] = shape[0] * shape[1] * ... * shape[i-1],
* if value > size_, return []
*/
Shape Arrangement::GetFrontElementByValue(int64_t value) const {
Shape out;
std::vector<int32_t> Arrangement::GetFrontElementByValue(int32_t value) const {
std::vector<int32_t> out;
if (GetDimSize() == 0) {
return out;
}
if (value <= size_) {
int64_t size = 1;
size_t shape_list_idx = 0;
int32_t size = 1;
uint32_t shape_list_idx = 0;
while (size < value) {
size *= array_[shape_list_idx];
if (size <= value) {
@ -88,9 +88,9 @@ std::shared_ptr<Arrangement> Arrangement::GetExpandedShapeByExpandListRemoveLeft
if (expand_list.size() != GetDimSize()) {
return nullptr;
}
Shape new_shape;
for (size_t i = 0; i < expand_list.size(); i++) {
Shape expand_shape = expand_list[i].GetFrontElementByValue(GetDimByIdx(i));
std::vector<int32_t> new_shape;
for (uint32_t i = 0; i < expand_list.size(); i++) {
std::vector<int32_t> expand_shape = expand_list[i].GetFrontElementByValue(GetDimByIdx(i));
if (expand_shape.empty()) {
new_shape.push_back(GetDimByIdx(i));
} else {
@ -109,11 +109,11 @@ std::shared_ptr<Arrangement> Arrangement::GetExpandedShapeByExpandListRemoveLeft
* arrangement_list = [[4, 2], [2, 2]]
*/
std::shared_ptr<std::vector<Arrangement>> Arrangement::GetExpandShapeList(const Arrangement &expand_shape) const {
int64_t size = 1;
size_t ind = 0;
int32_t size = 1;
uint32_t ind = 0;
std::vector<Arrangement> arrangement_list;
Shape shape;
for (size_t i = 0; i < expand_shape.GetDimSize(); i++) {
std::vector<int32_t> shape;
for (uint32_t i = 0; i < expand_shape.GetDimSize(); i++) {
size *= expand_shape.GetDimByIdx(i);
if (size > GetDimByIdx(ind)) {
MS_LOG(ERROR) << "invalid expand_shape";
@ -145,7 +145,7 @@ std::shared_ptr<std::pair<std::vector<Arrangement>, Arrangement>> Arrangement::G
if (expand_shape_list_ptr == nullptr) {
return nullptr;
}
Shape expand_num_list_shape;
std::vector<int32_t> expand_num_list_shape;
(void)std::transform(expand_shape_list_ptr->begin(), expand_shape_list_ptr->end(),
std::back_inserter(expand_num_list_shape),
[](const Arrangement &arr) { return SizeToInt(arr.GetDimSize()); });
@ -158,9 +158,9 @@ std::shared_ptr<std::pair<std::vector<Arrangement>, Arrangement>> Arrangement::G
return std::make_shared<std::pair<std::vector<Arrangement>, Arrangement>>(out_value);
}
Shape Arrangement::ComputeReverseAccumulateSumInReverseOrder() const {
Shape shape_accum;
int64_t size = 0;
std::vector<int32_t> Arrangement::ComputeReverseAccumulateSumInReverseOrder() const {
std::vector<int32_t> shape_accum;
int32_t size = 0;
for (auto iter = array_.end() - 1; iter >= array_.begin(); --iter) {
shape_accum.push_back(size);
size += *iter;
@ -173,11 +173,11 @@ std::shared_ptr<Arrangement> Arrangement::GetExpandedShapeByExpandListReserveLef
if (expand_list.size() != GetDimSize()) {
return nullptr;
}
Shape new_shape;
for (size_t i = 0; i < expand_list.size(); i++) {
std::vector<int32_t> new_shape;
for (uint32_t i = 0; i < expand_list.size(); i++) {
if (expand_list[i].GetDimSize() >= 1) {
int64_t size = 1;
for (size_t k = 0; k < expand_list[i].GetDimSize() - 1; k++) {
int32_t size = 1;
for (uint32_t k = 0; k < expand_list[i].GetDimSize() - 1; k++) {
new_shape.push_back(expand_list[i].GetDimByIdx(k));
size *= expand_list[i].GetDimByIdx(k);
}
@ -207,7 +207,7 @@ std::shared_ptr<Arrangement> Arrangement::GetUnifiedShape(const Arrangement &in2
if (status != Status::SUCCESS) {
return nullptr;
}
Shape out_shape;
std::vector<int32_t> out_shape;
status = AccumulateProductToShape(out_accum, &out_shape);
if (status != Status::SUCCESS) {
return nullptr;
@ -231,8 +231,8 @@ std::vector<size_t> Arrangement::GetSqueezeIdx() const {
}
Arrangement Arrangement::GetSqueezeArrangement() const {
Shape out_shape(array_.size());
auto it = std::copy_if(array_.begin(), array_.end(), out_shape.begin(), [](int64_t value) { return value != 1; });
std::vector<int32_t> out_shape(array_.size());
auto it = std::copy_if(array_.begin(), array_.end(), out_shape.begin(), [](int32_t value) { return value != 1; });
out_shape.resize(LongToSize(std::distance(out_shape.begin(), it)));
// if all elements are 1, out_shape = {1}

View File

@ -32,11 +32,11 @@ class Arrangement : public Array {
public:
Arrangement() : size_(1) {}
~Arrangement() override = default;
Status Init(const Shape &array) override;
int64_t size() const { return size_; }
Shape GetFrontElementByValue(int64_t value) const;
Status Init(const std::vector<int32_t> &array) override;
int32_t size() const { return size_; }
std::vector<int32_t> GetFrontElementByValue(int32_t value) const;
std::shared_ptr<std::vector<Arrangement>> GetExpandShapeList(const Arrangement &expand_shape) const;
Shape ComputeReverseAccumulateSumInReverseOrder() const;
std::vector<int32_t> ComputeReverseAccumulateSumInReverseOrder() const;
std::shared_ptr<Arrangement> GetExpandedShapeByExpandListReserveLeft(
const std::vector<Arrangement> &expand_list) const;
std::shared_ptr<Arrangement> GetExpandedShapeByExpandListRemoveLeft(
@ -50,7 +50,7 @@ class Arrangement : public Array {
private:
bool IsValidArrangement();
void ComputeSize();
int64_t size_;
int32_t size_;
};
} // namespace parallel
} // namespace mindspore

View File

@ -31,14 +31,14 @@ std::string Array::ToString() const {
return buffer.str();
}
Status Array::Init(const Shape &array) {
Status Array::Init(const std::vector<int32_t> &array) {
array_ = array;
return IsvalidArray() ? Status::SUCCESS : Status::FAILED;
}
bool Array::IsvalidArray() const { return true; }
int64_t Array::GetDimByIdx(size_t idx) const {
int32_t Array::GetDimByIdx(uint32_t idx) const {
size_t mod_idx = idx;
if (idx >= GetDimSize()) {
MS_LOG(EXCEPTION) << "idx is " << idx << ", but array size is " << GetDimSize();
@ -46,7 +46,7 @@ int64_t Array::GetDimByIdx(size_t idx) const {
return array_[mod_idx];
}
int64_t Array::GetDimByReverseIdx(size_t idx) const {
int32_t Array::GetDimByReverseIdx(uint32_t idx) const {
size_t mod_idx = idx;
if (idx >= GetDimSize()) {
MS_LOG(EXCEPTION) << "idx is " << idx << " but array size is " << GetDimSize();

View File

@ -23,7 +23,6 @@
#include <string>
#include <vector>
#include "frontend/parallel/status.h"
#include "frontend/parallel/device_matrix.h"
namespace mindspore {
namespace parallel {
@ -32,16 +31,16 @@ class Array {
Array() = default;
virtual ~Array() = default;
std::string ToString() const;
virtual Status Init(const Shape &array);
virtual Status Init(const std::vector<int32_t> &array);
bool IsvalidArray() const;
Shape array() const { return array_; }
std::vector<int32_t> array() const { return array_; }
size_t GetDimSize() const { return array_.size(); }
int64_t GetDimByIdx(size_t idx) const;
int64_t GetDimByReverseIdx(size_t idx) const;
int32_t GetDimByIdx(uint32_t idx) const;
int32_t GetDimByReverseIdx(uint32_t idx) const;
bool operator==(const Array &a1) const;
protected:
Shape array_;
std::vector<int32_t> array_;
};
} // namespace parallel
} // namespace mindspore

View File

@ -18,7 +18,6 @@
#include <functional>
#include <numeric>
#include <algorithm>
namespace mindspore {
namespace parallel {
@ -43,8 +42,8 @@ OperatorVector ConstructOperator::SkipRedisReshapeOP(Shape shape) {
}
Status ConstructOperator::ReshapeOP(Shape shape) {
int64_t prod = std::accumulate(shape.begin(), shape.end(), 1, std::multiplies<int64_t>());
int64_t prod_expect = std::accumulate(tensor_shape_.begin(), tensor_shape_.end(), 1, std::multiplies<int64_t>());
int32_t prod = std::accumulate(shape.begin(), shape.end(), 1, std::multiplies<int>());
int32_t prod_expect = std::accumulate(tensor_shape_.begin(), tensor_shape_.end(), 1, std::multiplies<int>());
if (prod != prod_expect) {
ValuePtr ptr = MakeValue(shape);
MS_EXCEPTION_IF_NULL(ptr);
@ -69,21 +68,12 @@ Operator CreateStridedSliceOp(int32_t value, const Shape &begin, const Shape &en
Attr attr_shrink_axis_mask = std::make_pair(SHRINK_AXIS_MASK, attr_value);
OperatorAttrs attrs = {attr_begin_mask, attr_end_mask, attr_ellipsis_mask, attr_new_axis_mask, attr_shrink_axis_mask};
std::vector<int32_t> begin_int;
(void)std::transform(begin.begin(), begin.end(), std::back_inserter(begin_int),
[](const int64_t &value) { return static_cast<int32_t>(value); });
ValuePtr param_begin_value = MakeValue(begin_int);
ValuePtr param_begin_value = MakeValue(begin);
Param param_begin = std::make_pair(std::make_pair(BEGIN, param_begin_value), 2);
std::vector<int32_t> end_int;
(void)std::transform(end.begin(), end.end(), std::back_inserter(end_int),
[](const int64_t &value) { return static_cast<int32_t>(value); });
ValuePtr param_end_value = MakeValue(end_int);
ValuePtr param_end_value = MakeValue(end);
Param param_end = std::make_pair(std::make_pair(END, param_end_value), 3);
std::vector<int32_t> strides_int;
(void)std::transform(strides.begin(), strides.end(), std::back_inserter(strides_int),
[](const int64_t &value) { return static_cast<int32_t>(value); });
ValuePtr param_strides_value = MakeValue(strides_int);
ValuePtr param_strides_value = MakeValue(strides);
Param param_strides = std::make_pair(std::make_pair(STRIDES, param_strides_value), 4);
OperatorParams params = {param_begin, param_end, param_strides};
OperatorArgs op_args = std::make_pair(attrs, params);
@ -96,16 +86,16 @@ Status ConstructOperator::StridedSliceOP(Args args) {
MS_LOG(ERROR) << "args size should not be less than 3!";
return Status::FAILED;
}
int64_t split_count = args[0];
int32_t split_count = args[0];
if (split_count <= 0) {
MS_LOG(ERROR) << "split_count should not be less than 0!";
return Status::FAILED;
}
int64_t split_dim = args[1];
int64_t dev_dim = args[2];
int32_t split_dim = args[1];
int32_t dev_dim = args[2];
std::vector<Group> group_list;
if (CreateGroupByDim(dev_size_ - LongToSize(dev_dim) - 1, &group_list) != SUCCESS) {
if (CreateGroupByDim(dev_size_ - IntToSize(dev_dim) - 1, &group_list) != SUCCESS) {
MS_LOG(ERROR) << "stride slice op: create group failed";
return FAILED;
} else if (group_list.empty()) { // this group only has one device, don't need do StridedSlice
@ -124,7 +114,7 @@ Status ConstructOperator::StridedSliceOP(Args args) {
Shape strides(size, 1);
size_t index = 0;
for (auto num : tensor_shape_) {
if (index != LongToSize(split_dim)) {
if (index != IntToSize(split_dim)) {
begin[index] = 0;
end[index] = num;
} else {
@ -133,9 +123,9 @@ Status ConstructOperator::StridedSliceOP(Args args) {
<< "! when construct StridedSlice operator";
return Status::INVALID_ARGUMENT;
}
int64_t count = num / split_count;
begin[index] = SizeToLong(rank) * count;
end[index] = (SizeToLong(rank) + 1) * count;
int32_t count = num / split_count;
begin[index] = SizeToInt(rank) * count;
end[index] = (SizeToInt(rank) + 1) * count;
}
index++;
}
@ -145,7 +135,7 @@ Status ConstructOperator::StridedSliceOP(Args args) {
return Status::SUCCESS;
}
Status ConstructOperator::AllGatherOP(int64_t dev_dim) {
Status ConstructOperator::AllGatherOP(int32_t dev_dim) {
if ((IntToSize(dev_dim) >= dev_size_) || (dev_dim < 0)) {
MS_LOG(ERROR) << "Invalid device dimension " << dev_dim << " when construct AllGather operator!";
return Status::INVALID_ARGUMENT;
@ -170,7 +160,7 @@ Status ConstructOperator::AllGatherOP(int64_t dev_dim) {
return Status::SUCCESS;
}
Status ConstructOperator::ConcatOP(int64_t concat_dim) {
Status ConstructOperator::ConcatOP(int32_t concat_dim) {
if (IntToSize(concat_dim) >= tensor_shape_.size()) {
MS_LOG(ERROR) << "Invalid tensor dimension " << concat_dim << " when construct Concat operator!";
return Status::INVALID_ARGUMENT;
@ -184,7 +174,7 @@ Status ConstructOperator::ConcatOP(int64_t concat_dim) {
return Status::SUCCESS;
}
Status ConstructOperator::SplitOP(int64_t split_count) {
Status ConstructOperator::SplitOP(int32_t split_count) {
if (split_count <= 0) {
MS_LOG(ERROR) << "Invalid split count when construct Split operator!";
return Status::FAILED;
@ -206,30 +196,30 @@ Status ConstructOperator::AlltoAllOP(Args args) {
MS_LOG(ERROR) << "args size should not be less than 4!";
return Status::FAILED;
}
int64_t split_count = args[0];
int64_t split_dim = args[1];
int64_t concat_dim = args[2];
int64_t dev_dim = args[3];
int32_t split_count = args[0];
int32_t split_dim = args[1];
int32_t concat_dim = args[2];
int32_t dev_dim = args[3];
if (split_count <= 0) {
MS_LOG(ERROR) << "Invalid split count when construct AlltoAll operator!";
return Status::FAILED;
}
if (tensor_shape_[LongToSize(split_dim)] % split_count != 0) {
if (tensor_shape_[IntToSize(split_dim)] % split_count != 0) {
MS_LOG(ERROR) << "Tensor can not be split into " << split_count << " slices in the dimension " << split_dim
<< "when construct AlltoAll operator!";
return Status::INVALID_ARGUMENT;
}
if (LongToSize(concat_dim) >= tensor_shape_.size()) {
if (IntToSize(concat_dim) >= tensor_shape_.size()) {
MS_LOG(ERROR) << "Invalid split count " << split_count << " when construct AlltoAll operator!";
return Status::INVALID_ARGUMENT;
}
if ((LongToSize(dev_dim) >= dev_size_) || (dev_dim < 0)) {
if ((IntToSize(dev_dim) >= dev_size_) || (dev_dim < 0)) {
MS_LOG(ERROR) << "Invalid device dimension " << dev_dim << " when construct AlltoAll operator!";
return Status::INVALID_ARGUMENT;
}
std::vector<Group> group_list;
if (CreateGroupByDim(dev_size_ - LongToSize(dev_dim) - 1, &group_list) != SUCCESS) {
if (CreateGroupByDim(dev_size_ - IntToSize(dev_dim) - 1, &group_list) != SUCCESS) {
MS_LOG(ERROR) << "AlltoAll op: create group failed";
return FAILED;
} else if (group_list.empty()) { // this group only has one device, don't need do alltoall

View File

@ -27,7 +27,7 @@
namespace mindspore {
namespace parallel {
using Args = std::vector<std::int64_t>;
using Args = std::vector<std::int32_t>;
class ConstructOperator {
public:
@ -38,9 +38,9 @@ class ConstructOperator {
OperatorVector SkipRedisReshapeOP(Shape shape);
Status ReshapeOP(Shape shape);
Status StridedSliceOP(Args args);
Status AllGatherOP(int64_t dev_dim);
Status SplitOP(int64_t split_count);
Status ConcatOP(int64_t concat_dim);
Status AllGatherOP(int32_t dev_dim);
Status SplitOP(int32_t split_count);
Status ConcatOP(int32_t concat_dim);
Status AlltoAllOP(Args args);
Operator GetOperator() const { return op_; }
void UpdateTensorShape(const Shape &tensor_shape) { tensor_shape_ = tensor_shape; }

View File

@ -26,7 +26,7 @@
namespace mindspore {
namespace parallel {
Status Map::Init(const Shape &array) {
Status Map::Init(const std::vector<int32_t> &array) {
Status status = Array::Init(array);
if (status != Status::SUCCESS) {
return Status::FAILED;
@ -39,11 +39,11 @@ Status Map::Init(const Shape &array) {
}
bool Map::IsValidMap() {
if (std::any_of(array_.begin(), array_.end(), [](int64_t value) { return ((value < 0) && (value != MAP_NONE)); })) {
if (std::any_of(array_.begin(), array_.end(), [](int32_t value) { return ((value < 0) && (value != MAP_NONE)); })) {
return false;
}
// check that all none -1 value in array_ is different
Shape sorted_array = array_;
std::vector<int32_t> sorted_array = array_;
std::sort(sorted_array.begin(), sorted_array.end());
int32_t value = MAP_NONE;
for (auto &element : sorted_array) {
@ -58,7 +58,7 @@ bool Map::IsValidMap() {
return true;
}
int64_t Map::GetMaxItem() const {
int32_t Map::GetMaxItem() const {
if (!array_.empty()) {
return *std::max_element(array_.begin(), array_.end());
} else {
@ -66,7 +66,7 @@ int64_t Map::GetMaxItem() const {
}
}
int32_t Map::GetIndexByValue(int64_t value) const {
int32_t Map::GetIndexByValue(int32_t value) const {
auto iter = find(array_.begin(), array_.end(), value);
if (iter != array_.end()) {
return static_cast<int32_t>(std::distance(array_.begin(), iter));
@ -82,15 +82,15 @@ std::shared_ptr<Map> Map::ExpandMapByNone(const Arrangement &expand_num_list) co
if (expand_num_list.GetDimSize() != GetDimSize()) {
return nullptr;
}
Shape new_shape;
for (size_t i = 0; i != GetDimSize(); i++) {
std::vector<int32_t> new_shape;
for (uint32_t i = 0; i != GetDimSize(); i++) {
if (GetDimByIdx(i) == MAP_NONE) {
for (int64_t j = 0; j < expand_num_list.GetDimByIdx(i); j++) {
for (int32_t j = 0; j < expand_num_list.GetDimByIdx(i); j++) {
new_shape.push_back(MAP_NONE);
}
} else {
new_shape.push_back(GetDimByIdx(i));
int64_t j = 1;
int32_t j = 1;
while (j < expand_num_list.GetDimByIdx(i)) {
new_shape.push_back(MAP_NONE);
j++;
@ -106,17 +106,17 @@ std::shared_ptr<Map> Map::ExpandMapByNone(const Arrangement &expand_num_list) co
* expand.size() should be equal to array_.size()
*/
std::shared_ptr<Map> Map::ExpandMapByDecreaseNumber(const Arrangement &expand_num_list) const {
if (GetMaxItem() >= static_cast<int64_t>(expand_num_list.GetDimSize())) {
if (GetMaxItem() >= static_cast<int32_t>(expand_num_list.GetDimSize())) {
return nullptr;
}
Shape new_shape;
for (size_t i = 0; i < GetDimSize(); i++) {
std::vector<int32_t> new_shape;
for (uint32_t i = 0; i < GetDimSize(); i++) {
if (GetDimByIdx(i) == MAP_NONE) {
new_shape.push_back(MAP_NONE);
} else {
int64_t start_map =
expand_num_list.ComputeReverseAccumulateSumInReverseOrder()[static_cast<size_t>(GetDimByIdx(i))];
for (int32_t k = expand_num_list.GetDimByReverseIdx(static_cast<size_t>(GetDimByIdx(i))) - 1; k >= 0; k--) {
int32_t start_map =
expand_num_list.ComputeReverseAccumulateSumInReverseOrder()[static_cast<uint32_t>(GetDimByIdx(i))];
for (int32_t k = expand_num_list.GetDimByReverseIdx(static_cast<uint32_t>(GetDimByIdx(i))) - 1; k >= 0; k--) {
new_shape.push_back(k + start_map);
}
}
@ -127,16 +127,16 @@ std::shared_ptr<Map> Map::ExpandMapByDecreaseNumber(const Arrangement &expand_nu
}
std::shared_ptr<std::vector<Arrangement>> Map::ReMapVector(const std::vector<Arrangement> &input_vector) const {
if (GetMaxItem() >= static_cast<int64_t>(input_vector.size())) {
if (GetMaxItem() >= static_cast<int32_t>(input_vector.size())) {
return nullptr;
}
std::vector<Arrangement> out;
Arrangement empty_arrangement;
for (size_t i = 0; i < GetDimSize(); i++) {
for (uint32_t i = 0; i < GetDimSize(); i++) {
if (GetDimByIdx(i) == MAP_NONE) {
out.push_back(empty_arrangement);
} else {
out.push_back(input_vector[input_vector.size() - 1 - LongToSize(GetDimByIdx(i))]);
out.push_back(input_vector[IntToUint(SizeToInt(input_vector.size()) - 1 - GetDimByIdx(i))]);
}
}
return std::make_shared<std::vector<Arrangement>>(out);
@ -144,7 +144,7 @@ std::shared_ptr<std::vector<Arrangement>> Map::ReMapVector(const std::vector<Arr
bool Map::CheckNoneByIdxList(std::vector<size_t> idx_list) const {
for (auto &value : idx_list) {
if (GetDimByIdx(value) != MAP_NONE) {
if (GetDimByIdx(SizeToUint(value)) != MAP_NONE) {
return false;
}
}
@ -152,11 +152,11 @@ bool Map::CheckNoneByIdxList(std::vector<size_t> idx_list) const {
}
Map Map::SqueezeMapByIdxList(std::vector<size_t> idx_list) const {
Shape out_shape;
std::vector<int32_t> out_shape;
for (size_t i = 0; i < GetDimSize(); i++) {
auto it = std::find(idx_list.begin(), idx_list.end(), i);
if (it == idx_list.end()) {
out_shape.push_back(GetDimByIdx(i));
out_shape.push_back(GetDimByIdx(SizeToUint(i)));
}
}
if (out_shape.empty()) {

View File

@ -34,9 +34,9 @@ class Map : public Array {
public:
Map() = default;
~Map() override = default;
Status Init(const Shape &array) override;
int64_t GetMaxItem() const;
int32_t GetIndexByValue(int64_t value) const;
Status Init(const std::vector<int32_t> &array) override;
int32_t GetMaxItem() const;
int32_t GetIndexByValue(int32_t value) const;
std::shared_ptr<Map> ExpandMapByNone(const Arrangement &expand_num_list) const;
std::shared_ptr<Map> ExpandMapByDecreaseNumber(const Arrangement &expand_num_list) const;
std::shared_ptr<std::vector<Arrangement>> ReMapVector(const std::vector<Arrangement> &input_vector) const;

View File

@ -47,8 +47,8 @@ Status RedistributionOperatorInfer::Init(const TensorLayout &tensor_layout, cons
constructor_.UpdateTensorShape(cur_tensor_layout_.slice_shape().array());
size_t key = 0;
Shape map = in_tensor_map_.array();
for (int64_t item : map) {
std::vector<int32_t> map = in_tensor_map_.array();
for (int32_t item : map) {
map_[key++] = item;
}
@ -83,9 +83,9 @@ Status RedistributionOperatorInfer::InferRedistributionOperator() {
// break loop structure with concat_by_axis
if (len_global == operator_list_.size() && !map_.empty()) {
size_t index = map_.begin()->first;
int64_t in_dim = map_[index];
int32_t in_dim = map_[index];
map_[index] = NONE;
Args args = {SizeToInt(index), in_dim, dev_mat_.GetDimByReverseIdx(LongToSize(in_dim))};
Args args = {SizeToInt(index), in_dim, dev_mat_.GetDimByReverseIdx(IntToUint(in_dim))};
if (InsertOperator(CONCAT_BY_AXIS, args) == Status::FAILED) {
return Status::FAILED;
}
@ -97,8 +97,8 @@ Status RedistributionOperatorInfer::InferRedistributionOperator() {
Status RedistributionOperatorInfer::InferSplitByAxis() {
for (auto iter = map_.begin(); iter != map_.end();) {
uint32_t index = iter->first;
int64_t in_dim = iter->second;
int64_t out_dim = out_tensor_map_.GetDimByIdx(index);
int32_t in_dim = iter->second;
int32_t out_dim = out_tensor_map_.GetDimByIdx(index);
if (in_dim == out_dim) {
(void)map_.erase(iter++);
continue;
@ -122,8 +122,8 @@ Status RedistributionOperatorInfer::InferSplitByAxis() {
Status RedistributionOperatorInfer::InferPermuteByAxis() {
for (auto iter = map_.begin(); iter != map_.end();) {
uint32_t index = iter->first;
int64_t in_dim = map_[index];
int64_t out_dim = out_tensor_map_.GetDimByIdx(index);
int32_t in_dim = map_[index];
int32_t out_dim = out_tensor_map_.GetDimByIdx(index);
if (in_dim == out_dim) {
(void)map_.erase(iter++);
continue;
@ -132,9 +132,9 @@ Status RedistributionOperatorInfer::InferPermuteByAxis() {
std::any_of(map_.begin(), map_.end(),
[out_dim](const RedistributionOperatorMap::value_type &a) { return a.second == out_dim; })) {
int32_t cat_dim = in_tensor_map_.GetIndexByValue(out_dim);
int64_t dev_num = dev_mat_.GetDimByReverseIdx(LongToSize(out_dim));
int32_t dev_num = dev_mat_.GetDimByReverseIdx(IntToUint(out_dim));
if (is_cost_model_) {
int64_t dev_dim = in_tensor_map_.GetDimByIdx(IntToUint(cat_dim));
int32_t dev_dim = in_tensor_map_.GetDimByIdx(IntToUint(cat_dim));
Args args_alltoall = {dev_mat_.GetDimByReverseIdx(IntToUint(dev_dim)), UintToInt(index), cat_dim, dev_dim,
dev_num};
if (InsertOperator(PERMUTE_BY_AXIS, args_alltoall) == Status::FAILED) {
@ -165,10 +165,10 @@ Status RedistributionOperatorInfer::InferPermuteByAxis() {
Status RedistributionOperatorInfer::InferConcatByAxis() {
for (auto iter = map_.begin(); iter != map_.end();) {
uint32_t index = iter->first;
int64_t in_dim = map_[index];
int64_t out_dim = out_tensor_map_.GetDimByIdx(index);
int32_t in_dim = map_[index];
int32_t out_dim = out_tensor_map_.GetDimByIdx(index);
if (in_dim != NONE && out_tensor_map_.GetIndexByValue(in_dim) == NONE) {
Args args = {SizeToInt(index), in_dim, dev_mat_.GetDimByReverseIdx(LongToSize(in_dim))};
Args args = {SizeToInt(index), in_dim, dev_mat_.GetDimByReverseIdx(IntToUint(in_dim))};
if (InsertOperator(CONCAT_BY_AXIS, args) == Status::FAILED) {
MS_LOG(ERROR) << "Insert ConcatByAxis Error!";
return Status::FAILED;
@ -215,7 +215,7 @@ Status RedistributionOperatorInfer::TransferSplitByAxis(Args args) {
MS_LOG(ERROR) << "args size should not be less than 3!";
return Status::FAILED;
}
size_t index = LongToSize(args[1]);
uint32_t index = IntToUint(args[1]);
if (constructor_.StridedSliceOP(args) != Status::SUCCESS) {
return Status::FAILED;
} else {
@ -239,11 +239,11 @@ Status RedistributionOperatorInfer::TransferPermuteByAxis(Args args) {
operator_vector_.push_back(constructor_.GetOperator());
output_info_vector_.push_back(std::make_pair(false, 0));
}
size_t index = LongToSize(args[1]);
int64_t val = args[2];
int64_t out_dim = out_tensor_map_.GetDimByIdx(index);
uint32_t index = IntToUint(args[1]);
int32_t val = args[2];
int32_t out_dim = out_tensor_map_.GetDimByIdx(index);
if (cur_tensor_layout_.UpdateTensorMap(LongToSize(val), NONE) == Status::FAILED) {
if (cur_tensor_layout_.UpdateTensorMap(IntToUint(val), NONE) == Status::FAILED) {
return Status::FAILED;
}
if (cur_tensor_layout_.UpdateTensorMap(index, out_dim) == Status::FAILED) {
@ -257,9 +257,9 @@ Status RedistributionOperatorInfer::TransferConcatByAxis(Args args) {
MS_LOG(ERROR) << "args size should not be less than 3!";
return Status::FAILED;
}
int64_t tensor_dim = args[0];
int64_t dev_dim = args[1];
int64_t split_count = args[2];
int32_t tensor_dim = args[0];
int32_t dev_dim = args[1];
int32_t split_count = args[2];
if (constructor_.AllGatherOP(dev_dim) != Status::SUCCESS) {
return Status::FAILED;
} else {
@ -280,7 +280,7 @@ Status RedistributionOperatorInfer::TransferConcatByAxis(Args args) {
output_info_vector_.push_back(std::make_pair(false, 0));
}
}
if (cur_tensor_layout_.UpdateTensorMap(LongToSize(tensor_dim), NONE) == Status::FAILED) {
if (cur_tensor_layout_.UpdateTensorMap(IntToUint(tensor_dim), NONE) == Status::FAILED) {
return Status::FAILED;
}
return Status::SUCCESS;

View File

@ -28,10 +28,10 @@
#include "utils/convert_utils.h"
namespace mindspore {
namespace parallel {
using DeviceArrangement = Shape;
using TensorMap = Shape;
using TensorShape = Shape;
using RedistributionOperatorMap = std::unordered_map<uint32_t, int64_t>;
using DeviceArrangement = std::vector<int32_t>;
using TensorMap = std::vector<int32_t>;
using TensorShape = std::vector<int32_t>;
using RedistributionOperatorMap = std::unordered_map<uint32_t, int32_t>;
using OperatorR = std::pair<OperatorName, Args>;
using OperatorC = std::pair<OperatorR, Shape>;
using OperatorList = std::vector<OperatorC>;

View File

@ -26,7 +26,7 @@ namespace parallel {
* shape = [2, 8, 32]
* shape_accum = [2, 2 * 8, 2 * 8 * 32]
*/
Status ShapeToAccumulateProduct(const Shape &shape, Shape *shape_accum) {
Status ShapeToAccumulateProduct(const std::vector<int32_t> &shape, std::vector<int64_t> *shape_accum) {
MS_EXCEPTION_IF_NULL(shape_accum);
shape_accum->clear();
int64_t size = 1;
@ -47,7 +47,7 @@ Status ShapeToAccumulateProduct(const Shape &shape, Shape *shape_accum) {
* shape_accum = [2 * 8 * 32, 8 * 32, 32]
*
*/
Status ShapeToAccumulateProductReverse(const Shape &shape, Shape *shape_accum) {
Status ShapeToAccumulateProductReverse(const std::vector<int32_t> &shape, std::vector<int64_t> *shape_accum) {
MS_EXCEPTION_IF_NULL(shape_accum);
shape_accum->clear();
int64_t size = 1;
@ -68,7 +68,7 @@ Status ShapeToAccumulateProductReverse(const Shape &shape, Shape *shape_accum) {
* shape = [2, 8, 32]
*
*/
Status AccumulateProductToShape(const Shape &shape_accum, Shape *shape) {
Status AccumulateProductToShape(const std::vector<int64_t> &shape_accum, std::vector<int32_t> *shape) {
MS_EXCEPTION_IF_NULL(shape);
shape->clear();
int64_t value = 1;
@ -81,7 +81,7 @@ Status AccumulateProductToShape(const Shape &shape_accum, Shape *shape) {
MS_LOG(ERROR) << "shape_accum is not a accumulate product in ascending order";
return Status::FAILED;
}
shape->push_back(static_cast<int64_t>((*iter) / value));
shape->push_back(static_cast<int32_t>((*iter) / value));
value = (*iter);
}
return Status::SUCCESS;
@ -92,7 +92,7 @@ Status AccumulateProductToShape(const Shape &shape_accum, Shape *shape) {
* shape_accum_reverse = [2 * 8 * 32, 8 * 32, 32]
* shape = [2, 8, 32]
*/
Status AccumulateProductReverseToShape(const Shape &shape_accum_reverse, Shape *shape) {
Status AccumulateProductReverseToShape(const std::vector<int64_t> &shape_accum_reverse, std::vector<int32_t> *shape) {
MS_EXCEPTION_IF_NULL(shape);
shape->clear();
int64_t value = 1;
@ -105,7 +105,7 @@ Status AccumulateProductReverseToShape(const Shape &shape_accum_reverse, Shape *
MS_LOG(ERROR) << "shape_accum is not a accumulate product in ascending order";
return Status::FAILED;
}
(void)shape->insert(shape->begin(), static_cast<int64_t>((*iter) / value));
(void)shape->insert(shape->begin(), static_cast<int32_t>((*iter) / value));
value = *iter;
}
return Status::SUCCESS;
@ -122,7 +122,8 @@ Status AccumulateProductReverseToShape(const Shape &shape_accum_reverse, Shape *
* in2 = [8, 16]
* *out = [2, 4, 8, 16]
*/
Status UnifyAccumulateProduct(const Shape &in1_accum, const Shape &in2_accum, Shape *out_accum) {
Status UnifyAccumulateProduct(const std::vector<int64_t> &in1_accum, const std::vector<int64_t> &in2_accum,
std::vector<int64_t> *out_accum) {
MS_EXCEPTION_IF_NULL(out_accum);
out_accum->clear();
auto in1_iter = in1_accum.begin();
@ -158,19 +159,19 @@ Status UnifyAccumulateProduct(const Shape &in1_accum, const Shape &in2_accum, Sh
* in2 = [2, 16]
* out = [2, 4, 4]
*/
Status UnifyShape(const Shape &in1, const Shape &in2, Shape *out) {
Status UnifyShape(const std::vector<int32_t> &in1, const std::vector<int32_t> &in2, std::vector<int32_t> *out) {
MS_EXCEPTION_IF_NULL(out);
Shape in1_accum;
std::vector<int64_t> in1_accum;
Status status = ShapeToAccumulateProduct(in1, &in1_accum);
if (status != Status::SUCCESS) {
return status;
}
Shape in2_accum;
std::vector<int64_t> in2_accum;
status = ShapeToAccumulateProduct(in2, &in2_accum);
if (status != Status::SUCCESS) {
return status;
}
Shape out_accum;
std::vector<int64_t> out_accum;
status = UnifyAccumulateProduct(in1_accum, in2_accum, &out_accum);
if (status != Status::SUCCESS) {
return status;
@ -193,8 +194,9 @@ Status UnifyShape(const Shape &in1, const Shape &in2, Shape *out) {
* expand_accum_reverse = [2 * 4 * 8, 4 * 8, 8]
* out_accum_reverse = [2 * 4 * 2 * 4 * 8, 4 * 2 * 4 * 8, 2 * 4 * 8, 4 * 8, 8]
*/
Status ExpandAccumulateProduct(const Shape &in_accum_reverse, const Shape &expand_accum_reverse,
Shape *out_accum_reverse) {
Status ExpandAccumulateProduct(const std::vector<int64_t> &in_accum_reverse,
const std::vector<int64_t> &expand_accum_reverse,
std::vector<int64_t> *out_accum_reverse) {
MS_EXCEPTION_IF_NULL(out_accum_reverse);
out_accum_reverse->clear();
auto in_riter = in_accum_reverse.rbegin();
@ -234,19 +236,19 @@ Status ExpandAccumulateProduct(const Shape &in_accum_reverse, const Shape &expan
* expand = [2, 4, 8]
* out = [2, 4, 2, 4, 8]
*/
Status ExpandShape(const Shape &in, const Shape &expand, Shape *out) {
Status ExpandShape(const std::vector<int32_t> &in, const std::vector<int32_t> &expand, std::vector<int32_t> *out) {
MS_EXCEPTION_IF_NULL(out);
Shape in_accum_reverse;
std::vector<int64_t> in_accum_reverse;
Status status = ShapeToAccumulateProductReverse(in, &in_accum_reverse);
if (status != Status::SUCCESS) {
return status;
}
Shape expand_accum_reverse;
std::vector<int64_t> expand_accum_reverse;
status = ShapeToAccumulateProductReverse(expand, &expand_accum_reverse);
if (status != Status::SUCCESS) {
return status;
}
Shape out_accum_reverse;
std::vector<int64_t> out_accum_reverse;
status = ExpandAccumulateProduct(in_accum_reverse, expand_accum_reverse, &out_accum_reverse);
if (status != Status::SUCCESS) {
return status;

View File

@ -24,7 +24,6 @@
#include <vector>
#include "frontend/parallel/status.h"
#include "frontend/parallel/device_matrix.h"
namespace mindspore {
namespace parallel {
@ -40,7 +39,7 @@ namespace parallel {
* shape_accum = [2, 2 * 8, 2 * 8 * 32]
*
*/
Status ShapeToAccumulateProduct(const Shape &shape, Shape *shape_accum);
Status ShapeToAccumulateProduct(const std::vector<int32_t> &shape, std::vector<int64_t> *shape_accum);
/*
* compute the accumulating product of all the values in shape from right to left,
@ -54,7 +53,7 @@ Status ShapeToAccumulateProduct(const Shape &shape, Shape *shape_accum);
* shape_accum = [2 * 8 * 32, 8 * 32, 32]
*
*/
Status ShapeToAccumulateProductReverse(const Shape &shape, Shape *shape_accum);
Status ShapeToAccumulateProductReverse(const std::vector<int32_t> &shape, std::vector<int64_t> *shape_accum);
/*
* compute the original shape from the accumulating product shape_accum,
@ -69,7 +68,7 @@ Status ShapeToAccumulateProductReverse(const Shape &shape, Shape *shape_accum);
* shape = [2, 8, 32]
*
*/
Status AccumulateProductToShape(const Shape &shape_accum, Shape *shape);
Status AccumulateProductToShape(const std::vector<int64_t> &shape_accum, std::vector<int32_t> *shape);
/*
* compute the original shape from the accumulating product shape_accum,
@ -84,7 +83,7 @@ Status AccumulateProductToShape(const Shape &shape_accum, Shape *shape);
* shape = [2, 8, 32]
*
*/
Status AccumulateProductReverseToShape(const Shape &shape_accum_reverse, Shape *shape);
Status AccumulateProductReverseToShape(const std::vector<int64_t> &shape_accum_reverse, std::vector<int32_t> *shape);
/*
* given two accumulate product in1_accum and in2_accum, compute the union of in1_accum and in2_accum,
@ -102,7 +101,8 @@ Status AccumulateProductReverseToShape(const Shape &shape_accum_reverse, Shape *
* in2_accum = [8, 16]
* out_accum = [2, 4, 8, 16]
*/
Status UnifyAccumulateProduct(const Shape &in1_accum, const Shape &in2_accum, Shape *out_accum);
Status UnifyAccumulateProduct(const std::vector<int64_t> &in1_accum, const std::vector<int64_t> &in2_accum,
std::vector<int64_t> *out_accum);
/*
* given two shape in1 = [din1_n-1, din1_n-2, ..., din1_0] and in2 = [din2_m-1, din2_m-2, ..., din2_m]
@ -117,7 +117,7 @@ Status UnifyAccumulateProduct(const Shape &in1_accum, const Shape &in2_accum, Sh
* in2 = [2, 16]
* out = [2, 4, 4]
*/
Status UnifyShape(const Shape &in1, const Shape &in2, Shape *out);
Status UnifyShape(const std::vector<int32_t> &in1, const std::vector<int32_t> &in2, std::vector<int32_t> *out);
/*
* given two accumulate product in reverse order of in and expand,
@ -141,8 +141,9 @@ Status UnifyShape(const Shape &in1, const Shape &in2, Shape *out);
* expand_accum_reverse = [2 * 4 * 8, 4 * 8, 8]
* out_accum_reverse = [2 * 4 * 2 * 4 * 8, 4 * 2 * 4 * 8, 2 * 4 * 8, 4 * 8, 8]
*/
Status ExpandAccumulateProduct(const Shape &in_accum_reverse, const Shape &expand_accum_reverse,
Shape *out_accum_reverse);
Status ExpandAccumulateProduct(const std::vector<int64_t> &in_accum_reverse,
const std::vector<int64_t> &expand_accum_reverse,
std::vector<int64_t> *out_accum_reverse);
/*
* given a shape in = [din_n-1, din_n-2, ..., d_0], and the expand shape expand= [dexp_m-1, dexp_m-2, ..., dexp_0],
@ -164,7 +165,7 @@ Status ExpandAccumulateProduct(const Shape &in_accum_reverse, const Shape &expan
* expand = [2, 4, 8]
* out = [2, 4, 2, 4, 8]
*/
Status ExpandShape(const Shape &in, const Shape &expand, Shape *out);
Status ExpandShape(const std::vector<int32_t> &in, const std::vector<int32_t> &expand, std::vector<int32_t> *out);
} // namespace parallel
} // namespace mindspore

View File

@ -64,8 +64,8 @@ Status TensorLayout::Init(const Arrangement &device_arrangement, const Map &tens
}
}
Status TensorLayout::InitFromVector(const Shape &device_arrangement, const Shape &tensor_map,
const Shape &tensor_shape) {
Status TensorLayout::InitFromVector(const std::vector<int32_t> &device_arrangement,
const std::vector<int32_t> &tensor_map, const std::vector<int32_t> &tensor_shape) {
if (device_arrangement_origin_.Init(device_arrangement) != SUCCESS) {
return FAILED;
}
@ -82,7 +82,7 @@ Status TensorLayout::InitFromVector(const Shape &device_arrangement, const Shape
}
bool TensorLayout::IsValidTensorLayout() const {
if (tensor_map_origin_.GetMaxItem() >= static_cast<int64_t>(device_arrangement_origin_.GetDimSize())) {
if (tensor_map_origin_.GetMaxItem() >= static_cast<int32_t>(device_arrangement_origin_.GetDimSize())) {
MS_LOG(ERROR) << "the max element in tensor_map_origin_ must be smaller than device_arrangement_origin_ size!";
return false;
}
@ -114,18 +114,18 @@ bool TensorLayout::TensorShapeDimensionIsDividedBySplitDeviceDimension() const {
}
void TensorLayout::RemoveElementEqualToOneInDeviceArrangement() {
Shape device_arrangement_shape;
Shape tensor_map_shape = tensor_map_origin_.array();
size_t dev_num = device_arrangement_origin_.GetDimSize();
size_t dev_num_left = device_arrangement_origin_.GetDimSize();
for (size_t i = 0; i < dev_num; i++) {
std::vector<int32_t> device_arrangement_shape;
std::vector<int32_t> tensor_map_shape = tensor_map_origin_.array();
uint32_t dev_num = SizeToUint(device_arrangement_origin_.GetDimSize());
int32_t dev_num_left = SizeToInt(device_arrangement_origin_.GetDimSize());
for (uint32_t i = 0; i < dev_num; i++) {
if (device_arrangement_origin_.GetDimByIdx(i) == 1) {
int32_t idx = GetTensorDimensionIndexByDeviceDimensionIndex(static_cast<int64_t>(dev_num - 1 - i));
int32_t idx = GetTensorDimensionIndexByDeviceDimensionIndex(static_cast<int32_t>(dev_num - 1 - i));
if (idx != -1) {
tensor_map_shape[static_cast<uint32_t>(idx)] = -1;
}
for (auto &value : tensor_map_shape) {
if (value >= SizeToLong(dev_num_left) - 1 - static_cast<int64_t>(i)) {
if (value >= dev_num_left - 1 - static_cast<int32_t>(i)) {
value--;
}
}
@ -139,7 +139,7 @@ void TensorLayout::RemoveElementEqualToOneInDeviceArrangement() {
}
// if idx is not in tensor_map, return -1
int32_t TensorLayout::GetTensorDimensionIndexByDeviceDimensionIndex(int64_t idx) const {
int32_t TensorLayout::GetTensorDimensionIndexByDeviceDimensionIndex(int32_t idx) const {
return tensor_map_.GetIndexByValue(idx);
}
@ -288,7 +288,7 @@ std::shared_ptr<TensorLayout> TensorLayout::ExpandDeviceArrangement(const Arrang
}
bool TensorLayout::TensorShapeCanBeExpanded(const Arrangement &expand_shape) const {
Shape in_expand_shape_shape;
std::vector<int32_t> in_expand_shape_shape;
Status status = ExpandShape(tensor_shape_.array(), expand_shape.array(), &in_expand_shape_shape);
if (status != Status::SUCCESS) {
return false;
@ -297,7 +297,7 @@ bool TensorLayout::TensorShapeCanBeExpanded(const Arrangement &expand_shape) con
}
std::shared_ptr<Arrangement> TensorLayout::ComputeExpandedTensorShape(const Arrangement &expand_shape) const {
Shape in_expand_shape_shape;
std::vector<int32_t> in_expand_shape_shape;
Status status = ExpandShape(tensor_shape_.array(), expand_shape.array(), &in_expand_shape_shape);
if (status != Status::SUCCESS) {
return nullptr;
@ -311,14 +311,14 @@ std::shared_ptr<Arrangement> TensorLayout::ComputeExpandedTensorShape(const Arra
}
Arrangement TensorLayout::slice_shape() const {
Shape shape;
for (size_t index = 0; index < tensor_map_.GetDimSize(); index++) {
int64_t dim = tensor_map_.GetDimByIdx(index);
int64_t num = tensor_shape_.GetDimByIdx(index);
std::vector<int32_t> shape;
for (uint32_t index = 0; index < tensor_map_.GetDimSize(); index++) {
int32_t dim = tensor_map_.GetDimByIdx(index);
int32_t num = tensor_shape_.GetDimByIdx(index);
if (dim == -1) {
shape.push_back(num);
} else {
int64_t divisor = device_arrangement_.GetDimByReverseIdx(IntToUint(dim));
int32_t divisor = device_arrangement_.GetDimByReverseIdx(IntToUint(dim));
shape.push_back(num / divisor);
}
}
@ -331,7 +331,7 @@ Arrangement TensorLayout::slice_shape() const {
}
}
Status TensorLayout::UpdateTensorMap(size_t index, int64_t value) {
Status TensorLayout::UpdateTensorMap(uint32_t index, int32_t value) {
if (index >= tensor_map_.GetDimSize()) {
MS_LOG(ERROR) << "Index is out of the size of the tensor map!";
return Status::FAILED;

View File

@ -38,7 +38,8 @@ class TensorLayout {
std::string StandardToString() const;
std::string OriginToString() const;
Status Init(const Arrangement &device_arrangement, const Map &tensor_map, const Arrangement &tensor_shape);
Status InitFromVector(const Shape &device_arrangement, const Shape &tensor_map, const Shape &tensor_shape);
Status InitFromVector(const std::vector<int32_t> &device_arrangement, const std::vector<int32_t> &tensor_map,
const std::vector<int32_t> &tensor_shape);
bool skip_redistribution() const { return skip_redistribution_; }
@ -78,7 +79,7 @@ class TensorLayout {
Arrangement slice_shape() const;
Status UpdateTensorMap(size_t index, int64_t value);
Status UpdateTensorMap(uint32_t index, int32_t value);
TensorLayout SqueezeShape() const;
@ -94,7 +95,7 @@ class TensorLayout {
int32_t GetSliceDeviceDimensionByTensorDimensionIndex(uint32_t idx) const;
int32_t GetSliceNumByTensorDimensionIndex(uint32_t idx) const;
bool TensorShapeDimensionIsDividedBySplitDeviceDimension() const;
int32_t GetTensorDimensionIndexByDeviceDimensionIndex(int64_t idx) const;
int32_t GetTensorDimensionIndexByDeviceDimensionIndex(int32_t idx) const;
Arrangement device_arrangement_origin_;
Map tensor_map_origin_;

View File

@ -48,10 +48,6 @@ py::object ValuePtrToPyData(const ValuePtr &value) {
MS_LOG(DEBUG) << "int";
py::int_ v = value->cast<Int32ImmPtr>()->value();
ret = v;
} else if (value->isa<Int64Imm>()) {
MS_LOG(DEBUG) << "int64";
py::int_ v = value->cast<Int64ImmPtr>()->value();
ret = v;
} else if (value->isa<UInt64Imm>()) {
MS_LOG(DEBUG) << "uint64";
py::int_ v = value->cast<UInt64ImmPtr>()->value();

View File

@ -25,7 +25,6 @@
#include <unordered_map>
#include <typeindex>
#include <memory>
#include <algorithm>
#include "utils/log_adapter.h"
#include "base/base.h"
@ -64,16 +63,7 @@ class Shape : public BaseShape {
static const int SHP_ANY = -1;
Shape() : shape_() {}
Shape(const std::initializer_list<int> &list) : shape_(list) {}
Shape(const std::initializer_list<int64_t> &list) {
std::vector<int64_t> list_in(list);
(void)std::transform(list_in.begin(), list_in.end(), std::back_inserter(shape_),
[](const int64_t &value) { return static_cast<int>(value); });
}
explicit Shape(const std::vector<int> &list) : shape_(list) {}
explicit Shape(const std::vector<int64_t> &list) {
(void)std::transform(list.begin(), list.end(), std::back_inserter(shape_),
[](const int64_t &value) { return static_cast<int>(value); });
}
~Shape() override = default;
MS_DECLARE_PARENT(Shape, BaseShape)
std::string ToString() const override;

View File

@ -154,13 +154,13 @@ class TestDPAlgo : public UT::Common {
void TestDPAlgo::SetUp() {
cost_graph = std::make_shared<CostGraph>();
cost_graph->SetDeviceMemoryAndCostParameter();
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 10; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(8);
stage_map.push_back(2);
@ -1327,8 +1327,8 @@ TEST_F(TestDPAlgo, test_GetStrategy_for_DoubleStarGraph) {
for (auto &op : cost_graph->GetOperators()) {
StrategyPtr s_strategy = op->selected_strategy();
Dimensions strategy_0 = s_strategy->GetInputDim()[0];
Dimensions strategy_1 = s_strategy->GetInputDim()[1];
std::vector<int32_t> strategy_0 = s_strategy->GetInputDim()[0];
std::vector<int32_t> strategy_1 = s_strategy->GetInputDim()[1];
std::string string_strategy_0 = "[";
for (size_t i = 0; i < strategy_0.size(); ++i) {

View File

@ -43,13 +43,13 @@ class TestEdgeCostModel : public UT::Common {
};
void TestEdgeCostModel::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 10; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(8);
stage_map.push_back(2);

View File

@ -53,13 +53,13 @@ class TestCostGraph : public UT::Common {
void TestCostGraph::SetUp() {
cost_graph.SetDeviceMemoryAndCostParameter();
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 10; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(8);
stage_map.push_back(2);

View File

@ -33,13 +33,13 @@ class TestMatMulCost : public UT::Common {
void TestMatMulCost::SetUp() {
mmcost_ = MatMulCost();
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 1050; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(1024);
stage_map.push_back(26);
@ -90,13 +90,13 @@ class TestActivationCost : public UT::Common {
void TestActivationCost::SetUp() {
ac_cost_ = ActivationCost();
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 1050; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(1024);
stage_map.push_back(26);
@ -142,13 +142,13 @@ class TestPReLUCost : public UT::Common {
void TestPReLUCost::SetUp() {
prelu_cost_ = PReLUCost();
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 1050; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(1024);
stage_map.push_back(26);

View File

@ -69,8 +69,8 @@ void TestDeviceManager::TearDown() {
}
TEST_F(TestDeviceManager, test_dm_init_AND_get_device_list) {
RankList dev_list;
RankList stage_map;
std::vector<int32_t> dev_list;
std::vector<int32_t> stage_map;
int32_t local_dev = 0;
dev_list.push_back(5);
@ -85,12 +85,12 @@ TEST_F(TestDeviceManager, test_dm_init_AND_get_device_list) {
ASSERT_EQ(dm_.DeviceNum(), 4);
ASSERT_EQ(dm_.GetStageNum(), (int32_t)(2));
RankList dev_list_0 = dm_.GetDeviceListByStageId(0);
RankList dev_list_1 = dm_.GetDeviceListByStageId(1);
std::vector<int32_t> dev_list_0 = dm_.GetDeviceListByStageId(0);
std::vector<int32_t> dev_list_1 = dm_.GetDeviceListByStageId(1);
ASSERT_EQ(dev_list_0.size(), 2);
ASSERT_EQ(dev_list_1.size(), 2);
RankList::iterator it = dev_list_0.begin();
std::vector<int32_t>::iterator it = dev_list_0.begin();
ASSERT_EQ((*it), int32_t(5));
it++;
ASSERT_EQ((*it), int32_t(3));
@ -112,7 +112,7 @@ TEST_F(TestDeviceManager, test_CreateNewDeviceByRank) {
TEST_F(TestDeviceManager, test_CreateDeviceListByRankList) {
std::vector<Device> dev_list;
RankList rlist;
std::vector<int32_t> rlist;
rlist.push_back(int32_t(2));
rlist.push_back(int32_t(1));
dev_list = dm_.CreateDeviceListByRankList(rlist);

View File

@ -38,13 +38,13 @@ class TestActivationInfo : public UT::Common {
};
void TestActivationInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 1050; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(1024);
stage_map.push_back(26);
@ -64,18 +64,18 @@ void TestActivationInfo::SetUp() {
}
TEST_F(TestActivationInfo, InferDevMatrixShape1) {
Strategys inputs = {{2, 4, 8, 16}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
activation->Init(strategy);
Shape dev_matrix_shape = activation->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = activation->dev_matrix_shape();
Shape expect = {2, 4, 8, 16};
std::vector<int32_t> expect = {2, 4, 8, 16};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestActivationInfo, InferSliceShape1) {
Strategys str = {{2, 4, 8, 16}};
std::vector<Dimensions> str = {{2, 4, 8, 16}};
StrategyPtr strategy = NewStrategy(0, str);
activation->Init(strategy);
@ -96,7 +96,7 @@ TEST_F(TestActivationInfo, InferSliceShape1) {
}
TEST_F(TestActivationInfo, GetTensorLayout1) {
Strategys str = {{2, 4, 8, 16}};
std::vector<Dimensions> str = {{2, 4, 8, 16}};
StrategyPtr strategy = NewStrategy(0, str);
activation->Init(strategy);
@ -117,7 +117,7 @@ TEST_F(TestActivationInfo, GetTensorLayout1) {
}
TEST_F(TestActivationInfo, GetForwardOp1) {
Strategys inputs = {{2, 4, 8, 16}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
activation->Init(strategy);
@ -128,7 +128,7 @@ TEST_F(TestActivationInfo, GetForwardOp1) {
}
TEST_F(TestActivationInfo, GetMirrorOPs1) {
Strategys inputs = {{1, 4, 8, 16}};
std::vector<Dimensions> inputs = {{1, 4, 8, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
activation->Init(strategy);
@ -148,7 +148,7 @@ TEST_F(TestActivationInfo, GetMirrorOPs1) {
}
TEST_F(TestActivationInfo, GetMirrorOPs2) {
Strategys inputs = {{2, 4, 8, 16}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
activation->Init(strategy);
@ -161,7 +161,7 @@ TEST_F(TestActivationInfo, GetMirrorOPs2) {
TEST_F(TestActivationInfo, CheckStrategy1) {
// Success: {{2,4,8,16}}
Strategys inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = activation->Init(strategy);
@ -170,7 +170,7 @@ TEST_F(TestActivationInfo, CheckStrategy1) {
TEST_F(TestActivationInfo, CheckStrategy2) {
// Success: {{2,4,8,16}}
Strategys inputs = {{2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = activation->Init(strategy);

View File

@ -40,13 +40,13 @@ class TestActivation : public UT::Common {
};
void TestActivation::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 1050; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(1024);
stage_map.push_back(26);
@ -101,7 +101,7 @@ TEST_F(TestActivation, test_softmax_strategies) {
ASSERT_NE(sp, nullptr);
Cost cost = *(swc->cost_list[0]);
Strategys stra = sp->GetInputDim();
std::vector<Dimensions> stra = sp->GetInputDim();
ASSERT_GT(stra.size(), 0);
Dimensions input0_stra = stra[0];
ASSERT_GT(input0_stra.size(), 2);

View File

@ -38,13 +38,13 @@ class TestGeluInfo : public UT::Common {
};
void TestGeluInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 130; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(128);
stage_map.push_back(2);
@ -63,18 +63,18 @@ void TestGeluInfo::SetUp() {
}
TEST_F(TestGeluInfo, InferDevMatrixShape1) {
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
gelu->Init(strategy);
Shape dev_matrix_shape = gelu->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = gelu->dev_matrix_shape();
Shape expect = {2, 4, 1, 16};
std::vector<int32_t> expect = {2, 4, 1, 16};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestGeluInfo, InferSliceShape1) {
Strategys str = {{2, 4, 1, 16}};
std::vector<Dimensions> str = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, str);
gelu->Init(strategy);
@ -95,7 +95,7 @@ TEST_F(TestGeluInfo, InferSliceShape1) {
}
TEST_F(TestGeluInfo, GetTensorLayout1) {
Strategys str = {{2, 4, 1, 16}};
std::vector<Dimensions> str = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, str);
gelu->Init(strategy);
@ -116,7 +116,7 @@ TEST_F(TestGeluInfo, GetTensorLayout1) {
}
TEST_F(TestGeluInfo, GetForwardOp1) {
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
gelu->Init(strategy);
@ -127,7 +127,7 @@ TEST_F(TestGeluInfo, GetForwardOp1) {
}
TEST_F(TestGeluInfo, GetMirrorOPs1) {
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
gelu->Init(strategy);
@ -140,7 +140,7 @@ TEST_F(TestGeluInfo, GetMirrorOPs1) {
TEST_F(TestGeluInfo, CheckStrategy1) {
// Success: {{2,4,1,16}}
Strategys inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = gelu->Init(strategy);
@ -149,7 +149,7 @@ TEST_F(TestGeluInfo, CheckStrategy1) {
TEST_F(TestGeluInfo, CheckStrategy2) {
// Success: {{2,4,1,16}}
Strategys inputs = {{2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = gelu->Init(strategy);
@ -158,7 +158,7 @@ TEST_F(TestGeluInfo, CheckStrategy2) {
TEST_F(TestGeluInfo, CheckStrategy3) {
// Success: {{2,4,1,16}}
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = gelu->Init(strategy);

View File

@ -34,13 +34,13 @@ class TestGenerateStrategy : public UT::Common {
};
void TestGenerateStrategy::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 10; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(8);
stage_map.push_back(2);

View File

@ -38,13 +38,13 @@ class TestGetNextInfo : public UT::Common {
};
void TestGetNextInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 8; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(8);
int32_t local_dev = 0;
// create a new g_device_manager
@ -65,16 +65,16 @@ void TestGetNextInfo::SetUp() {
}
TEST_F(TestGetNextInfo, InferDevMatrixShape1) {
Strategys inputs = {{}, {}};
std::vector<Dimensions> inputs = {{}, {}};
StrategyPtr strategy = NewStrategy(0, inputs);
get_next->Init(strategy);
Shape dev_matrix_shape = get_next->dev_matrix_shape();
Shape expect = {8, 1};
std::vector<int32_t> dev_matrix_shape = get_next->dev_matrix_shape();
std::vector<int32_t> expect = {8, 1};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestGetNextInfo, InferSliceShape1) {
Strategys str = {{}, {}};
std::vector<Dimensions> str = {{}, {}};
StrategyPtr strategy = NewStrategy(0, str);
get_next->Init(strategy);
@ -90,7 +90,7 @@ TEST_F(TestGetNextInfo, InferSliceShape1) {
}
TEST_F(TestGetNextInfo, GetTensorLayout1) {
Strategys str = {{}, {}};
std::vector<Dimensions> str = {{}, {}};
StrategyPtr strategy = NewStrategy(0, str);
get_next->Init(strategy);
std::vector<TensorInfo> outputs = get_next->outputs_tensor_info();
@ -106,14 +106,14 @@ TEST_F(TestGetNextInfo, GetTensorLayout1) {
}
TEST_F(TestGetNextInfo, CheckStrategy1) {
Strategys inputs = {};
std::vector<Dimensions> inputs = {};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = get_next->Init(strategy);
ASSERT_EQ(ret, SUCCESS);
}
TEST_F(TestGetNextInfo, CheckStrategy2) {
Strategys inputs = {{8, 1}, {8}};
std::vector<Dimensions> inputs = {{8, 1}, {8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = get_next->Init(strategy);
ASSERT_EQ(ret, FAILED);

View File

@ -38,13 +38,13 @@ class TestL2NormalizeInfo : public UT::Common {
};
void TestL2NormalizeInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 34; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(32);
stage_map.push_back(2);
@ -64,18 +64,18 @@ void TestL2NormalizeInfo::SetUp() {
}
TEST_F(TestL2NormalizeInfo, InferDevMatrixShape1) {
Strategys inputs = {{4, 1, 8}};
std::vector<Dimensions> inputs = {{4, 1, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
norm->Init(strategy);
Shape dev_matrix_shape = norm->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = norm->dev_matrix_shape();
Shape expect = {4, 1, 8};
std::vector<int32_t> expect = {4, 1, 8};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestL2NormalizeInfo, InferSliceShape1) {
Strategys str = {{4, 1, 8}};
std::vector<Dimensions> str = {{4, 1, 8}};
StrategyPtr strategy = NewStrategy(0, str);
norm->Init(strategy);
@ -96,7 +96,7 @@ TEST_F(TestL2NormalizeInfo, InferSliceShape1) {
}
TEST_F(TestL2NormalizeInfo, GetTensorLayout1) {
Strategys str = {{4, 1, 8}};
std::vector<Dimensions> str = {{4, 1, 8}};
StrategyPtr strategy = NewStrategy(0, str);
norm->Init(strategy);
@ -117,7 +117,7 @@ TEST_F(TestL2NormalizeInfo, GetTensorLayout1) {
}
TEST_F(TestL2NormalizeInfo, GetForwardOp1) {
Strategys inputs = {{4, 1, 8}};
std::vector<Dimensions> inputs = {{4, 1, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
norm->Init(strategy);
@ -128,7 +128,7 @@ TEST_F(TestL2NormalizeInfo, GetForwardOp1) {
}
TEST_F(TestL2NormalizeInfo, GetMirrorOPs1) {
Strategys inputs = {{4, 1, 8}};
std::vector<Dimensions> inputs = {{4, 1, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
norm->Init(strategy);
@ -140,7 +140,7 @@ TEST_F(TestL2NormalizeInfo, GetMirrorOPs1) {
}
TEST_F(TestL2NormalizeInfo, CheckStrategy1) {
Strategys inputs = {{4, 1, 8}, {4, 1, 8}};
std::vector<Dimensions> inputs = {{4, 1, 8}, {4, 1, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = norm->Init(strategy);
@ -148,7 +148,7 @@ TEST_F(TestL2NormalizeInfo, CheckStrategy1) {
}
TEST_F(TestL2NormalizeInfo, CheckStrategy2) {
Strategys inputs = {{4, 2, 3}};
std::vector<Dimensions> inputs = {{4, 2, 3}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = norm->Init(strategy);
@ -156,7 +156,7 @@ TEST_F(TestL2NormalizeInfo, CheckStrategy2) {
}
TEST_F(TestL2NormalizeInfo, CheckStrategy3) {
Strategys inputs = {{4, 2, 3, 4}};
std::vector<Dimensions> inputs = {{4, 2, 3, 4}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = norm->Init(strategy);
@ -164,7 +164,7 @@ TEST_F(TestL2NormalizeInfo, CheckStrategy3) {
}
TEST_F(TestL2NormalizeInfo, CheckStrategy4) {
Strategys inputs = {{4, 1, 8}};
std::vector<Dimensions> inputs = {{4, 1, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = norm->Init(strategy);
@ -172,7 +172,7 @@ TEST_F(TestL2NormalizeInfo, CheckStrategy4) {
}
TEST_F(TestL2NormalizeInfo, mirror_ops) {
Strategys inputs = {{2, 1, 8}};
std::vector<Dimensions> inputs = {{2, 1, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
norm->Init(strategy);

View File

@ -38,13 +38,13 @@ class TestLogSoftmaxInfo : public UT::Common {
};
void TestLogSoftmaxInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 130; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(128);
stage_map.push_back(2);
@ -64,18 +64,18 @@ void TestLogSoftmaxInfo::SetUp() {
}
TEST_F(TestLogSoftmaxInfo, InferDevMatrixShape1) {
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
log_softmax->Init(strategy);
Shape dev_matrix_shape = log_softmax->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = log_softmax->dev_matrix_shape();
Shape expect = {2, 4, 1, 16};
std::vector<int32_t> expect = {2, 4, 1, 16};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestLogSoftmaxInfo, InferSliceShape1) {
Strategys str = {{2, 4, 1, 16}};
std::vector<Dimensions> str = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, str);
log_softmax->Init(strategy);
@ -96,7 +96,7 @@ TEST_F(TestLogSoftmaxInfo, InferSliceShape1) {
}
TEST_F(TestLogSoftmaxInfo, GetTensorLayout1) {
Strategys str = {{2, 4, 1, 16}};
std::vector<Dimensions> str = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, str);
log_softmax->Init(strategy);
@ -117,7 +117,7 @@ TEST_F(TestLogSoftmaxInfo, GetTensorLayout1) {
}
TEST_F(TestLogSoftmaxInfo, GetForwardOp1) {
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
log_softmax->Init(strategy);
@ -128,7 +128,7 @@ TEST_F(TestLogSoftmaxInfo, GetForwardOp1) {
}
TEST_F(TestLogSoftmaxInfo, GetMirrorOPs1) {
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
log_softmax->Init(strategy);
@ -141,7 +141,7 @@ TEST_F(TestLogSoftmaxInfo, GetMirrorOPs1) {
TEST_F(TestLogSoftmaxInfo, CheckStrategy1) {
// Success: {{2,4,1,16}}
Strategys inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = log_softmax->Init(strategy);
@ -150,7 +150,7 @@ TEST_F(TestLogSoftmaxInfo, CheckStrategy1) {
TEST_F(TestLogSoftmaxInfo, CheckStrategy2) {
// Success: {{2,4,1,16}}
Strategys inputs = {{2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = log_softmax->Init(strategy);
@ -159,7 +159,7 @@ TEST_F(TestLogSoftmaxInfo, CheckStrategy2) {
TEST_F(TestLogSoftmaxInfo, CheckStrategy3) {
// Success: {{2,4,1,16}}
Strategys inputs = {{2, 4, 8, 16}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = log_softmax->Init(strategy);
@ -167,7 +167,7 @@ TEST_F(TestLogSoftmaxInfo, CheckStrategy3) {
}
TEST_F(TestLogSoftmaxInfo, GetDeviceList1) {
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
log_softmax->Init(strategy);

View File

@ -42,13 +42,13 @@ class TestMatmulInfo : public UT::Common {
};
void TestMatmulInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 1050; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(1024);
stage_map.push_back(26);
@ -94,77 +94,77 @@ void TestMatmulInfo::SetUp() {
}
TEST_F(TestMatmulInfo, InferDevMatrixShape1) {
Strategys inputs = {{2, 4, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
matmul1->Init(strategy);
Shape dev_matrix_shape = matmul1->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = matmul1->dev_matrix_shape();
Shape expect = {2, 4, 8, 16, 1};
std::vector<int32_t> expect = {2, 4, 8, 16, 1};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestMatmulInfo, InferDevMatrixShape2) {
Strategys inputs = {{2, 4, 8, 8}, {2, 4, 8, 2}};
std::vector<Dimensions> inputs = {{2, 4, 8, 8}, {2, 4, 8, 2}};
StrategyPtr strategy = NewStrategy(0, inputs);
matmul1->Init(strategy);
Shape dev_matrix_shape = matmul1->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = matmul1->dev_matrix_shape();
Shape expect = {2, 4, 8, 8, 2};
std::vector<int32_t> expect = {2, 4, 8, 8, 2};
ASSERT_EQ(dev_matrix_shape, expect);
}
// matmul2
TEST_F(TestMatmulInfo, InferDevMatrixShape3) {
Strategys inputs = {{2, 4, 8, 16}, {1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}, {1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
matmul2->Init(strategy);
Shape dev_matrix_shape = matmul2->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = matmul2->dev_matrix_shape();
Shape expect = {2, 4, 8, 16, 1};
std::vector<int32_t> expect = {2, 4, 8, 16, 1};
ASSERT_EQ(dev_matrix_shape, expect);
}
// matmul2
TEST_F(TestMatmulInfo, InferDevMatrixShape4) {
Strategys inputs = {{2, 4, 8, 8}, {2, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8, 8}, {2, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
matmul2->Init(strategy);
Shape dev_matrix_shape = matmul2->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = matmul2->dev_matrix_shape();
Shape expect = {2, 4, 8, 8, 2};
std::vector<int32_t> expect = {2, 4, 8, 8, 2};
ASSERT_EQ(dev_matrix_shape, expect);
}
// matmul3
TEST_F(TestMatmulInfo, InferDevMatrixShape5) {
Strategys inputs = {{8, 16}, {2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{8, 16}, {2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
matmul3->Init(strategy);
Shape dev_matrix_shape = matmul3->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = matmul3->dev_matrix_shape();
Shape expect = {2, 4, 8, 16, 1};
std::vector<int32_t> expect = {2, 4, 8, 16, 1};
ASSERT_EQ(dev_matrix_shape, expect);
}
// matmul3
TEST_F(TestMatmulInfo, InferDevMatrixShape6) {
Strategys inputs = {{8, 8}, {2, 4, 2, 8}};
std::vector<Dimensions> inputs = {{8, 8}, {2, 4, 2, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
matmul3->Init(strategy);
Shape dev_matrix_shape = matmul3->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = matmul3->dev_matrix_shape();
Shape expect = {2, 4, 8, 8, 2};
std::vector<int32_t> expect = {2, 4, 8, 8, 2};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestMatmulInfo, InferTensorMap1) {
Strategys str = {{2, 4, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> str = {{2, 4, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, str);
matmul1->Init(strategy);
@ -190,7 +190,7 @@ TEST_F(TestMatmulInfo, InferTensorMap1) {
// matmul2
TEST_F(TestMatmulInfo, InferTensorMap2) {
Strategys str = {{2, 4, 8, 16}, {1, 16}};
std::vector<Dimensions> str = {{2, 4, 8, 16}, {1, 16}};
StrategyPtr strategy = NewStrategy(0, str);
matmul2->Init(strategy);
@ -216,7 +216,7 @@ TEST_F(TestMatmulInfo, InferTensorMap2) {
// matmul3
TEST_F(TestMatmulInfo, InferTensorMap3) {
Strategys str = {{8, 16}, {2, 4, 1, 16}};
std::vector<Dimensions> str = {{8, 16}, {2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, str);
matmul3->Init(strategy);
@ -241,7 +241,7 @@ TEST_F(TestMatmulInfo, InferTensorMap3) {
}
TEST_F(TestMatmulInfo, InferSliceShape1) {
Strategys str = {{2, 4, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> str = {{2, 4, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, str);
matmul1->Init(strategy);
@ -267,7 +267,7 @@ TEST_F(TestMatmulInfo, InferSliceShape1) {
// matmul2
TEST_F(TestMatmulInfo, InferSliceShape2) {
Strategys str = {{2, 4, 8, 16}, {1, 16}};
std::vector<Dimensions> str = {{2, 4, 8, 16}, {1, 16}};
StrategyPtr strategy = NewStrategy(0, str);
matmul2->Init(strategy);
@ -293,7 +293,7 @@ TEST_F(TestMatmulInfo, InferSliceShape2) {
// matmul3
TEST_F(TestMatmulInfo, InferSliceShape3) {
Strategys str = {{8, 16}, {2, 4, 1, 16}};
std::vector<Dimensions> str = {{8, 16}, {2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, str);
matmul3->Init(strategy);
@ -319,7 +319,7 @@ TEST_F(TestMatmulInfo, InferSliceShape3) {
// matmul3
TEST_F(TestMatmulInfo, GetTensorLayout3) {
Strategys str = {{8, 16}, {2, 4, 1, 16}};
std::vector<Dimensions> str = {{8, 16}, {2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, str);
matmul3->Init(strategy);
@ -344,7 +344,7 @@ TEST_F(TestMatmulInfo, GetTensorLayout3) {
}
TEST_F(TestMatmulInfo, GetForwardOp1) {
Strategys inputs = {{2, 4, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
matmul1->Init(strategy);
@ -370,7 +370,7 @@ TEST_F(TestMatmulInfo, GetForwardOp1) {
}
TEST_F(TestMatmulInfo, GetForwardOp2) {
Strategys inputs = {{2, 4, 8, 1}, {2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 8, 1}, {2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
matmul1->Init(strategy);
@ -380,7 +380,7 @@ TEST_F(TestMatmulInfo, GetForwardOp2) {
}
TEST_F(TestMatmulInfo, GetVirtualDivOp1) {
Strategys inputs = {{2, 4, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
matmul1->Init(strategy);
@ -399,7 +399,7 @@ TEST_F(TestMatmulInfo, GetVirtualDivOp1) {
}
TEST_F(TestMatmulInfo, GetMirrorOPs1) {
Strategys inputs = {{2, 4, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
matmul1->Init(strategy);
@ -419,7 +419,7 @@ TEST_F(TestMatmulInfo, GetMirrorOPs1) {
// matmul2
TEST_F(TestMatmulInfo, GetMirrorOPs2) {
Strategys inputs = {{2, 4, 1, 16}, {8, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}, {8, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
matmul2->Init(strategy);
@ -439,7 +439,7 @@ TEST_F(TestMatmulInfo, GetMirrorOPs2) {
// matmul3
TEST_F(TestMatmulInfo, GetMirrorOPs3) {
Strategys inputs = {{8, 16}, {2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{8, 16}, {2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
matmul3->Init(strategy);
@ -457,7 +457,7 @@ TEST_F(TestMatmulInfo, GetMirrorOPs3) {
}
TEST_F(TestMatmulInfo, GetMirrorOPs4) {
Strategys inputs = {{2, 4, 1, 16}, {2, 4, 16, 8}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}, {2, 4, 16, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
matmul1->Init(strategy);
@ -467,7 +467,7 @@ TEST_F(TestMatmulInfo, GetMirrorOPs4) {
}
TEST_F(TestMatmulInfo, InitTwice) {
Strategys inputs = {{2, 4, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
// init twice
@ -489,7 +489,7 @@ TEST_F(TestMatmulInfo, InitTwice) {
TEST_F(TestMatmulInfo, CheckStrategy1) {
// Success: {{2,4,8,16}, {2,4,16,1}}
Strategys inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = matmul1->Init(strategy);
@ -498,7 +498,7 @@ TEST_F(TestMatmulInfo, CheckStrategy1) {
TEST_F(TestMatmulInfo, CheckStrategy2) {
// Success: {{2,4,8,16}, {2,4,16,1}}
Strategys inputs = {{2, 4, 8, 16}, {4, 16, 1}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}, {4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = matmul1->Init(strategy);
@ -507,7 +507,7 @@ TEST_F(TestMatmulInfo, CheckStrategy2) {
TEST_F(TestMatmulInfo, CheckStrategy3) {
// Success: {{2,4,8,16}, {2,4,16,1}}
Strategys inputs = {{2, 4, 8, 16}, {2, 4, 8, 1}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}, {2, 4, 8, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = matmul1->Init(strategy);
@ -516,7 +516,7 @@ TEST_F(TestMatmulInfo, CheckStrategy3) {
TEST_F(TestMatmulInfo, CheckStrategy4) {
// Success: {{2,4,8,16}, {2,4,16,1}}
Strategys inputs = {{2, 4, 8, 16}, {2, 3, 16, 1}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}, {2, 3, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = matmul1->Init(strategy);
@ -525,7 +525,7 @@ TEST_F(TestMatmulInfo, CheckStrategy4) {
TEST_F(TestMatmulInfo, CheckStrategy5) {
// Success: {{2,4,8,16}, {2,4,16,1}}
Strategys inputs = {{0, 4, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{0, 4, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = matmul1->Init(strategy);
@ -534,7 +534,7 @@ TEST_F(TestMatmulInfo, CheckStrategy5) {
TEST_F(TestMatmulInfo, CheckStrategy6) {
// Success: {{2,4,8,16}, {2,4,16,1}}
Strategys inputs = {{-1, 4, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{-1, 4, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = matmul1->Init(strategy);
@ -543,7 +543,7 @@ TEST_F(TestMatmulInfo, CheckStrategy6) {
TEST_F(TestMatmulInfo, CheckStrategy7) {
// Success: {{2,4,8,16}, {2,4,16,1}}
Strategys inputs = {{4, 4, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{4, 4, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = matmul1->Init(strategy);
@ -552,7 +552,7 @@ TEST_F(TestMatmulInfo, CheckStrategy7) {
TEST_F(TestMatmulInfo, InitFailed) {
// matmul4 attr is wrong
Strategys inputs = {{4, 4, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{4, 4, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = matmul4->Init(strategy);

View File

@ -38,13 +38,13 @@ class TestOneHotInfo : public UT::Common {
};
void TestOneHotInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 10; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(8);
stage_map.push_back(2);
@ -64,43 +64,43 @@ void TestOneHotInfo::SetUp() {
}
TEST_F(TestOneHotInfo, InferDevMatrixShape1) {
Strategys inputs = {{8, 1}, {}, {}};
std::vector<Dimensions> inputs = {{8, 1}, {}, {}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status status = onehot_info->Init(strategy);
ASSERT_EQ(status, SUCCESS);
Shape dev_matrix_shape = onehot_info->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = onehot_info->dev_matrix_shape();
Shape expect = {8, 1};
std::vector<int32_t> expect = {8, 1};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestOneHotInfo, InferDevMatrixShape2) {
Strategys inputs = {{4, 1}, {}, {}};
std::vector<Dimensions> inputs = {{4, 1}, {}, {}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status status = onehot_info->Init(strategy);
ASSERT_EQ(status, SUCCESS);
Shape dev_matrix_shape = onehot_info->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = onehot_info->dev_matrix_shape();
Shape expect = {2, 4, 1};
std::vector<int32_t> expect = {2, 4, 1};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestOneHotInfo, InferDevMatrixShape3) {
Strategys inputs = {{4, 2}, {}, {}};
std::vector<Dimensions> inputs = {{4, 2}, {}, {}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status status = onehot_info->Init(strategy);
ASSERT_EQ(status, FAILED);
Shape dev_matrix_shape = onehot_info->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = onehot_info->dev_matrix_shape();
Shape expect = {4, 2};
std::vector<int32_t> expect = {4, 2};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestOneHotInfo, InferTensorMap2) {
Strategys str = {{8, 1}, {}, {}};
std::vector<Dimensions> str = {{8, 1}, {}, {}};
StrategyPtr strategy = NewStrategy(0, str);
Status status = onehot_info->Init(strategy);
@ -122,7 +122,7 @@ TEST_F(TestOneHotInfo, InferTensorMap2) {
}
TEST_F(TestOneHotInfo, InferSliceShape1) {
Strategys str = {{8, 1}, {}, {}};
std::vector<Dimensions> str = {{8, 1}, {}, {}};
StrategyPtr strategy = NewStrategy(0, str);
Status status = onehot_info->Init(strategy);
@ -144,7 +144,7 @@ TEST_F(TestOneHotInfo, InferSliceShape1) {
}
TEST_F(TestOneHotInfo, InferSliceShape2) {
Strategys str = {{4, 2}, {}, {}};
std::vector<Dimensions> str = {{4, 2}, {}, {}};
StrategyPtr strategy = NewStrategy(0, str);
Status status = onehot_info->Init(strategy);
@ -166,7 +166,7 @@ TEST_F(TestOneHotInfo, InferSliceShape2) {
}
TEST_F(TestOneHotInfo, InferSliceShape3) {
Strategys str = {{2, 2}, {}, {}};
std::vector<Dimensions> str = {{2, 2}, {}, {}};
StrategyPtr strategy = NewStrategy(0, str);
Status status = onehot_info->Init(strategy);
@ -188,7 +188,7 @@ TEST_F(TestOneHotInfo, InferSliceShape3) {
}
TEST_F(TestOneHotInfo, GetMirrorOPs1) {
Strategys inputs = {{8, 1}, {}, {}};
std::vector<Dimensions> inputs = {{8, 1}, {}, {}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status status = onehot_info->Init(strategy);
@ -199,7 +199,7 @@ TEST_F(TestOneHotInfo, GetMirrorOPs1) {
}
TEST_F(TestOneHotInfo, CheckStrategy1) {
Strategys inputs = {{16}, {}, {}};
std::vector<Dimensions> inputs = {{16}, {}, {}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = onehot_info->Init(strategy);

View File

@ -38,13 +38,13 @@ class TestOneHotInfo2 : public UT::Common {
};
void TestOneHotInfo2::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 10; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(8);
stage_map.push_back(2);
@ -64,43 +64,43 @@ void TestOneHotInfo2::SetUp() {
}
TEST_F(TestOneHotInfo2, InferDevMatrixShape1) {
Strategys inputs = {{1, 8}, {}, {}};
std::vector<Dimensions> inputs = {{1, 8}, {}, {}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status status = onehot_info2->Init(strategy);
ASSERT_EQ(status, SUCCESS);
Shape dev_matrix_shape = onehot_info2->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = onehot_info2->dev_matrix_shape();
Shape expect = {8, 1};
std::vector<int32_t> expect = {8, 1};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestOneHotInfo2, InferDevMatrixShape2) {
Strategys inputs = {{1, 4}, {}, {}};
std::vector<Dimensions> inputs = {{1, 4}, {}, {}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status status = onehot_info2->Init(strategy);
ASSERT_EQ(status, SUCCESS);
Shape dev_matrix_shape = onehot_info2->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = onehot_info2->dev_matrix_shape();
Shape expect = {2, 4, 1};
std::vector<int32_t> expect = {2, 4, 1};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestOneHotInfo2, InferDevMatrixShape3) {
Strategys inputs = {{2, 4}, {}, {}};
std::vector<Dimensions> inputs = {{2, 4}, {}, {}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status status = onehot_info2->Init(strategy);
ASSERT_EQ(status, FAILED);
Shape dev_matrix_shape = onehot_info2->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = onehot_info2->dev_matrix_shape();
Shape expect = {4, 2};
std::vector<int32_t> expect = {4, 2};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestOneHotInfo2, InferTensorMap2) {
Strategys str = {{1, 8}, {}, {}};
std::vector<Dimensions> str = {{1, 8}, {}, {}};
StrategyPtr strategy = NewStrategy(0, str);
Status status = onehot_info2->Init(strategy);
@ -122,7 +122,7 @@ TEST_F(TestOneHotInfo2, InferTensorMap2) {
}
TEST_F(TestOneHotInfo2, InferSliceShape1) {
Strategys str = {{1, 8}, {}, {}};
std::vector<Dimensions> str = {{1, 8}, {}, {}};
StrategyPtr strategy = NewStrategy(0, str);
Status status = onehot_info2->Init(strategy);
@ -144,7 +144,7 @@ TEST_F(TestOneHotInfo2, InferSliceShape1) {
}
TEST_F(TestOneHotInfo2, InferSliceShape2) {
Strategys str = {{2, 4}, {}, {}};
std::vector<Dimensions> str = {{2, 4}, {}, {}};
StrategyPtr strategy = NewStrategy(0, str);
Status status = onehot_info2->Init(strategy);
@ -166,7 +166,7 @@ TEST_F(TestOneHotInfo2, InferSliceShape2) {
}
TEST_F(TestOneHotInfo2, InferSliceShape3) {
Strategys str = {{2, 2}, {}, {}};
std::vector<Dimensions> str = {{2, 2}, {}, {}};
StrategyPtr strategy = NewStrategy(0, str);
Status status = onehot_info2->Init(strategy);

View File

@ -38,13 +38,13 @@ class TestPowInfo : public UT::Common {
};
void TestPowInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 66; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(64);
stage_map.push_back(2);
@ -63,18 +63,18 @@ void TestPowInfo::SetUp() {
}
TEST_F(TestPowInfo, InferDevMatrixShape1) {
Strategys inputs = {{2, 4, 8}, {2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}, {2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
pow->Init(strategy);
Shape dev_matrix_shape = pow->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = pow->dev_matrix_shape();
Shape expect = {2, 4, 8};
std::vector<int32_t> expect = {2, 4, 8};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestPowInfo, InferSliceShape1) {
Strategys str = {{2, 4, 8}, {2, 4, 8}};
std::vector<Dimensions> str = {{2, 4, 8}, {2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, str);
pow->Init(strategy);
@ -95,7 +95,7 @@ TEST_F(TestPowInfo, InferSliceShape1) {
}
TEST_F(TestPowInfo, GetTensorLayout1) {
Strategys str = {{2, 4, 8}, {2, 4, 8}};
std::vector<Dimensions> str = {{2, 4, 8}, {2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, str);
pow->Init(strategy);
@ -116,7 +116,7 @@ TEST_F(TestPowInfo, GetTensorLayout1) {
}
TEST_F(TestPowInfo, GetForwardOp1) {
Strategys inputs = {{2, 4, 8}, {2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}, {2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
pow->Init(strategy);
@ -127,7 +127,7 @@ TEST_F(TestPowInfo, GetForwardOp1) {
}
TEST_F(TestPowInfo, GetMirrorOPs1) {
Strategys inputs = {{2, 4, 8}, {2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}, {2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
pow->Init(strategy);
@ -139,7 +139,7 @@ TEST_F(TestPowInfo, GetMirrorOPs1) {
}
TEST_F(TestPowInfo, CheckStrategy1) {
Strategys inputs = {{2, 2, 8}, {2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 2, 8}, {2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = pow->Init(strategy);
@ -147,7 +147,7 @@ TEST_F(TestPowInfo, CheckStrategy1) {
}
TEST_F(TestPowInfo, CheckStrategy2) {
Strategys inputs = {{2, 4, 8, 16}, {2, 4, 8, 16}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}, {2, 4, 8, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = pow->Init(strategy);
@ -155,7 +155,7 @@ TEST_F(TestPowInfo, CheckStrategy2) {
}
TEST_F(TestPowInfo, CheckStrategy3) {
Strategys inputs = {{2, 4, 8}, {2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}, {2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = pow->Init(strategy);

View File

@ -39,13 +39,13 @@ class TestPReLUInfo : public UT::Common {
};
void TestPReLUInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 1050; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(1024);
stage_map.push_back(26);
int32_t local_dev = 0;
@ -64,18 +64,18 @@ void TestPReLUInfo::SetUp() {
}
TEST_F(TestPReLUInfo, InferDevMatrixShape1) {
Strategys inputs = {{2, 1, 8, 16}, {1}};
std::vector<Dimensions> inputs = {{2, 1, 8, 16}, {1}};
StrategyPtr strategy = NewStrategy(0, inputs);
prelu->Init(strategy);
Shape dev_matrix_shape = prelu->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = prelu->dev_matrix_shape();
Shape expect = {4, 2, 1, 8, 16};
std::vector<int32_t> expect = {4, 2, 1, 8, 16};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestPReLUInfo, InferSliceShape1) {
Strategys str = {{2, 1, 8, 16}, {1}};
std::vector<Dimensions> str = {{2, 1, 8, 16}, {1}};
StrategyPtr strategy = NewStrategy(0, str);
prelu->Init(strategy);
@ -98,7 +98,7 @@ TEST_F(TestPReLUInfo, InferSliceShape1) {
}
TEST_F(TestPReLUInfo, GetTensorLayout1) {
Strategys str = {{2, 1, 8, 16}, {1}};
std::vector<Dimensions> str = {{2, 1, 8, 16}, {1}};
StrategyPtr strategy = NewStrategy(0, str);
prelu->Init(strategy);
@ -122,7 +122,7 @@ TEST_F(TestPReLUInfo, GetTensorLayout1) {
}
TEST_F(TestPReLUInfo, GetMirrorOPs1) {
Strategys str = {{2, 1, 2, 2}, {1}};
std::vector<Dimensions> str = {{2, 1, 2, 2}, {1}};
StrategyPtr strategy = NewStrategy(0, str);
prelu->Init(strategy);
MirrorOps mirror_ops = prelu->mirror_ops();
@ -139,14 +139,14 @@ TEST_F(TestPReLUInfo, GetMirrorOPs1) {
TEST_F(TestPReLUInfo, CheckStrategy1) {
// Success: {{2,1,8,16},{1}}
Strategys inputs = {{2, 1, 8, 16}};
std::vector<Dimensions> inputs = {{2, 1, 8, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = prelu->Init(strategy);
ASSERT_EQ(ret, FAILED);
}
TEST_F(TestPReLUInfo, CheckStrategy2) {
Strategys inputs = {{2, 4, 8, 16}, {4}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}, {4}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = prelu->Init(strategy);
ASSERT_EQ(ret, SUCCESS);
@ -169,18 +169,18 @@ TEST_F(TestPReLUInfo, AutoStrategy1) {
}
TEST_F(TestPReLUInfo, InferDevMatrixShape_2d1) {
Strategys inputs = {{128, 1}, {1}};
std::vector<Dimensions> inputs = {{128, 1}, {1}};
StrategyPtr strategy = NewStrategy(0, inputs);
prelu_2d->Init(strategy);
Shape dev_matrix_shape = prelu_2d->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = prelu_2d->dev_matrix_shape();
Shape expect = {8, 128, 1};
std::vector<int32_t> expect = {8, 128, 1};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestPReLUInfo, InferSliceShape_2d1) {
Strategys str = {{128, 1}, {1}};
std::vector<Dimensions> str = {{128, 1}, {1}};
StrategyPtr strategy = NewStrategy(0, str);
prelu_2d->Init(strategy);
@ -203,7 +203,7 @@ TEST_F(TestPReLUInfo, InferSliceShape_2d1) {
}
TEST_F(TestPReLUInfo, GetTensorLayout_2d1) {
Strategys str = {{128, 1}, {1}};
std::vector<Dimensions> str = {{128, 1}, {1}};
StrategyPtr strategy = NewStrategy(0, str);
prelu_2d->Init(strategy);
@ -227,7 +227,7 @@ TEST_F(TestPReLUInfo, GetTensorLayout_2d1) {
}
TEST_F(TestPReLUInfo, GetMirrorOPs_2d1) {
Strategys str = {{128, 1}, {1}};
std::vector<Dimensions> str = {{128, 1}, {1}};
StrategyPtr strategy = NewStrategy(0, str);
prelu_2d->Init(strategy);
MirrorOps mirror_ops = prelu_2d->mirror_ops();
@ -244,14 +244,14 @@ TEST_F(TestPReLUInfo, GetMirrorOPs_2d1) {
TEST_F(TestPReLUInfo, CheckStrategy_2d1) {
// Success: {{2,1,8,16},{1}}
Strategys inputs = {{128, 1}};
std::vector<Dimensions> inputs = {{128, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = prelu_2d->Init(strategy);
ASSERT_EQ(ret, FAILED);
}
TEST_F(TestPReLUInfo, CheckStrategy_2d2) {
Strategys inputs = {{128, 4}, {4}};
std::vector<Dimensions> inputs = {{128, 4}, {4}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = prelu_2d->Init(strategy);
ASSERT_EQ(ret, SUCCESS);

View File

@ -39,13 +39,13 @@ class TestReduceSumInfo : public UT::Common {
void TestReduceSumInfo::SetUp() {
UT::InitPythonPath();
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 34; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(32);
stage_map.push_back(2);
@ -68,18 +68,18 @@ void TestReduceSumInfo::SetUp() {
}
TEST_F(TestReduceSumInfo, InferDevMatrixShape1) {
Strategys inputs = {{4, 8, 1}};
std::vector<Dimensions> inputs = {{4, 8, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
reduce_sum->Init(strategy);
Shape dev_matrix_shape = reduce_sum->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = reduce_sum->dev_matrix_shape();
Shape expect = {4, 8, 1};
std::vector<int32_t> expect = {4, 8, 1};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestReduceSumInfo, InferSliceShape1) {
Strategys str = {{4, 8, 1}};
std::vector<Dimensions> str = {{4, 8, 1}};
StrategyPtr strategy = NewStrategy(0, str);
reduce_sum->Init(strategy);
@ -100,7 +100,7 @@ TEST_F(TestReduceSumInfo, InferSliceShape1) {
}
TEST_F(TestReduceSumInfo, GetTensorLayout1) {
Strategys str = {{4, 8, 1}};
std::vector<Dimensions> str = {{4, 8, 1}};
StrategyPtr strategy = NewStrategy(0, str);
reduce_sum->Init(strategy);
@ -121,7 +121,7 @@ TEST_F(TestReduceSumInfo, GetTensorLayout1) {
}
TEST_F(TestReduceSumInfo, GetForwardOp1) {
Strategys inputs = {{4, 8, 1}};
std::vector<Dimensions> inputs = {{4, 8, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
reduce_sum->Init(strategy);
@ -132,7 +132,7 @@ TEST_F(TestReduceSumInfo, GetForwardOp1) {
}
TEST_F(TestReduceSumInfo, GetForwardOp2) {
Strategys inputs = {{4, 4, 2}};
std::vector<Dimensions> inputs = {{4, 4, 2}};
StrategyPtr strategy = NewStrategy(0, inputs);
reduce_sum->Init(strategy);
@ -156,7 +156,7 @@ TEST_F(TestReduceSumInfo, GetForwardOp2) {
}
TEST_F(TestReduceSumInfo, GetMirrorOPs1) {
Strategys inputs = {{4, 8, 1}};
std::vector<Dimensions> inputs = {{4, 8, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
reduce_sum->Init(strategy);
@ -168,7 +168,7 @@ TEST_F(TestReduceSumInfo, GetMirrorOPs1) {
}
TEST_F(TestReduceSumInfo, GetMirrorOPs2) {
Strategys inputs = {{4, 4, 1}};
std::vector<Dimensions> inputs = {{4, 4, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
reduce_sum->Init(strategy);
@ -187,7 +187,7 @@ TEST_F(TestReduceSumInfo, GetMirrorOPs2) {
}
TEST_F(TestReduceSumInfo, CheckStrategy1) {
Strategys inputs = {{2, 2, 8, 16}};
std::vector<Dimensions> inputs = {{2, 2, 8, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = reduce_sum->Init(strategy);
@ -195,7 +195,7 @@ TEST_F(TestReduceSumInfo, CheckStrategy1) {
}
TEST_F(TestReduceSumInfo, CheckStrategy2) {
Strategys inputs = {{2, 4, 8}, {2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}, {2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = reduce_sum->Init(strategy);
@ -203,7 +203,7 @@ TEST_F(TestReduceSumInfo, CheckStrategy2) {
}
TEST_F(TestReduceSumInfo, CheckStrategy3) {
Strategys inputs = {{4, 4, 2}};
std::vector<Dimensions> inputs = {{4, 4, 2}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = reduce_sum->Init(strategy);
@ -211,7 +211,7 @@ TEST_F(TestReduceSumInfo, CheckStrategy3) {
}
TEST_F(TestReduceSumInfo, CheckStrategy4) {
Strategys inputs = {{4, 8, 1}};
std::vector<Dimensions> inputs = {{4, 8, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = reduce_sum->Init(strategy);

View File

@ -38,13 +38,13 @@ class TestReshapeInfo : public UT::Common {
};
void TestReshapeInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 34; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(32);
stage_map.push_back(2);
@ -68,29 +68,29 @@ void TestReshapeInfo::SetUp() {
}
TEST_F(TestReshapeInfo, InferDevMatrixShape1) {
Strategys inputs = {{4, 1, 1, 1}};
std::vector<Dimensions> inputs = {{4, 1, 1, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
reshape->Init(strategy);
Shape dev_matrix_shape = reshape->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = reshape->dev_matrix_shape();
Shape expect = {8, 4};
std::vector<int32_t> expect = {8, 4};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestReshapeInfo, InferDevMatrixShape2) {
Strategys inputs = {{32, 1, 1, 1}};
std::vector<Dimensions> inputs = {{32, 1, 1, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
reshape->Init(strategy);
Shape dev_matrix_shape = reshape->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = reshape->dev_matrix_shape();
Shape expect = {32};
std::vector<int32_t> expect = {32};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestReshapeInfo, InferSliceShape1) {
Strategys str = {{4, 1, 1, 1}};
std::vector<Dimensions> str = {{4, 1, 1, 1}};
StrategyPtr strategy = NewStrategy(0, str);
reshape->Init(strategy);
@ -111,7 +111,7 @@ TEST_F(TestReshapeInfo, InferSliceShape1) {
}
TEST_F(TestReshapeInfo, InferSliceShape2) {
Strategys str = {{32, 1, 1, 1}};
std::vector<Dimensions> str = {{32, 1, 1, 1}};
StrategyPtr strategy = NewStrategy(0, str);
reshape->Init(strategy);
@ -132,7 +132,7 @@ TEST_F(TestReshapeInfo, InferSliceShape2) {
}
TEST_F(TestReshapeInfo, GetTensorLayout1) {
Strategys str = {{4, 1, 1, 1}};
std::vector<Dimensions> str = {{4, 1, 1, 1}};
StrategyPtr strategy = NewStrategy(0, str);
reshape->Init(strategy);
@ -153,7 +153,7 @@ TEST_F(TestReshapeInfo, GetTensorLayout1) {
}
TEST_F(TestReshapeInfo, GetTensorLayout2) {
Strategys str = {{32, 1, 1, 1}};
std::vector<Dimensions> str = {{32, 1, 1, 1}};
StrategyPtr strategy = NewStrategy(0, str);
reshape->Init(strategy);
@ -174,7 +174,7 @@ TEST_F(TestReshapeInfo, GetTensorLayout2) {
}
TEST_F(TestReshapeInfo, GetForwardOp1) {
Strategys inputs = {{4, 1, 1, 1}};
std::vector<Dimensions> inputs = {{4, 1, 1, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
reshape->Init(strategy);
@ -185,7 +185,7 @@ TEST_F(TestReshapeInfo, GetForwardOp1) {
}
TEST_F(TestReshapeInfo, GetMirrorOPs1) {
Strategys inputs = {{4, 1, 1, 1}};
std::vector<Dimensions> inputs = {{4, 1, 1, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
reshape->Init(strategy);
@ -197,7 +197,7 @@ TEST_F(TestReshapeInfo, GetMirrorOPs1) {
}
TEST_F(TestReshapeInfo, CheckStrategy1) {
Strategys inputs = {{1, 4, 8}};
std::vector<Dimensions> inputs = {{1, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = reshape->Init(strategy);
@ -205,7 +205,7 @@ TEST_F(TestReshapeInfo, CheckStrategy1) {
}
TEST_F(TestReshapeInfo, CheckStrategy2) {
Strategys inputs = {{2, 4, 8}, {2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}, {2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = reshape->Init(strategy);
@ -213,7 +213,7 @@ TEST_F(TestReshapeInfo, CheckStrategy2) {
}
TEST_F(TestReshapeInfo, CheckStrategy3) {
Strategys inputs = {{4, 1, 1, 1}};
std::vector<Dimensions> inputs = {{4, 1, 1, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = reshape->Init(strategy);

View File

@ -38,13 +38,13 @@ class TestSoftmaxLoss : public UT::Common {
};
void TestSoftmaxLoss::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 65; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(64);
stage_map.push_back(1);
@ -64,18 +64,18 @@ void TestSoftmaxLoss::SetUp() {
}
TEST_F(TestSoftmaxLoss, InferDevMatrixShape1) {
Strategys inputs = {{2, 4, 8, 1}, {2, 4, 8, 1}};
std::vector<Dimensions> inputs = {{2, 4, 8, 1}, {2, 4, 8, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
loss->Init(strategy);
Shape dev_matrix_shape = loss->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = loss->dev_matrix_shape();
Shape expect = {2, 4, 8, 1};
std::vector<int32_t> expect = {2, 4, 8, 1};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestSoftmaxLoss, InferSliceShape1) {
Strategys str = {{2, 4, 8, 1}, {2, 4, 8, 1}};
std::vector<Dimensions> str = {{2, 4, 8, 1}, {2, 4, 8, 1}};
StrategyPtr strategy = NewStrategy(0, str);
loss->Init(strategy);
@ -104,7 +104,7 @@ TEST_F(TestSoftmaxLoss, InferSliceShape1) {
}
TEST_F(TestSoftmaxLoss, GetTensorLayout1) {
Strategys str = {{2, 4, 8, 1}, {2, 4, 8, 1}};
std::vector<Dimensions> str = {{2, 4, 8, 1}, {2, 4, 8, 1}};
StrategyPtr strategy = NewStrategy(0, str);
loss->Init(strategy);
@ -133,7 +133,7 @@ TEST_F(TestSoftmaxLoss, GetTensorLayout1) {
}
TEST_F(TestSoftmaxLoss, GetForwardOp1) {
Strategys inputs = {{2, 4, 8, 1}, {2, 4, 8, 1}};
std::vector<Dimensions> inputs = {{2, 4, 8, 1}, {2, 4, 8, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
loss->Init(strategy);
@ -144,7 +144,7 @@ TEST_F(TestSoftmaxLoss, GetForwardOp1) {
}
TEST_F(TestSoftmaxLoss, GetMirrorOPs1) {
Strategys inputs = {{2, 4, 8, 1}, {2, 4, 8, 1}};
std::vector<Dimensions> inputs = {{2, 4, 8, 1}, {2, 4, 8, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
loss->Init(strategy);
@ -156,7 +156,7 @@ TEST_F(TestSoftmaxLoss, GetMirrorOPs1) {
}
TEST_F(TestSoftmaxLoss, GetVirtualDivOPs1) {
Strategys inputs = {{1, 4, 8, 1}, {1, 4, 8, 1}};
std::vector<Dimensions> inputs = {{1, 4, 8, 1}, {1, 4, 8, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
loss->Init(strategy);
@ -176,7 +176,7 @@ TEST_F(TestSoftmaxLoss, GetVirtualDivOPs1) {
TEST_F(TestSoftmaxLoss, CheckStrategy1) {
// Success: {{2,4,8,16}}
Strategys inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = loss->Init(strategy);
@ -185,7 +185,7 @@ TEST_F(TestSoftmaxLoss, CheckStrategy1) {
TEST_F(TestSoftmaxLoss, CheckStrategy2) {
// Success: {{2,4,8,16}}
Strategys inputs = {{2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = loss->Init(strategy);

View File

@ -39,13 +39,13 @@ class TestSoftmaxInfo : public UT::Common {
};
void TestSoftmaxInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 130; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(128);
stage_map.push_back(2);
@ -68,18 +68,18 @@ void TestSoftmaxInfo::SetUp() {
}
TEST_F(TestSoftmaxInfo, InferDevMatrixShape1) {
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
softmax->Init(strategy);
Shape dev_matrix_shape = softmax->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = softmax->dev_matrix_shape();
Shape expect = {2, 4, 1, 16};
std::vector<int32_t> expect = {2, 4, 1, 16};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestSoftmaxInfo, InferSliceShape1) {
Strategys str = {{2, 4, 1, 16}};
std::vector<Dimensions> str = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, str);
softmax->Init(strategy);
@ -100,7 +100,7 @@ TEST_F(TestSoftmaxInfo, InferSliceShape1) {
}
TEST_F(TestSoftmaxInfo, GetTensorLayout1) {
Strategys str = {{2, 4, 1, 16}};
std::vector<Dimensions> str = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, str);
softmax->Init(strategy);
@ -121,7 +121,7 @@ TEST_F(TestSoftmaxInfo, GetTensorLayout1) {
}
TEST_F(TestSoftmaxInfo, GetForwardOp1) {
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
softmax->Init(strategy);
@ -132,7 +132,7 @@ TEST_F(TestSoftmaxInfo, GetForwardOp1) {
}
TEST_F(TestSoftmaxInfo, GetMirrorOPs1) {
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
softmax->Init(strategy);
@ -145,7 +145,7 @@ TEST_F(TestSoftmaxInfo, GetMirrorOPs1) {
TEST_F(TestSoftmaxInfo, CheckStrategy1) {
// Success: {{2,4,1,16}}
Strategys inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = softmax->Init(strategy);
@ -154,7 +154,7 @@ TEST_F(TestSoftmaxInfo, CheckStrategy1) {
TEST_F(TestSoftmaxInfo, CheckStrategy2) {
// Success: {{2,4,1,16}}
Strategys inputs = {{2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = softmax->Init(strategy);
@ -163,7 +163,7 @@ TEST_F(TestSoftmaxInfo, CheckStrategy2) {
TEST_F(TestSoftmaxInfo, CheckStrategy3) {
// Success: {{2,4,1,16}}
Strategys inputs = {{2, 4, 8, 16}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = softmax->Init(strategy);
@ -172,7 +172,7 @@ TEST_F(TestSoftmaxInfo, CheckStrategy3) {
TEST_F(TestSoftmaxInfo, InitFailed1) {
// softmax2's axis is wrong
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = softmax2->Init(strategy);
@ -181,7 +181,7 @@ TEST_F(TestSoftmaxInfo, InitFailed1) {
TEST_F(TestSoftmaxInfo, InitFailed2) {
// dev num is wrong
Strategys inputs = {{2, 4, 1, 100}};
std::vector<Dimensions> inputs = {{2, 4, 1, 100}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = softmax2->Init(strategy);

View File

@ -38,13 +38,13 @@ class TestTanhInfo : public UT::Common {
};
void TestTanhInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 130; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(128);
stage_map.push_back(2);
@ -63,18 +63,18 @@ void TestTanhInfo::SetUp() {
}
TEST_F(TestTanhInfo, InferDevMatrixShape1) {
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
tanh->Init(strategy);
Shape dev_matrix_shape = tanh->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = tanh->dev_matrix_shape();
Shape expect = {2, 4, 1, 16};
std::vector<int32_t> expect = {2, 4, 1, 16};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestTanhInfo, InferSliceShape1) {
Strategys str = {{2, 4, 1, 16}};
std::vector<Dimensions> str = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, str);
tanh->Init(strategy);
@ -95,7 +95,7 @@ TEST_F(TestTanhInfo, InferSliceShape1) {
}
TEST_F(TestTanhInfo, GetTensorLayout1) {
Strategys str = {{2, 4, 1, 16}};
std::vector<Dimensions> str = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, str);
tanh->Init(strategy);
@ -116,7 +116,7 @@ TEST_F(TestTanhInfo, GetTensorLayout1) {
}
TEST_F(TestTanhInfo, GetForwardOp1) {
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
tanh->Init(strategy);
@ -127,7 +127,7 @@ TEST_F(TestTanhInfo, GetForwardOp1) {
}
TEST_F(TestTanhInfo, GetMirrorOPs1) {
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
tanh->Init(strategy);
@ -140,7 +140,7 @@ TEST_F(TestTanhInfo, GetMirrorOPs1) {
TEST_F(TestTanhInfo, CheckStrategy1) {
// Success: {{2,4,1,16}}
Strategys inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = tanh->Init(strategy);
@ -149,7 +149,7 @@ TEST_F(TestTanhInfo, CheckStrategy1) {
TEST_F(TestTanhInfo, CheckStrategy2) {
// Success: {{2,4,1,16}}
Strategys inputs = {{2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = tanh->Init(strategy);
@ -158,7 +158,7 @@ TEST_F(TestTanhInfo, CheckStrategy2) {
TEST_F(TestTanhInfo, CheckStrategy3) {
// Success: {{2,4,1,16}}
Strategys inputs = {{2, 4, 1, 16}};
std::vector<Dimensions> inputs = {{2, 4, 1, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = tanh->Init(strategy);

View File

@ -38,13 +38,13 @@ class TestTensorAddInfo : public UT::Common {
};
void TestTensorAddInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 34; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(32);
stage_map.push_back(2);
@ -66,18 +66,18 @@ void TestTensorAddInfo::SetUp() {
}
TEST_F(TestTensorAddInfo, InferDevMatrixShape1) {
Strategys inputs = {{2, 4, 4}, {2, 4, 4}};
std::vector<Dimensions> inputs = {{2, 4, 4}, {2, 4, 4}};
StrategyPtr strategy = NewStrategy(0, inputs);
tensor_add->Init(strategy);
Shape dev_matrix_shape = tensor_add->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = tensor_add->dev_matrix_shape();
Shape expect = {2, 4, 4};
std::vector<int32_t> expect = {2, 4, 4};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestTensorAddInfo, InferSliceShape1) {
Strategys str = {{2, 4, 4}, {2, 4, 4}};
std::vector<Dimensions> str = {{2, 4, 4}, {2, 4, 4}};
StrategyPtr strategy = NewStrategy(0, str);
tensor_add->Init(strategy);
@ -101,7 +101,7 @@ TEST_F(TestTensorAddInfo, InferSliceShape1) {
}
TEST_F(TestTensorAddInfo, GetTensorLayout1) {
Strategys str = {{2, 4, 4}, {2, 4, 4}};
std::vector<Dimensions> str = {{2, 4, 4}, {2, 4, 4}};
StrategyPtr strategy = NewStrategy(0, str);
tensor_add->Init(strategy);
@ -125,7 +125,7 @@ TEST_F(TestTensorAddInfo, GetTensorLayout1) {
}
TEST_F(TestTensorAddInfo, GetForwardOp1) {
Strategys inputs = {{2, 4, 4}, {2, 4, 4}};
std::vector<Dimensions> inputs = {{2, 4, 4}, {2, 4, 4}};
StrategyPtr strategy = NewStrategy(0, inputs);
tensor_add->Init(strategy);
@ -136,7 +136,7 @@ TEST_F(TestTensorAddInfo, GetForwardOp1) {
}
TEST_F(TestTensorAddInfo, GetMirrorOPs1) {
Strategys inputs = {{2, 4, 4}, {2, 4, 4}};
std::vector<Dimensions> inputs = {{2, 4, 4}, {2, 4, 4}};
StrategyPtr strategy = NewStrategy(0, inputs);
tensor_add->Init(strategy);
@ -148,7 +148,7 @@ TEST_F(TestTensorAddInfo, GetMirrorOPs1) {
}
TEST_F(TestTensorAddInfo, CheckStrategy1) {
Strategys inputs = {{2, 4, 4}, {2, 6, 4}};
std::vector<Dimensions> inputs = {{2, 4, 4}, {2, 6, 4}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = tensor_add->Init(strategy);
@ -156,7 +156,7 @@ TEST_F(TestTensorAddInfo, CheckStrategy1) {
}
TEST_F(TestTensorAddInfo, CheckStrategy2) {
Strategys inputs = {{2, 4, 8}, {2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}, {2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = tensor_add->Init(strategy);
@ -164,7 +164,7 @@ TEST_F(TestTensorAddInfo, CheckStrategy2) {
}
TEST_F(TestTensorAddInfo, CheckStrategy3) {
Strategys inputs = {{2, 4, 6}};
std::vector<Dimensions> inputs = {{2, 4, 6}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = tensor_add->Init(strategy);
@ -172,7 +172,7 @@ TEST_F(TestTensorAddInfo, CheckStrategy3) {
}
TEST_F(TestTensorAddInfo, CheckStrategy4) {
Strategys inputs = {{2, 4, 4}, {2, 4, 4}};
std::vector<Dimensions> inputs = {{2, 4, 4}, {2, 4, 4}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = tensor_add->Init(strategy);
@ -224,7 +224,7 @@ TEST_F(TestTensorAddInfo, GenerateStrategies1) {
}
TEST_F(TestTensorAddInfo, mirror_ops) {
Strategys inputs = {{1, 8}, {4, 1}};
std::vector<Dimensions> inputs = {{1, 8}, {4, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
tensor_add1->Init(strategy);

View File

@ -19,7 +19,6 @@
#include "frontend/parallel/device_manager.h"
#include "frontend/parallel/ops_info/operator_info.h"
#include "frontend/parallel/ops_info/tmp_identity_info.h"
#include "frontend/parallel/step_parallel.h"
namespace mindspore {
namespace parallel {
@ -27,6 +26,7 @@ namespace parallel {
class TmpIdentityInfo;
using TmpIdentityInfoPtr = std::shared_ptr<TmpIdentityInfo>;
TmpIdentityInfoPtr identity_ptr;
using TensorMap = std::vector<int32_t>;
class TestTmpIdentityInfo : public UT::Common {
public:
@ -38,13 +38,13 @@ class TestTmpIdentityInfo : public UT::Common {
};
void TestTmpIdentityInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 1050; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(1024);
stage_map.push_back(26);
@ -65,18 +65,18 @@ void TestTmpIdentityInfo::SetUp() {
}
TEST_F(TestTmpIdentityInfo, InferDevMatrixShape1) {
Strategys inputs = {{2, 4, 8, 16}};
std::vector<Dimensions> inputs = {{2, 4, 8, 16}};
StrategyPtr strategy = NewStrategy(0, inputs);
identity_ptr->Init(strategy);
Shape dev_matrix_shape = identity_ptr->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = identity_ptr->dev_matrix_shape();
Shape expect = {2, 4, 8, 16};
std::vector<int32_t> expect = {2, 4, 8, 16};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestTmpIdentityInfo, InferSliceShape1) {
Strategys str = {{2, 4, 8, 16}};
std::vector<Dimensions> str = {{2, 4, 8, 16}};
StrategyPtr strategy = NewStrategy(0, str);
identity_ptr->Init(strategy);
@ -97,7 +97,7 @@ TEST_F(TestTmpIdentityInfo, InferSliceShape1) {
}
TEST_F(TestTmpIdentityInfo, GetTensorLayout1) {
Strategys str = {{2, 4, 8, 16}};
std::vector<Dimensions> str = {{2, 4, 8, 16}};
StrategyPtr strategy = NewStrategy(0, str);
identity_ptr->Init(strategy);
@ -119,7 +119,7 @@ TEST_F(TestTmpIdentityInfo, GetTensorLayout1) {
TEST_F(TestTmpIdentityInfo, CheckStrategy1) {
// Success: {{2,4,8,16}}
Strategys inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> inputs = {{2, 2, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = identity_ptr->Init(strategy);
@ -128,7 +128,7 @@ TEST_F(TestTmpIdentityInfo, CheckStrategy1) {
TEST_F(TestTmpIdentityInfo, CheckStrategy2) {
// Success: {{2,4,8,16}}
Strategys inputs = {{2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = identity_ptr->Init(strategy);

View File

@ -38,13 +38,13 @@ class TestTransposeInfo : public UT::Common {
};
void TestTransposeInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 34; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(32);
stage_map.push_back(2);
@ -68,29 +68,29 @@ void TestTransposeInfo::SetUp() {
}
TEST_F(TestTransposeInfo, InferDevMatrixShape1) {
Strategys inputs = {{4, 8}};
std::vector<Dimensions> inputs = {{4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
transpose->Init(strategy);
Shape dev_matrix_shape = transpose->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = transpose->dev_matrix_shape();
Shape expect = {4, 8};
std::vector<int32_t> expect = {4, 8};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestTransposeInfo, InferDevMatrixShape2) {
Strategys inputs = {{4, 1}};
std::vector<Dimensions> inputs = {{4, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
transpose->Init(strategy);
Shape dev_matrix_shape = transpose->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = transpose->dev_matrix_shape();
Shape expect = {8, 4, 1};
std::vector<int32_t> expect = {8, 4, 1};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestTransposeInfo, InferSliceShape1) {
Strategys str = {{4, 8}};
std::vector<Dimensions> str = {{4, 8}};
StrategyPtr strategy = NewStrategy(0, str);
transpose->Init(strategy);
@ -111,7 +111,7 @@ TEST_F(TestTransposeInfo, InferSliceShape1) {
}
TEST_F(TestTransposeInfo, GetTensorLayout1) {
Strategys str = {{4, 8}};
std::vector<Dimensions> str = {{4, 8}};
StrategyPtr strategy = NewStrategy(0, str);
transpose->Init(strategy);
@ -132,7 +132,7 @@ TEST_F(TestTransposeInfo, GetTensorLayout1) {
}
TEST_F(TestTransposeInfo, GetForwardOp1) {
Strategys inputs = {{4, 8}};
std::vector<Dimensions> inputs = {{4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
transpose->Init(strategy);
@ -143,7 +143,7 @@ TEST_F(TestTransposeInfo, GetForwardOp1) {
}
TEST_F(TestTransposeInfo, GetMirrorOPs1) {
Strategys inputs = {{4, 8}};
std::vector<Dimensions> inputs = {{4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
transpose->Init(strategy);
@ -155,7 +155,7 @@ TEST_F(TestTransposeInfo, GetMirrorOPs1) {
}
TEST_F(TestTransposeInfo, CheckStrategy1) {
Strategys inputs = {{1, 4, 8}};
std::vector<Dimensions> inputs = {{1, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = transpose->Init(strategy);
@ -163,7 +163,7 @@ TEST_F(TestTransposeInfo, CheckStrategy1) {
}
TEST_F(TestTransposeInfo, CheckStrategy2) {
Strategys inputs = {{2, 4, 8}, {2, 4, 8}};
std::vector<Dimensions> inputs = {{2, 4, 8}, {2, 4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = transpose->Init(strategy);
@ -171,7 +171,7 @@ TEST_F(TestTransposeInfo, CheckStrategy2) {
}
TEST_F(TestTransposeInfo, CheckStrategy3) {
Strategys inputs = {{4, 8}};
std::vector<Dimensions> inputs = {{4, 8}};
StrategyPtr strategy = NewStrategy(0, inputs);
Status ret = transpose->Init(strategy);

View File

@ -32,13 +32,13 @@ class TestStepAutoParallel : public UT::Common {
};
void TestStepAutoParallel::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 20; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(16);
stage_map.push_back(4);

View File

@ -34,13 +34,13 @@ class TestStepParallel : public UT::Common {
void TestStepParallel::SetUp() { UT::InitPythonPath(); }
void Init_Device_Manager() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 20; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(16);
stage_map.push_back(4);
@ -52,26 +52,17 @@ void Init_Device_Manager() {
}
CNodePtr Make_Node(Shape x, Shape y, Shape out, int condition = 0) {
std::vector<int32_t> x_shape;
std::vector<int32_t> y_shape;
std::vector<int32_t> out_shape;
FuncGraphPtr func_graph = std::make_shared<FuncGraph>();
ParameterPtr param1 = func_graph->add_parameter();
ParameterPtr param2 = func_graph->add_parameter();
(void)std::transform(x.begin(), x.end(), std::back_inserter(x_shape),
[](const int64_t &value) { return static_cast<int>(value); });
(void)std::transform(y.begin(), y.end(), std::back_inserter(y_shape),
[](const int64_t &value) { return static_cast<int>(value); });
(void)std::transform(out.begin(), out.end(), std::back_inserter(out_shape),
[](const int64_t &value) { return static_cast<int>(value); });
param1->set_name("x");
param2->set_name("y");
BaseShapePtr shape1 = std::make_shared<abstract::Shape>(x);
BaseShapePtr shape2 = std::make_shared<abstract::Shape>(y);
BaseShapePtr shape3 = std::make_shared<abstract::Shape>(out);
std::shared_ptr<tensor::Tensor> inputs_x = std::make_shared<tensor::Tensor>(kNumberTypeInt32, x_shape);
std::shared_ptr<tensor::Tensor> inputs_y = std::make_shared<tensor::Tensor>(kNumberTypeInt32, y_shape);
std::shared_ptr<tensor::Tensor> inputs_out = std::make_shared<tensor::Tensor>(kNumberTypeInt32, out_shape);
std::shared_ptr<tensor::Tensor> inputs_x = std::make_shared<tensor::Tensor>(kNumberTypeInt32, x);
std::shared_ptr<tensor::Tensor> inputs_y = std::make_shared<tensor::Tensor>(kNumberTypeInt32, y);
std::shared_ptr<tensor::Tensor> inputs_out = std::make_shared<tensor::Tensor>(kNumberTypeInt32, out);
AbstractBasePtr abstract1 = abstract::FromValue(inputs_x, true);
AbstractBasePtr abstract2 = abstract::FromValue(inputs_y, true);
AbstractBasePtr abstract3 = abstract::FromValue(inputs_out, true);
@ -121,11 +112,11 @@ CNodePtr Make_Node(Shape x, Shape y, Shape out, int condition = 0) {
}
FuncGraphManagerPtr Make_Manager(int condition = 0) {
std::vector<int32_t> inputs_x = {64, 32};
std::vector<int32_t> inputs_y = {32, 64};
std::vector<int32_t> inputs_z = {64, 128};
std::vector<int32_t> outputs_1 = {64, 64};
std::vector<int32_t> outputs_2 = {64, 128};
Shape inputs_x = {64, 32};
Shape inputs_y = {32, 64};
Shape inputs_z = {64, 128};
Shape outputs_1 = {64, 64};
Shape outputs_2 = {64, 128};
FuncGraphPtr func_graph = std::make_shared<FuncGraph>();
ParameterPtr param1 = func_graph->add_parameter();
ParameterPtr param2 = func_graph->add_parameter();
@ -143,8 +134,8 @@ FuncGraphManagerPtr Make_Manager(int condition = 0) {
param1->set_abstract(abstract_x);
param2->set_abstract(abstract_y);
param3->set_abstract(abstract_z);
Dimensions v1 = {2, 2};
Dimensions v2 = {2, 4};
std::vector<int> v1 = {2, 2};
std::vector<int> v2 = {2, 4};
std::vector<ValuePtr> elements = {MakeValue(v1), MakeValue(v2)};
ValueTuplePtr var = std::make_shared<ValueTuple>(elements);
std::vector<AnfNodePtr> inputs;
@ -162,8 +153,8 @@ FuncGraphManagerPtr Make_Manager(int condition = 0) {
prim1->AddAttr("instance_name", MakeValue("matmul1"));
prim1->AddAttr("strategy", var);
inputs.clear();
Dimensions v3 = {2, 2};
Dimensions v4 = {2, 4};
std::vector<int> v3 = {2, 2};
std::vector<int> v4 = {2, 4};
std::vector<ValuePtr> elements2 = {MakeValue(v3), MakeValue(v4)};
ValueTuplePtr var2 = std::make_shared<ValueTuple>(elements2);
inputs.push_back(NewValueNode(prim::kPrimMatMul));
@ -195,8 +186,8 @@ FuncGraphManagerPtr Make_Manager(int condition = 0) {
break;
}
case 3: {
Dimensions vt1 = {2, 4};
Dimensions vt2 = {2, 4};
std::vector<int> vt1 = {2, 4};
std::vector<int> vt2 = {2, 4};
std::vector<ValuePtr> elements_t2 = {MakeValue(vt1), MakeValue(vt2)};
ValueTuplePtr var_t2 = std::make_shared<ValueTuple>(elements_t2);
prim1->set_attr("strategy", var_t2);
@ -233,9 +224,9 @@ TEST_F(TestStepParallel, ExtractStrategy) {
std::vector<ValuePtr> elements = {val1, val2};
ValueTuplePtr strategy_tuple = std::make_shared<ValueTuple>(elements);
attrs["strategy"] = strategy_tuple;
Strategys strategy_expect = {v1, v2};
std::vector<Dimensions> strategy_expect = {v1, v2};
StrategyPtr strategy = ExtractStrategy(attrs);
Strategys strategy_test = strategy->GetInputDim();
std::vector<Dimensions> strategy_test = strategy->GetInputDim();
ASSERT_EQ(strategy_expect, strategy_test);
}
@ -362,7 +353,7 @@ TEST_F(TestStepParallel, OperatorInstance) {
prim->set_attr("transpose_b", transpose_b);
auto attrs = prim->attrs();
// creat strategy
Strategys strategy = {{2, 2}, {2, 4}};
std::vector<Dimensions> strategy = {{2, 2}, {2, 4}};
StrategyPtr strategyPtr = parallel::NewStrategy(0, strategy);
// creat shape
Shapes inputs_shape = std::vector<Shape>{{64, 32}, {32, 64}};
@ -523,7 +514,7 @@ TEST_F(TestStepParallel, GetTensorInLayout) {
prim->set_attr("transpose_b", transpose_b);
auto attrs = prim->attrs();
// creat strategy
Strategys strategy = {{2, 2}, {2, 4}};
std::vector<Dimensions> strategy = {{2, 2}, {2, 4}};
StrategyPtr strategyPtr = parallel::NewStrategy(0, strategy);
// creat shape
Shapes inputs_shape = std::vector<Shape>{{64, 32}, {32, 64}};
@ -534,9 +525,9 @@ TEST_F(TestStepParallel, GetTensorInLayout) {
node->set_user_data<OperatorInfo>(matmul_info);
OperatorInfoPtr distribute_operator_pre = node->user_data<OperatorInfo>();
TensorLayout tensorlayout_e;
Shape array = {64, 64};
std::vector<int32_t> array = {64, 64};
TensorLayout tensorlayout = GetTensorInLayout(node1, prim, distribute_operator_pre);
Shape tensor_shape_test = tensorlayout.tensor_shape().array();
std::vector<int32_t> tensor_shape_test = tensorlayout.tensor_shape().array();
ASSERT_EQ(array, tensor_shape_test);
}

View File

@ -33,9 +33,9 @@ class TestStrategy : public UT::Common {
TEST_F(TestStrategy, GetInputNumber) {
int32_t number = 2;
int32_t stage = 1;
Dimensions dimension1 = {2, 4};
Dimensions dimension2 = {2, 2};
Strategys inputs = {dimension1, dimension2};
std::vector<int32_t> dimension1 = {2, 4};
std::vector<int32_t> dimension2 = {2, 2};
std::vector<std::vector<int32_t>> inputs = {dimension1, dimension2};
Strategy strategy(stage, inputs);
int32_t number_test = strategy.GetInputNumber();
@ -44,9 +44,9 @@ TEST_F(TestStrategy, GetInputNumber) {
TEST_F(TestStrategy, GetInputStage) {
int32_t stage = 1;
Dimensions dimension1 = {2, 4};
Dimensions dimension2 = {2, 2};
Strategys inputs = {dimension1, dimension2};
std::vector<int32_t> dimension1 = {2, 4};
std::vector<int32_t> dimension2 = {2, 2};
std::vector<std::vector<int32_t>> inputs = {dimension1, dimension2};
Strategy strategy(stage, inputs);
int32_t stage_test = strategy.GetInputStage();
@ -55,23 +55,23 @@ TEST_F(TestStrategy, GetInputStage) {
TEST_F(TestStrategy, GetInputDim) {
int32_t stage = 1;
Dimensions dimension1 = {2, 4};
Dimensions dimension2 = {2, 2};
Strategys inputs = {dimension1, dimension2};
std::vector<int32_t> dimension1 = {2, 4};
std::vector<int32_t> dimension2 = {2, 2};
std::vector<std::vector<int32_t>> inputs = {dimension1, dimension2};
Strategy strategy(stage, inputs);
Strategys inputs_test = strategy.GetInputDim();
std::vector<std::vector<int32_t>> inputs_test = strategy.GetInputDim();
ASSERT_EQ(inputs, inputs_test);
}
TEST_F(TestStrategy, IsEqual) {
int32_t stage1 = 0, stage2 = 0, stage3 = 1, stage4 = 0;
Dimensions dimension1 = {8, 1};
Dimensions dimension2 = {1, 8};
Strategys inputs1 = {dimension1};
Strategys inputs2 = {dimension1};
Strategys inputs3 = {dimension2};
Strategys inputs4 = {dimension1, dimension2};
std::vector<int32_t> dimension1 = {8, 1};
std::vector<int32_t> dimension2 = {1, 8};
std::vector<std::vector<int32_t>> inputs1 = {dimension1};
std::vector<std::vector<int32_t>> inputs2 = {dimension1};
std::vector<std::vector<int32_t>> inputs3 = {dimension2};
std::vector<std::vector<int32_t>> inputs4 = {dimension1, dimension2};
StrategyPtr stra1 = std::make_shared<Strategy>(stage1, inputs1);
StrategyPtr stra2 = std::make_shared<Strategy>(stage2, inputs2);

View File

@ -39,12 +39,12 @@ class TestConstructOperator : public UT::Common {
};
void TestConstructOperator::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 1050; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(1024);
stage_map.push_back(26);
@ -62,7 +62,7 @@ void TestConstructOperator::SetUp() {
MatMulInfoPtr matmul = std::make_shared<MatMulInfo>("matmul_info", inputs_shape_1, outputs_shape_1, attr_1);
Strategys str = {{2, 4, 8, 16}, {2, 4, 16, 1}};
std::vector<Dimensions> str = {{2, 4, 8, 16}, {2, 4, 16, 1}};
StrategyPtr strategy = NewStrategy(0, str);
matmul->Init(strategy);
Shape tensor_shape = {512, 1024};
@ -79,8 +79,8 @@ TEST_F(TestConstructOperator, TestReshapeOP) {
TEST_F(TestConstructOperator, TestStridedSliceOP) {
Args args = {1, 2, 3};
int64_t split_count = args[0];
int64_t split_dim = args[1];
int32_t split_count = args[0];
int32_t split_dim = args[1];
Shape device_arrangement = {8, 4};
Arrangement dev_mat;
dev_mat.Init(device_arrangement);
@ -98,18 +98,12 @@ TEST_F(TestConstructOperator, TestStridedSliceOP) {
OperatorParams params = op.second.second;
ValuePtr begin_ptr = params[0].first.second;
ValuePtr end_ptr = params[1].first.second;
std::vector<int32_t> begin_int = GetValue<const std::vector<int32_t>>(begin_ptr);
std::vector<int32_t> end_int = GetValue<const std::vector<int32_t>>(end_ptr);
Shape begin;
Shape end;
(void)std::transform(begin_int.begin(), begin_int.end(), std::back_inserter(begin),
[](const int32_t &value) { return static_cast<int64_t>(value); });
(void)std::transform(end_int.begin(), end_int.end(), std::back_inserter(end),
[](const int32_t &value) { return static_cast<int64_t>(value); });
Shape begin = GetValue<const std::vector<int>>(begin_ptr);
Shape end = GetValue<const std::vector<int>>(end_ptr);
for (size_t i = 0; i < begin.size(); i++) {
int64_t diff = end[i] - begin[i];
int64_t num = shape[i];
if (SizeToLong(i) != split_dim) {
int32_t diff = end[i] - begin[i];
int32_t num = shape[i];
if (SizeToInt(i) != split_dim) {
ASSERT_EQ(diff, shape[i]);
} else {
ASSERT_EQ(diff, num / split_count);

View File

@ -20,11 +20,14 @@
#include "frontend/parallel/tensor_layout/tensor_layout.h"
#include "frontend/parallel/tensor_layout/redistribution_layout_transfer.h"
#include "util_layout_gen_test.h"
#include "frontend/parallel/step_parallel.h"
namespace mindspore {
namespace parallel {
using DeviceArrangement = std::vector<int32_t>;
using TensorMap = std::vector<int32_t>;
using TensorShape = std::vector<int32_t>;
class TestRedistributionLayoutTransfer : public UT::Common {
public:
TestRedistributionLayoutTransfer() {}
@ -242,13 +245,13 @@ void ValidRedistributionLayoutCheck(const DeviceArrangement& in_device_arrangeme
unified_out_tensor_map, unified_tensor_shape);
}
void ValidRedistributionLayoutCheckAll(int64_t device_pow_size, int64_t tensor_pow_size,
int64_t max_device_dim, int64_t max_shape_dim) {
void ValidRedistributionLayoutCheckAll(int32_t device_pow_size, int32_t tensor_pow_size,
int32_t max_device_dim, int32_t max_shape_dim) {
std::vector<std::tuple<DeviceArrangement, TensorMap, TensorShape>> layout_list;
GenerateValidLayoutByDeviceSizeAndTensorSize(device_pow_size, tensor_pow_size, max_device_dim, max_shape_dim,
&layout_list);
for (size_t in = 0; in < layout_list.size(); in++) {
for (size_t out = 0; out < layout_list.size(); out++) {
for (uint32_t in = 0; in < layout_list.size(); in++) {
for (uint32_t out = 0; out < layout_list.size(); out++) {
DeviceArrangement in_device_arrangement = std::get<0>(layout_list[in]);
TensorMap in_tensor_map = std::get<1>(layout_list[in]);
TensorShape in_tensor_shape = std::get<2>(layout_list[in]);
@ -270,15 +273,15 @@ void ValidRedistributionLayoutCheckAll(int64_t device_pow_size, int64_t tensor_p
}
TEST_F(TestRedistributionLayoutTransfer, RedistributionLayoutTransferCheckAll) {
int64_t device_pow_size_max = 4;
int64_t tensor_pow_size_max = 4;
int64_t device_pow_size_min = 1;
int64_t tensor_pow_size_min = 1;
const int64_t max_device_dim = 5;
const int64_t max_shape_dim = 5;
int64_t device_pow_size = device_pow_size_min;
int32_t device_pow_size_max = 4;
int32_t tensor_pow_size_max = 4;
int32_t device_pow_size_min = 1;
int32_t tensor_pow_size_min = 1;
const int32_t max_device_dim = 5;
const int32_t max_shape_dim = 5;
int32_t device_pow_size = device_pow_size_min;
while (device_pow_size <= device_pow_size_max) {
int64_t tensor_pow_size = tensor_pow_size_min;
int32_t tensor_pow_size = tensor_pow_size_min;
while (tensor_pow_size <= tensor_pow_size_max) {
ValidRedistributionLayoutCheckAll(device_pow_size, tensor_pow_size, max_device_dim, max_shape_dim);
tensor_pow_size++;

View File

@ -28,13 +28,13 @@ class TestRedistributionOperatorInfer : public UT::Common {
TestRedistributionOperatorInfer() {}
void SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 1050; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(1024);
stage_map.push_back(26);

View File

@ -21,11 +21,14 @@
#include "frontend/parallel/tensor_layout/reshape_layout_transfer.h"
#include "util_layout_gen_test.h"
#include "utils/log_adapter.h"
#include "frontend/parallel/step_parallel.h"
namespace mindspore {
namespace parallel {
using DeviceArrangement = std::vector<int32_t>;
using TensorMap = std::vector<int32_t>;
using TensorShape = std::vector<int32_t>;
class TestReshapeLayoutTransfer : public UT::Common {
public:
TestReshapeLayoutTransfer() {}
@ -257,13 +260,13 @@ TEST_F(TestReshapeLayoutTransfer, ValidInferUnifiedLayoutCheck11) {
ValidUnifiedLayoutCheck(device_arrangement, in_tensor_map, in_tensor_shape, out_tensor_map, out_tensor_shape);
}
void ValidInferUnifiedLayoutCheckAll(int64_t device_pow_size, int64_t tensor_pow_size,
int64_t max_device_dim, int64_t max_shape_dim) {
void ValidInferUnifiedLayoutCheckAll(int32_t device_pow_size, int32_t tensor_pow_size,
int32_t max_device_dim, int32_t max_shape_dim) {
std::vector<std::tuple<DeviceArrangement, TensorMap, TensorShape>> layout_list;
GenerateValidLayoutByDeviceSizeAndTensorSize(device_pow_size, tensor_pow_size, max_device_dim, max_shape_dim,
&layout_list);
for (size_t in = 0; in < layout_list.size(); in++) {
for (size_t out = 0; out < layout_list.size(); out++) {
for (uint32_t in = 0; in < layout_list.size(); in++) {
for (uint32_t out = 0; out < layout_list.size(); out++) {
DeviceArrangement in_device_arrangement = std::get<0>(layout_list[in]);
TensorMap in_tensor_map = std::get<1>(layout_list[in]);
TensorShape in_tensor_shape = std::get<2>(layout_list[in]);
@ -284,15 +287,15 @@ void ValidInferUnifiedLayoutCheckAll(int64_t device_pow_size, int64_t tensor_pow
}
TEST_F(TestReshapeLayoutTransfer, ValidInferUnifiedLayoutCheckAll) {
int64_t device_pow_size_max = 4;
int64_t tensor_pow_size_max = 4;
int64_t device_pow_size_min = 1;
int64_t tensor_pow_size_min = 1;
const int64_t max_device_dim = 5;
const int64_t max_shape_dim = 5;
int64_t device_pow_size = device_pow_size_min;
int32_t device_pow_size_max = 4;
int32_t tensor_pow_size_max = 4;
int32_t device_pow_size_min = 1;
int32_t tensor_pow_size_min = 1;
const int32_t max_device_dim = 5;
const int32_t max_shape_dim = 5;
int32_t device_pow_size = device_pow_size_min;
while (device_pow_size <= device_pow_size_max) {
int64_t tensor_pow_size = tensor_pow_size_min;
int32_t tensor_pow_size = tensor_pow_size_min;
while (tensor_pow_size <= tensor_pow_size_max) {
ValidInferUnifiedLayoutCheckAll(device_pow_size, tensor_pow_size, max_device_dim, max_shape_dim);
tensor_pow_size++;
@ -302,15 +305,15 @@ TEST_F(TestReshapeLayoutTransfer, ValidInferUnifiedLayoutCheckAll) {
}
TEST_F(TestReshapeLayoutTransfer, ValidInferUnifiedLayoutCheckAll2) {
int64_t device_pow_size_max = 1;
int64_t tensor_pow_size_max = 2;
int64_t device_pow_size_min = 1;
int64_t tensor_pow_size_min = 2;
const int64_t max_device_dim = 5;
const int64_t max_shape_dim = 5;
int64_t device_pow_size = device_pow_size_min;
int32_t device_pow_size_max = 1;
int32_t tensor_pow_size_max = 2;
int32_t device_pow_size_min = 1;
int32_t tensor_pow_size_min = 2;
const int32_t max_device_dim = 5;
const int32_t max_shape_dim = 5;
int32_t device_pow_size = device_pow_size_min;
while (device_pow_size <= device_pow_size_max) {
int64_t tensor_pow_size = tensor_pow_size_min;
int32_t tensor_pow_size = tensor_pow_size_min;
while (tensor_pow_size <= tensor_pow_size_max) {
ValidInferUnifiedLayoutCheckAll(device_pow_size, tensor_pow_size, max_device_dim, max_shape_dim);
tensor_pow_size++;

View File

@ -26,7 +26,7 @@ namespace parallel {
* shape_accum = [2, 2 * 8, 2 * 8 * 32]
*/
TEST(ShapeUtilTest, ShapeToAccumulateProduct) {
Shape shape = {2, 8, 32};
std::vector<int32_t> shape = {2, 8, 32};
std::vector<int64_t> shape_accum;
Status status = ShapeToAccumulateProduct(shape, &shape_accum);
ASSERT_EQ(Status::SUCCESS, status);
@ -39,7 +39,7 @@ TEST(ShapeUtilTest, ShapeToAccumulateProduct) {
* shape_accum = [2 * 8 * 32, 8 * 32, 32]
*/
TEST(ShapeUtilTest, ShapeToAccumulateProductReverse) {
Shape shape = {2, 8, 32};
std::vector<int32_t> shape = {2, 8, 32};
std::vector<int64_t> shape_accum;
Status status = ShapeToAccumulateProductReverse(shape, &shape_accum);
ASSERT_EQ(Status::SUCCESS, status);
@ -53,10 +53,10 @@ TEST(ShapeUtilTest, ShapeToAccumulateProductReverse) {
*/
TEST(ShapeUtilTest, AccumulateProductToShape) {
std::vector<int64_t> shape_accum = {2, 2 * 8, 2 * 8 * 32};
Shape shape;
std::vector<int32_t> shape;
Status status = AccumulateProductToShape(shape_accum, &shape);
ASSERT_EQ(Status::SUCCESS, status);
Shape shape_expect = {2, 8, 32};
std::vector<int32_t> shape_expect = {2, 8, 32};
ASSERT_EQ(shape_expect, shape);
}
@ -66,10 +66,10 @@ TEST(ShapeUtilTest, AccumulateProductToShape) {
*/
TEST(ShapeUtilTest, AccumulateProductReverseToShape) {
std::vector<int64_t> shape_accum = {2 * 8 * 32, 8 * 32, 32};
Shape shape;
std::vector<int32_t> shape;
Status status = AccumulateProductReverseToShape(shape_accum, &shape);
ASSERT_EQ(Status::SUCCESS, status);
Shape shape_expect = {2, 8, 32};
std::vector<int32_t> shape_expect = {2, 8, 32};
ASSERT_EQ(shape_expect, shape);
}
@ -94,12 +94,12 @@ TEST(ShapeUtilTest, UnifyAccumulateProduct) {
* out = [2, 2, 2]
*/
TEST(ShapeUtilTest, UnifyShape1) {
Shape in1 = {2, 4};
Shape in2 = {4, 2};
Shape out;
std::vector<int32_t> in1 = {2, 4};
std::vector<int32_t> in2 = {4, 2};
std::vector<int32_t> out;
Status status = UnifyShape(in1, in2, &out);
ASSERT_EQ(Status::SUCCESS, status);
Shape out_expect = {2, 2, 2};
std::vector<int32_t> out_expect = {2, 2, 2};
ASSERT_EQ(out_expect, out);
}
@ -109,12 +109,12 @@ TEST(ShapeUtilTest, UnifyShape1) {
* out = [2, 4, 4]
*/
TEST(ShapeUtilTest, UnifyShape2) {
Shape in1 = {8, 4};
Shape in2 = {2, 16};
Shape out;
std::vector<int32_t> in1 = {8, 4};
std::vector<int32_t> in2 = {2, 16};
std::vector<int32_t> out;
Status status = UnifyShape(in1, in2, &out);
ASSERT_EQ(Status::SUCCESS, status);
Shape out_expect = {2, 4, 4};
std::vector<int32_t> out_expect = {2, 4, 4};
ASSERT_EQ(out_expect, out);
}
@ -184,12 +184,12 @@ TEST(ShapeUtilTest, ExpandAccumulateProduct4) {
* out = [2, 8, 4, 8]
*/
TEST(ShapeUtilTest, ExpandShape1) {
Shape in = {2, 8, 32};
Shape expand = {16, 4, 8};
Shape out;
std::vector<int32_t> in = {2, 8, 32};
std::vector<int32_t> expand = {16, 4, 8};
std::vector<int32_t> out;
Status status = ExpandShape(in, expand, &out);
ASSERT_EQ(Status::SUCCESS, status);
Shape out_expect = {2, 8, 4, 8};
std::vector<int32_t> out_expect = {2, 8, 4, 8};
ASSERT_EQ(out_expect, out);
}
@ -199,12 +199,12 @@ TEST(ShapeUtilTest, ExpandShape1) {
* out = [2, 8, 4, 8]
*/
TEST(ShapeUtilTest, ExpandShape2) {
Shape in = {2, 8, 32};
Shape expand = {2, 4, 8};
Shape out;
std::vector<int32_t> in = {2, 8, 32};
std::vector<int32_t> expand = {2, 4, 8};
std::vector<int32_t> out;
Status status = ExpandShape(in, expand, &out);
ASSERT_EQ(Status::SUCCESS, status);
Shape out_expect = {2, 4, 2, 4, 8};
std::vector<int32_t> out_expect = {2, 4, 2, 4, 8};
ASSERT_EQ(out_expect, out);
}

View File

@ -18,7 +18,6 @@
#include "common/common_test.h"
#include "common/py_func_graph_fetcher.h"
#include "frontend/parallel/tensor_layout/tensor_layout.h"
#include "frontend/parallel/step_parallel.h"
namespace mindspore {
namespace parallel {
@ -32,12 +31,12 @@ class TestTensorLayout : public UT::Common {
virtual void TearDown() {}
};
void ReshapeExpandDeviceArrangementTestFunction(const DeviceArrangement& in_device_arrangement_shape,
const TensorMap& in_tensor_map_shape,
const TensorShape& in_tensor_shape_shape,
const DeviceArrangement& out_device_arrangement_shape,
const TensorMap& out_tensor_map_shape,
const TensorShape& out_tensor_shape_shape) {
void ReshapeExpandDeviceArrangementTestFunction(const std::vector<int32_t>& in_device_arrangement_shape,
const std::vector<int32_t>& in_tensor_map_shape,
const std::vector<int32_t>& in_tensor_shape_shape,
const std::vector<int32_t>& out_device_arrangement_shape,
const std::vector<int32_t>& out_tensor_map_shape,
const std::vector<int32_t>& out_tensor_shape_shape) {
Arrangement device_arrangement;
Status status = device_arrangement.Init(in_device_arrangement_shape);
ASSERT_EQ(Status::SUCCESS, status);
@ -71,12 +70,12 @@ void ReshapeExpandDeviceArrangementTestFunction(const DeviceArrangement& in_devi
*
*/
TEST_F(TestTensorLayout, ReshapeExpandDeviceArrangement1) {
DeviceArrangement device_arrangement = {8, 4};
TensorMap tensor_map = {1, 0};
TensorShape tensor_shape = {512, 1024};
DeviceArrangement device_arrangement_new = {4, 2, 2, 2};
TensorMap tensor_map_expect = {3, 2, 1, 0};
TensorShape tensor_shape_expect = {4, 128, 2, 512};
std::vector<int32_t> device_arrangement = {8, 4};
std::vector<int32_t> tensor_map = {1, 0};
std::vector<int32_t> tensor_shape = {512, 1024};
std::vector<int32_t> device_arrangement_new = {4, 2, 2, 2};
std::vector<int32_t> tensor_map_expect = {3, 2, 1, 0};
std::vector<int32_t> tensor_shape_expect = {4, 128, 2, 512};
ReshapeExpandDeviceArrangementTestFunction(device_arrangement, tensor_map, tensor_shape, device_arrangement_new,
tensor_map_expect, tensor_shape_expect);
}
@ -92,12 +91,12 @@ TEST_F(TestTensorLayout, ReshapeExpandDeviceArrangement1) {
* out_tensor_shape = [2, 256, 4, 256]
*/
TEST_F(TestTensorLayout, ReshapeExpandDeviceArrangement2) {
DeviceArrangement device_arrangement = {8, 4};
TensorMap tensor_map = {0, 1};
TensorShape tensor_shape = {512, 1024};
DeviceArrangement device_arrangement_new = {4, 2, 2, 2};
TensorMap tensor_map_expect = {1, 0, 3, 2};
TensorShape tensor_shape_expect = {2, 256, 4, 256};
std::vector<int32_t> device_arrangement = {8, 4};
std::vector<int32_t> tensor_map = {0, 1};
std::vector<int32_t> tensor_shape = {512, 1024};
std::vector<int32_t> device_arrangement_new = {4, 2, 2, 2};
std::vector<int32_t> tensor_map_expect = {1, 0, 3, 2};
std::vector<int32_t> tensor_shape_expect = {2, 256, 4, 256};
ReshapeExpandDeviceArrangementTestFunction(device_arrangement, tensor_map, tensor_shape, device_arrangement_new,
tensor_map_expect, tensor_shape_expect);
}
@ -112,12 +111,12 @@ TEST_F(TestTensorLayout, ReshapeExpandDeviceArrangement2) {
* out_tensor_shape = [4, 128, 1024]
*/
TEST_F(TestTensorLayout, ReshapeExpandDeviceArrangement3) {
DeviceArrangement device_arrangement = {8, 4};
TensorMap tensor_map = {1, -1};
TensorShape tensor_shape = {512, 1024};
DeviceArrangement device_arrangement_new = {4, 2, 2, 2};
TensorMap tensor_map_expect = {3, 2, -1};
TensorShape tensor_shape_expect = {4, 128, 1024};
std::vector<int32_t> device_arrangement = {8, 4};
std::vector<int32_t> tensor_map = {1, -1};
std::vector<int32_t> tensor_shape = {512, 1024};
std::vector<int32_t> device_arrangement_new = {4, 2, 2, 2};
std::vector<int32_t> tensor_map_expect = {3, 2, -1};
std::vector<int32_t> tensor_shape_expect = {4, 128, 1024};
ReshapeExpandDeviceArrangementTestFunction(device_arrangement, tensor_map, tensor_shape, device_arrangement_new,
tensor_map_expect, tensor_shape_expect);
}
@ -133,33 +132,33 @@ TEST_F(TestTensorLayout, ReshapeExpandDeviceArrangement3) {
* out_tensor_shape = [512, 4, 256]
*/
TEST_F(TestTensorLayout, ReshapeExpandDeviceArrangement4) {
DeviceArrangement device_arrangement = {8, 4};
TensorMap tensor_map = {0, 1};
TensorShape tensor_shape = {512, 1024};
DeviceArrangement device_arrangement_new = {4, 2, 4};
TensorMap tensor_map_expect = {0, 2, 1};
TensorShape tensor_shape_expect = {512, 4, 256};
std::vector<int32_t> device_arrangement = {8, 4};
std::vector<int32_t> tensor_map = {0, 1};
std::vector<int32_t> tensor_shape = {512, 1024};
std::vector<int32_t> device_arrangement_new = {4, 2, 4};
std::vector<int32_t> tensor_map_expect = {0, 2, 1};
std::vector<int32_t> tensor_shape_expect = {512, 4, 256};
ReshapeExpandDeviceArrangementTestFunction(device_arrangement, tensor_map, tensor_shape, device_arrangement_new,
tensor_map_expect, tensor_shape_expect);
}
TEST_F(TestTensorLayout, ReshapeExpandDeviceArrangement5) {
DeviceArrangement device_arrangement = {8, 4};
TensorMap tensor_map = {1, -1, 0};
TensorShape tensor_shape = {128, 4, 1024};
DeviceArrangement device_arrangement_new = {8, 4};
TensorMap tensor_map_expect = {1, -1, 0};
TensorShape tensor_shape_expect = {128, 4, 1024};
std::vector<int32_t> device_arrangement = {8, 4};
std::vector<int32_t> tensor_map = {1, -1, 0};
std::vector<int32_t> tensor_shape = {128, 4, 1024};
std::vector<int32_t> device_arrangement_new = {8, 4};
std::vector<int32_t> tensor_map_expect = {1, -1, 0};
std::vector<int32_t> tensor_shape_expect = {128, 4, 1024};
ReshapeExpandDeviceArrangementTestFunction(device_arrangement, tensor_map, tensor_shape, device_arrangement_new,
tensor_map_expect, tensor_shape_expect);
}
void ExpandTensorShapeTestFunction(const DeviceArrangement& in_device_arrangement_shape,
const TensorMap& in_tensor_map_shape,
const TensorShape& in_tensor_shape_shape,
const DeviceArrangement& out_device_arrangement_shape,
const TensorMap& out_tensor_map_shape,
const TensorShape& out_tensor_shape_shape) {
void ExpandTensorShapeTestFunction(const std::vector<int32_t>& in_device_arrangement_shape,
const std::vector<int32_t>& in_tensor_map_shape,
const std::vector<int32_t>& in_tensor_shape_shape,
const std::vector<int32_t>& out_device_arrangement_shape,
const std::vector<int32_t>& out_tensor_map_shape,
const std::vector<int32_t>& out_tensor_shape_shape) {
Arrangement device_arrangement;
Status status = device_arrangement.Init(in_device_arrangement_shape);
ASSERT_EQ(Status::SUCCESS, status);
@ -194,31 +193,31 @@ void ExpandTensorShapeTestFunction(const DeviceArrangement& in_device_arrangemen
* out_tensor_map = [2, 1, 0],
*/
TEST_F(TestTensorLayout, ExpandTensorShape1) {
DeviceArrangement device_arrangement = {8, 4};
TensorMap tensor_map = {1, 0};
TensorShape tensor_shape = {512, 1024};
DeviceArrangement device_arrangement_expect = {4, 2, 4};
TensorMap tensor_map_expect = {2, 1, 0};
TensorShape tensor_shape_new = {4, 128, 1024};
std::vector<int32_t> device_arrangement = {8, 4};
std::vector<int32_t> tensor_map = {1, 0};
std::vector<int32_t> tensor_shape = {512, 1024};
std::vector<int32_t> device_arrangement_expect = {4, 2, 4};
std::vector<int32_t> tensor_map_expect = {2, 1, 0};
std::vector<int32_t> tensor_shape_new = {4, 128, 1024};
ExpandTensorShapeTestFunction(device_arrangement, tensor_map, tensor_shape, device_arrangement_expect,
tensor_map_expect, tensor_shape_new);
}
TEST_F(TestTensorLayout, ExpandTensorShape2) {
DeviceArrangement device_arrangement = {8, 4};
TensorMap tensor_map = {1, 0};
TensorShape tensor_shape = {128, 4096};
DeviceArrangement device_arrangement_expect = {8, 4};
TensorMap tensor_map_expect = {1, 0, -1};
TensorShape tensor_shape_new = {128, 4, 1024};
std::vector<int32_t> device_arrangement = {8, 4};
std::vector<int32_t> tensor_map = {1, 0};
std::vector<int32_t> tensor_shape = {128, 4096};
std::vector<int32_t> device_arrangement_expect = {8, 4};
std::vector<int32_t> tensor_map_expect = {1, 0, -1};
std::vector<int32_t> tensor_shape_new = {128, 4, 1024};
ExpandTensorShapeTestFunction(device_arrangement, tensor_map, tensor_shape, device_arrangement_expect,
tensor_map_expect, tensor_shape_new);
}
TEST_F(TestTensorLayout, GetSliceShape) {
DeviceArrangement in_device_arrangement = {8, 4};
TensorMap in_tensor_map = {1, -1};
TensorShape in_tensor_shape = {512, 1024};
std::vector<int32_t> in_device_arrangement = {8, 4};
std::vector<int32_t> in_tensor_map = {1, -1};
std::vector<int32_t> in_tensor_shape = {512, 1024};
Arrangement device_arrangement;
device_arrangement.Init(in_device_arrangement);
Map tensor_map;
@ -234,9 +233,9 @@ TEST_F(TestTensorLayout, GetSliceShape) {
}
TEST_F(TestTensorLayout, UpdateTensorMap) {
DeviceArrangement in_device_arrangement = {8, 4};
TensorMap in_tensor_map = {1, -1};
TensorShape in_tensor_shape = {512, 1024};
std::vector<int32_t> in_device_arrangement = {8, 4};
std::vector<int32_t> in_tensor_map = {1, -1};
std::vector<int32_t> in_tensor_shape = {512, 1024};
Arrangement device_arrangement;
device_arrangement.Init(in_device_arrangement);
Map tensor_map;
@ -251,12 +250,12 @@ TEST_F(TestTensorLayout, UpdateTensorMap) {
ASSERT_EQ(in_tensor_map, new_tensor_map);
}
void RemoveElementEqualToOneInDeviceArrangementTestFunction(const DeviceArrangement& in_device_arrangement_shape,
const TensorMap& in_tensor_map_shape,
const TensorShape& in_tensor_shape_shape,
const DeviceArrangement& out_device_arrangement_shape,
const TensorMap& out_tensor_map_shape,
const TensorShape& out_tensor_shape_shape) {
void RemoveElementEqualToOneInDeviceArrangementTestFunction(const std::vector<int32_t>& in_device_arrangement_shape,
const std::vector<int32_t>& in_tensor_map_shape,
const std::vector<int32_t>& in_tensor_shape_shape,
const std::vector<int32_t>& out_device_arrangement_shape,
const std::vector<int32_t>& out_tensor_map_shape,
const std::vector<int32_t>& out_tensor_shape_shape) {
Arrangement device_arrangement;
Status status = device_arrangement.Init(in_device_arrangement_shape);
ASSERT_EQ(Status::SUCCESS, status);
@ -278,45 +277,45 @@ void RemoveElementEqualToOneInDeviceArrangementTestFunction(const DeviceArrangem
}
TEST_F(TestTensorLayout, RemoveElementEqualToOneInDeviceArrangement1) {
DeviceArrangement device_arrangement = {2, 2, 1};
TensorMap tensor_map = {2, 1};
TensorShape tensor_shape = {128, 4096};
DeviceArrangement device_arrangement_expect = {2, 2};
TensorMap tensor_map_expect = {1, 0};
TensorShape tensor_shape_new = {128, 4096};
std::vector<int32_t> device_arrangement = {2, 2, 1};
std::vector<int32_t> tensor_map = {2, 1};
std::vector<int32_t> tensor_shape = {128, 4096};
std::vector<int32_t> device_arrangement_expect = {2, 2};
std::vector<int32_t> tensor_map_expect = {1, 0};
std::vector<int32_t> tensor_shape_new = {128, 4096};
RemoveElementEqualToOneInDeviceArrangementTestFunction(
device_arrangement, tensor_map, tensor_shape, device_arrangement_expect, tensor_map_expect, tensor_shape_new);
}
TEST_F(TestTensorLayout, RemoveElementEqualToOneInDeviceArrangement2) {
DeviceArrangement device_arrangement = {16, 1, 1};
TensorMap tensor_map = {2, 0};
TensorShape tensor_shape = {128, 4096};
DeviceArrangement device_arrangement_expect = {16};
TensorMap tensor_map_expect = {0, -1};
TensorShape tensor_shape_new = {128, 4096};
std::vector<int32_t> device_arrangement = {16, 1, 1};
std::vector<int32_t> tensor_map = {2, 0};
std::vector<int32_t> tensor_shape = {128, 4096};
std::vector<int32_t> device_arrangement_expect = {16};
std::vector<int32_t> tensor_map_expect = {0, -1};
std::vector<int32_t> tensor_shape_new = {128, 4096};
RemoveElementEqualToOneInDeviceArrangementTestFunction(
device_arrangement, tensor_map, tensor_shape, device_arrangement_expect, tensor_map_expect, tensor_shape_new);
}
TEST_F(TestTensorLayout, RemoveElementEqualToOneInDeviceArrangement3) {
DeviceArrangement device_arrangement = {1, 16, 1};
TensorMap tensor_map = {2, 1};
TensorShape tensor_shape = {128, 4096};
DeviceArrangement device_arrangement_expect = {16};
TensorMap tensor_map_expect = {-1, 0};
TensorShape tensor_shape_new = {128, 4096};
std::vector<int32_t> device_arrangement = {1, 16, 1};
std::vector<int32_t> tensor_map = {2, 1};
std::vector<int32_t> tensor_shape = {128, 4096};
std::vector<int32_t> device_arrangement_expect = {16};
std::vector<int32_t> tensor_map_expect = {-1, 0};
std::vector<int32_t> tensor_shape_new = {128, 4096};
RemoveElementEqualToOneInDeviceArrangementTestFunction(
device_arrangement, tensor_map, tensor_shape, device_arrangement_expect, tensor_map_expect, tensor_shape_new);
}
TEST_F(TestTensorLayout, RemoveElementEqualToOneInDeviceArrangement4) {
DeviceArrangement device_arrangement = {1, 1, 1};
TensorMap tensor_map = {2, 1};
TensorShape tensor_shape = {128, 4096};
DeviceArrangement device_arrangement_expect = {};
TensorMap tensor_map_expect = {-1, -1};
TensorShape tensor_shape_new = {128, 4096};
std::vector<int32_t> device_arrangement = {1, 1, 1};
std::vector<int32_t> tensor_map = {2, 1};
std::vector<int32_t> tensor_shape = {128, 4096};
std::vector<int32_t> device_arrangement_expect = {};
std::vector<int32_t> tensor_map_expect = {-1, -1};
std::vector<int32_t> tensor_shape_new = {128, 4096};
RemoveElementEqualToOneInDeviceArrangementTestFunction(
device_arrangement, tensor_map, tensor_shape, device_arrangement_expect, tensor_map_expect, tensor_shape_new);
}

View File

@ -18,7 +18,6 @@
#include "common/common_test.h"
#include "common/py_func_graph_fetcher.h"
#include "frontend/parallel/tensor_layout/tensor_redistribution.h"
#include "frontend/parallel/step_parallel.h"
namespace mindspore {
namespace parallel {
@ -34,7 +33,7 @@ class TestTensorRedistribution : public UT::Common {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(16);
stage_map.push_back(4);
@ -50,9 +49,9 @@ class TestTensorRedistribution : public UT::Common {
// Redistribution: Reshape -> SplitByAxis -> ConcatByAxis -> SplitByAxis -> Reshape
TEST_F(TestTensorRedistribution, TestInferRedistribution1) {
DeviceArrangement device_arrangement = {2, 4, 2};
TensorMap tensor_map = {2, 0};
TensorShape tensor_shape = {512, 1024};
std::vector<int32_t> device_arrangement = {2, 4, 2};
std::vector<int32_t> tensor_map = {2, 0};
std::vector<int32_t> tensor_shape = {512, 1024};
Arrangement in_device_arrangement;
Status status = in_device_arrangement.Init(device_arrangement);
@ -103,9 +102,9 @@ TEST_F(TestTensorRedistribution, TestInferRedistribution1) {
// Redistribution: AlltoAll
TEST_F(TestTensorRedistribution, TestInferRedistribution2) {
DeviceArrangement device_arrangement = {16, 1, 1};
TensorMap tensor_map = {2, 0};
TensorShape tensor_shape = {512, 1024};
std::vector<int32_t> device_arrangement = {16, 1, 1};
std::vector<int32_t> tensor_map = {2, 0};
std::vector<int32_t> tensor_shape = {512, 1024};
Arrangement in_device_arrangement;
Status status = in_device_arrangement.Init(device_arrangement);
@ -155,9 +154,9 @@ TEST_F(TestTensorRedistribution, TestInferRedistribution2) {
// Redistribution: Reshape
TEST_F(TestTensorRedistribution, TestInferRedistribution3) {
DeviceArrangement device_arrangement = {8};
TensorMap tensor_map = {0, -1, -1, -1};
TensorShape tensor_shape = {128, 64, 1, 1};
std::vector<int32_t> device_arrangement = {8};
std::vector<int32_t> tensor_map = {0, -1, -1, -1};
std::vector<int32_t> tensor_shape = {128, 64, 1, 1};
Arrangement in_device_arrangement;
Status status = in_device_arrangement.Init(device_arrangement);

View File

@ -28,21 +28,21 @@ using std::pow;
namespace mindspore {
namespace parallel {
std::vector<Shape> combine(const Shape& in, int64_t target) {
std::vector<Shape> output;
for (int64_t i = 0; i < pow(2, in.size()); i++) {
size_t temp = 0;
size_t count = 0;
Shape left;
for (size_t j = 0; j < in.size(); j++) {
std::vector<std::vector<int32_t>> combine(const std::vector<int32_t>& in, int32_t target) {
std::vector<std::vector<int32_t>> output;
for (int32_t i = 0; i < pow(2, in.size()); i++) {
int32_t temp = 0;
int32_t count = 0;
std::vector<int32_t> left;
for (int32_t j = 0; j < in.size(); j++) {
if ((i & (1 << j)) != 0) {
left.push_back(j);
count++;
}
}
if (count == target) {
Shape one_case;
for (size_t j = 0; j < count; j++) {
std::vector<int32_t> one_case;
for (int32_t j = 0; j < count; j++) {
temp = in.size() - 1 - left[j];
one_case.push_back(in[temp]);
}
@ -54,23 +54,24 @@ std::vector<Shape> combine(const Shape& in, int64_t target) {
return output;
}
void GenerateValidShapeBySizeAndDim(int64_t pow_size, int64_t dim, std::vector<Shape>* out) {
void GenerateValidShapeBySizeAndDim(int32_t pow_size, int32_t dim,
std::vector<std::vector<int32_t>>* out) {
out->clear();
Shape in;
for (int64_t i = 1; i < pow_size; i++) {
std::vector<int32_t> in;
for (int32_t i = 1; i < pow_size; i++) {
in.push_back(i);
}
std::vector<Shape> combine_result;
std::vector<std::vector<int32_t>> combine_result;
combine_result = combine(in, dim - 1);
if (combine_result.size() == 0) {
int64_t size = exp2(pow_size);
Shape item = {size};
int32_t size = exp2(pow_size);
std::vector<int32_t> item = {size};
out->push_back(item);
}
for (size_t i = 0; i < combine_result.size(); i++) {
Shape item;
int64_t prev = 0;
for (int64_t j = combine_result[i].size() - 1; j >= 0; j--) {
for (uint32_t i = 0; i < combine_result.size(); i++) {
std::vector<int32_t> item;
int32_t prev = 0;
for (int32_t j = combine_result[i].size() - 1; j >= 0; j--) {
item.push_back(exp2(combine_result[i][j] - prev));
prev = combine_result[i][j];
}
@ -80,21 +81,22 @@ void GenerateValidShapeBySizeAndDim(int64_t pow_size, int64_t dim, std::vector<S
return;
}
void GenerateValidShapeBySize(int64_t pow_size, std::vector<Shape>* out) {
void GenerateValidShapeBySize(int32_t pow_size, std::vector<std::vector<int32_t>>* out) {
out->clear();
for (int64_t dim = 1; dim <= pow_size; dim++) {
std::vector<Shape> combine_result;
for (int32_t dim = 1; dim <= pow_size; dim++) {
std::vector<std::vector<int32_t>> combine_result;
GenerateValidShapeBySizeAndDim(pow_size, dim, &combine_result);
for (size_t i = 0; i < combine_result.size(); i++) {
for (uint32_t i = 0; i < combine_result.size(); i++) {
out->push_back(combine_result[i]);
}
}
return;
}
TensorMap GenerateTensorMap(const int64_t& map_size, const Shape& pos_index, const Shape& pos_value) {
TensorMap tensor_map(map_size, -1);
for (size_t i = 0; i < pos_index.size() && i < pos_value.size(); i++) {
std::vector<int32_t> GenerateTensorMap(const uint32_t& map_size, const std::vector<int32_t>& pos_index,
const std::vector<int32_t>& pos_value) {
std::vector<int32_t> tensor_map(map_size, -1);
for (uint32_t i = 0; i < pos_index.size() && i < pos_value.size(); i++) {
if (pos_index[i] >= map_size) {
continue;
}
@ -103,43 +105,43 @@ TensorMap GenerateTensorMap(const int64_t& map_size, const Shape& pos_index, con
return tensor_map;
}
void GenerateValidTensorMap(const DeviceArrangement& device_arrangement, const TensorShape& tensor_shape,
std::vector<TensorMap>* tensor_map_list) {
void GenerateValidTensorMap(const std::vector<int32_t>& device_arrangement, const std::vector<int32_t>& tensor_shape,
std::vector<std::vector<int32_t>>* tensor_map_list) {
tensor_map_list->clear();
int64_t device_size = device_arrangement.size();
int64_t shape_size = tensor_shape.size();
Shape pos_ind_combine_in;
for (int64_t i = 0; i < shape_size; i++) {
int32_t device_size = device_arrangement.size();
int32_t shape_size = tensor_shape.size();
std::vector<int32_t> pos_ind_combine_in;
for (int32_t i = 0; i < shape_size; i++) {
pos_ind_combine_in.push_back(i);
}
Shape dev_ind_combine_in;
for (int64_t i = 0; i < device_size; i++) {
std::vector<int32_t> dev_ind_combine_in;
for (int32_t i = 0; i < device_size; i++) {
dev_ind_combine_in.push_back(i);
}
TensorMap none_map(tensor_shape.size(), -1);
std::vector<int32_t> none_map(tensor_shape.size(), -1);
tensor_map_list->push_back(none_map);
for (int64_t pos_num = 1; (pos_num <= shape_size) && (pos_num <= device_size); pos_num++) {
std::vector<Shape> pos_index;
for (uint32_t pos_num = 1; (pos_num <= shape_size) && (pos_num <= device_size); pos_num++) {
std::vector<std::vector<int32_t>> pos_index;
pos_index = combine(pos_ind_combine_in, pos_num);
std::vector<Shape> dev_index;
std::vector<std::vector<int32_t>> dev_index;
dev_index = combine(dev_ind_combine_in, pos_num);
for (size_t l = 0; l < dev_index.size(); l++) {
Shape pos_value_combine_in;
for (int l = 0; l < dev_index.size(); l++) {
std::vector<int32_t> pos_value_combine_in;
for (int32_t i = dev_index[l].size() - 1; i >= 0; i--) {
pos_value_combine_in.push_back(dev_index[l][i]);
}
std::vector<Shape> pos_value;
Shape::iterator it = pos_value_combine_in.begin();
std::vector<std::vector<int32_t>> pos_value;
std::vector<int32_t>::iterator it = pos_value_combine_in.begin();
do {
Shape pos_value_item;
for (size_t m = 0; m < pos_num; m++) {
std::vector<int32_t> pos_value_item;
for (uint32_t m = 0; m < pos_num; m++) {
pos_value_item.push_back(pos_value_combine_in[m]);
}
pos_value.push_back(pos_value_item);
} while (next_permutation(it, it + pos_num));
for (size_t j = 0; j < pos_index.size(); j++) {
for (size_t k = 0; k < pos_value.size(); k++) {
TensorMap tensor_map = GenerateTensorMap(shape_size, pos_index[j], pos_value[k]);
for (uint32_t j = 0; j < pos_index.size(); j++) {
for (uint32_t k = 0; k < pos_value.size(); k++) {
std::vector<int32_t> tensor_map = GenerateTensorMap(shape_size, pos_index[j], pos_value[k]);
tensor_map_list->push_back(tensor_map);
}
}
@ -149,19 +151,19 @@ void GenerateValidTensorMap(const DeviceArrangement& device_arrangement, const T
}
void GenerateValidLayoutByDeviceSizeAndTensorSize(
int64_t device_pow_size, int64_t tensor_pow_size, int64_t max_device_dim,
int64_t max_shape_dim,
std::vector<std::tuple<DeviceArrangement, TensorMap, TensorShape>>* layout_list) {
int32_t device_pow_size, int32_t tensor_pow_size, int32_t max_device_dim,
int32_t max_shape_dim,
std::vector<std::tuple<std::vector<int32_t>, std::vector<int32_t>, std::vector<int32_t>>>* layout_list) {
layout_list->clear();
std::vector<DeviceArrangement> device_arrangement_list;
std::vector<std::vector<int32_t>> device_arrangement_list;
GenerateValidShapeBySize(device_pow_size, &device_arrangement_list);
std::vector<TensorShape> tensor_shape_list;
std::vector<std::vector<int32_t>> tensor_shape_list;
GenerateValidShapeBySize(tensor_pow_size, &tensor_shape_list);
for (size_t device_idx = 0; device_idx < device_arrangement_list.size(); device_idx++) {
for (size_t shape_idx = 0; shape_idx < tensor_shape_list.size(); shape_idx++) {
std::vector<TensorMap> tensor_map_list;
for (uint32_t device_idx = 0; device_idx < device_arrangement_list.size(); device_idx++) {
for (uint32_t shape_idx = 0; shape_idx < tensor_shape_list.size(); shape_idx++) {
std::vector<std::vector<int32_t>> tensor_map_list;
GenerateValidTensorMap(device_arrangement_list[device_idx], tensor_shape_list[shape_idx], &tensor_map_list);
for (size_t map_idx = 0; map_idx < tensor_map_list.size(); map_idx++) {
for (uint32_t map_idx = 0; map_idx < tensor_map_list.size(); map_idx++) {
if (!CheckLayoutValid(device_arrangement_list[device_idx], tensor_map_list[map_idx],
tensor_shape_list[shape_idx])) {
continue;
@ -174,8 +176,8 @@ void GenerateValidLayoutByDeviceSizeAndTensorSize(
return;
}
bool CheckLayoutValid(const DeviceArrangement& device_arrangement, const TensorMap& tensor_map,
const TensorShape& tensor_shape) {
bool CheckLayoutValid(const std::vector<int32_t>& device_arrangement, const std::vector<int32_t>& tensor_map,
const std::vector<int32_t>& tensor_shape) {
bool flag = false;
if ((tensor_map.size() - ComputeNoneNumber(tensor_map)) > device_arrangement.size()) {
return flag;
@ -186,9 +188,9 @@ bool CheckLayoutValid(const DeviceArrangement& device_arrangement, const TensorM
return true;
}
size_t ComputeNoneNumber(const TensorMap& tensor_map) {
size_t num = 0;
for (size_t i = 0; i < tensor_map.size(); i++) {
uint32_t ComputeNoneNumber(const std::vector<int32_t>& tensor_map) {
uint32_t num = 0;
for (uint32_t i = 0; i < tensor_map.size(); i++) {
if (tensor_map[i] == -1) {
num++;
}
@ -196,14 +198,14 @@ size_t ComputeNoneNumber(const TensorMap& tensor_map) {
return num;
}
bool ShapeIsDividedByDevice(const DeviceArrangement& device_arrangement, const TensorMap& tensor_map,
const TensorShape& tensor_shape) {
bool ShapeIsDividedByDevice(const std::vector<int32_t>& device_arrangement, const std::vector<int32_t>& tensor_map,
const std::vector<int32_t>& tensor_shape) {
bool flag = false;
for (uint32_t i = 0; i < tensor_map.size() && i < tensor_shape.size(); i++) {
if (tensor_map[i] == -1) {
continue;
}
int64_t dim = device_arrangement[device_arrangement.size() - 1 - tensor_map[i]];
int32_t dim = device_arrangement[device_arrangement.size() - 1 - tensor_map[i]];
if (tensor_shape[i] % dim != 0) {
return flag;
}
@ -211,8 +213,8 @@ bool ShapeIsDividedByDevice(const DeviceArrangement& device_arrangement, const T
return true;
}
bool IsExpended(const Shape& in1, const Shape& in2) {
int64_t size = 1;
bool IsExpended(const std::vector<int32_t>& in1, const std::vector<int32_t>& in2) {
int32_t size = 1;
uint32_t ind = 0;
for (uint32_t i = 0; i < in1.size(); i++) {
size *= in1[i];
@ -234,9 +236,9 @@ bool IsExpended(const Shape& in1, const Shape& in2) {
return true;
}
void ComputeAccumDeviceTOAccumShapeMap(const DeviceArrangement& device_arrangement,
const TensorMap& tensor_map, const TensorShape& tensor_shape,
std::map<int64_t, int64_t>* accum_device_to_accum_shape_map) {
void ComputeAccumDeviceTOAccumShapeMap(const std::vector<int32_t>& device_arrangement,
const std::vector<int32_t>& tensor_map, const std::vector<int32_t>& tensor_shape,
std::map<int32_t, int32_t>* accum_device_to_accum_shape_map) {
accum_device_to_accum_shape_map->clear();
std::vector<int64_t> shape_accum_reverse;
Status status = ShapeToAccumulateProductReverse(tensor_shape, &shape_accum_reverse);
@ -256,42 +258,42 @@ void ComputeAccumDeviceTOAccumShapeMap(const DeviceArrangement& device_arrangeme
return;
}
void IsLinearValue(int64_t small, int64_t big, int64_t small_value, int64_t big_value, int64_t middle,
int64_t middle_value) {
void IsLinearValue(int32_t small, int32_t big, int32_t small_value, int32_t big_value, int32_t middle,
int32_t middle_value) {
ASSERT_NE(big, small);
int64_t value = (middle - small) * (big_value - small_value) / (big - small) + small_value;
int32_t value = (middle - small) * (big_value - small_value) / (big - small) + small_value;
ASSERT_EQ(middle_value, value);
}
void LayoutTransferValidLayoutChangeCheck(const DeviceArrangement& in_device_arrangement,
const TensorMap& in_tensor_map,
const TensorShape& in_tensor_shape,
const DeviceArrangement& out_device_arrangement,
const TensorMap& out_tensor_map,
const TensorShape& out_tensor_shape) {
void LayoutTransferValidLayoutChangeCheck(const std::vector<int32_t>& in_device_arrangement,
const std::vector<int32_t>& in_tensor_map,
const std::vector<int32_t>& in_tensor_shape,
const std::vector<int32_t>& out_device_arrangement,
const std::vector<int32_t>& out_tensor_map,
const std::vector<int32_t>& out_tensor_shape) {
bool is_expended = IsExpended(out_device_arrangement, in_device_arrangement);
ASSERT_EQ(true, is_expended);
is_expended = IsExpended(out_tensor_shape, in_tensor_shape);
ASSERT_EQ(true, is_expended);
std::map<int64_t, int64_t> out_accum_device_to_accum_shape_map;
std::map<int32_t, int32_t> out_accum_device_to_accum_shape_map;
ComputeAccumDeviceTOAccumShapeMap(out_device_arrangement, out_tensor_map, out_tensor_shape,
&out_accum_device_to_accum_shape_map);
std::map<int64_t, int64_t> in_accum_device_to_accum_shape_map;
std::map<int32_t, int32_t> in_accum_device_to_accum_shape_map;
ComputeAccumDeviceTOAccumShapeMap(in_device_arrangement, in_tensor_map, in_tensor_shape,
&in_accum_device_to_accum_shape_map);
std::map<int64_t, int64_t>::iterator in_iter = in_accum_device_to_accum_shape_map.begin();
std::map<int32_t, int32_t>::iterator in_iter = in_accum_device_to_accum_shape_map.begin();
while (in_iter != in_accum_device_to_accum_shape_map.end()) {
if (in_iter->second != out_accum_device_to_accum_shape_map[in_iter->first]) {
continue;
}
in_iter++;
}
std::map<int64_t, int64_t>::iterator out_iter = out_accum_device_to_accum_shape_map.begin();
std::map<int32_t, int32_t>::iterator out_iter = out_accum_device_to_accum_shape_map.begin();
while (out_iter != out_accum_device_to_accum_shape_map.end()) {
if (out_accum_device_to_accum_shape_map.find(out_iter->first) == out_accum_device_to_accum_shape_map.end()) {
in_iter = in_accum_device_to_accum_shape_map.begin();
int64_t small = 1;
int64_t big = 1;
int32_t small = 1;
int32_t big = 1;
while (in_iter != in_accum_device_to_accum_shape_map.end()) {
if (in_iter->first < out_iter->first) {
small = in_iter->second;
@ -309,18 +311,18 @@ void LayoutTransferValidLayoutChangeCheck(const DeviceArrangement& in_device_arr
if (big == 1) {
ASSERT_EQ(true, false);
}
int64_t small_value = in_accum_device_to_accum_shape_map[small];
int64_t big_value = in_accum_device_to_accum_shape_map[big];
int32_t small_value = in_accum_device_to_accum_shape_map[small];
int32_t big_value = in_accum_device_to_accum_shape_map[big];
IsLinearValue(small, big, small_value, big_value, out_iter->first, out_iter->second);
}
out_iter++;
}
}
void ValidLayoutChangeCheck(const DeviceArrangement& in_device_arrangement,
const TensorMap& in_tensor_map, const TensorShape& in_tensor_shape,
const DeviceArrangement& out_device_arrangement,
const TensorMap& out_tensor_map, const TensorShape& out_tensor_shape) {
void ValidLayoutChangeCheck(const std::vector<int32_t>& in_device_arrangement,
const std::vector<int32_t>& in_tensor_map, const std::vector<int32_t>& in_tensor_shape,
const std::vector<int32_t>& out_device_arrangement,
const std::vector<int32_t>& out_tensor_map, const std::vector<int32_t>& out_tensor_shape) {
LayoutTransferValidLayoutChangeCheck(in_device_arrangement, in_tensor_map, in_tensor_shape, out_device_arrangement,
out_tensor_map, out_tensor_shape);
}

View File

@ -21,50 +21,51 @@
#include <vector>
#include "frontend/parallel/tensor_layout/tensor_layout.h"
#include "frontend/parallel/step_parallel.h"
namespace mindspore {
namespace parallel {
std::vector<Shape> combine(const Shape& in, int64_t target);
std::vector<std::vector<int32_t>> combine(const std::vector<int32_t>& in, int32_t target);
void GenerateValidShapeBySizeAndDim(int64_t pow_size, int64_t dim, std::vector<Shape>* out);
void GenerateValidShapeBySizeAndDim(int32_t pow_size, int32_t dim,
std::vector<std::vector<int32_t>>* out);
void GenerateValidShapeBySize(int64_t pow_size, std::vector<Shape>* out);
void GenerateValidShapeBySize(int32_t pow_size, std::vector<std::vector<int32_t>>* out);
TensorMap GenerateTensorMap(const int64_t& map_size, const Shape& pos_index, const Shape& pos_value);
std::vector<int32_t> GenerateTensorMap(const uint32_t& map_size, const std::vector<int32_t>& pos_index,
const std::vector<int32_t>& pos_value);
void GenerateValidTensorMap(const DeviceArrangement& device_arrangement, const TensorMap& tensor_shape,
std::vector<TensorMap>* tensor_map_list);
void GenerateValidTensorMap(const std::vector<int32_t>& device_arrangement, const std::vector<int32_t>& tensor_shape,
std::vector<std::vector<int32_t>>* tensor_map_list);
void GenerateValidLayoutByDeviceSizeAndTensorSize(
int64_t device_pow_size, int64_t tensor_pow_size, int64_t max_device_dim,
int64_t max_shape_dim,
std::vector<std::tuple<DeviceArrangement, TensorMap, TensorShape>>* layout_list);
int32_t device_pow_size, int32_t tensor_pow_size, int32_t max_device_dim,
int32_t max_shape_dim,
std::vector<std::tuple<std::vector<int32_t>, std::vector<int32_t>, std::vector<int32_t>>>* layout_list);
size_t ComputeNoneNumber(const TensorMap& tensor_map);
uint32_t ComputeNoneNumber(const std::vector<int32_t>& tensor_map);
bool ShapeIsDividedByDevice(const DeviceArrangement& device_arrangement, const TensorMap& tensor_map,
const TensorShape& tensor_shape);
bool ShapeIsDividedByDevice(const std::vector<int32_t>& device_arrangement, const std::vector<int32_t>& tensor_map,
const std::vector<int32_t>& tensor_shape);
bool CheckLayoutValid(const DeviceArrangement& device_arrangement, const TensorMap& tensor_map,
const TensorShape& tensor_shape);
bool CheckLayoutValid(const std::vector<int32_t>& device_arrangement, const std::vector<int32_t>& tensor_map,
const std::vector<int32_t>& tensor_shape);
void ComputeAccumDeviceTOAccumShapeMap(const DeviceArrangement& device_arrangement,
const TensorMap& tensor_map, const TensorShape& tensor_shape,
std::map<int64_t, int64_t>* accum_device_to_accum_shape_map);
void ComputeAccumDeviceTOAccumShapeMap(const std::vector<int32_t>& device_arrangement,
const std::vector<int32_t>& tensor_map, const std::vector<int32_t>& tensor_shape,
std::map<int32_t, int32_t>* accum_device_to_accum_shape_map);
void LayoutTransferValidLayoutChangeCheck(const DeviceArrangement& in_device_arrangement,
const TensorMap& in_tensor_map,
const TensorShape& in_tensor_shape,
const DeviceArrangement& out_device_arrangement,
const TensorMap& out_tensor_map,
const TensorShape& out_tensor_shape);
void LayoutTransferValidLayoutChangeCheck(const std::vector<int32_t>& in_device_arrangement,
const std::vector<int32_t>& in_tensor_map,
const std::vector<int32_t>& in_tensor_shape,
const std::vector<int32_t>& out_device_arrangement,
const std::vector<int32_t>& out_tensor_map,
const std::vector<int32_t>& out_tensor_shape);
void ValidLayoutChangeCheck(const DeviceArrangement& in_device_arrangement,
const TensorMap& in_tensor_map, const TensorShape& in_tensor_shape,
const DeviceArrangement& out_device_arrangement,
const TensorMap& out_tensor_map, const TensorShape& out_tensor_shape);
void ValidLayoutChangeCheck(const std::vector<int32_t>& in_device_arrangement,
const std::vector<int32_t>& in_tensor_map, const std::vector<int32_t>& in_tensor_shape,
const std::vector<int32_t>& out_device_arrangement,
const std::vector<int32_t>& out_tensor_map, const std::vector<int32_t>& out_tensor_shape);
} // namespace parallel
} // namespace mindspore

View File

@ -37,13 +37,13 @@ class TestVirtualDatasetInfo : public UT::Common {
};
void TestVirtualDatasetInfo::SetUp() {
RankList dev_list;
std::vector<int32_t> dev_list;
for (int32_t i = 0; i < 130; i++) {
dev_list.push_back(i);
}
RankList stage_map;
std::vector<int32_t> stage_map;
stage_map.push_back(16);
stage_map.push_back(114);
@ -62,27 +62,27 @@ void TestVirtualDatasetInfo::SetUp() {
}
TEST_F(TestVirtualDatasetInfo, InferDevMatrixShape1) {
Strategys inputs = {{16, 1}, {16, 1}, {16, 1}};
std::vector<Dimensions> inputs = {{16, 1}, {16, 1}, {16, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
virtual_dataset->Init(strategy);
Shape dev_matrix_shape = virtual_dataset->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = virtual_dataset->dev_matrix_shape();
Shape expect = {16};
std::vector<int32_t> expect = {16};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestVirtualDatasetInfo, InferDevMatrixShape2) {
Strategys inputs = {{8, 1}, {8, 1}, {8, 1}};
std::vector<Dimensions> inputs = {{8, 1}, {8, 1}, {8, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
virtual_dataset->Init(strategy);
Shape dev_matrix_shape = virtual_dataset->dev_matrix_shape();
std::vector<int32_t> dev_matrix_shape = virtual_dataset->dev_matrix_shape();
Shape expect = {8, 2};
std::vector<int32_t> expect = {8, 2};
ASSERT_EQ(dev_matrix_shape, expect);
}
TEST_F(TestVirtualDatasetInfo, InferSliceShape1) {
Strategys str = {{8, 1}, {8, 1}, {8, 1}};
std::vector<Dimensions> str = {{8, 1}, {8, 1}, {8, 1}};
StrategyPtr strategy = NewStrategy(0, str);
virtual_dataset->Init(strategy);
@ -127,7 +127,7 @@ TEST_F(TestVirtualDatasetInfo, InferSliceShape1) {
}
TEST_F(TestVirtualDatasetInfo, GetTensorLayout1) {
Strategys str = {{8, 1}, {8, 1}, {8, 1}};
std::vector<Dimensions> str = {{8, 1}, {8, 1}, {8, 1}};
StrategyPtr strategy = NewStrategy(0, str);
virtual_dataset->Init(strategy);
@ -148,7 +148,7 @@ TEST_F(TestVirtualDatasetInfo, GetTensorLayout1) {
}
TEST_F(TestVirtualDatasetInfo, GetForwardOp1) {
Strategys inputs = {{8, 1}, {8, 1}, {8, 1}};
std::vector<Dimensions> inputs = {{8, 1}, {8, 1}, {8, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
virtual_dataset->Init(strategy);
@ -159,7 +159,7 @@ TEST_F(TestVirtualDatasetInfo, GetForwardOp1) {
}
TEST_F(TestVirtualDatasetInfo, GetMirrorOPs1) {
Strategys inputs = {{8, 1}, {8, 1}, {8, 1}};
std::vector<Dimensions> inputs = {{8, 1}, {8, 1}, {8, 1}};
StrategyPtr strategy = NewStrategy(0, inputs);
virtual_dataset->Init(strategy);