Merge pull request !3248 from shenwei41/sw_mastertags/v0.6.0-beta
| @@ -186,7 +186,7 @@ std::shared_ptr<ProjectDataset> Dataset::Project(const std::vector<std::string> | |||||
| // Helper function to create default RandomSampler. | // Helper function to create default RandomSampler. | ||||
| std::shared_ptr<SamplerObj> CreateDefaultSampler() { | std::shared_ptr<SamplerObj> CreateDefaultSampler() { | ||||
| int32_t num_samples = 0; // 0 means to sample all ids. | |||||
| const int32_t num_samples = 0; // 0 means to sample all ids. | |||||
| bool replacement = false; | bool replacement = false; | ||||
| return std::make_shared<RandomSamplerObj>(replacement, num_samples); | return std::make_shared<RandomSamplerObj>(replacement, num_samples); | ||||
| } | } | ||||
| @@ -1157,8 +1157,8 @@ Status DEPipeline::ParseTFReaderOp(const py::dict &args, std::shared_ptr<Dataset | |||||
| if (sampler) { | if (sampler) { | ||||
| (void)builder->SetSampler(std::move(sampler)); | (void)builder->SetSampler(std::move(sampler)); | ||||
| } else if (cache_client) { | } else if (cache_client) { | ||||
| int64_t num_samples = 0; | |||||
| int64_t start_index = 0; | |||||
| const int64_t num_samples = 0; | |||||
| const int64_t start_index = 0; | |||||
| sampler = std::make_shared<SequentialSampler>(num_samples, start_index); | sampler = std::make_shared<SequentialSampler>(num_samples, start_index); | ||||
| (void)builder->SetSampler(std::move(sampler)); | (void)builder->SetSampler(std::move(sampler)); | ||||
| } | } | ||||
| @@ -1511,8 +1511,8 @@ Status DEPipeline::ParseRandomDataOp(const py::dict &args, std::shared_ptr<Datas | |||||
| if (sampler) { | if (sampler) { | ||||
| (void)builder.SetSampler(std::move(sampler)); | (void)builder.SetSampler(std::move(sampler)); | ||||
| } else if (cache_client) { | } else if (cache_client) { | ||||
| int64_t num_samples = 0; | |||||
| int64_t start_index = 0; | |||||
| const int64_t num_samples = 0; | |||||
| const int64_t start_index = 0; | |||||
| sampler = std::make_shared<SequentialSampler>(num_samples, start_index); | sampler = std::make_shared<SequentialSampler>(num_samples, start_index); | ||||
| (void)builder.SetSampler(std::move(sampler)); | (void)builder.SetSampler(std::move(sampler)); | ||||
| } | } | ||||
| @@ -111,6 +111,7 @@ class BatchFetchRequest : public BaseRequest { | |||||
| friend class CacheService; | friend class CacheService; | ||||
| BatchFetchRequest(connection_id_type connection_id, const std::vector<row_id_type> &row_id) | BatchFetchRequest(connection_id_type connection_id, const std::vector<row_id_type> &row_id) | ||||
| : BaseRequest(connection_id, RequestType::kBatchFetchRows), row_id_(row_id) {} | : BaseRequest(connection_id, RequestType::kBatchFetchRows), row_id_(row_id) {} | ||||
| ~BatchFetchRequest() = default; | |||||
| Status RestoreRows(TensorTable *out); | Status RestoreRows(TensorTable *out); | ||||
| private: | private: | ||||
| @@ -130,6 +131,8 @@ class CreationCacheRequest : public BaseRequest { | |||||
| CreateCacheFlag flag = CreateCacheFlag::kNone) | CreateCacheFlag flag = CreateCacheFlag::kNone) | ||||
| : BaseRequest(connection_id, RequestType::kCreateCache), cache_mem_sz(cache_mem_sz), flag_(flag) {} | : BaseRequest(connection_id, RequestType::kCreateCache), cache_mem_sz(cache_mem_sz), flag_(flag) {} | ||||
| ~CreationCacheRequest() = default; | |||||
| std::string cookie() const { return cookie_; } | std::string cookie() const { return cookie_; } | ||||
| private: | private: | ||||
| @@ -142,6 +145,8 @@ class PurgeCacheRequest : public BaseRequest { | |||||
| public: | public: | ||||
| friend class CacheServer; | friend class CacheServer; | ||||
| explicit PurgeCacheRequest(connection_id_type connection_id) : BaseRequest(connection_id, RequestType::kPurgeCache) {} | explicit PurgeCacheRequest(connection_id_type connection_id) : BaseRequest(connection_id, RequestType::kPurgeCache) {} | ||||
| ~PurgeCacheRequest() = default; | |||||
| }; | }; | ||||
| /// \brief Request to destroy a cache | /// \brief Request to destroy a cache | ||||
| class DestroyCacheRequest : public BaseRequest { | class DestroyCacheRequest : public BaseRequest { | ||||
| @@ -149,6 +154,9 @@ class DestroyCacheRequest : public BaseRequest { | |||||
| friend class CacheServer; | friend class CacheServer; | ||||
| explicit DestroyCacheRequest(connection_id_type connection_id) | explicit DestroyCacheRequest(connection_id_type connection_id) | ||||
| : BaseRequest(connection_id, RequestType::kDestroyCache) {} | : BaseRequest(connection_id, RequestType::kDestroyCache) {} | ||||
| /// \brief Destructor | |||||
| ~DestroyCacheRequest() = default; | |||||
| }; | }; | ||||
| /// \brief Obtain the statistics of the current connection | /// \brief Obtain the statistics of the current connection | ||||
| class GetStatRequest : public BaseRequest { | class GetStatRequest : public BaseRequest { | ||||
| @@ -156,6 +164,9 @@ class GetStatRequest : public BaseRequest { | |||||
| friend class CacheServer; | friend class CacheServer; | ||||
| friend class CacheService; | friend class CacheService; | ||||
| explicit GetStatRequest(connection_id_type connection_id) : BaseRequest(connection_id, RequestType::kGetStat) {} | explicit GetStatRequest(connection_id_type connection_id) : BaseRequest(connection_id, RequestType::kGetStat) {} | ||||
| ~GetStatRequest() = default; | |||||
| row_id_type GetMinRowId() const { | row_id_type GetMinRowId() const { | ||||
| auto *msg = flatbuffers::GetRoot<ServiceStatMsg>(mem_.GetPointer()); | auto *msg = flatbuffers::GetRoot<ServiceStatMsg>(mem_.GetPointer()); | ||||
| return msg->min_row_id(); | return msg->min_row_id(); | ||||
| @@ -217,6 +228,8 @@ class BuildPhaseDoneRequest : public BaseRequest { | |||||
| BuildPhaseDoneRequest(connection_id_type connection_id, const std::string &cookie) | BuildPhaseDoneRequest(connection_id_type connection_id, const std::string &cookie) | ||||
| : BaseRequest(connection_id, RequestType::kBuildPhaseDone), cookie_(cookie) {} | : BaseRequest(connection_id, RequestType::kBuildPhaseDone), cookie_(cookie) {} | ||||
| ~BuildPhaseDoneRequest() = default; | |||||
| private: | private: | ||||
| std::string cookie_; | std::string cookie_; | ||||
| }; | }; | ||||
| @@ -35,6 +35,9 @@ class RepeatPass : public NodePass { | |||||
| /// \brief Constructor | /// \brief Constructor | ||||
| RepeatPass(); | RepeatPass(); | ||||
| /// \brief Destructor | |||||
| ~RepeatPass() = default; | |||||
| /// \brief Identifies the subtree below this node as being in a repeated path of the tree. | /// \brief Identifies the subtree below this node as being in a repeated path of the tree. | ||||
| /// \param[in] node The node being visited | /// \param[in] node The node being visited | ||||
| /// \param[inout] modified Indicator if the node was changed at all | /// \param[inout] modified Indicator if the node was changed at all | ||||
| @@ -67,8 +67,8 @@ Status CachePass::RunOnNode(std::shared_ptr<CacheOp> node, bool *modified) { | |||||
| MS_LOG(INFO) << "Cache transform pass: Set up cache sampler from non-mappable leaf."; | MS_LOG(INFO) << "Cache transform pass: Set up cache sampler from non-mappable leaf."; | ||||
| } else { | } else { | ||||
| // We're a cache op but no sampler was saved from leaf, so create a default sampler | // We're a cache op but no sampler was saved from leaf, so create a default sampler | ||||
| int64_t num_samples = 0; | |||||
| int64_t start_index = 0; | |||||
| const int64_t num_samples = 0; | |||||
| const int64_t start_index = 0; | |||||
| sampler_ = std::make_shared<SequentialSampler>(num_samples, start_index); | sampler_ = std::make_shared<SequentialSampler>(num_samples, start_index); | ||||
| node->SetSampler(std::move(sampler_)); | node->SetSampler(std::move(sampler_)); | ||||
| MS_LOG(INFO) << "Cache transform pass: Creating default sequential sampler for cache op."; | MS_LOG(INFO) << "Cache transform pass: Creating default sequential sampler for cache op."; | ||||
| @@ -36,6 +36,9 @@ class CachePass : public NodePass { | |||||
| /// \param[in] transform_pass Raw pointer back to controlling tree pass | /// \param[in] transform_pass Raw pointer back to controlling tree pass | ||||
| explicit CachePass(CacheTransformPass *transform_pass); | explicit CachePass(CacheTransformPass *transform_pass); | ||||
| /// \brief Destructor | |||||
| ~CachePass() = default; | |||||
| /// \brief Identifies the subtree below this node as a cached descendant tree. | /// \brief Identifies the subtree below this node as a cached descendant tree. | ||||
| /// \param[in] node The node being visited | /// \param[in] node The node being visited | ||||
| /// \param[inout] modified Indicator if the node was changed at all | /// \param[inout] modified Indicator if the node was changed at all | ||||
| @@ -37,6 +37,9 @@ class CacheTransformPass : public TreePass { | |||||
| /// \brief Constructor | /// \brief Constructor | ||||
| CacheTransformPass(); | CacheTransformPass(); | ||||
| /// \brief Destructor | |||||
| ~CacheTransformPass() = default; | |||||
| /// \brief Runs a cache_pass first to set up the transformation nodes, and then drives any of these transformations | /// \brief Runs a cache_pass first to set up the transformation nodes, and then drives any of these transformations | ||||
| /// \param[inout] tree The tree to operate on. | /// \param[inout] tree The tree to operate on. | ||||
| /// \param[inout] Indicate of the tree was modified. | /// \param[inout] Indicate of the tree was modified. | ||||
| @@ -664,8 +664,8 @@ Status AutoContrast(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor | |||||
| table.push_back(i); | table.push_back(i); | ||||
| } | } | ||||
| } else { | } else { | ||||
| float scale = 255.0 / (hi - lo); | |||||
| float offset = -1 * lo * scale; | |||||
| const float scale = 255.0 / (hi - lo); | |||||
| const float offset = -1 * lo * scale; | |||||
| for (int32_t i = 0; i < 256; i++) { | for (int32_t i = 0; i < 256; i++) { | ||||
| int32_t ix = static_cast<int32_t>(i * scale + offset); | int32_t ix = static_cast<int32_t>(i * scale + offset); | ||||
| ix = std::max(ix, 0); | ix = std::max(ix, 0); | ||||