!7094 C++ API: Move vision ops to new vision files; create transforms namespace

Merge pull request !7094 from cathwong/ckw_c_api_transforms_tests
pull/7094/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit a261def3c9

@ -28,4 +28,5 @@ add_library(cpp-API OBJECT
transforms.cc
samplers.cc
text.cc
vision.cc
)

@ -20,8 +20,13 @@
namespace mindspore {
namespace dataset {
namespace api {
// Transform operations for text.
namespace text {
// FUNCTIONS TO CREATE TEXT OPERATIONS
// (In alphabetical order)
std::shared_ptr<LookupOperation> Lookup(const std::shared_ptr<Vocab> &vocab, const std::string &unknown_token,
const DataType &data_type) {
auto op = std::make_shared<LookupOperation>(vocab, unknown_token, data_type);
@ -32,6 +37,12 @@ std::shared_ptr<LookupOperation> Lookup(const std::shared_ptr<Vocab> &vocab, con
return op;
}
/* ####################################### Validator Functions ############################################ */
/* ####################################### Derived TensorOperation classes ################################# */
// (In alphabetical order)
// LookupOperation
LookupOperation::LookupOperation(const std::shared_ptr<Vocab> &vocab, const std::string &unknown_token,
const DataType &data_type)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -14,8 +14,8 @@
* limitations under the License.
*/
#ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_API_TEXT_H_
#define MINDSPORE_CCSRC_MINDDATA_DATASET_API_TEXT_H_
#ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_TEXT_H_
#define MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_TEXT_H_
#include <vector>
#include <memory>
@ -68,4 +68,4 @@ class LookupOperation : public TensorOperation {
} // namespace api
} // namespace dataset
} // namespace mindspore
#endif // MINDSPORE_CCSRC_MINDDATA_DATASET_API_TEXT_H_
#endif // MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_TEXT_H_

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -102,6 +102,7 @@ SET(DE_UT_SRCS
build_vocab_test.cc
c_api_samplers_test.cc
c_api_transforms_test.cc
c_api_vision_test.cc
c_api_dataset_ops_test.cc
c_api_dataset_album_test.cc
c_api_dataset_cifar_test.cc
@ -124,8 +125,8 @@ SET(DE_UT_SRCS
swap_red_blue_test.cc
distributed_sampler_test.cc
data_helper_test.cc
image_process_test.cc
slice_op_test.cc
image_process_test.cc
slice_op_test.cc
)
if (ENABLE_PYTHON)

@ -16,7 +16,7 @@
#include "common/common.h"
#include "minddata/dataset/core/tensor_row.h"
#include "minddata/dataset/include/datasets.h"
#include "minddata/dataset/include/transforms.h"
#include "minddata/dataset/include/vision.h"
using namespace mindspore::dataset::api;
using mindspore::dataset::Tensor;

@ -15,7 +15,7 @@
*/
#include "common/common.h"
#include "minddata/dataset/include/datasets.h"
#include "minddata/dataset/include/transforms.h"
#include "minddata/dataset/include/vision.h"
#include "minddata/dataset/core/config_manager.h"
#include "minddata/dataset/core/global_context.h"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -55,3 +55,17 @@ TEST_F(MindDataTestCenterCropOp, TestOp2) {
EXPECT_TRUE(s.IsError());
ASSERT_TRUE(s.get_code() == StatusCode::kUnexpectedError);
}
TEST_F(MindDataTestCenterCropOp, TestOp3) {
MS_LOG(INFO) << "Doing MindDataTestCenterCropOp::TestOp3. Test single integer input for square crop.";
std::shared_ptr<Tensor> output_tensor;
int side = 128;
std::unique_ptr<CenterCropOp> op(new CenterCropOp(side));
EXPECT_TRUE(op->OneToOne());
Status s = op->Compute(input_tensor_, &output_tensor);
EXPECT_TRUE(s.IsOk());
// Confirm both height and width are of size <side>.
EXPECT_EQ(side, output_tensor->shape()[0]);
EXPECT_EQ(side, output_tensor->shape()[1]);
std::shared_ptr<CVTensor> p = CVTensor::AsCVTensor(output_tensor);
}

Loading…
Cancel
Save