!12611 add master new cops

From: @lyvette
Reviewed-by: 
Signed-off-by:
This commit is contained in:
mindspore-ci-bot 2021-02-26 14:24:13 +08:00 committed by Gitee
commit d180693e60
8 changed files with 227 additions and 8 deletions

View File

@ -0,0 +1,24 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ops/grad/abs_grad.h"
#include <memory>
namespace mindspore {
namespace ops {
REGISTER_PRIMITIVE_C(kNameAbsGrad, AbsGrad);
} // namespace ops
} // namespace mindspore

View File

@ -0,0 +1,40 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MINDSPORE_CORE_OPS_ABS_GRAD_H_
#define MINDSPORE_CORE_OPS_ABS_GRAD_H_
#include <map>
#include <vector>
#include <string>
#include <memory>
#include "ops/primitive_c.h"
#include "abstract/abstract_value.h"
#include "utils/check_convert_utils.h"
namespace mindspore {
namespace ops {
constexpr auto kNameAbsGrad = "AbsGrad";
class AbsGrad : public PrimitiveC {
public:
AbsGrad() : PrimitiveC(kNameAbsGrad) {}
~AbsGrad() = default;
MS_DECLARE_PARENT(AbsGrad, PrimitiveC);
void Init() {}
};
} // namespace ops
} // namespace mindspore
#endif // MINDSPORE_CORE_OPS_ABS_GRAD_H_

View File

@ -0,0 +1,24 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ops/lin_space.h"
#include <memory>
namespace mindspore {
namespace ops {
REGISTER_PRIMITIVE_C(kNameLinSpace, LinSpace);
} // namespace ops
} // namespace mindspore

View File

@ -0,0 +1,39 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MINDSPORE_CORE_OPS_LIN_SPACE_H_
#define MINDSPORE_CORE_OPS_LIN_SPACE_H_
#include <vector>
#include <memory>
#include "ops/primitive_c.h"
#include "abstract/abstract_value.h"
#include "utils/check_convert_utils.h"
namespace mindspore {
namespace ops {
constexpr auto kNameLinSpace = "LinSpace";
class LinSpace : public PrimitiveC {
public:
LinSpace() : PrimitiveC(kNameLinSpace) { InitIOName({"start", "stop", "num"}, {"output"}); }
~LinSpace() = default;
MS_DECLARE_PARENT(LinSpace, PrimitiveC);
void Init() {}
};
} // namespace ops
} // namespace mindspore
#endif // MINDSPORE_CORE_OPS_LIN_SPACE_H_

View File

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* Copyright 2021 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,14 +31,14 @@ void RandomStandardNormal::set_seed(const int64_t seed) { this->AddAttr(kSeed, M
void RandomStandardNormal::set_seed2(const int64_t seed2) { this->AddAttr(kSeed2, MakeValue(seed2)); }
bool RandomStandardNormal::get_seed() const {
int64_t RandomStandardNormal::get_seed() const {
auto value_ptr = GetAttr(kSeed);
return GetValue<bool>(value_ptr);
return GetValue<int64_t>(value_ptr);
}
bool RandomStandardNormal::get_seed2() const {
int64_t RandomStandardNormal::get_seed2() const {
auto value_ptr = GetAttr(kSeed2);
return GetValue<bool>(value_ptr);
return GetValue<int64_t>(value_ptr);
}
REGISTER_PRIMITIVE_C(kNameRandomStandardNormal, RandomStandardNormal);

View File

@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* Copyright 2021 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -37,8 +37,8 @@ class RandomStandardNormal : public PrimitiveC {
void set_seed(const int64_t seed);
void set_seed2(const int64_t seed2);
bool get_seed() const;
bool get_seed2() const;
int64_t get_seed() const;
int64_t get_seed2() const;
};
AbstractBasePtr RandomStandardNormalInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive,

View File

@ -0,0 +1,46 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ops/uniform_real.h"
#include <string>
#include <memory>
#include <vector>
#include "ops/op_utils.h"
#include "utils/check_convert_utils.h"
namespace mindspore {
namespace ops {
void UniformReal::Init(const int64_t seed, const int64_t seed2) {
this->set_seed(seed);
this->set_seed2(seed2);
}
void UniformReal::set_seed(const int64_t seed) { this->AddAttr(kSeed, MakeValue(seed)); }
void UniformReal::set_seed2(const int64_t seed2) { this->AddAttr(kSeed2, MakeValue(seed2)); }
int64_t UniformReal::get_seed() const {
auto value_ptr = GetAttr(kSeed);
return GetValue<int64_t>(value_ptr);
}
int64_t UniformReal::get_seed2() const {
auto value_ptr = GetAttr(kSeed2);
return GetValue<int64_t>(value_ptr);
}
REGISTER_PRIMITIVE_C(kNameUniformReal, UniformReal);
} // namespace ops
} // namespace mindspore

View File

@ -0,0 +1,46 @@
/**
* Copyright 2021 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MINDSPORE_CORE_OPS_RANDOM_UNIFORM_REAL_H_
#define MINDSPORE_CORE_OPS_RANDOM_UNIFORM_REAL_H_
#include <map>
#include <vector>
#include <string>
#include <memory>
#include "ops/primitive_c.h"
#include "abstract/abstract_value.h"
#include "utils/check_convert_utils.h"
namespace mindspore {
namespace ops {
constexpr auto kNameUniformReal = "UniformReal";
class UniformReal : public PrimitiveC {
public:
UniformReal() : PrimitiveC(kNameUniformReal) {}
~UniformReal() = default;
MS_DECLARE_PARENT(UniformReal, PrimitiveC);
void Init(const int64_t seed, const int64_t seed2);
void set_seed(const int64_t seed);
void set_seed2(const int64_t seed2);
int64_t get_seed() const;
int64_t get_seed2() const;
};
} // namespace ops
} // namespace mindspore
#endif // MINDSPORE_CORE_OPS_RANDOM_UNIFORM_REAL_H_