1111#include " core/framework/allocation_planner.h"
1212#include " core/framework/ml_value_patterns_planner.h"
1313#include " core/common/logging/logging.h"
14- // #include "core/framework/session_state.h"
1514
1615namespace Lotus {
1716
@@ -115,34 +114,37 @@ class ExecutionFrame {
115114 // Return nullptr if index map to an value that is an unused optional input/output
116115 template <typename T>
117116 const T* GetValue (int index) const {
118- LOTUS_ENFORCE (index >= 0 && index < node_values_.size ());
117+ LOTUS_ENFORCE (index >= 0 && static_cast < size_t >( index) < node_values_.size ());
119118 return node_values_[index] >= 0 ? &all_values_[node_values_[index]].Get <T>() : nullptr ;
120119 }
121120
122121 Fence_t GetFence (int index) const {
123- LOTUS_ENFORCE (index >= 0 && index < node_values_.size ());
122+ LOTUS_ENFORCE (index >= 0 && static_cast < size_t >( index) < node_values_.size ());
124123 return node_values_[index] >= 0 ? all_values_[node_values_[index]].Fence () : nullptr ;
125124 }
126125
127126 // Return nullptr if index map to an value that is an unused optional input/output
128127 MLDataType GetType (int index) const {
129- LOTUS_ENFORCE (index >= 0 && index < node_values_.size ());
128+ LOTUS_ENFORCE (index >= 0 && static_cast < size_t >( index) < node_values_.size ());
130129 return node_values_[index] >= 0 ? all_values_[node_values_[index]].Type () : nullptr ;
131130 }
132131
133132 // Return nullptr if index map to an value that is an unused optional input/output
134133 template <typename T>
135134 T* GetMutableValue (int index) {
136- LOTUS_ENFORCE (index >= 0 && index < node_values_.size ());
135+ LOTUS_ENFORCE (index >= 0 && static_cast < size_t >( index) < node_values_.size ());
137136 return node_values_[index] >= 0 ? all_values_[node_values_[index]].GetMutable <T>() : nullptr ;
138137 }
139138
140139 AllocatorPtr GetAllocator (const AllocatorInfo& info);
141140
142- void ReleaseMLValue (int mlvalue_idx) {
143- LOTUS_ENFORCE (mlvalue_idx >= 0 || mlvalue_idx < all_values_.size ());
141+ Status ReleaseMLValue (int mlvalue_idx) {
142+ if (mlvalue_idx < 0 || mlvalue_idx >= all_values_.size ()) {
143+ return LOTUS_MAKE_STATUS (LOTUS, INVALID_ARGUMENT, " invalid index " , mlvalue_idx);
144+ }
144145 all_values_[mlvalue_idx] = MLValue ();
145146 TraceFree (mlvalue_idx);
147+ return Status::OK ();
146148 }
147149
148150 const Lotus::SessionState& SessionState () const {
@@ -170,8 +172,8 @@ class ExecutionFrame {
170172 bool create_fence);
171173
172174 void Init (const LotusIR::Graph* graph,
173- const std::unordered_map<string, MLValue>& feeds,
174- const std::vector<string>& output_names,
175+ const std::unordered_map<std:: string, MLValue>& feeds,
176+ const std::vector<std:: string>& output_names,
175177 const std::vector<MLValue>& fetches);
176178
177179 void SetupNodeArg (const LotusIR::NodeArg* arg);
@@ -187,7 +189,7 @@ class ExecutionFrame {
187189 template <typename T>
188190 Status GetOrCreateMLValue (int index, const MLValueAllocationParameters& parameters, T*& value) {
189191 if (index < 0 || index >= node_values_.size ()) {
190- return Status (LOTUS, INVALID_ARGUMENT,
192+ return Status (Common:: LOTUS, Common:: INVALID_ARGUMENT,
191193 " Try to access with invalid node value index: " + std::to_string (index));
192194 }
193195
@@ -236,7 +238,7 @@ class ExecutionFrame {
236238 // i-th kernel is still waiting for pending_counts_[i] inputs.
237239 std::vector<int > pending_counts_; // not used currently
238240
239- std::unordered_map<string, int > value_name_to_index_;
241+ std::unordered_map<std:: string, int > value_name_to_index_;
240242
241243 const Lotus::SessionState& session_state_;
242244
0 commit comments