diff --git a/mace/ops/opencl/image/resize_nearest_neighbor.h b/mace/ops/opencl/image/resize_nearest_neighbor.h index 7527f00832b9e79391956bc210ff6b9cbe3da5ee..8f5bca6b029599e7a42899453279c4f77758196b 100644 --- a/mace/ops/opencl/image/resize_nearest_neighbor.h +++ b/mace/ops/opencl/image/resize_nearest_neighbor.h @@ -94,9 +94,7 @@ MaceStatus ResizeNearestNeighborKernel::Compute( const index_t in_height = input->dim(1); const index_t in_width = input->dim(2); const index_t channels = input->dim(3); - Tensor::MappingGuard input_mapper(input); Tensor::MappingGuard size_mapper(size); - Tensor::MappingGuard output_mapper(output); const index_t out_height = size->data()[0]; const index_t out_width = size->data()[1]; const index_t channel_blocks = RoundUpDiv4(channels); diff --git a/mace/ops/resize_nearest_neighbor.cc b/mace/ops/resize_nearest_neighbor.cc index 7cbec0bcc1f8cfdcbe22db73cb3468e416044e4e..c40fd46dce86d382df5dec340fbd66cf143f782d 100644 --- a/mace/ops/resize_nearest_neighbor.cc +++ b/mace/ops/resize_nearest_neighbor.cc @@ -78,6 +78,7 @@ class ResizeNearestNeighborOp : public Operation { MACE_UNUSED(context); const Tensor *input = this->Input(0); const Tensor *size = this->Input(1); + Tensor::MappingGuard size_mapper(size); Tensor *output = this->Output(0); MACE_CHECK(input->dim_size() == 4 && size->dim_size() == 1, @@ -95,7 +96,6 @@ class ResizeNearestNeighborOp : public Operation { std::vector out_shape{batch, channels, out_height, out_width}; MACE_RETURN_IF_ERROR(output->Resize(out_shape)); Tensor::MappingGuard input_mapper(input); - Tensor::MappingGuard size_mapper(size); Tensor::MappingGuard output_mapper(output); const T *input_data = input->data(); T *output_data = output->mutable_data(); diff --git a/mace/ops/resize_nearest_neighbor_test.cc b/mace/ops/resize_nearest_neighbor_test.cc index 9d0ed8c6be2dcf03e583c7f6234f998b4aa04ffb..b950047204a1dd8e3fb721622d7ce44635f08b0d 100644 --- a/mace/ops/resize_nearest_neighbor_test.cc +++ b/mace/ops/resize_nearest_neighbor_test.cc @@ -107,9 +107,7 @@ void TestRandomResizeNearestNeighbor() { {batch, in_height, in_width, channels}); net.TransformDataFormat("Input", NHWC, "InputNCHW", NCHW); - net.AddInputFromArray("Size", - {2}, size); - + net.AddInputFromArray("Size", {2}, size); OpDefBuilder("ResizeNearestNeighbor", "ResizeNearestNeighborTest") .Input("InputNCHW") .Input("Size") diff --git a/tools/common.py b/tools/common.py index 79dba084272682e32faf7a1dea20dc63c29cd6a9..8e69ed8ed20cb8d20b83d2492afe3f377a65c8c3 100644 --- a/tools/common.py +++ b/tools/common.py @@ -209,28 +209,32 @@ def sha256_checksum(fname): return hash_func.hexdigest() -def get_dockerfile_file(dockerfile_path="", - dockerfile_sha256_checksum=""): - dockerfile = dockerfile_path +def get_dockerfile_info(dockerfile_path="", + dockerfile_sha256_checksum="", + docker_image_tag=""): + dockerfile_local_path = "" if dockerfile_path.startswith("http://") or \ dockerfile_path.startswith("https://"): - dockerfile = \ - "third_party/caffe/" + md5sum(dockerfile_path) + "/Dockerfile" + dockerfile_local_path = \ + "third_party/caffe/" + docker_image_tag + dockerfile = dockerfile_local_path + "/Dockerfile" + if not os.path.exists(dockerfile_local_path): + os.makedirs(dockerfile_local_path) if not os.path.exists(dockerfile) or \ sha256_checksum(dockerfile) != dockerfile_sha256_checksum: - os.makedirs(dockerfile.strip("/Dockerfile")) MaceLogger.info("Downloading Dockerfile, please wait ...") six.moves.urllib.request.urlretrieve(dockerfile_path, dockerfile) MaceLogger.info("Dockerfile downloaded successfully.") - if dockerfile: + if dockerfile_local_path: if sha256_checksum(dockerfile) != dockerfile_sha256_checksum: MaceLogger.error(ModuleName.MODEL_CONVERTER, "Dockerfile sha256checksum not match") else: - dockerfile = "third_party/caffe" + dockerfile_local_path = "third_party/caffe" + docker_image_tag = "lastest" - return dockerfile + return dockerfile_local_path, docker_image_tag def get_model_files(model_file_path, @@ -397,6 +401,7 @@ class YAMLKeyword(object): graph_optimize_options = 'graph_optimize_options' # internal use for now cl_mem_type = 'cl_mem_type' backend = 'backend' + docker_image_tag = 'docker_image_tag' dockerfile_path = 'dockerfile_path' dockerfile_sha256_checksum = 'dockerfile_sha256_checksum' diff --git a/tools/device.py b/tools/device.py index ccc174f38c6d592d232dc6def0d3ff0759e38095..07e92878db3b0e0effc6814aa5d68df10dc16983 100644 --- a/tools/device.py +++ b/tools/device.py @@ -626,16 +626,21 @@ class DeviceWrapper: if model_config[YAMLKeyword.quantize] == 1: validate_type = device_type + '_QUANTIZE' - dockerfile_path = get_dockerfile_file( - model_config.get(YAMLKeyword.dockerfile_path), - model_config.get(YAMLKeyword.dockerfile_sha256_checksum) # noqa - ) if YAMLKeyword.dockerfile_path in model_config else "third_party/caffe" # noqa + dockerfile_path, docker_image_tag = \ + get_dockerfile_info( + model_config.get(YAMLKeyword.dockerfile_path), + model_config.get( + YAMLKeyword.dockerfile_sha256_checksum), + model_config.get(YAMLKeyword.docker_image_tag) + ) if YAMLKeyword.dockerfile_path in model_config \ + else ("third_party/caffe", "lastest") sh_commands.validate_model( abi=target_abi, device=self, model_file_path=model_file_path, weight_file_path=weight_file_path, + docker_image_tag=docker_image_tag, dockerfile_path=dockerfile_path, platform=model_config[YAMLKeyword.platform], device_type=device_type, diff --git a/tools/sh_commands.py b/tools/sh_commands.py index 6a945d13c2eb7e72a21fc37f675060e0ee419c28..035348ff2baae673ae798ce6cf4e40c771b877b8 100644 --- a/tools/sh_commands.py +++ b/tools/sh_commands.py @@ -641,6 +641,7 @@ def validate_model(abi, device, model_file_path, weight_file_path, + docker_image_tag, dockerfile_path, platform, device_type, @@ -684,8 +685,8 @@ def validate_model(abi, validation_threshold, ",".join(input_data_types), backend, log_file) elif platform == "caffe": - image_name = "mace-caffe:latest" - container_name = "mace_caffe_validator" + image_name = "mace-caffe:" + docker_image_tag + container_name = "mace_caffe_" + docker_image_tag + "_validator" if caffe_env == common.CaffeEnvType.LOCAL: try: