!44061 [assistant][ops] Add uniformReal算子

Merge pull request !44061 from Joseph_Lee/uniformReal
This commit is contained in:
i-robot 2022-11-25 06:48:22 +00:00 committed by Gitee
commit 1043db6137
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 3 additions and 1 deletions

View File

@ -53,6 +53,7 @@ abstract::AbstractBasePtr UniformRealInfer(const abstract::AnalysisEnginePtr &,
const std::string &op_name = primitive->name();
const int64_t kMinInputNum = 1;
const int64_t kMaxInputNum = 3;
// Check Input
(void)CheckAndConvertUtils::CheckInteger("input numbers", SizeToLong(input_args.size()), kGreaterEqual, kMinInputNum,
op_name);
(void)CheckAndConvertUtils::CheckInteger("input numbers", SizeToLong(input_args.size()), kLessEqual, kMaxInputNum,
@ -60,13 +61,14 @@ abstract::AbstractBasePtr UniformRealInfer(const abstract::AnalysisEnginePtr &,
ShapeVector shape;
abstract::ShapePtr output_shape;
auto shape_value = input_args[0]->BuildValue();
auto shape_value = input_args[kInputIndex0]->BuildValue();
if (!shape_value->isa<AnyValue>() && !shape_value->isa<None>()) {
shape = shape_value->isa<tensor::Tensor>()
? CheckAndConvertUtils::CheckTensorIntValue("input[shape]", shape_value, op_name)
: CheckAndConvertUtils::CheckTupleInt("input[shape]", shape_value, op_name);
output_shape = std::make_shared<abstract::Shape>(shape);
} else {
// ToSupport Dynamic
shape = {-2}; // unknown dimension.
output_shape = std::make_shared<abstract::Shape>(shape);
}