Misc C++ lint fixes

PiperOrigin-RevId: 253947920
This commit is contained in:
Gaurav Jain 2019-06-19 01:01:22 -07:00 committed by TensorFlower Gardener
parent 0978e88e0e
commit 1aef10221d
3 changed files with 14 additions and 13 deletions

View File

@ -21,7 +21,6 @@ limitations under the License.
#include <memory>
#include <queue>
#include <string>
#include <thread>
#include <vector>
#include "tensorflow/c/c_api.h"
@ -112,7 +111,7 @@ struct TFE_TensorHandle {
};
struct TFE_TensorDebugInfo {
TFE_TensorDebugInfo(const std::vector<tensorflow::int64>& dims)
explicit TFE_TensorDebugInfo(const std::vector<tensorflow::int64>& dims)
: dev_dims(dims) {}
// Fully-padded, minor-to-major.
@ -144,7 +143,7 @@ struct TFE_ProfilerContext {
};
struct TFE_Profiler {
TFE_Profiler(TFE_ProfilerContext* ctx) {
explicit TFE_Profiler(TFE_ProfilerContext* ctx) {
profiler = tensorflow::ProfilerSession::Create(&ctx->profiler_context);
}
@ -231,7 +230,7 @@ struct TFE_MonitoringBoolGauge2 : TFE_MonitoringGauge<bool, 2> {
};
struct TFE_MonitoringBuckets {
TFE_MonitoringBuckets(
explicit TFE_MonitoringBuckets(
std::function<std::unique_ptr<tensorflow::monitoring::Buckets>(void)>
fn) {
create_buckets = fn;
@ -286,7 +285,7 @@ struct TFE_TraceContext {
std::vector<std::pair<tensorflow::TensorHandle*, TF_Output>>* input_tensors =
nullptr;
TFE_TraceContext(TF_Graph* graph) : graph(graph) {}
explicit TFE_TraceContext(TF_Graph* graph) : graph(graph) {}
~TFE_TraceContext() {
delete input_tensors;

View File

@ -17,7 +17,7 @@ limitations under the License.
namespace tensorflow {
EagerNode::EagerNode(tensorflow::uint64 id) : id(id) {}
EagerNode::EagerNode(tensorflow::uint64 id) : id_(id) {}
EagerExecutor::~EagerExecutor() {
tensorflow::mutex_lock l(node_queue_mutex_);
@ -48,10 +48,10 @@ void EagerExecutor::Add(std::unique_ptr<EagerNode> node) {
}
int64 qlen = node_queue_.size();
if (qlen > 0) {
if (node_queue_.back()->id >= node->id) {
if (node_queue_.back()->Id() >= node->Id()) {
status_ = tensorflow::errors::InvalidArgument(
"Inserting EagerNode with non-increasing ids:",
node_queue_.back()->id, " vs ", node->id);
node_queue_.back()->Id(), " vs ", node->Id());
// node will be automatically deleted
return;
}
@ -78,8 +78,8 @@ tensorflow::Status EagerExecutor::WaitImpl(bool wait_all,
if (!status_.ok()) return status_;
if (node_queue_.empty()) return tensorflow::Status::OK();
if (wait_all) {
node_id = node_queue_.back()->id;
} else if (node_id < node_queue_.front()->id) {
node_id = node_queue_.back()->Id();
} else if (node_id < node_queue_.front()->Id()) {
// Note that we are relying on the ops being dispatched sequentially from
// the queue.
return tensorflow::Status::OK();
@ -127,7 +127,7 @@ void EagerExecutor::Run() {
curr_node = node_queue_.front().get();
// We update the last_node_id_ before calling Run() to ensure the value
// is updated before the response callback.
last_node_id_ = curr_node->id;
last_node_id_ = curr_node->Id();
}
tensorflow::Status status = curr_node->Run();
const bool ok = status.ok();

View File

@ -21,7 +21,6 @@ limitations under the License.
#include <memory>
#include <queue>
#include <string>
#include <thread>
#include <vector>
#include "tensorflow/core/common_runtime/device_factory.h"
@ -56,9 +55,12 @@ class EagerNode {
// it should poison the corresponding tensor handles in this method.
virtual void Abort(Status status) = 0;
uint64 Id() const { return id_; }
private:
// An id unique to the TFE_Context under which this node is created. Allocated
// monotonically.
const uint64 id;
const uint64 id_;
};
// A class for handling async execution (see TFE_ContextSetAsync).