fix codex warning 0729

This commit is contained in:
huanghui 2021-07-29 10:49:38 +08:00
parent ad589e6780
commit fd56922cf9
7 changed files with 31 additions and 20 deletions

View File

@ -68,7 +68,7 @@ std::shared_ptr<GraphCell> MsModel::GenerateGraphCell(const std::vector<std::vec
MS_LOG(ERROR) << "Inputs " << i << " is not supported to resize, debug string: " << param->DebugString();
return nullptr;
}
shape_ptr->shape() = dims[i];
shape_ptr->set_shape(dims[i]);
}
auto graph = std::make_shared<Graph>(std::make_shared<Graph::GraphData>(func_graph, ModelType::kMindIR));

View File

@ -99,6 +99,8 @@ class GraphTupleParamTransform {
mng->AddFuncGraph(new_fg);
return new_fg;
}
private:
std::unordered_map<FuncGraphPtr, FuncGraphPtr> cache_;
};
} // namespace opt

View File

@ -29,8 +29,6 @@ class NormalDistribution;
template <class T>
class NormalDistribution<T, float> {
public:
std::array<float, gResultNum> result;
bool UInt32ToFloat32(uint32_t input, float *output) {
const uint32_t temp_value = input & 0x7fffffu;
const uint32_t exp = static_cast<uint32_t>(127);
@ -55,11 +53,14 @@ class NormalDistribution<T, float> {
const float threshold = 1.0e-7f;
temp[0] = temp[0] < threshold ? threshold : temp[0];
temp[1] = temp[1] < threshold ? threshold : temp[1];
result[i] = sqrt(-2.0 * log(temp[0])) * sin(2 * PI * temp[1]);
result[i + 1] = sqrt(-2.0 * log(temp[0])) * cos(2 * PI * temp[1]);
result_[i] = sqrt(-2.0 * log(temp[0])) * sin(2 * PI * temp[1]);
result_[i + 1] = sqrt(-2.0 * log(temp[0])) * cos(2 * PI * temp[1]);
}
return result;
return result_;
}
private:
std::array<float, gResultNum> result_;
};
template <class T>

View File

@ -77,13 +77,15 @@ class Shape : public BaseShape {
bool operator==(const BaseShape &other) const override;
BaseShapePtr Clone() const override { return std::make_shared<Shape>(shape_, min_shape_, max_shape_); }
void Broaden() override;
ShapeVector &shape() { return shape_; }
ShapeVector &min_shape() { return min_shape_; }
ShapeVector &max_shape() { return max_shape_; }
void set_shape(const ShapeVector &shape) { shape_ = shape; }
const ShapeVector &shape() { return shape_; }
const ShapeVector &min_shape() { return min_shape_; }
const ShapeVector &max_shape() { return max_shape_; }
bool IsDynamic() const override {
return std::any_of(shape_.begin(), shape_.end(), [](int64_t s) { return s < 0; });
}
private:
ShapeVector shape_; // use SHP_ANY to implement the any shape in python
ShapeVector min_shape_; // record minimum length for each dynamic dimension
ShapeVector max_shape_; // record maximum length for each dynamic dimension

View File

@ -88,9 +88,9 @@ void TraceContext::ProcessAttributeFromContext() {
// if there is trace context, get info from previous context
if (!TraceManager::trace_context_stack_.empty()) {
TraceContextPtr top = TraceManager::trace_context_stack_.top();
trace_info_ = top->trace_info_;
location_ = top->location_;
func_name_ = top->func_name_;
trace_info_ = top->trace_info();
location_ = top->location();
func_name_ = top->func_name();
}
}

View File

@ -97,14 +97,6 @@ class TraceGuard {
};
class TraceContext {
public:
LocationPtr location_;
TraceInfoPtr trace_info_;
std::string func_name_;
protected:
void ProcessAttributeFromContext();
public:
~TraceContext() = default;
explicit TraceContext(const LocationPtr &loc) {
@ -125,6 +117,14 @@ class TraceContext {
TraceInfoPtr trace_info() const { return trace_info_; }
void set_func_name(const std::string &func_name) { func_name_ = func_name; }
std::string func_name() { return func_name_; }
protected:
void ProcessAttributeFromContext();
private:
LocationPtr location_;
TraceInfoPtr trace_info_;
std::string func_name_;
};
class DebugInfo : public Base {
@ -200,6 +200,8 @@ class NodeDebugInfo : public DebugInfo {
std::shared_ptr<AnfNode> get_node() const { return node_.lock(); }
void set_py_func_belonged(const std::string &name) { py_func_belonged_ = name; }
std::string get_python_func_belonged() override { return py_func_belonged_; }
private:
AnfNodeWeakPtr node_;
std::string py_func_belonged_;
};
@ -232,6 +234,8 @@ class GraphDebugInfo : public DebugInfo {
std::string get_full_name() { return full_name_; }
void set_deco_location(const LocationPtr &deco_list_loc);
std::string get_python_func_belonged() override { return py_func_name_; }
private:
FuncGraphWeakPtr func_graph_;
LocationPtr deco_loc_;
std::string py_func_name_;

View File

@ -258,6 +258,8 @@ class TraceSpecialize : public TraceInfo {
std::string full_name() const override { return full_name_ + counter_ + "_"; }
~TraceSpecialize() override = default;
TraceInfoPtr clone() override { return std::make_shared<TraceSpecialize>(*shared_from_base<TraceSpecialize>()); }
private:
std::string counter_;
};