1 /** 2 * Copyright 2020 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_CACHE_DATASET_CACHE_H_ 17 #define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_CACHE_DATASET_CACHE_H_ 18 19 #include <memory> 20 21 #include "minddata/dataset/engine/datasetops/dataset_op.h" 22 #include "minddata/dataset/engine/ir/datasetops/source/samplers/samplers_ir.h" 23 #include "minddata/dataset/util/status.h" 24 25 namespace mindspore::dataset { 26 class DatasetCache { 27 public: 28 virtual ~DatasetCache() = default; 29 30 virtual Status Build() = 0; 31 32 virtual Status ValidateParams() = 0; 33 34 virtual Status CreateCacheOp(int32_t num_workers, int32_t connector_queue_size, std::shared_ptr<SamplerObj> sampler, 35 std::shared_ptr<DatasetOp> *ds) = 0; 36 37 virtual Status CreateCacheLookupOp(int32_t num_workers, int32_t connector_queue_size, 38 std::shared_ptr<SamplerObj> sampler, std::shared_ptr<DatasetOp> *ds) = 0; 39 40 virtual Status CreateCacheMergeOp(int32_t num_workers, int32_t connector_queue_size, 41 std::shared_ptr<DatasetOp> *ds) = 0; 42 to_json(nlohmann::json * out_json)43 virtual Status to_json(nlohmann::json *out_json) { return Status::OK(); } 44 45 #ifndef ENABLE_ANDROID 46 static Status from_json(nlohmann::json json_obj, std::shared_ptr<DatasetCache> *cache); 47 #endif 48 }; 49 } // namespace mindspore::dataset 50 #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_IR_CACHE_DATASET_CACHE_H_ 51