Browse Source

add c++ Annotation

tags/v1.6.0
huchunmei 4 years ago
parent
commit
0b5ce37c24
7 changed files with 23 additions and 9 deletions
  1. +3
    -0
      mindspore/core/ops/roll.h
  2. +4
    -2
      mindspore/core/ops/sparse_apply_r_m_s_prop.h
  3. +3
    -2
      mindspore/core/ops/trunc.h
  4. +8
    -0
      mindspore/core/ops/unpack.h
  5. +2
    -2
      mindspore/nn/layer/basic.py
  6. +1
    -1
      mindspore/nn/optim/lamb.py
  7. +2
    -2
      mindspore/ops/operations/nn_ops.py

+ 3
- 0
mindspore/core/ops/roll.h View File

@@ -26,9 +26,12 @@
namespace mindspore {
namespace ops {
constexpr auto kNameRoll = "Roll";
/// \brief Rolls the elements of a tensor along an axis.
class Roll : public PrimitiveC {
public:
/// \brief Constructor.
Roll() : PrimitiveC(kNameRoll) { InitIOName({"input_x"}, {"output"}); }
/// \brief Destructor.
~Roll() = default;
MS_DECLARE_PARENT(Roll, PrimitiveC);
};


+ 4
- 2
mindspore/core/ops/sparse_apply_r_m_s_prop.h View File

@@ -29,12 +29,14 @@
namespace mindspore {
namespace ops {
constexpr auto kNameSparseApplyRMSProp = "SparseApplyRMSProp";
class MS_CORE_API SparseApplyRMSProp : public PrimitiveC {
/// \brief Update relevant entries according to the rmsprop algorithm.
class SparseApplyRMSProp : public PrimitiveC {
public:
/// \brief Constructor.
SparseApplyRMSProp() : PrimitiveC(kNameSparseApplyRMSProp) {
InitIOName({"var", "ms", "mom", "lr", "grad", "indices"}, {"var", "ms", "mom"});
}
/// \brief Destructor.
~SparseApplyRMSProp() = default;
MS_DECLARE_PARENT(SparseApplyRMSProp, PrimitiveC);
};


+ 3
- 2
mindspore/core/ops/trunc.h View File

@@ -26,12 +26,13 @@

namespace mindspore {
namespace ops {

constexpr auto kNameTrunc = "Trunc";
/// \brief Returns a new tensor with the truncated integer values of the elements of input.
class Trunc : public PrimitiveC {
public:
/// \brief Constructor.
Trunc() : PrimitiveC(kNameTrunc) { InitIOName({"input_x"}, {"output_y"}); }
/// \brief Destructor.
~Trunc() = default;
MS_DECLARE_PARENT(Trunc, PrimitiveC);
};


+ 8
- 0
mindspore/core/ops/unpack.h View File

@@ -31,13 +31,21 @@
namespace mindspore {
namespace ops {
constexpr auto kNameUnpack = "Unpack";
/// \brief Unstacks tensor in specified axis. Refer to Python API @ref mindspore.ops.Unstack for more details.
class MS_CORE_API Unpack : public PrimitiveC {
public:
/// \brief Constructor.
Unpack() : PrimitiveC(kNameUnpack) {}
/// \brief Destructor.
~Unpack() = default;
MS_DECLARE_PARENT(Unpack, PrimitiveC);
/// \brief Init. Refer to the parameters of Python API @ref mindspore.ops.Unstack for the inputs.
void Init(const int64_t axis = 0);
/// \brief Set axis.
void set_axis(const int64_t axis);
/// \brief Get axis.
///
/// \return axis.
int64_t get_axis() const;
};
AbstractBasePtr UnpackInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive,


+ 2
- 2
mindspore/nn/layer/basic.py View File

@@ -975,10 +975,10 @@ class Unfold(Cell):
def _check_tuple_or_list(arg_name, arg_val, prim_name):
Validator.check_value_type(f"{arg_name}s", ksizes, [tuple, list], self.cls_name)
if len(arg_val) != 4 or arg_val[0] != 1 or arg_val[3] != 1:
raise ValueError(f"For '{prim_name}' the format of {arg_name}s should be [1, {arg_name}_row, "
raise ValueError(f"For '{prim_name}' the format of '{arg_name}s' should be [1, {arg_name}_row, "
f"{arg_name}_col, 1], but got {arg_val}.")
if not isinstance(arg_val[1], int) or not isinstance(arg_val[2], int) or arg_val[1] < 1 or arg_val[2] < 1:
raise ValueError(f"For '{prim_name}' the {arg_name}_row and {arg_name}_col in {arg_name}s should be "
raise ValueError(f"For '{prim_name}' the {arg_name}_row and {arg_name}_col in '{arg_name}s' should be "
f"an positive integer number, but got {arg_name}_row is {arg_val[1]}, "
f"{arg_name}_col is {arg_val[2]}")



+ 1
- 1
mindspore/nn/optim/lamb.py View File

@@ -190,7 +190,7 @@ class Lamb(Optimizer):
m_t = \frac{m_t}{\beta_1^t}\\
v_t = \frac{v_t}{\beta_2^t}\\
r_t = \frac{m_t}{\sqrt{v_t}+\epsilon}\\
w_t = w_{t-1} -\eta_t \frac{\left \| w_{t-1}\right \|}{\left \| r_t + \lambda w_{t-1}\right \|} (r_t + \lambda w_{t-1})
w_t = w_{t-1} -\eta_t \frac{\| w_{t-1} \|}{\| r_t + \lambda w_{t-1} \|} (r_t + \lambda w_{t-1})
\end{gather*}

where :math:`m` is the 1st moment, and :math:`v` the 2nd moment, :math:`\eta` the


+ 2
- 2
mindspore/ops/operations/nn_ops.py View File

@@ -3747,9 +3747,9 @@ class GeLU(Primitive):
GeLU is defined as follows:

.. math::
\text{output} = 0.5 * x * (1 + erf(x / \sqrt{2})),
\text{output} = 0.5 * x * (1 + tanh(x / \sqrt{2})),

where :math:`erf` is the "Gauss error function" .
where :math:`tanh` is the hyperbolic tangent.

Inputs:
- **x** (Tensor) - Input to compute the GeLU with data type of float16 or float32.


Loading…
Cancel
Save