forked from mindspore-Ecosystem/mindspore
!17259 MD CI code warning fixes
From: @cathwong Reviewed-by: @robingrosman,@pandoublefeng Signed-off-by: @robingrosman
This commit is contained in:
commit
a0d47b4dea
|
@ -241,16 +241,16 @@ PYBIND_REGISTER(TextFileNode, 2, ([](const py::module *m) {
|
|||
PYBIND_REGISTER(TFRecordNode, 2, ([](const py::module *m) {
|
||||
(void)py::class_<TFRecordNode, DatasetNode, std::shared_ptr<TFRecordNode>>(*m, "TFRecordNode",
|
||||
"to create a TFRecordNode")
|
||||
.def(py::init([](py::list dataset_files, std::shared_ptr<SchemaObj> schema, py::list columns_list,
|
||||
int64_t num_samples, int32_t shuffle, int32_t num_shards, int32_t shard_id,
|
||||
bool shard_equal_rows) {
|
||||
.def(py::init([](const py::list dataset_files, std::shared_ptr<SchemaObj> schema,
|
||||
const py::list columns_list, int64_t num_samples, int32_t shuffle,
|
||||
int32_t num_shards, int32_t shard_id, bool shard_equal_rows) {
|
||||
std::shared_ptr<TFRecordNode> tfrecord = std::make_shared<TFRecordNode>(
|
||||
toStringVector(dataset_files), schema, toStringVector(columns_list), num_samples,
|
||||
toShuffleMode(shuffle), num_shards, shard_id, shard_equal_rows, nullptr);
|
||||
THROW_IF_ERROR(tfrecord->ValidateParams());
|
||||
return tfrecord;
|
||||
}))
|
||||
.def(py::init([](py::list dataset_files, std::string schema, py::list columns_list,
|
||||
.def(py::init([](const py::list dataset_files, std::string schema, py::list columns_list,
|
||||
int64_t num_samples, int32_t shuffle, int32_t num_shards, int32_t shard_id,
|
||||
bool shard_equal_rows) {
|
||||
std::shared_ptr<TFRecordNode> tfrecord = std::make_shared<TFRecordNode>(
|
||||
|
|
|
@ -160,7 +160,7 @@ std::vector<std::shared_ptr<DatasetNode>> toDatasetNode(std::shared_ptr<DatasetN
|
|||
return vector;
|
||||
}
|
||||
|
||||
std::shared_ptr<SamplerObj> toSamplerObj(py::handle py_sampler, bool isMindDataset) {
|
||||
std::shared_ptr<SamplerObj> toSamplerObj(const py::handle py_sampler, bool isMindDataset) {
|
||||
if (py_sampler.is_none()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ std::shared_ptr<TensorOperation> toTensorOperation(py::handle operation);
|
|||
|
||||
std::vector<std::shared_ptr<DatasetNode>> toDatasetNode(std::shared_ptr<DatasetNode> self, py::list datasets);
|
||||
|
||||
std::shared_ptr<SamplerObj> toSamplerObj(py::handle py_sampler, bool isMindDataset = false);
|
||||
std::shared_ptr<SamplerObj> toSamplerObj(const py::handle py_sampler, bool isMindDataset = false);
|
||||
|
||||
std::shared_ptr<DatasetCache> toDatasetCache(std::shared_ptr<CacheClient> cc);
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ RandomChoice::RandomChoice(const std::vector<TensorTransform *> &transforms) : d
|
|||
RandomChoice::RandomChoice(const std::vector<std::shared_ptr<TensorTransform>> &transforms)
|
||||
: data_(std::make_shared<Data>()) {
|
||||
(void)std::transform(transforms.begin(), transforms.end(), std::back_inserter(data_->transforms_),
|
||||
[](std::shared_ptr<TensorTransform> op) -> std::shared_ptr<TensorOperation> {
|
||||
[](const std::shared_ptr<TensorTransform> op) -> std::shared_ptr<TensorOperation> {
|
||||
return op != nullptr ? op->Parse() : nullptr;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -658,10 +658,10 @@ struct RandomSelectSubpolicy::Data {
|
|||
RandomSelectSubpolicy::RandomSelectSubpolicy(
|
||||
const std::vector<std::vector<std::pair<TensorTransform *, double>>> &policy)
|
||||
: data_(std::make_shared<Data>()) {
|
||||
for (int32_t i = 0; i < policy.size(); i++) {
|
||||
for (uint32_t i = 0; i < policy.size(); i++) {
|
||||
std::vector<std::pair<std::shared_ptr<TensorOperation>, double>> subpolicy;
|
||||
|
||||
for (int32_t j = 0; j < policy[i].size(); j++) {
|
||||
for (uint32_t j = 0; j < policy[i].size(); j++) {
|
||||
TensorTransform *op = policy[i][j].first;
|
||||
std::shared_ptr<TensorOperation> operation = (op ? op->Parse() : nullptr);
|
||||
double prob = policy[i][j].second;
|
||||
|
@ -674,10 +674,10 @@ RandomSelectSubpolicy::RandomSelectSubpolicy(
|
|||
RandomSelectSubpolicy::RandomSelectSubpolicy(
|
||||
const std::vector<std::vector<std::pair<std::shared_ptr<TensorTransform>, double>>> &policy)
|
||||
: data_(std::make_shared<Data>()) {
|
||||
for (int32_t i = 0; i < policy.size(); i++) {
|
||||
for (uint32_t i = 0; i < policy.size(); i++) {
|
||||
std::vector<std::pair<std::shared_ptr<TensorOperation>, double>> subpolicy;
|
||||
|
||||
for (int32_t j = 0; j < policy[i].size(); j++) {
|
||||
for (uint32_t j = 0; j < policy[i].size(); j++) {
|
||||
std::shared_ptr<TensorTransform> op = policy[i][j].first;
|
||||
std::shared_ptr<TensorOperation> operation = (op ? op->Parse() : nullptr);
|
||||
double prob = policy[i][j].second;
|
||||
|
@ -900,9 +900,10 @@ UniformAugment::UniformAugment(const std::vector<TensorTransform *> &transforms,
|
|||
|
||||
UniformAugment::UniformAugment(const std::vector<std::shared_ptr<TensorTransform>> &transforms, int32_t num_ops)
|
||||
: data_(std::make_shared<Data>()) {
|
||||
(void)std::transform(
|
||||
transforms.begin(), transforms.end(), std::back_inserter(data_->transforms_),
|
||||
[](std::shared_ptr<TensorTransform> op) -> std::shared_ptr<TensorOperation> { return op ? op->Parse() : nullptr; });
|
||||
(void)std::transform(transforms.begin(), transforms.end(), std::back_inserter(data_->transforms_),
|
||||
[](const std::shared_ptr<TensorTransform> op) -> std::shared_ptr<TensorOperation> {
|
||||
return op ? op->Parse() : nullptr;
|
||||
});
|
||||
data_->num_ops_ = num_ops;
|
||||
}
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@ class ImageFolderOp : public MappableLeafOp {
|
|||
std::map<std::string, int32_t> class_index_;
|
||||
std::unique_ptr<DataSchema> data_schema_;
|
||||
int64_t sampler_ind_;
|
||||
int64_t dirname_offset_;
|
||||
uint64_t dirname_offset_;
|
||||
std::vector<ImageLabelPair> image_label_pairs_;
|
||||
std::unique_ptr<Queue<std::string>> folder_name_queue_;
|
||||
std::unique_ptr<Queue<FolderImagesPair>> image_name_queue_;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
namespace mindspore {
|
||||
namespace dataset {
|
||||
/* ####################################### Validator Functions ############################################ */
|
||||
Status ValidateProbability(const std::string &op_name, const float probability) {
|
||||
Status ValidateProbability(const std::string &op_name, const double probability) {
|
||||
if (probability < 0.0 || probability > 1.0) {
|
||||
std::string err_msg = op_name + ": probability must be between 0.0 and 1.0, got: " + std::to_string(probability);
|
||||
MS_LOG(ERROR) << err_msg;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
namespace mindspore {
|
||||
namespace dataset {
|
||||
// Helper function to validate probability
|
||||
Status ValidateProbability(const std::string &op_name, const float probability);
|
||||
Status ValidateProbability(const std::string &op_name, const double probability);
|
||||
|
||||
// Helper function to positive int scalar
|
||||
Status ValidateIntScalarPositive(const std::string &op_name, const std::string &scalar_name, int32_t scalar);
|
||||
|
|
|
@ -476,4 +476,5 @@ def check_c_tensor_op(param, param_name):
|
|||
|
||||
|
||||
def replace_none(value, default):
|
||||
"""Replace None value with default"""
|
||||
return value if value is not None else default
|
||||
|
|
|
@ -50,6 +50,7 @@ class TensorOperation:
|
|||
return output_tensor_list[0] if len(output_tensor_list) == 1 else tuple(output_tensor_list)
|
||||
|
||||
def parse(self):
|
||||
"""parse function - not yet implemented"""
|
||||
raise NotImplementedError("TensorOperation has to implement parse() method.")
|
||||
|
||||
|
||||
|
@ -307,7 +308,8 @@ class Concatenate(TensorOperation):
|
|||
|
||||
Args:
|
||||
axis (int, optional): Concatenate the tensors along given axis (Default=0).
|
||||
prepend (numpy.array, optional): NumPy array to be prepended to the already concatenated tensors (Default=None).
|
||||
prepend (numpy.array, optional): NumPy array to be prepended to the already concatenated tensors
|
||||
(Default=None).
|
||||
append (numpy.array, optional): NumPy array to be appended to the already concatenated tensors (Default=None).
|
||||
|
||||
Examples:
|
||||
|
|
|
@ -271,8 +271,9 @@ def check_random_apply(method):
|
|||
|
||||
for i, transform in enumerate(transforms):
|
||||
if str(transform).find("c_transform") >= 0:
|
||||
raise ValueError("transforms[{}] is not a py transforms. Should not use a c transform in py transform" \
|
||||
.format(i))
|
||||
raise ValueError(
|
||||
"transforms[{}] is not a py transforms. Should not use a c transform in py transform" \
|
||||
.format(i))
|
||||
|
||||
if prob is not None:
|
||||
type_check(prob, (float, int,), "prob")
|
||||
|
@ -293,8 +294,9 @@ def check_transforms_list(method):
|
|||
type_check(transforms, (list,), "transforms")
|
||||
for i, transform in enumerate(transforms):
|
||||
if str(transform).find("c_transform") >= 0:
|
||||
raise ValueError("transforms[{}] is not a py transforms. Should not use a c transform in py transform" \
|
||||
.format(i))
|
||||
raise ValueError(
|
||||
"transforms[{}] is not a py transforms. Should not use a c transform in py transform" \
|
||||
.format(i))
|
||||
return method(self, *args, **kwargs)
|
||||
|
||||
return new_method
|
||||
|
|
Loading…
Reference in New Issue