From c87f8f56d61b1d437fb9d4695a4176a04e2c722c Mon Sep 17 00:00:00 2001 From: Moaz Reyad Date: Tue, 14 Jul 2026 03:10:32 +0200 Subject: [PATCH] docs: fix spelling and grammar errors --- cmake/Thirdparty/FindOpenCL.cmake | 4 +- doc/conf.py | 2 +- doc/device.rst | 6 +- doc/tensor.rst | 2 +- .../autograd/mnist_cnn.py | 10 +-- .../autograd/resnet_dist.py | 2 +- examples/cnn/autograd/mnist_cnn.py | 10 +-- examples/cnn/autograd/resnet_cifar10.py | 10 +-- examples/cnn/autograd/resnet_dist.py | 2 +- examples/cnn/autograd/xceptionnet.py | 2 +- examples/cnn/train_cnn.py | 2 +- examples/cnn_ms/autograd/mnist_cnn.py | 10 +-- examples/cnn_ms/autograd/resnet_cifar10.py | 10 +-- examples/cnn_ms/autograd/resnet_dist.py | 2 +- examples/cnn_ms/autograd/xceptionnet.py | 2 +- examples/cnn_ms/model/alexnet.py | 2 +- examples/cnn_ms/train_cnn.py | 4 +- examples/cnn_ms/train_ms_model.py | 4 +- examples/cpp/cifar10/README.md | 6 +- .../Cardiovascular_Disease/train.py | 2 +- .../train.py | 2 +- .../application/Kidney_Disease/train.py | 2 +- .../application/Malaria_Disease/train.py | 2 +- examples/healthcare/data/bloodmnist.py | 2 +- examples/hfl/README.md | 2 +- examples/largedataset_cnn/README.md | 2 +- .../largedataset_cnn/autograd/mnist_cnn.py | 10 +-- .../largedataset_cnn/autograd/resnet_dist.py | 2 +- examples/largedataset_cnn/model/alexnet.py | 2 +- examples/largedataset_cnn/train_largedata.py | 2 +- examples/malaria_cnn/train_cnn.py | 2 +- .../ml/model_selection/exps/shared_args.py | 2 +- .../ml/model_selection/pg_interface.py | 6 +- .../src/controller/controler.py | 2 +- .../src/dataset_utils/sequence_dataloader.py | 4 +- .../src/dataset_utils/stream_dataloader.py | 4 +- .../src/eva_engine/coordinator.py | 4 +- .../singa_ms/cnn_ms/autograd/mnist_cnn.py | 10 +-- .../cnn_ms/autograd/resnet_cifar10.py | 10 +-- .../singa_ms/cnn_ms/autograd/resnet_dist.py | 2 +- .../singa_ms/cnn_ms/autograd/xceptionnet.py | 2 +- .../phase1/algo/singa_ms/cnn_ms/train_cnn.py | 4 +- .../algo/singa_ms/cnn_ms/train_ms_model.py | 4 +- .../eva_engine/phase1/concurrent_evaluator.py | 2 +- .../src/eva_engine/phase1/evaluator.py | 6 +- .../src/eva_engine/phase1/run_phase1.py | 4 +- .../src/eva_engine/phase2/algo/trainer.py | 2 +- .../src/eva_engine/phase2/run_sh.py | 2 +- .../src/eva_engine/phase2/run_uniform.py | 6 +- .../src/query_api/img_explore_ea.py | 2 +- .../src/query_api/interface.py | 2 +- .../src/query_api/query_api_img.py | 2 +- .../src/query_api/query_api_mlp.py | 4 +- .../src/search_space/core/model_params.py | 2 +- .../src/search_space/core/space.py | 2 +- .../src/search_space/mlp_api/space.py | 18 ++-- .../ml/model_selection/src/tools/io_tools.py | 2 +- .../model_selection/src/tools/res_measure.py | 2 +- .../internal/ml/model_slicing/README.md | 2 +- .../internal/ml/model_slicing/baseline_int.py | 2 +- .../internal/ml/model_slicing/pg_interface.py | 2 +- .../ml/model_slicing/save_satistics.py | 2 +- .../pg_extension/src/bindings/inference.rs | 10 +-- .../pg_extension/src/bindings/ml_register.rs | 2 +- .../internal/pg_extension/src/bindings/ms.rs | 2 +- .../Trails/singa_pkg_code/tensor.py | 12 +-- examples/onnx/arcface.py | 4 +- examples/onnx/bert/bert-squad.py | 4 +- examples/onnx/bert/run_onnx_squad.py | 2 +- examples/onnx/bert/tokenization.py | 2 +- examples/onnx/densenet121.py | 4 +- examples/onnx/fer_emotion.py | 4 +- examples/onnx/gpt2/gpt2.py | 4 +- examples/onnx/mobilenet.py | 4 +- examples/onnx/resnet18.py | 4 +- examples/onnx/ro_bert_a/ro_bert_a.py | 4 +- examples/onnx/shufflenetv1.py | 4 +- examples/onnx/shufflenetv2.py | 4 +- examples/onnx/squeezenet.py | 4 +- examples/onnx/superresolution.py | 2 +- examples/onnx/tiny_yolov2.py | 4 +- examples/onnx/training/train.py | 2 +- examples/onnx/vgg16.py | 4 +- examples/onnx/vgg19.py | 4 +- examples/rbm/train.py | 2 +- .../singa_peft/examples/autograd/mnist_cnn.py | 10 +-- .../examples/autograd/resnet_dist.py | 2 +- examples/singa_peft/examples/model/rbm.py | 2 +- examples/singa_peft/examples/train.py | 4 +- include/singa/core/device.h | 8 +- include/singa/core/memory.h | 2 +- include/singa/core/tensor.h | 20 ++--- include/singa/io/communicator.h | 2 +- include/singa/io/decoder.h | 4 +- include/singa/io/encoder.h | 2 +- include/singa/io/reader.h | 2 +- include/singa/io/snapshot.h | 6 +- include/singa/model/feed_forward_net.h | 4 +- include/singa/model/layer.h | 8 +- include/singa/model/metric.h | 6 +- include/singa/model/optimizer.h | 12 +-- include/singa/utils/factory.h | 4 +- include/singa/utils/logging.h | 4 +- include/singa/utils/safe_queue.h | 10 +-- python/singa/autograd.py | 44 +++++----- python/singa/data.py | 2 +- python/singa/image_tool.py | 8 +- python/singa/initializer.py | 2 +- python/singa/layer.py | 36 ++++---- python/singa/opt.py | 6 +- python/singa/snapshot.py | 4 +- python/singa/sonnx.py | 88 +++++++++---------- python/singa/tensor.py | 12 +-- python/singa/utils.py | 8 +- setup.py | 10 +-- src/CMakeLists.txt | 2 +- src/api/core_device.i | 2 +- src/api/numpy.i | 2 +- src/core/scheduler/scheduler.cc | 6 +- src/core/tensor/math_kernel.cu | 6 +- src/core/tensor/tensor.cc | 18 ++-- src/core/tensor/tensor_math.h | 2 +- src/core/tensor/tensor_math_cpp.h | 6 +- src/io/communicator.cc | 8 +- src/io/image_transformer.cc | 10 +-- src/io/jpg_decoder.cc | 2 +- src/io/jpg_encoder.cc | 4 +- src/io/network/endpoint.cc | 10 +-- src/model/feed_forward_net.cc | 6 +- src/model/layer/activation.cc | 4 +- src/model/layer/batchnorm.cc | 4 +- src/model/layer/cudnn_activation.cc | 2 +- src/model/operation/convolution.cc | 2 +- src/model/operation/rnn.cc | 4 +- src/model/updater/updater.cc | 2 +- test/python/test_onnx.py | 2 +- test/python/test_onnx_backend.py | 2 +- test/python/test_operation.py | 8 +- test/singa/test_activation.cc | 4 +- test/singa/test_cudnn_activation.cc | 4 +- tool/code-format/README.md | 8 +- tool/conda/docker/cpu/Dockerfile | 2 +- tool/conda/docker/cuda10.2/Dockerfile | 2 +- tool/conda/docker/cuda10/Dockerfile | 2 +- tool/conda/singa/build.sh | 2 +- tool/docker/README.md | 2 +- tool/docker/build.sh | 2 +- tool/jenkins/README.md | 4 +- tool/jenkins/test.sh | 2 +- tool/linting/README.md | 2 +- tool/release/README.md | 4 +- 151 files changed, 411 insertions(+), 411 deletions(-) diff --git a/cmake/Thirdparty/FindOpenCL.cmake b/cmake/Thirdparty/FindOpenCL.cmake index c358d8a1a4..bd9d012790 100644 --- a/cmake/Thirdparty/FindOpenCL.cmake +++ b/cmake/Thirdparty/FindOpenCL.cmake @@ -33,7 +33,7 @@ if(ENV_OPENCLROOT) OPENCL_INCLUDE_DIR NAMES CL/cl.h OpenCL/cl.h PATHS "${ENV_OPENCLROOT}/include" - #NO_DEFAULT_PATH #uncomment this is you wish to surpress the use of default paths for OpenCL + #NO_DEFAULT_PATH #uncomment this is you wish to suppress the use of default paths for OpenCL ) if (("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") OR ("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")) @@ -51,7 +51,7 @@ if(ENV_OPENCLROOT) OPENCL_LIBRARY NAMES OpenCL PATHS "${OPENCL_LIB_SEARCH_PATH}" - #NO_DEFAULT_PATH #uncomment this is you wish to surpress the use of default paths for OpenCL + #NO_DEFAULT_PATH #uncomment this is you wish to suppress the use of default paths for OpenCL ) else(ENV_OPENCLROOT) find_path( diff --git a/doc/conf.py b/doc/conf.py index dfeea13870..e912f1327e 100755 --- a/doc/conf.py +++ b/doc/conf.py @@ -40,7 +40,7 @@ import sys # If the user has singa codebase -# will build document from code comments in these loactions +# will build document from code comments in these locations sys.path.append(os.path.abspath('../python/')) sys.path.append(os.path.abspath('../build/python/')) diff --git a/doc/device.rst b/doc/device.rst index 400907d03d..2fe2dcf0f7 100644 --- a/doc/device.rst +++ b/doc/device.rst @@ -20,16 +20,16 @@ Device ======= -The Device abstract represents any hardware device with memory and compuation units. +The Device abstract represents any hardware device with memory and computation units. All [Tensor operations](tensor.html) are scheduled by the resident device for execution. Tensor memory is also managed by the device's memory manager. Therefore, optimization of memory and execution are implemented in the Device class. Specific devices ---------------- -Currently, SINGA has three Device implmentations, +Currently, SINGA has three Device implementations, -1. CudaGPU for an Nvidia GPU card which runs Cuda code +1. CudaGPU for an NVIDIA GPU card which runs CUDA code 2. CppCPU for a CPU which runs Cpp code 3. OpenclGPU for a GPU card which runs OpenCL code diff --git a/doc/tensor.rst b/doc/tensor.rst index 5a2898b444..8f8940094c 100644 --- a/doc/tensor.rst +++ b/doc/tensor.rst @@ -29,7 +29,7 @@ allocated on the same device except copy functions. Tensor implementation --------------------- -SINGA has three different sets of implmentations of Tensor functions, one for each +SINGA has three different sets of implementations of Tensor functions, one for each type of Device. * 'tensor_math_cpp.h' implements operations using Cpp (with CBLAS) for CppGPU devices. diff --git a/examples/cifar_distributed_cnn/autograd/mnist_cnn.py b/examples/cifar_distributed_cnn/autograd/mnist_cnn.py index 16752ceabe..e9b9c11d1d 100644 --- a/examples/cifar_distributed_cnn/autograd/mnist_cnn.py +++ b/examples/cifar_distributed_cnn/autograd/mnist_cnn.py @@ -135,7 +135,7 @@ def reduce_variable(variable, dist_opt, reducer): return output -# Function to sychronize SINGA TENSOR initial model parameters +# Function to synchronize SINGA TENSOR initial model parameters def synchronize(tensor, dist_opt): dist_opt.all_reduce(tensor.data) dist_opt.wait() @@ -176,7 +176,7 @@ def train_mnist_cnn(DIST=False, batch_size = 64 sgd = opt.SGD(lr=0.005, momentum=0.9, weight_decay=1e-5) - # Prepare training and valadiation data + # Prepare training and validation data train_x, train_y, test_x, test_y = load_dataset() IMG_SIZE = 28 num_classes = 10 @@ -216,7 +216,7 @@ def train_mnist_cnn(DIST=False, idx = np.arange(train_x.shape[0], dtype=np.int32) if DIST: - #Sychronize the initial parameters + #Synchronize the initial parameters autograd.training = True x = np.random.randn(batch_size, 1, IMG_SIZE, IMG_SIZE).astype(np.float32) @@ -228,7 +228,7 @@ def train_mnist_cnn(DIST=False, for p, g in autograd.backward(loss): synchronize(p, sgd) - # Training and evaulation loop + # Training and evaluation loop for epoch in range(max_epoch): start_time = time.time() np.random.shuffle(idx) @@ -287,7 +287,7 @@ def train_mnist_cnn(DIST=False, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/cifar_distributed_cnn/autograd/resnet_dist.py b/examples/cifar_distributed_cnn/autograd/resnet_dist.py index 6f9b56ceeb..4d2cfb60cd 100755 --- a/examples/cifar_distributed_cnn/autograd/resnet_dist.py +++ b/examples/cifar_distributed_cnn/autograd/resnet_dist.py @@ -33,7 +33,7 @@ sgd = opt.DistOpt(sgd) if (sgd.global_rank == 0): - print("Start intialization...........", flush=True) + print("Start initialization...........", flush=True) dev = device.create_cuda_gpu_on(sgd.local_rank) diff --git a/examples/cnn/autograd/mnist_cnn.py b/examples/cnn/autograd/mnist_cnn.py index 16752ceabe..e9b9c11d1d 100644 --- a/examples/cnn/autograd/mnist_cnn.py +++ b/examples/cnn/autograd/mnist_cnn.py @@ -135,7 +135,7 @@ def reduce_variable(variable, dist_opt, reducer): return output -# Function to sychronize SINGA TENSOR initial model parameters +# Function to synchronize SINGA TENSOR initial model parameters def synchronize(tensor, dist_opt): dist_opt.all_reduce(tensor.data) dist_opt.wait() @@ -176,7 +176,7 @@ def train_mnist_cnn(DIST=False, batch_size = 64 sgd = opt.SGD(lr=0.005, momentum=0.9, weight_decay=1e-5) - # Prepare training and valadiation data + # Prepare training and validation data train_x, train_y, test_x, test_y = load_dataset() IMG_SIZE = 28 num_classes = 10 @@ -216,7 +216,7 @@ def train_mnist_cnn(DIST=False, idx = np.arange(train_x.shape[0], dtype=np.int32) if DIST: - #Sychronize the initial parameters + #Synchronize the initial parameters autograd.training = True x = np.random.randn(batch_size, 1, IMG_SIZE, IMG_SIZE).astype(np.float32) @@ -228,7 +228,7 @@ def train_mnist_cnn(DIST=False, for p, g in autograd.backward(loss): synchronize(p, sgd) - # Training and evaulation loop + # Training and evaluation loop for epoch in range(max_epoch): start_time = time.time() np.random.shuffle(idx) @@ -287,7 +287,7 @@ def train_mnist_cnn(DIST=False, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/cnn/autograd/resnet_cifar10.py b/examples/cnn/autograd/resnet_cifar10.py index 7541736994..bde510b7e0 100644 --- a/examples/cnn/autograd/resnet_cifar10.py +++ b/examples/cnn/autograd/resnet_cifar10.py @@ -138,7 +138,7 @@ def reduce_variable(variable, dist_opt, reducer): return output -# Function to sychronize SINGA TENSOR initial model parameters +# Function to synchronize SINGA TENSOR initial model parameters def synchronize(tensor, dist_opt): dist_opt.all_reduce(tensor.data) dist_opt.wait() @@ -199,7 +199,7 @@ def train_cifar10(DIST=False, idx = np.arange(train_x.shape[0], dtype=np.int32) if DIST: - # Sychronize the initial parameters + # Synchronize the initial parameters autograd.training = True x = np.random.randn(batch_size, 3, IMG_SIZE, IMG_SIZE).astype(np.float32) @@ -258,11 +258,11 @@ def train_cifar10(DIST=False, flush=True) if partial_update: - # Sychronize parameters before evaluation phase + # Synchronize parameters before evaluation phase for p in param: synchronize(p, sgd) - # Evaulation phase + # Evaluation phase autograd.training = False for b in range(num_test_batch): x = test_x[b * batch_size:(b + 1) * batch_size] @@ -275,7 +275,7 @@ def train_cifar10(DIST=False, to_categorical(y, num_classes)) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/cnn/autograd/resnet_dist.py b/examples/cnn/autograd/resnet_dist.py index 6f9b56ceeb..4d2cfb60cd 100644 --- a/examples/cnn/autograd/resnet_dist.py +++ b/examples/cnn/autograd/resnet_dist.py @@ -33,7 +33,7 @@ sgd = opt.DistOpt(sgd) if (sgd.global_rank == 0): - print("Start intialization...........", flush=True) + print("Start initialization...........", flush=True) dev = device.create_cuda_gpu_on(sgd.local_rank) diff --git a/examples/cnn/autograd/xceptionnet.py b/examples/cnn/autograd/xceptionnet.py index 8fb23d8cbb..3a83226295 100644 --- a/examples/cnn/autograd/xceptionnet.py +++ b/examples/cnn/autograd/xceptionnet.py @@ -279,7 +279,7 @@ def forward(self, input): if __name__ == '__main__': model = Xception(num_classes=1000) - print('Start intialization............') + print('Start initialization............') dev = device.create_cuda_gpu_on(0) #dev = device.create_cuda_gpu() diff --git a/examples/cnn/train_cnn.py b/examples/cnn/train_cnn.py index 5c06470702..28b657e3f4 100644 --- a/examples/cnn/train_cnn.py +++ b/examples/cnn/train_cnn.py @@ -247,7 +247,7 @@ def run(global_rank, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/cnn_ms/autograd/mnist_cnn.py b/examples/cnn_ms/autograd/mnist_cnn.py index 16752ceabe..e9b9c11d1d 100644 --- a/examples/cnn_ms/autograd/mnist_cnn.py +++ b/examples/cnn_ms/autograd/mnist_cnn.py @@ -135,7 +135,7 @@ def reduce_variable(variable, dist_opt, reducer): return output -# Function to sychronize SINGA TENSOR initial model parameters +# Function to synchronize SINGA TENSOR initial model parameters def synchronize(tensor, dist_opt): dist_opt.all_reduce(tensor.data) dist_opt.wait() @@ -176,7 +176,7 @@ def train_mnist_cnn(DIST=False, batch_size = 64 sgd = opt.SGD(lr=0.005, momentum=0.9, weight_decay=1e-5) - # Prepare training and valadiation data + # Prepare training and validation data train_x, train_y, test_x, test_y = load_dataset() IMG_SIZE = 28 num_classes = 10 @@ -216,7 +216,7 @@ def train_mnist_cnn(DIST=False, idx = np.arange(train_x.shape[0], dtype=np.int32) if DIST: - #Sychronize the initial parameters + #Synchronize the initial parameters autograd.training = True x = np.random.randn(batch_size, 1, IMG_SIZE, IMG_SIZE).astype(np.float32) @@ -228,7 +228,7 @@ def train_mnist_cnn(DIST=False, for p, g in autograd.backward(loss): synchronize(p, sgd) - # Training and evaulation loop + # Training and evaluation loop for epoch in range(max_epoch): start_time = time.time() np.random.shuffle(idx) @@ -287,7 +287,7 @@ def train_mnist_cnn(DIST=False, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/cnn_ms/autograd/resnet_cifar10.py b/examples/cnn_ms/autograd/resnet_cifar10.py index d71e0f29b6..c9cec87ebf 100644 --- a/examples/cnn_ms/autograd/resnet_cifar10.py +++ b/examples/cnn_ms/autograd/resnet_cifar10.py @@ -138,7 +138,7 @@ def reduce_variable(variable, dist_opt, reducer): return output -# Function to sychronize SINGA TENSOR initial model parameters +# Function to synchronize SINGA TENSOR initial model parameters def synchronize(tensor, dist_opt): dist_opt.all_reduce(tensor.data) dist_opt.wait() @@ -199,7 +199,7 @@ def train_cifar10(DIST=False, idx = np.arange(train_x.shape[0], dtype=np.int32) if DIST: - # Sychronize the initial parameters + # Synchronize the initial parameters autograd.training = True x = np.random.randn(batch_size, 3, IMG_SIZE, IMG_SIZE).astype(np.float32) @@ -258,11 +258,11 @@ def train_cifar10(DIST=False, flush=True) if partial_update: - # Sychronize parameters before evaluation phase + # Synchronize parameters before evaluation phase for p in param: synchronize(p, sgd) - # Evaulation phase + # Evaluation phase autograd.training = False for b in range(num_test_batch): x = test_x[b * batch_size:(b + 1) * batch_size] @@ -275,7 +275,7 @@ def train_cifar10(DIST=False, to_categorical(y, num_classes)) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/cnn_ms/autograd/resnet_dist.py b/examples/cnn_ms/autograd/resnet_dist.py index 6f9b56ceeb..4d2cfb60cd 100644 --- a/examples/cnn_ms/autograd/resnet_dist.py +++ b/examples/cnn_ms/autograd/resnet_dist.py @@ -33,7 +33,7 @@ sgd = opt.DistOpt(sgd) if (sgd.global_rank == 0): - print("Start intialization...........", flush=True) + print("Start initialization...........", flush=True) dev = device.create_cuda_gpu_on(sgd.local_rank) diff --git a/examples/cnn_ms/autograd/xceptionnet.py b/examples/cnn_ms/autograd/xceptionnet.py index 8fb23d8cbb..3a83226295 100644 --- a/examples/cnn_ms/autograd/xceptionnet.py +++ b/examples/cnn_ms/autograd/xceptionnet.py @@ -279,7 +279,7 @@ def forward(self, input): if __name__ == '__main__': model = Xception(num_classes=1000) - print('Start intialization............') + print('Start initialization............') dev = device.create_cuda_gpu_on(0) #dev = device.create_cuda_gpu() diff --git a/examples/cnn_ms/model/alexnet.py b/examples/cnn_ms/model/alexnet.py index 85209f63f4..c3ac97284a 100644 --- a/examples/cnn_ms/model/alexnet.py +++ b/examples/cnn_ms/model/alexnet.py @@ -102,7 +102,7 @@ def set_optimizer(self, optimizer): def create_model(pretrained=False, **kwargs): - """Constructs a AlexNet model. + """Constructs an AlexNet model. Args: pretrained (bool): If True, returns a pre-trained model. diff --git a/examples/cnn_ms/train_cnn.py b/examples/cnn_ms/train_cnn.py index d7f8f70767..9ff4cc5d8f 100644 --- a/examples/cnn_ms/train_cnn.py +++ b/examples/cnn_ms/train_cnn.py @@ -409,7 +409,7 @@ def run(global_rank, synflow_flag = False # Train the model - if epoch == (max_epoch - 1) and b == (num_train_batch - 1): ### synflow calcuation for the last batch + if epoch == (max_epoch - 1) and b == (num_train_batch - 1): ### synflow calculation for the last batch print ("last epoch calculate synflow") synflow_flag = True ### step 1: all one input @@ -472,7 +472,7 @@ def run(global_rank, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, mssgd, reducer) # Output the evaluation accuracy diff --git a/examples/cnn_ms/train_ms_model.py b/examples/cnn_ms/train_ms_model.py index 529db1c463..0cc7fe83d0 100644 --- a/examples/cnn_ms/train_ms_model.py +++ b/examples/cnn_ms/train_ms_model.py @@ -402,7 +402,7 @@ def run(global_rank, synflow_flag = False # Train the model - if epoch == (max_epoch - 1) and b == (num_train_batch - 1): ### synflow calcuation for the last batch + if epoch == (max_epoch - 1) and b == (num_train_batch - 1): ### synflow calculation for the last batch print ("last epoch calculate synflow") synflow_flag = True ### step 1: all one input @@ -470,7 +470,7 @@ def run(global_rank, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, mssgd, reducer) # Output the evaluation accuracy diff --git a/examples/cpp/cifar10/README.md b/examples/cpp/cifar10/README.md index 7bb63e72cd..dc9ddab2f8 100644 --- a/examples/cpp/cifar10/README.md +++ b/examples/cpp/cifar10/README.md @@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License. --> -# Train CNN over Cifar-10 +# Train CNN over CIFAR-10 Convolution neural network (CNN) is a type of feed-forward artificial neural @@ -42,7 +42,7 @@ are required. Please refer to the installation page for detailed instructions. ### Data preparation -The binary Cifar-10 dataset could be downloaded by +The binary CIFAR-10 dataset could be downloaded by python download_data.py bin @@ -55,7 +55,7 @@ The Python version could be downloaded by There are four training programs 1. train.py. The following command would train the VGG model using the python -version of the Cifar-10 dataset in 'cifar-10-batches-py' folder. +version of the CIFAR-10 dataset in 'cifar-10-batches-py' folder. python train.py vgg cifar-10-batches-py diff --git a/examples/healthcare/application/Cardiovascular_Disease/train.py b/examples/healthcare/application/Cardiovascular_Disease/train.py index 2caa689989..2c2234e11b 100644 --- a/examples/healthcare/application/Cardiovascular_Disease/train.py +++ b/examples/healthcare/application/Cardiovascular_Disease/train.py @@ -243,7 +243,7 @@ def run(global_rank, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/healthcare/application/Diabetic_Disease/Diabetic_Retinopathy_Classification/train.py b/examples/healthcare/application/Diabetic_Disease/Diabetic_Retinopathy_Classification/train.py index e3f3649f26..264bf543ad 100644 --- a/examples/healthcare/application/Diabetic_Disease/Diabetic_Retinopathy_Classification/train.py +++ b/examples/healthcare/application/Diabetic_Disease/Diabetic_Retinopathy_Classification/train.py @@ -233,7 +233,7 @@ def run(global_rank, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/healthcare/application/Kidney_Disease/train.py b/examples/healthcare/application/Kidney_Disease/train.py index 1af8c24ef6..e1431cb55e 100644 --- a/examples/healthcare/application/Kidney_Disease/train.py +++ b/examples/healthcare/application/Kidney_Disease/train.py @@ -242,7 +242,7 @@ def run(global_rank, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/healthcare/application/Malaria_Disease/train.py b/examples/healthcare/application/Malaria_Disease/train.py index 78fbd31def..f57e1a7aec 100644 --- a/examples/healthcare/application/Malaria_Disease/train.py +++ b/examples/healthcare/application/Malaria_Disease/train.py @@ -236,7 +236,7 @@ def run(global_rank, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/healthcare/data/bloodmnist.py b/examples/healthcare/data/bloodmnist.py index 4042a0c7d5..addcac7acd 100644 --- a/examples/healthcare/data/bloodmnist.py +++ b/examples/healthcare/data/bloodmnist.py @@ -209,7 +209,7 @@ def batchgenerator(self, indexes, batch_size, data_size): Return: batch_x (Numpy ndarray): batch array of input images (B, C, H, W) - batch_y (Numpy ndarray): batch array of ground truth lables (B,) + batch_y (Numpy ndarray): batch array of ground truth labels (B,) """ batch_x = np.zeros((batch_size,) + data_size) batch_y = np.zeros((batch_size,) + (1,), dtype=np.int32) diff --git a/examples/hfl/README.md b/examples/hfl/README.md index 2916bc5609..12a66d35a1 100644 --- a/examples/hfl/README.md +++ b/examples/hfl/README.md @@ -20,7 +20,7 @@ # Horizontal Federated Learning Example -This is an example of federated learning (FL) using the Singa framework. In FL, there is a server and a set of clients. Each client has a local dataset. +This is an example of federated learning (FL) using the SINGA framework. In FL, there is a server and a set of clients. Each client has a local dataset. In each iteration, each client trains the model using its local dataset and uploads the model gradient to the server, which aggregates to get the global gradient using the Federated Average algorithm. The server sends the global gradient to all clients for iterative model training. This example uses the Bank dataset and an MLP model in FL. diff --git a/examples/largedataset_cnn/README.md b/examples/largedataset_cnn/README.md index 9a757a61d9..3fd29cc42f 100755 --- a/examples/largedataset_cnn/README.md +++ b/examples/largedataset_cnn/README.md @@ -23,7 +23,7 @@ Examples inside this folder show how to train CNN models using SINGA for image c is from the filesystem. It reads the dataset from the filesystem defined by `process_data.py`. Hence, users can modify `process_data.py` -for their perference of dataset format. +for their preference of dataset format. In the current setting, 'classes.txt' contains the names of the classes at each line. For example, if it is a food dataset containing three classes, 'classes.txt' may read like this: diff --git a/examples/largedataset_cnn/autograd/mnist_cnn.py b/examples/largedataset_cnn/autograd/mnist_cnn.py index 9fa921c5be..9b112e95bf 100644 --- a/examples/largedataset_cnn/autograd/mnist_cnn.py +++ b/examples/largedataset_cnn/autograd/mnist_cnn.py @@ -135,7 +135,7 @@ def reduce_variable(variable, dist_opt, reducer): return output -# Function to sychronize SINGA TENSOR initial model parameters +# Function to synchronize SINGA TENSOR initial model parameters def synchronize(tensor, dist_opt): dist_opt.all_reduce(tensor.data) dist_opt.wait() @@ -176,7 +176,7 @@ def train_mnist_cnn(DIST=False, batch_size = 64 sgd = opt.SGD(lr=0.005, momentum=0.9, weight_decay=1e-5) - # Prepare training and valadiation data + # Prepare training and validation data train_x, train_y, test_x, test_y = load_dataset() IMG_SIZE = 28 num_classes = 10 @@ -216,7 +216,7 @@ def train_mnist_cnn(DIST=False, idx = np.arange(train_x.shape[0], dtype=np.int32) if DIST: - #Sychronize the initial parameters + #Synchronize the initial parameters autograd.training = True x = np.random.randn(batch_size, 1, IMG_SIZE, IMG_SIZE).astype(np.float32) @@ -228,7 +228,7 @@ def train_mnist_cnn(DIST=False, for p, g in autograd.backward(loss): synchronize(p, sgd) - # Training and evaulation loop + # Training and evaluation loop for epoch in range(max_epoch): start_time = time.time() np.random.shuffle(idx) @@ -287,7 +287,7 @@ def train_mnist_cnn(DIST=False, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/largedataset_cnn/autograd/resnet_dist.py b/examples/largedataset_cnn/autograd/resnet_dist.py index 6f9b56ceeb..4d2cfb60cd 100755 --- a/examples/largedataset_cnn/autograd/resnet_dist.py +++ b/examples/largedataset_cnn/autograd/resnet_dist.py @@ -33,7 +33,7 @@ sgd = opt.DistOpt(sgd) if (sgd.global_rank == 0): - print("Start intialization...........", flush=True) + print("Start initialization...........", flush=True) dev = device.create_cuda_gpu_on(sgd.local_rank) diff --git a/examples/largedataset_cnn/model/alexnet.py b/examples/largedataset_cnn/model/alexnet.py index cad7b1e3f3..8917af1264 100644 --- a/examples/largedataset_cnn/model/alexnet.py +++ b/examples/largedataset_cnn/model/alexnet.py @@ -102,7 +102,7 @@ def set_optimizer(self, optimizer): def create_model(pretrained=False, **kwargs): - """Constructs a AlexNet model. + """Constructs an AlexNet model. Args: pretrained (bool): If True, returns a pre-trained model. diff --git a/examples/largedataset_cnn/train_largedata.py b/examples/largedataset_cnn/train_largedata.py index a6b770450c..487401658a 100755 --- a/examples/largedataset_cnn/train_largedata.py +++ b/examples/largedataset_cnn/train_largedata.py @@ -223,7 +223,7 @@ def run(global_rank, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/malaria_cnn/train_cnn.py b/examples/malaria_cnn/train_cnn.py index 4a54e6c839..6183907fd6 100644 --- a/examples/malaria_cnn/train_cnn.py +++ b/examples/malaria_cnn/train_cnn.py @@ -231,7 +231,7 @@ def run(global_rank, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/model_selection/Trails/internal/ml/model_selection/exps/shared_args.py b/examples/model_selection/Trails/internal/ml/model_selection/exps/shared_args.py index c8a4200320..244f2ed3fd 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/exps/shared_args.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/exps/shared_args.py @@ -94,7 +94,7 @@ def mlp_trainner_args(parser): 'nb101: 108, nb201: 200') parser.add_argument('--batch_size', type=int, default=32, help='batch size') - parser.add_argument('--lr', type=float, default=0.001, help="learning reate") + parser.add_argument('--lr', type=float, default=0.001, help="learning rate") parser.add_argument('--patience', type=int, default=1, help='number of epochs for stopping training') # parser.add_argument('--eval_freq', type=int, default=10000, help='max number of batches to train per epoch') diff --git a/examples/model_selection/Trails/internal/ml/model_selection/pg_interface.py b/examples/model_selection/Trails/internal/ml/model_selection/pg_interface.py index 3636c51db3..c24c6d1e54 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/pg_interface.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/pg_interface.py @@ -34,7 +34,7 @@ def exception_catcher(func): def wrapper(encoded_str: str): global_res = "NA, " try: - # each functon accepts a json string + # each function accepts a json string params = json.loads(encoded_str) config_file = params.get("config_file") @@ -489,7 +489,7 @@ def benchmark_filtering_phase_latency(params: dict, args: Namespace): # Then, at the end of your program, you can stop the thread: print("Done, time sleep for 10 seconds") - # wait the resource montor flush + # wait the resource monitor flush time.sleep(10) stop_event.set() thread.join() @@ -611,7 +611,7 @@ def records_results(params: dict, args: Namespace): _evaluator.time_usage["compute_latency"] \ / len(_evaluator.time_usage["track_compute"][2:]) - logger.info(f"Saving time usag to {time_output_file}") + logger.info(f"Saving time usage to {time_output_file}") # compute time write_json(time_output_file, _evaluator.time_usage) except: diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/controller/controler.py b/examples/model_selection/Trails/internal/ml/model_selection/src/controller/controler.py index 0b49e33178..0de96f3759 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/controller/controler.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/controller/controler.py @@ -169,7 +169,7 @@ def get_current_top_k_models(self, k=-1): :return: """ if k == -1: - # retur all models + # return all models return self.ranked_models else: return self.ranked_models[-k:] diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/dataset_utils/sequence_dataloader.py b/examples/model_selection/Trails/internal/ml/model_selection/src/dataset_utils/sequence_dataloader.py index 9503d87b46..59cb808611 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/dataset_utils/sequence_dataloader.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/dataset_utils/sequence_dataloader.py @@ -53,14 +53,14 @@ def fetch_data(self): if response.status_code == 200: batch = response.json() - # in trianing, we use iteraiton-per-epoch to control the end + # in training, we use iteraiton-per-epoch to control the end if batch == self.end_signal: if self.name_space == "valid": # end_signal in inference, stop ! logger.info("[StreamingDataLoader]: last iteration in valid is meet!") self.data_queue.put({self.end_signal: True}) else: - # end_signal in trianing, then keep training + # end_signal in training, then keep training continue else: # convert to tensor again diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/dataset_utils/stream_dataloader.py b/examples/model_selection/Trails/internal/ml/model_selection/src/dataset_utils/stream_dataloader.py index 9c5211081e..0e35c4466f 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/dataset_utils/stream_dataloader.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/dataset_utils/stream_dataloader.py @@ -53,14 +53,14 @@ def fetch_data(self): if response.status_code == 200: batch = response.json() - # in trianing, we use iteraiton-per-epoch to control the end + # in training, we use iteraiton-per-epoch to control the end if batch == self.end_signal: if self.name_space == "valid": # end_signal in inference, stop ! logger.info("[StreamingDataLoader]: last iteration in valid is meet!") self.data_queue.put({self.end_signal: True}) else: - # end_signal in trianing, then keep training + # end_signal in training, then keep training continue else: # convert to tensor again diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/coordinator.py b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/coordinator.py index cd9bf95e1d..9b36141780 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/coordinator.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/coordinator.py @@ -59,12 +59,12 @@ def schedule(dataset: str, sh: BudgetAwareControllerSH, T_: float, t1_: float, t only_phase1: bool = False): """ :param dataset - :param sh: BudgetAwareControllerSH instnace + :param sh: BudgetAwareControllerSH instance :param T_: user given time budget :param t1_: time to score one model :param t2_: time to train one model :param w_: number of workers, for parallelly running. - :param search_space_ins: search spcae instance + :param search_space_ins: search space instance :param N_K_ratio: N/K = N_K_ratio :param only_phase1: Only use filtering phase. """ diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/mnist_cnn.py b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/mnist_cnn.py index 16752ceabe..e9b9c11d1d 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/mnist_cnn.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/mnist_cnn.py @@ -135,7 +135,7 @@ def reduce_variable(variable, dist_opt, reducer): return output -# Function to sychronize SINGA TENSOR initial model parameters +# Function to synchronize SINGA TENSOR initial model parameters def synchronize(tensor, dist_opt): dist_opt.all_reduce(tensor.data) dist_opt.wait() @@ -176,7 +176,7 @@ def train_mnist_cnn(DIST=False, batch_size = 64 sgd = opt.SGD(lr=0.005, momentum=0.9, weight_decay=1e-5) - # Prepare training and valadiation data + # Prepare training and validation data train_x, train_y, test_x, test_y = load_dataset() IMG_SIZE = 28 num_classes = 10 @@ -216,7 +216,7 @@ def train_mnist_cnn(DIST=False, idx = np.arange(train_x.shape[0], dtype=np.int32) if DIST: - #Sychronize the initial parameters + #Synchronize the initial parameters autograd.training = True x = np.random.randn(batch_size, 1, IMG_SIZE, IMG_SIZE).astype(np.float32) @@ -228,7 +228,7 @@ def train_mnist_cnn(DIST=False, for p, g in autograd.backward(loss): synchronize(p, sgd) - # Training and evaulation loop + # Training and evaluation loop for epoch in range(max_epoch): start_time = time.time() np.random.shuffle(idx) @@ -287,7 +287,7 @@ def train_mnist_cnn(DIST=False, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/resnet_cifar10.py b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/resnet_cifar10.py index d71e0f29b6..c9cec87ebf 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/resnet_cifar10.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/resnet_cifar10.py @@ -138,7 +138,7 @@ def reduce_variable(variable, dist_opt, reducer): return output -# Function to sychronize SINGA TENSOR initial model parameters +# Function to synchronize SINGA TENSOR initial model parameters def synchronize(tensor, dist_opt): dist_opt.all_reduce(tensor.data) dist_opt.wait() @@ -199,7 +199,7 @@ def train_cifar10(DIST=False, idx = np.arange(train_x.shape[0], dtype=np.int32) if DIST: - # Sychronize the initial parameters + # Synchronize the initial parameters autograd.training = True x = np.random.randn(batch_size, 3, IMG_SIZE, IMG_SIZE).astype(np.float32) @@ -258,11 +258,11 @@ def train_cifar10(DIST=False, flush=True) if partial_update: - # Sychronize parameters before evaluation phase + # Synchronize parameters before evaluation phase for p in param: synchronize(p, sgd) - # Evaulation phase + # Evaluation phase autograd.training = False for b in range(num_test_batch): x = test_x[b * batch_size:(b + 1) * batch_size] @@ -275,7 +275,7 @@ def train_cifar10(DIST=False, to_categorical(y, num_classes)) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/resnet_dist.py b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/resnet_dist.py index 6f9b56ceeb..4d2cfb60cd 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/resnet_dist.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/resnet_dist.py @@ -33,7 +33,7 @@ sgd = opt.DistOpt(sgd) if (sgd.global_rank == 0): - print("Start intialization...........", flush=True) + print("Start initialization...........", flush=True) dev = device.create_cuda_gpu_on(sgd.local_rank) diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/xceptionnet.py b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/xceptionnet.py index 8fb23d8cbb..3a83226295 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/xceptionnet.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/autograd/xceptionnet.py @@ -279,7 +279,7 @@ def forward(self, input): if __name__ == '__main__': model = Xception(num_classes=1000) - print('Start intialization............') + print('Start initialization............') dev = device.create_cuda_gpu_on(0) #dev = device.create_cuda_gpu() diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/train_cnn.py b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/train_cnn.py index c17e1b6c42..7fcd283e3f 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/train_cnn.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/train_cnn.py @@ -414,7 +414,7 @@ def run(global_rank, synflow_flag = False # Train the model - if epoch == (max_epoch - 1) and b == (num_train_batch - 1): ### synflow calcuation for the last batch + if epoch == (max_epoch - 1) and b == (num_train_batch - 1): ### synflow calculation for the last batch print ("last epoch calculate synflow") synflow_flag = True ### step 1: all one input @@ -482,7 +482,7 @@ def run(global_rank, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, mssgd, reducer) # Output the evaluation accuracy diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/train_ms_model.py b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/train_ms_model.py index 8cdda8fe1d..ff4569ff56 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/train_ms_model.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/algo/singa_ms/cnn_ms/train_ms_model.py @@ -427,7 +427,7 @@ def run(global_rank, synflow_flag = False # Train the model - if epoch == (max_epoch - 1) and b == (num_train_batch - 1): ### synflow calcuation for the last batch + if epoch == (max_epoch - 1) and b == (num_train_batch - 1): ### synflow calculation for the last batch print ("last epoch calculate synflow") synflow_flag = True ### step 1: all one input @@ -499,7 +499,7 @@ def run(global_rank, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, mssgd, reducer) # Output the evaluation accuracy diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/concurrent_evaluator.py b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/concurrent_evaluator.py index ea53d4e667..3ee724f6d0 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/concurrent_evaluator.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/concurrent_evaluator.py @@ -50,7 +50,7 @@ def __init__(self, device: str, num_label: int, dataset_name: str, :param train_loader: :param is_simulate: :param metrics: which TFMEM to use? - :param enable_cache: if cache embedding for scoring? only used on structued data + :param enable_cache: if cache embedding for scoring? only used on structured data """ self.metrics = metrics self.is_simulate = is_simulate diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/evaluator.py b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/evaluator.py index 3255d69bcc..9d0c79d17c 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/evaluator.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/evaluator.py @@ -53,8 +53,8 @@ def __init__(self, device: str, num_label: int, dataset_name: str, :param train_loader: :param is_simulate: :param metrics: which TFMEM to use? - :param enable_cache: if cache embedding for scoring? only used on structued data - :param db_config: how to connect to databaes + :param enable_cache: if cache embedding for scoring? only used on structured data + :param db_config: how to connect to databases :param data_retrievel: sql or spi """ self.metrics = metrics @@ -339,7 +339,7 @@ def _p1_evaluate_simu_jacflow(self, model_acquire: ModelAcquireData) -> dict: def _p1_evaluate_simu(self, model_acquire: ModelAcquireData) -> dict: """ - This involves simulate get alls core, + This involves simulate get all core, """ if self.score_getter is None: self.score_getter = SimulateScore(space_name=self.search_space_ins.name, diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/run_phase1.py b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/run_phase1.py index 3f81101e4d..848cd83935 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/run_phase1.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase1/run_phase1.py @@ -20,7 +20,7 @@ import json from src.common.structure import ModelAcquireData, ModelEvaData -from src.controller.controler import SampleController +from src.controller.controller import SampleController from src.controller.sampler_all.seq_sampler import SequenceSampler from src.eva_engine.phase1.evaluator import P1Evaluator @@ -149,7 +149,7 @@ def run_phase1(self) -> (list, list, list, list): model_eva.model_score, simple_score_sum=self.args.simple_score_sum) - # this is to measure the value of metrix, sum of two value. + # this is to measure the value of metric, sum of two value. if len(trace_highest_score) == 0: trace_highest_score.append(ranked_score) trace_highest_scored_models_id.append(str(arch_id)) diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase2/algo/trainer.py b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase2/algo/trainer.py index 4ea5038051..f5441e30d0 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase2/algo/trainer.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase2/algo/trainer.py @@ -592,7 +592,7 @@ def fully_train_arch(cls, # print ("test_correct: ", test_correct) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, mssgd, reducer) # Output the evaluation accuracy diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase2/run_sh.py b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase2/run_sh.py index b2188e6b8c..5eaf3f9a06 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase2/run_sh.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase2/run_sh.py @@ -160,7 +160,7 @@ def run_phase2(self, U: int, candidates_m: list) -> (str, float, float): if self.is_simulate: logger.info( f"5. [trails] Phase2 Done, Select {candidates_m[0]}, " - f"simulate={self.is_simulate}. Acqure the ground truth") + f"simulate={self.is_simulate}. Acquire the ground truth") best_perform, _ = self._evaluator.p2_evaluate(candidates_m[0], self.max_unit_per_model) else: logger.info( diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase2/run_uniform.py b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase2/run_uniform.py index 8b32fab3df..506e70842d 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase2/run_uniform.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/eva_engine/phase2/run_uniform.py @@ -66,7 +66,7 @@ def schedule_budget_per_model_based_on_T(self, space_name, fixed_time_budget, K_ def pre_calculate_epoch_required(self, K, U, eta: int=3, max_unit_per_model: int=200): """ :param B: total budget for phase 2 - :param U: mini unit computation for each modle + :param U: mini unit computation for each model :param candidates_m: :return: """ @@ -74,7 +74,7 @@ def pre_calculate_epoch_required(self, K, U, eta: int=3, max_unit_per_model: int def run_phase2(self, U: int, candidates_m: list): """ - :param U: mini unit computation for each modle + :param U: mini unit computation for each model :param candidates_m: :return: """ @@ -83,7 +83,7 @@ def run_phase2(self, U: int, candidates_m: list): candidates = copy(candidates_m) min_budget_required = 0 - # todo: this is to run the full training, when compute full traiing + # todo: this is to run the full training, when compute full training # U = self.max_unit_per_model if U >= self.max_unit_per_model: diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/img_explore_ea.py b/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/img_explore_ea.py index ae3f691044..6ecb58b3f1 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/img_explore_ea.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/img_explore_ea.py @@ -47,7 +47,7 @@ def fetch_from_db(space_name, dataset, run_id_m, N_m): """ :param run_id_m: run_id 100 max - :param B1_m: number of models evaluted + :param B1_m: number of models evaluated :return: """ global con diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/interface.py b/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/interface.py index 265ecdc5a7..b6c1ccc3c3 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/interface.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/interface.py @@ -25,7 +25,7 @@ def profile_NK_trade_off(dataset): """ - This is get from the profling result. + This is obtained from the profiling results. We try various N/K combinations, and find this is better. """ if dataset == Config.c10: diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/query_api_img.py b/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/query_api_img.py index b5f77e38ac..346f2f047d 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/query_api_img.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/query_api_img.py @@ -73,7 +73,7 @@ def guess_train_one_epoch_time(search_space_m, dataset): class ImgScoreQueryApi: # Multiton pattern - # use those algoroithm => new tfmem + # use those algorithm => new tfmem default_alg_name_list = ["nas_wot", "synflow"] _instances = {} diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/query_api_mlp.py b/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/query_api_mlp.py index 1527567924..81d471153e 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/query_api_mlp.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/query_api/query_api_mlp.py @@ -43,7 +43,7 @@ exp_mlp_score_uci = os.path.join(base_dir, "micro_sensitivity/3_batch_size/4/score_mlp_sp_uci_diabetes_batch_size_32_cpu.json") exp_mlp_score_criteo = os.path.join(base_dir, "micro_sensitivity/3_batch_size/4/score_mlp_sp_criteo_batch_size_32_cpu.json") -# todo here we use weigth sharing. +# todo here we use weight sharing. mlp_score_frappe_weight_share = os.path.join(base_dir, "tab_data/weight_share_nas_frappe.json") # pre computed result @@ -76,7 +76,7 @@ class GTMLP: _instances = {} - # use those algoroithm => new tfmem + # use those algorithm => new tfmem default_alg_name_list = ["nas_wot", "synflow"] device = "cpu" diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/search_space/core/model_params.py b/examples/model_selection/Trails/internal/ml/model_selection/src/search_space/core/model_params.py index 0851964e51..09dd0e1122 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/search_space/core/model_params.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/search_space/core/model_params.py @@ -32,7 +32,7 @@ def __init__(self, num_labels): class ModelMicroCfg: """ Micro space cfg - Identifier for each model, connection patter, operations etc. + Identifier for each model, connection pattern, operations etc. encoding = serialized(ModelMicroCfg) """ diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/search_space/core/space.py b/examples/model_selection/Trails/internal/ml/model_selection/src/search_space/core/space.py index 607c65ac5f..3e06cf47a2 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/search_space/core/space.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/search_space/core/space.py @@ -157,7 +157,7 @@ def mutate_architecture(self, parent_arch: ModelMicroCfg) -> (str, ModelMicroCfg def get_reinforcement_learning_policy(self, lr_rate): """ - This is fpr reinforcement learning policy sampler + This is for reinforcement learning policy sampler :return: """ raise NotImplementedError diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/search_space/mlp_api/space.py b/examples/model_selection/Trails/internal/ml/model_selection/src/search_space/mlp_api/space.py index 33a9b6fb12..24269cd9ba 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/search_space/mlp_api/space.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/search_space/mlp_api/space.py @@ -542,7 +542,7 @@ def profiling_score_time( device = "cpu" if is_simulate: gtmlp = GTMLP(dataset) - # todo, we use hybird here. + # todo, we use hybrid here. # those are from the pre-calculator _train_time_per_epoch = gtmlp.get_score_one_model_time("cpu") score_time = _train_time_per_epoch @@ -575,7 +575,7 @@ def profiling_score_time( # batch_data=batch, # batch_labels=target) # - # # re-init hte net + # # re-init the net # del super_net # # super_net = DNNModel( # super_net = SINGADNNModel( @@ -607,7 +607,7 @@ def profiling_score_time( score_time = time.time() - score_time_begin - # re-init hte net + # re-init the net del super_net return score_time @@ -633,7 +633,7 @@ def profiling_train_time(self, dataset: str, noutput=self.model_cfg.num_labels) # super_net.init_embedding(requires_grad=True) # super_net.to(device) - # only train for ony iteratin to evaluat the time usage. + # only train for only iteration to evaluat the time usage. targs = copy.deepcopy(args) valid_auc, train_time_epoch, train_log = ModelTrainer.fully_train_arch( model=super_net, @@ -657,7 +657,7 @@ def profiling(self, dataset: str, if is_simulate: gtmlp = GTMLP(dataset) - # todo, we use hybird here. + # todo, we use hybrid here. # those are from the pre-calculator _train_time_per_epoch = gtmlp.get_score_one_model_time("cpu") score_time = _train_time_per_epoch @@ -692,7 +692,7 @@ def profiling(self, dataset: str, batch_data=batch, batch_labels=target) - # re-init hte net + # re-init the net del super_net # super_net = DNNModel( super_net = SINGADNNModel( @@ -715,7 +715,7 @@ def profiling(self, dataset: str, score_time = time.time() - score_time_begin - # re-init hte net + # re-init the net del super_net if is_simulate: @@ -735,7 +735,7 @@ def profiling(self, dataset: str, # super_net.init_embedding(requires_grad=True) # super_net.to(device) - # only train for ony iteratin to evaluat the time usage. + # only train for only iteration to evaluat the time usage. targs = copy.deepcopy(args) valid_auc, train_time_epoch, train_log = ModelTrainer.fully_train_arch( model=super_net, @@ -778,7 +778,7 @@ def get_arch_size(self, arch_micro: ModelMicroCfg) -> int: def sample_all_models(self) -> Generator[str, ModelMicroCfg, None]: assert isinstance(self.model_cfg, MlpMacroCfg) - # 2-dimensional matrix for the search spcae + # 2-dimensional matrix for the search space space = [] for _ in range(self.model_cfg.num_layers): space.append(self.model_cfg.layer_choices) diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/tools/io_tools.py b/examples/model_selection/Trails/internal/ml/model_selection/src/tools/io_tools.py index a66575b7b1..7be0430846 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/tools/io_tools.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/tools/io_tools.py @@ -34,7 +34,7 @@ def read_json(file_name): def write_json(file_name, data): - print(f"writting {file_name}...") + print(f"writing {file_name}...") with open(file_name, 'w') as outfile: outfile.write(json.dumps(data)) diff --git a/examples/model_selection/Trails/internal/ml/model_selection/src/tools/res_measure.py b/examples/model_selection/Trails/internal/ml/model_selection/src/tools/res_measure.py index bc261fa54b..fda9121302 100644 --- a/examples/model_selection/Trails/internal/ml/model_selection/src/tools/res_measure.py +++ b/examples/model_selection/Trails/internal/ml/model_selection/src/tools/res_measure.py @@ -74,7 +74,7 @@ def print_usage(): time.sleep(interval) - print("Stop monitering, flust to disk") + print("Stop monitoring, flust to disk") write_json(output_file, metrics) stop_event = stop_event or threading.Event() diff --git a/examples/model_selection/Trails/internal/ml/model_slicing/README.md b/examples/model_selection/Trails/internal/ml/model_slicing/README.md index 44979a684b..3fe845e182 100644 --- a/examples/model_selection/Trails/internal/ml/model_slicing/README.md +++ b/examples/model_selection/Trails/internal/ml/model_slicing/README.md @@ -315,7 +315,7 @@ SELECT inference( 8000 ); -# explaination +# explanation EXPLAIN (ANALYZE, BUFFERS) SELECT inference( 'frappe', '{"2":977}', diff --git a/examples/model_selection/Trails/internal/ml/model_slicing/baseline_int.py b/examples/model_selection/Trails/internal/ml/model_slicing/baseline_int.py index e10fd7a148..b88a43dca9 100644 --- a/examples/model_selection/Trails/internal/ml/model_slicing/baseline_int.py +++ b/examples/model_selection/Trails/internal/ml/model_slicing/baseline_int.py @@ -134,7 +134,7 @@ def reload_argparse(file_path: str): parser.add_argument('path', type=str, help="directory to model file") parser.add_argument('--flag', '-p', action='store_true', - help="wehther to print profile") + help="whether to print profile") parser.add_argument('--print_net', '--b', action='store_true', help="print the structure of network") diff --git a/examples/model_selection/Trails/internal/ml/model_slicing/pg_interface.py b/examples/model_selection/Trails/internal/ml/model_slicing/pg_interface.py index b33ad148b9..f344a18226 100644 --- a/examples/model_selection/Trails/internal/ml/model_slicing/pg_interface.py +++ b/examples/model_selection/Trails/internal/ml/model_slicing/pg_interface.py @@ -55,7 +55,7 @@ def read_json(file_name): def exception_catcher(func): def wrapper(encoded_str: str): try: - # each functon accepts a json string + # each function accepts a json string params = json.loads(encoded_str) config_file = params.get("config_file") diff --git a/examples/model_selection/Trails/internal/ml/model_slicing/save_satistics.py b/examples/model_selection/Trails/internal/ml/model_slicing/save_satistics.py index 2f77d313c2..00c9c3c0b5 100644 --- a/examples/model_selection/Trails/internal/ml/model_slicing/save_satistics.py +++ b/examples/model_selection/Trails/internal/ml/model_slicing/save_satistics.py @@ -25,7 +25,7 @@ def write_json(file_name, data): - print(f"writting {file_name}...") + print(f"writing {file_name}...") with open(file_name, 'w') as outfile: outfile.write(json.dumps(data)) diff --git a/examples/model_selection/Trails/internal/pg_extension/src/bindings/inference.rs b/examples/model_selection/Trails/internal/pg_extension/src/bindings/inference.rs index aa6161184f..add1ab25af 100644 --- a/examples/model_selection/Trails/internal/pg_extension/src/bindings/inference.rs +++ b/examples/model_selection/Trails/internal/pg_extension/src/bindings/inference.rs @@ -182,7 +182,7 @@ pub fn run_inference_shared_memory( response.insert("overall_query_latency", overall_elapsed_time.clone()); response.insert("diff", diff_time.clone()); - // Step 4: Return to PostgresSQL + // Step 4: Return to PostgreSQL return serde_json::json!(response); } @@ -292,7 +292,7 @@ pub fn run_inference( &response_json, "records_results"); - // Step 4: Return to PostgresSQL + // Step 4: Return to PostgreSQL return serde_json::json!(response); } @@ -474,7 +474,7 @@ pub fn run_inference_shared_memory_write_once( &response_json, "records_results"); - // Step 4: Return to PostgresSQL + // Step 4: Return to PostgreSQL return serde_json::json!(response); } @@ -626,7 +626,7 @@ pub fn run_inference_shared_memory_write_once_int_exp( &response_json, "records_results"); - // Step 4: Return to PostgresSQL + // Step 4: Return to PostgreSQL return serde_json::json!(response); } @@ -767,7 +767,7 @@ pub fn run_inference_shared_memory_write_once_int( &response_json, "records_results"); - // Step 4: Return to PostgresSQL + // Step 4: Return to PostgreSQL return serde_json::json!(response); } diff --git a/examples/model_selection/Trails/internal/pg_extension/src/bindings/ml_register.rs b/examples/model_selection/Trails/internal/pg_extension/src/bindings/ml_register.rs index 617edf52fc..c6a46e7977 100644 --- a/examples/model_selection/Trails/internal/pg_extension/src/bindings/ml_register.rs +++ b/examples/model_selection/Trails/internal/pg_extension/src/bindings/ml_register.rs @@ -36,7 +36,7 @@ pub fn run_python_function( let parameters_str = parameters.to_string(); let results = Python::with_gil(|py| -> String { - // load package such that it can import python packages, we do this onyl for integrate with polarDB env + // load package such that it can import python packages, we do this only for integrate with polarDB env let sys_module = py.import("sys").unwrap(); let sys_path: &PyList = sys_module.getattr("path").unwrap().downcast().unwrap(); sys_path.append("/home/postgres/Trails/internal/ml/model_selection/").unwrap(); diff --git a/examples/model_selection/Trails/internal/pg_extension/src/bindings/ms.rs b/examples/model_selection/Trails/internal/pg_extension/src/bindings/ms.rs index bc8640430f..adcf1fd5fe 100644 --- a/examples/model_selection/Trails/internal/pg_extension/src/bindings/ms.rs +++ b/examples/model_selection/Trails/internal/pg_extension/src/bindings/ms.rs @@ -259,7 +259,7 @@ pub fn benchmark_filtering_latency_in_db( &record_task_json, "records_results"); - // Step 4: Return to PostgresSQL + // Step 4: Return to PostgreSQL return serde_json::json!(return_result); } diff --git a/examples/model_selection/Trails/singa_pkg_code/tensor.py b/examples/model_selection/Trails/singa_pkg_code/tensor.py index d1ebb61d9c..7a9d7ea876 100644 --- a/examples/model_selection/Trails/singa_pkg_code/tensor.py +++ b/examples/model_selection/Trails/singa_pkg_code/tensor.py @@ -234,7 +234,7 @@ def reshape(self, shape): Args: shape (list): new shape, which should have the same - volumn as the original shape. + volume as the original shape. Returns: new tensor reshaped @@ -502,7 +502,7 @@ def uniform(self, low, high, inplace=True): Args: low (float): the lower bound - high (float): the hight bound + high (float): the higher bound inplace: inplace flag Returns: @@ -806,7 +806,7 @@ def reshape(tensor, shape): Args: tensor (Tensor): the tensor to be changed - shape (list): the new shape, which should have the same volumn as the + shape (list): the new shape, which should have the same volume as the old shape. Returns: @@ -1303,7 +1303,7 @@ def einsum(ops, *args): 2.repeat(A,repeats) 3.transpose(A,axes = None) Do the matrix to matrix einsum calculation according to the operands - Warning : this function could only support two matrix' einsum calcultion + Warning : this function could only support two matrix' einsum calculation Args: ops(string): the string specifies the subscripts for summation such as @@ -1312,7 +1312,7 @@ def einsum(ops, *args): but here only support two tensors. Returns: - Singa.Tensor the output matirx of the einsum calculation + Singa.Tensor the output matrix of the einsum calculation The best way to understand this function is to try the examples below: A_ = [0,1,2,3,4,5,6,7,8,9,10,11] @@ -1331,7 +1331,7 @@ def einsum(ops, *args): A = A_.reshape(4,3) B = A_.reshape(4,3) - Here the einsum calculation is the same as normol 'eltwise_mult' + Here the einsum calculation is the same as normal 'eltwise_mult' Res = einsum('ki,ki->ki',A,B) >>> [[ 0 1 4] diff --git a/examples/onnx/arcface.py b/examples/onnx/arcface.py index 6050418446..76a9b78941 100644 --- a/examples/onnx/arcface.py +++ b/examples/onnx/arcface.py @@ -84,13 +84,13 @@ def train_one_batch(self, x, y): # sg_ir = sonnx.prepare(onnx_model) # run without graph # y = sg_ir.run([img1, img2]) - logging.info("model compling...") + logging.info("model compiling...") dev = device.create_cuda_gpu() x = tensor.Tensor(device=dev, data=np.concatenate((img1, img2), axis=0)) model = MyModel(onnx_model) model.compile([x], is_train=False, use_graph=True, sequential=True) - # verifty the test + # verify the test # from utils import load_dataset # inputs, ref_outputs = load_dataset(os.path.join('/tmp', 'resnet100', 'test_data_set_0')) # x_batch = tensor.Tensor(device=dev, data=inputs[0]) diff --git a/examples/onnx/bert/bert-squad.py b/examples/onnx/bert/bert-squad.py index 936968eada..635c823c00 100644 --- a/examples/onnx/bert/bert-squad.py +++ b/examples/onnx/bert/bert-squad.py @@ -139,14 +139,14 @@ def train_one_batch(self, x, y): # prepare the model if m is None: - logging.info("model compling...") + logging.info("model compiling...") m = MyModel(onnx_model) # m.compile(x_batch, is_train=False, use_graph=True, sequential=True) logging.info("model running for sample {}...".format(idx)) outputs = m.forward(*x_batch) - logging.info("hanlde the result of sample {}...".format(idx)) + logging.info("handle the result of sample {}...".format(idx)) result = [] for outp in outputs: result.append(tensor.to_numpy(outp)) diff --git a/examples/onnx/bert/run_onnx_squad.py b/examples/onnx/bert/run_onnx_squad.py index f9a60da47c..40b9f5ec9f 100644 --- a/examples/onnx/bert/run_onnx_squad.py +++ b/examples/onnx/bert/run_onnx_squad.py @@ -15,7 +15,7 @@ Inference for squad/bert using onnx. This is going to do the samem as 'python run_squad.py --do_predict=True ...' using a squad/bert model -that was converted to onnx. Lots of code was taken from run_squad.py. +that was converted to ONNX. Lots of code was taken from run_squad.py. You run it with: diff --git a/examples/onnx/bert/tokenization.py b/examples/onnx/bert/tokenization.py index 09b9b4fd7b..c01060dc9b 100644 --- a/examples/onnx/bert/tokenization.py +++ b/examples/onnx/bert/tokenization.py @@ -357,7 +357,7 @@ def tokenize(self, text): def _is_whitespace(char): """Checks whether `chars` is a whitespace character.""" - # \t, \n, and \r are technically contorl characters but we treat them + # \t, \n, and \r are technically control characters but we treat them # as whitespace since they are generally considered as such. if char == " " or char == "\t" or char == "\n" or char == "\r": return True diff --git a/examples/onnx/densenet121.py b/examples/onnx/densenet121.py index c8a8f95dc2..cb9dfecbac 100644 --- a/examples/onnx/densenet121.py +++ b/examples/onnx/densenet121.py @@ -85,13 +85,13 @@ def train_one_batch(self, x, y): # sg_ir = sonnx.prepare(onnx_model) # run without graph # y = sg_ir.run([img]) - logging.info("model compling...") + logging.info("model compiling...") dev = device.create_cuda_gpu() x = tensor.Tensor(device=dev, data=img) model = MyModel(onnx_model) model.compile([x], is_train=False, use_graph=True, sequential=True) - # verifty the test + # verify the test # from utils import load_dataset # inputs, ref_outputs = load_dataset(os.path.join('/tmp', 'densenet121', 'test_data_set_0')) # x_batch = tensor.Tensor(device=dev, data=inputs[0]) diff --git a/examples/onnx/fer_emotion.py b/examples/onnx/fer_emotion.py index e9805805d4..9246e24aa4 100644 --- a/examples/onnx/fer_emotion.py +++ b/examples/onnx/fer_emotion.py @@ -80,13 +80,13 @@ def train_one_batch(self, x, y): # sg_ir = sonnx.prepare(onnx_model) # run without graph # y = sg_ir.run([img]) - logging.info("model compling...") + logging.info("model compiling...") dev = device.create_cuda_gpu() x = tensor.PlaceHolder(img.shape, device=dev) model = MyModel(onnx_model) model.compile([x], is_train=False, use_graph=True, sequential=True) - # verifty the test + # verify the test # from utils import load_dataset # inputs, ref_outputs = load_dataset(os.path.join('/tmp', 'emotion_ferplus', 'test_data_set_0')) # x_batch = tensor.Tensor(device=dev, data=inputs[0]) diff --git a/examples/onnx/gpt2/gpt2.py b/examples/onnx/gpt2/gpt2.py index dd27334358..4c6dfd8207 100644 --- a/examples/onnx/gpt2/gpt2.py +++ b/examples/onnx/gpt2/gpt2.py @@ -77,12 +77,12 @@ def train_one_batch(self, x, y): logging.info("preprocessing...") input_ids = preprocess() - logging.info("model compling...") + logging.info("model compiling...") dev = device.get_default_device() x = tensor.Tensor(device=dev, data=input_ids) model = MyModel(onnx_model) - # verifty the test + # verify the test # from utils import load_dataset # sg_ir = sonnx.prepare(onnx_model) # run without graph # inputs, ref_outputs = load_dataset( diff --git a/examples/onnx/mobilenet.py b/examples/onnx/mobilenet.py index ad394ca535..77504d548f 100644 --- a/examples/onnx/mobilenet.py +++ b/examples/onnx/mobilenet.py @@ -86,13 +86,13 @@ def train_one_batch(self, x, y): # sg_ir = sonnx.prepare(onnx_model) # run without graph # y = sg_ir.run([img]) - logging.info("model compling...") + logging.info("model compiling...") dev = device.create_cuda_gpu() x = tensor.PlaceHolder(img.shape, device=dev) model = MyModel(onnx_model) model.compile([x], is_train=False, use_graph=True, sequential=True) - # verifty the test + # verify the test # from utils import load_dataset # inputs, ref_outputs = load_dataset(os.path.join('/tmp', 'mobilenetv2-1.0', 'test_data_set_0')) # x_batch = tensor.Tensor(device=dev, data=inputs[0]) diff --git a/examples/onnx/resnet18.py b/examples/onnx/resnet18.py index b66c3fb299..af31fcac7c 100644 --- a/examples/onnx/resnet18.py +++ b/examples/onnx/resnet18.py @@ -84,13 +84,13 @@ def train_one_batch(self, x, y): # sg_ir = sonnx.prepare(onnx_model) # run without graph # y = sg_ir.run([img]) - logging.info("model compling...") + logging.info("model compiling...") dev = device.create_cuda_gpu() x = tensor.PlaceHolder(img.shape, device=dev) model = MyModel(onnx_model) model.compile([x], is_train=False, use_graph=True, sequential=True) - # verifty the test + # verify the test # from utils import load_dataset # inputs, ref_outputs = load_dataset(os.path.join('/tmp', 'resnet18v1', 'test_data_set_0')) # x_batch = tensor.Tensor(device=dev, data=inputs[0]) diff --git a/examples/onnx/ro_bert_a/ro_bert_a.py b/examples/onnx/ro_bert_a/ro_bert_a.py index b6b02ed9ee..9b5e423fe8 100644 --- a/examples/onnx/ro_bert_a/ro_bert_a.py +++ b/examples/onnx/ro_bert_a/ro_bert_a.py @@ -69,12 +69,12 @@ def train_one_batch(self, x, y): logging.info("preprocessing...") input_ids = preprocess() - logging.info("model compling...") + logging.info("model compiling...") dev = device.get_default_device() x = tensor.Tensor(device=dev, data=input_ids) model = MyModel(onnx_model) - # verifty the test + # verify the test # from utils import load_dataset # sg_ir = sonnx.prepare(onnx_model) # run without graph # inputs, ref_outputs = load_dataset( diff --git a/examples/onnx/shufflenetv1.py b/examples/onnx/shufflenetv1.py index 139d6d3b4a..dc326875ec 100644 --- a/examples/onnx/shufflenetv1.py +++ b/examples/onnx/shufflenetv1.py @@ -82,13 +82,13 @@ def train_one_batch(self, x, y): # sg_ir = sonnx.prepare(onnx_model) # run without graph # y = sg_ir.run([img]) - logging.info("model compling...") + logging.info("model compiling...") dev = device.create_cuda_gpu() x = tensor.Tensor(device=dev, data=img) model = MyModel(onnx_model) model.compile([x], is_train=False, use_graph=True, sequential=True) - # verifty the test + # verify the test # from utils import load_dataset # inputs, ref_outputs = load_dataset(os.path.join('/tmp', 'shufflenet', 'test_data_set_0')) # x_batch = tensor.Tensor(device=dev, data=inputs[0]) diff --git a/examples/onnx/shufflenetv2.py b/examples/onnx/shufflenetv2.py index 60f84a4c79..57d6009cad 100644 --- a/examples/onnx/shufflenetv2.py +++ b/examples/onnx/shufflenetv2.py @@ -86,13 +86,13 @@ def train_one_batch(self, x, y): # sg_ir = sonnx.prepare(onnx_model) # run without graph # y = sg_ir.run([img]) - logging.info("model compling...") + logging.info("model compiling...") dev = device.create_cuda_gpu() x = tensor.PlaceHolder(img.shape, device=dev) model = MyModel(onnx_model) model.compile([x], is_train=False, use_graph=True, sequential=True) - # verifty the test + # verify the test # from utils import load_dataset # inputs, ref_outputs = load_dataset(os.path.join('/tmp', 'model', 'test_shufflenetv2', # 'model.onnx')) diff --git a/examples/onnx/squeezenet.py b/examples/onnx/squeezenet.py index 861550cba6..d9e145f013 100644 --- a/examples/onnx/squeezenet.py +++ b/examples/onnx/squeezenet.py @@ -85,13 +85,13 @@ def train_one_batch(self, x, y): # sg_ir = sonnx.prepare(onnx_model) # run without graph # y = sg_ir.run([img]) - logging.info("model compling...") + logging.info("model compiling...") dev = device.create_cuda_gpu() x = tensor.Tensor(device=dev, data=img) model = MyModel(onnx_model) model.compile([x], is_train=False, use_graph=True, sequential=True) - # verifty the test + # verify the test # from utils import load_dataset # inputs, ref_outputs = load_dataset(os.path.join('/tmp', 'squeezenet1.1', 'test_data_set_0')) # x_batch = tensor.Tensor(device=dev, data=inputs[0]) diff --git a/examples/onnx/superresolution.py b/examples/onnx/superresolution.py index caaae19d9a..0cee88b648 100644 --- a/examples/onnx/superresolution.py +++ b/examples/onnx/superresolution.py @@ -79,7 +79,7 @@ def train_one_batch(self, x, y): # sg_ir = sonnx.prepare(onnx_model) # run without graph # y = sg_ir.run([img]) - logging.info("model compling...") + logging.info("model compiling...") dev = device.create_cuda_gpu() x = tensor.PlaceHolder(img_y.shape, device=dev) model = MyModel(onnx_model) diff --git a/examples/onnx/tiny_yolov2.py b/examples/onnx/tiny_yolov2.py index 72d3666994..c44e38f063 100644 --- a/examples/onnx/tiny_yolov2.py +++ b/examples/onnx/tiny_yolov2.py @@ -139,13 +139,13 @@ def train_one_batch(self, x, y): # sg_ir = sonnx.prepare(onnx_model) # run without graph # y = sg_ir.run([img]) - logging.info("model compling...") + logging.info("model compiling...") dev = device.create_cuda_gpu() x = tensor.PlaceHolder(img.shape, device=dev) model = MyModel(onnx_model) model.compile([x], is_train=False, use_graph=True, sequential=True) - # verifty the test + # verify the test # from utils import load_dataset # inputs, ref_outputs = load_dataset(os.path.join('/tmp', 'tiny_yolov2', 'test_data_set_0')) # x_batch = tensor.Tensor(device=dev, data=inputs[0]) diff --git a/examples/onnx/training/train.py b/examples/onnx/training/train.py index 8407bfe7d4..625691bd9d 100644 --- a/examples/onnx/training/train.py +++ b/examples/onnx/training/train.py @@ -276,7 +276,7 @@ def run(global_rank, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the Evaulation Accuracy from Multiple Devices + # Reduce the Evaluation Accuracy from Multiple Devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the Evaluation Accuracy diff --git a/examples/onnx/vgg16.py b/examples/onnx/vgg16.py index 369cee9e58..c6612e37fb 100644 --- a/examples/onnx/vgg16.py +++ b/examples/onnx/vgg16.py @@ -84,13 +84,13 @@ def train_one_batch(self, x, y): # sg_ir = sonnx.prepare(onnx_model) # run without graph # y = sg_ir.run([img]) - logging.info("model compling...") + logging.info("model compiling...") dev = device.create_cuda_gpu() x = tensor.PlaceHolder(img.shape, device=dev) model = MyModel(onnx_model) model.compile([x], is_train=False, use_graph=True, sequential=True) - # verifty the test + # verify the test # from utils import load_dataset # inputs, ref_outputs = load_dataset(os.path.join('/tmp', 'vgg16', 'test_data_set_0')) # x_batch = tensor.Tensor(device=dev, data=inputs[0]) diff --git a/examples/onnx/vgg19.py b/examples/onnx/vgg19.py index a2c3ea73c7..a14ff59215 100644 --- a/examples/onnx/vgg19.py +++ b/examples/onnx/vgg19.py @@ -84,13 +84,13 @@ def train_one_batch(self, x, y): # sg_ir = sonnx.prepare(onnx_model) # run without graph # y = sg_ir.run([img]) - logging.info("model compling...") + logging.info("model compiling...") dev = device.create_cuda_gpu() x = tensor.PlaceHolder(img.shape, device=dev) model = MyModel(onnx_model) model.compile([x], is_train=False, use_graph=True, sequential=True) - # verifty the test + # verify the test # from utils import load_dataset # inputs, ref_outputs = load_dataset(os.path.join('/tmp', 'vgg19', 'test_data_set_0')) # x_batch = tensor.Tensor(device=dev, data=inputs[0]) diff --git a/examples/rbm/train.py b/examples/rbm/train.py index a2419ab92a..6ff10a6fdd 100755 --- a/examples/rbm/train.py +++ b/examples/rbm/train.py @@ -46,7 +46,7 @@ def load_train_data(file_path): def train(data_file, use_gpu, num_epoch=10, batch_size=100): - print('Start intialization............') + print('Start initialization............') lr = 0.0005 # Learning rate weight_decay = 0.0002 hdim = 1000 diff --git a/examples/singa_peft/examples/autograd/mnist_cnn.py b/examples/singa_peft/examples/autograd/mnist_cnn.py index 16752ceabe..e9b9c11d1d 100644 --- a/examples/singa_peft/examples/autograd/mnist_cnn.py +++ b/examples/singa_peft/examples/autograd/mnist_cnn.py @@ -135,7 +135,7 @@ def reduce_variable(variable, dist_opt, reducer): return output -# Function to sychronize SINGA TENSOR initial model parameters +# Function to synchronize SINGA TENSOR initial model parameters def synchronize(tensor, dist_opt): dist_opt.all_reduce(tensor.data) dist_opt.wait() @@ -176,7 +176,7 @@ def train_mnist_cnn(DIST=False, batch_size = 64 sgd = opt.SGD(lr=0.005, momentum=0.9, weight_decay=1e-5) - # Prepare training and valadiation data + # Prepare training and validation data train_x, train_y, test_x, test_y = load_dataset() IMG_SIZE = 28 num_classes = 10 @@ -216,7 +216,7 @@ def train_mnist_cnn(DIST=False, idx = np.arange(train_x.shape[0], dtype=np.int32) if DIST: - #Sychronize the initial parameters + #Synchronize the initial parameters autograd.training = True x = np.random.randn(batch_size, 1, IMG_SIZE, IMG_SIZE).astype(np.float32) @@ -228,7 +228,7 @@ def train_mnist_cnn(DIST=False, for p, g in autograd.backward(loss): synchronize(p, sgd) - # Training and evaulation loop + # Training and evaluation loop for epoch in range(max_epoch): start_time = time.time() np.random.shuffle(idx) @@ -287,7 +287,7 @@ def train_mnist_cnn(DIST=False, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/examples/singa_peft/examples/autograd/resnet_dist.py b/examples/singa_peft/examples/autograd/resnet_dist.py index 6f9b56ceeb..4d2cfb60cd 100644 --- a/examples/singa_peft/examples/autograd/resnet_dist.py +++ b/examples/singa_peft/examples/autograd/resnet_dist.py @@ -33,7 +33,7 @@ sgd = opt.DistOpt(sgd) if (sgd.global_rank == 0): - print("Start intialization...........", flush=True) + print("Start initialization...........", flush=True) dev = device.create_cuda_gpu_on(sgd.local_rank) diff --git a/examples/singa_peft/examples/model/rbm.py b/examples/singa_peft/examples/model/rbm.py index a2419ab92a..6ff10a6fdd 100644 --- a/examples/singa_peft/examples/model/rbm.py +++ b/examples/singa_peft/examples/model/rbm.py @@ -46,7 +46,7 @@ def load_train_data(file_path): def train(data_file, use_gpu, num_epoch=10, batch_size=100): - print('Start intialization............') + print('Start initialization............') lr = 0.0005 # Learning rate weight_decay = 0.0002 hdim = 1000 diff --git a/examples/singa_peft/examples/train.py b/examples/singa_peft/examples/train.py index 4c6e856e00..31dcde4446 100644 --- a/examples/singa_peft/examples/train.py +++ b/examples/singa_peft/examples/train.py @@ -222,7 +222,7 @@ def run(global_rank, test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy @@ -352,7 +352,7 @@ def peft(global_rank, out_test = peft_model(tx) test_correct += accuracy(tensor.to_numpy(out_test), y) if DIST: - # Reduce the evaulation accuracy from multiple devices + # Reduce the evaluation accuracy from multiple devices test_correct = reduce_variable(test_correct, sgd, reducer) # Output the evaluation accuracy diff --git a/include/singa/core/device.h b/include/singa/core/device.h index 50644c02e2..e46f1c9b9e 100644 --- a/include/singa/core/device.h +++ b/include/singa/core/device.h @@ -68,7 +68,7 @@ class Device { void EnableGraph(bool enable) { graph_enabled_ = enable; } - static void EnableLazyAlloc(bool enbale) { lazy_alloc_ = enbale; } + static void EnableLazyAlloc(bool enable) { lazy_alloc_ = enable; } /// Called by Tensor. Block* NewBlock(int size); @@ -206,7 +206,7 @@ class CppCPU : public Device { // class OpenclDevice : public Device { }; #ifdef USE_CUDA -// Represent a Nvidia GPU which runs cuda code. +// Represent a NVIDIA GPU which runs cuda code. class CudaGPU : public Device { public: ~CudaGPU(); @@ -322,7 +322,7 @@ class Platform { static int GetNumGPUs(); /// Return the device IDs of available GPUs. - /// TODO(wangwei) return the IDs according to free memory in decending order + /// TODO(wangwei) return the IDs according to free memory in descending order static const std::vector GetGPUIDs(); static const std::pair GetGPUMemSize(const int device); @@ -342,7 +342,7 @@ class Platform { const std::vector& devices, size_t init_size = 0); static std::vector> UsedDevice; - /// This function is implementd by Caffe (http://caffe.berkeleyvision.org/). + /// This function is implemented by Caffe (http://caffe.berkeleyvision.org/). /// This function checks the availability of GPU #device_id. /// It attempts to create a context on the device by calling cudaFree(0). /// cudaSetDevice() alone is not sufficient to check the availability. diff --git a/include/singa/core/memory.h b/include/singa/core/memory.h index a43532ec78..9db394f0c2 100644 --- a/include/singa/core/memory.h +++ b/include/singa/core/memory.h @@ -67,7 +67,7 @@ class CnMemPool : public DeviceMemPool { std::pair GetMemUsage() override; std::pair GetMemUsage(int id) override; - // release all memory and set cnmem manager to unintialized + // release all memory and set cnmem manager to uninitialized ~CnMemPool(); protected: diff --git a/include/singa/core/tensor.h b/include/singa/core/tensor.h index 8d3f721fd3..837f96c14a 100644 --- a/include/singa/core/tensor.h +++ b/include/singa/core/tensor.h @@ -261,7 +261,7 @@ class Tensor { Tensor &Transpose(const vector &axes); /// Return a view of the input tensor whose shape is broadcasted to be - /// compitable with the given shape + /// compatible with the given shape Tensor &Broadcast(const Shape &shape, const int ignore_last_dim = 0); /// Reset the shape, device, and data type as given tensor. @@ -331,7 +331,7 @@ ToType TypeCast(const FromType &x) { return static_cast(x); } -Tensor Boradcast(const Shape &shape); +Tensor Broadcast(const Shape &shape); /// Reshape the given tensor and generate a new tensor; the total vol should /// match @@ -346,7 +346,7 @@ Tensor Resize(const Tensor &in, const Shape &s); Tensor Transpose(const Tensor &in); /// Return a view of the input tensor whose shape is broadcasted to be -/// compitable with the given shape +/// compatible with the given shape Tensor Broadcast(const Tensor &in, const Shape &shape, const int ignore_last_dim = 0); @@ -425,15 +425,15 @@ void Transform(const Tensor &in, Tensor *out); Tensor ReLUBackward(const Tensor &in1, const Tensor &in2); void ReLUBackward(const Tensor &in1, const Tensor &in2, Tensor *out); -/// Element-wise opeartion, out[i]=in[i]^x +/// Element-wise operation, out[i]=in[i]^x template Tensor Pow(const Tensor &in, const SType x); -/// Element-wise opeartion, out[i]=in[i]^x +/// Element-wise operation, out[i]=in[i]^x template void Pow(const Tensor &in, const SType x, Tensor *out); -/// Element-wise opeartion, out[i]=baes[i]^exp[i] +/// Element-wise operation, out[i]=baes[i]^exp[i] Tensor Pow(const Tensor &base, const Tensor &exp); -/// Element-wise opeartion, out[i]=baes[i]^exp[i] +/// Element-wise operation, out[i]=baes[i]^exp[i] void Pow(const Tensor &base, const Tensor &exp, Tensor *out); /// Element-wise operation, out[i]= (in[i] < x) ? 1.f : 0.f @@ -598,13 +598,13 @@ void Axpy(SType alpha, const Tensor &in, Tensor *out); void Axpy(const Tensor &alpha, const Tensor &in, Tensor *out); -/// Do matrix vector multipication or matrix matrix multiplication depdending +/// Do matrix vector multiplication or matrix matrix multiplication depending /// on the Tensor shape. result = A * B Tensor Mult(const Tensor &A, const Tensor &B); -/// Do matrix vector multipication or matrix matrix multiplication depdending +/// Do matrix vector multiplication or matrix matrix multiplication depending /// on the Tensor shape. C = A * B void Mult(const Tensor &A, const Tensor &B, Tensor *C); -/// Do matrix vector multipication or matrix matrix multiplication depdending +/// Do matrix vector multiplication or matrix matrix multiplication depending /// on the Tensor shape. out = alpha lhs * rhs + beta * out template void Mult(const SType alpha, const Tensor &A, const Tensor &B, const SType beta, diff --git a/include/singa/io/communicator.h b/include/singa/io/communicator.h index 8344873e96..284878aef9 100644 --- a/include/singa/io/communicator.h +++ b/include/singa/io/communicator.h @@ -41,7 +41,7 @@ namespace singa { do { \ cusparseStatus_t e = cmd; \ if (e != CUSPARSE_STATUS_SUCCESS) { \ - printf("Falied: Cusparse Error %s:%d '%d'\n", __FILE__, __LINE__, \ + printf("Failed: Cusparse Error %s:%d '%d'\n", __FILE__, __LINE__, \ int(e)); \ exit(EXIT_FAILURE); \ } \ diff --git a/include/singa/io/decoder.h b/include/singa/io/decoder.h index 00f4ca8f2e..dd534d2501 100644 --- a/include/singa/io/decoder.h +++ b/include/singa/io/decoder.h @@ -38,7 +38,7 @@ class Decoder { }; #ifdef USE_OPENCV -/// Decode the string as an ImageRecord object and convert it into a image +/// Decode the string as an ImageRecord object and convert it into an image /// tensor (dtype is kFloat32) and a label tensor (dtype is kInt). class JPGDecoder : public Decoder { public: @@ -55,7 +55,7 @@ class JPGDecoder : public Decoder { }; #endif -/// Decode the string of csv formated data into data tensor +/// Decode the string of csv formatted data into data tensor /// (dtype is kFloat32) and optionally a label tensor (dtype is kInt). class CSVDecoder : public Decoder { public: diff --git a/include/singa/io/encoder.h b/include/singa/io/encoder.h index 5ca7b21fb6..f34d267c1b 100644 --- a/include/singa/io/encoder.h +++ b/include/singa/io/encoder.h @@ -60,7 +60,7 @@ class JPGEncoder : public Encoder { }; #endif // USE_OPENCV -/// Convert values from tensors into a csv formated string. +/// Convert values from tensors into a csv formatted string. class CSVEncoder : public Encoder { public: void Setup(const EncoderConf& conf) override {} diff --git a/include/singa/io/reader.h b/include/singa/io/reader.h index 66d7e37b28..64ce6f7a07 100644 --- a/include/singa/io/reader.h +++ b/include/singa/io/reader.h @@ -54,7 +54,7 @@ class Reader { /// Read a tuple. /// return true if read successfully; - /// return flase if coming to the end of the file; + /// return false if coming to the end of the file; /// LOG(FATAL) if error happens. virtual bool Read(std::string* key, std::string* value) = 0; diff --git a/include/singa/io/snapshot.h b/include/singa/io/snapshot.h index 0d0df1a652..20b251c54d 100644 --- a/include/singa/io/snapshot.h +++ b/include/singa/io/snapshot.h @@ -35,9 +35,9 @@ namespace singa { /// The snapshot management. -/// It dumps the model parameter snapshot as checkpoint files, which coud be +/// It dumps the model parameter snapshot as checkpoint files, which could be /// used for fine-tuning and deployment. -/// The model paramters are separated from model definition, i.e., net +/// The model parameters are separated from model definition, i.e., net /// construction. Users either randomly initialize the layer parameters or using /// the parameters from checkpoint files using Snapshot after creating the /// neural network. @@ -45,7 +45,7 @@ class Snapshot { public: enum Mode { kRead, kWrite }; /// .model is the binary file for parameter key-value pair. - /// .meta is the text file describing information about paramters, + /// .meta is the text file describing information about parameters, /// i.e. /// name and shape, one line per parameter. /// kRead for reading snapshot, whereas kWrite for dumping out snapshot. diff --git a/include/singa/model/feed_forward_net.h b/include/singa/model/feed_forward_net.h index 1bf112cc09..fd11ff1c3c 100644 --- a/include/singa/model/feed_forward_net.h +++ b/include/singa/model/feed_forward_net.h @@ -46,14 +46,14 @@ class FeedForwardNet { // AddSliceLayer(Layer* layer, vector dst); /// Add a layer by providing its configuration, and setup it. - /// Assume the layer is added in corret order. + /// Assume the layer is added in correct order. /// For the first layer, 'sample_shape' (the input sample shape) is necessary /// for calling Setup(). std::shared_ptr Add(const LayerConf& conf, const Shape* sample_shape = nullptr); /// Set some fields used for training and evaluating the neural net. - /// This method will instantiate an Updater ,then wrap the Optimier into + /// This method will instantiate an Updater ,then wrap the Optimizer into /// Updater and always register the parameters of the net instance. /// If the neural net is constructed for evaluation only, then 'opt' is not /// necessary; But for training, both 'opt' and 'loss' are necessary. diff --git a/include/singa/model/layer.h b/include/singa/model/layer.h index ca07a19d68..811e576a4a 100644 --- a/include/singa/model/layer.h +++ b/include/singa/model/layer.h @@ -58,7 +58,7 @@ class Layer { /// Destruct objects created by this layer. virtual ~Layer() {}; - /// Each layer sub-class would optionaly have a type name. + /// Each layer sub-class would optionally have a type name. /// Used for debugging and logging. virtual const std::string layer_type() const { return "Unknown"; } @@ -199,7 +199,7 @@ class Layer { return vector{}; } - /// Return names of all parmaeters. + /// Return names of all parameters. const vector param_names() { vector pname; for (const auto& spec : param_specs_) pname.push_back(spec.name()); @@ -221,10 +221,10 @@ class Layer { vector param_specs_; }; -/// Name should be formated as cudnn_xxx, singacpp_xxx, singacuda_xxx, +/// Name should be formatted as cudnn_xxx, singacpp_xxx, singacuda_xxx, /// singacl_xxx, where xxx is the real layer type, e.g., convolution, relu, etc. /// xxx should only have lower case letters. -/// if the implmentation is transparent to cpp/cuda/opencl, then register all +/// if the implementation is transparent to cpp/cuda/opencl, then register all /// possible identifiers. For instance, Dropout is registered three times, /// RegisterLayerClass("singacpp_dropout", Dropout) /// RegisterLayerClass("singacl_dropout", Dropout) diff --git a/include/singa/model/metric.h b/include/singa/model/metric.h index ad7f7171b3..743d048759 100644 --- a/include/singa/model/metric.h +++ b/include/singa/model/metric.h @@ -47,15 +47,15 @@ class Metric { /// Compute the metric for each data sample virtual Tensor Forward(const Tensor& prediction, const Tensor& target) = 0; - /// Comptue the metric value averaged over all samples (in a batch) + /// Compute the metric value averaged over all samples (in a batch) float Evaluate(const Tensor& prediction, const Tensor& target) { const Tensor metric = Forward(prediction, target); return Sum(metric) / (1.0f * metric.Size()); } }; -/// Compute the accuray of the prediction, which is matched against the +/// Compute the accuracy of the prediction, which is matched against the /// ground truth labels. -/// TODO(wangwei) consider multi-label cases. +/// TODO(wangwei) considerr multi-label cases. class Accuracy : public Metric { public: /// Set meta fields from user configurations. diff --git a/include/singa/model/optimizer.h b/include/singa/model/optimizer.h index d5260cbf55..5e21fc6ec8 100644 --- a/include/singa/model/optimizer.h +++ b/include/singa/model/optimizer.h @@ -42,7 +42,7 @@ class Optimizer { public: Optimizer() = default; virtual ~Optimizer(); - /// Setup the optimzier using configurations from serialized string (for + /// Setup the optimizer using configurations from serialized string (for /// binding languages). void Setup(const string& str) { OptimizerConf conf; @@ -77,7 +77,7 @@ class Optimizer { int step = -1); /// The argument is a function that returns the learning rate given the - /// current step (i.e., curren running iteration). + /// current step (i.e., current running iteration). void SetLearningRateGenerator(function func) { learning_rate_generator_ = func; } @@ -100,7 +100,7 @@ class Optimizer { }; /// Apply constraints for parameters (gradient). -/// E.g., restrict the norm of parmeter gradients to be within a threshold. +/// E.g., restrict the norm of parameter gradients to be within a threshold. /// \ref http://keras.io/constraints/ /// TODO(wangwei) implement a sub-class for each type of constraint class Constraint { @@ -115,7 +115,7 @@ class Constraint { conf.ParseFromString(conf_str); Setup(conf); } - /// Apply the constraint to a single parmeter object, e.g., W, or b + /// Apply the constraint to a single parameter object, e.g., W, or b /// e.g., clip each gradient if it is too large w.r.t the threshold, /// \ref /// https://www.reddit.com/r/MachineLearning/comments/31b6x8/gradient_clipping_rnns/ @@ -129,7 +129,7 @@ class Constraint { /// currently only support "L2" norm constraint, i.e., the norm should be less /// than the configured threshold_, otherwise, the parameters would be clipped /// to make the norm within that threshold. - /// TODO(wangwei) consider other constraint, e.g., hard clip and unitnorm. + /// TODO(wangwei) considerr other constraint, e.g., hard clip and unitnorm. string type_ = "Unknown"; float threshold_; }; @@ -152,7 +152,7 @@ class Regularizer { Setup(conf); } - /// Apply the regularizer to a single parmeter object, e.g., W, or b + /// Apply the regularizer to a single parameter object, e.g., W, or b /// e.g., clip each gradient if it is too large w.r.t the threshold, /// \ref /// https://www.reddit.com/r/MachineLearning/comments/31b6x8/gradient_clipping_rnns/ diff --git a/include/singa/utils/factory.h b/include/singa/utils/factory.h index 472b34c36b..0c198cc1c9 100644 --- a/include/singa/utils/factory.h +++ b/include/singa/utils/factory.h @@ -28,7 +28,7 @@ #include "singa/utils/logging.h" /** - * Macro that creats a function which instantiate a subclass instance and + * Macro that creates a function that instantiates a subclass instance and * returns pointer to the base class. */ #define CreateInstance(SubClass, BaseClass) \ @@ -39,7 +39,7 @@ * 1. register class creation function that generates a class * object based on id. * 2. call Create() func to call the creation function and return - * a pointer to the base calss. + * a pointer to the base class. */ template class Factory { diff --git a/include/singa/utils/logging.h b/include/singa/utils/logging.h index 92ab7336e5..c6e2b56294 100644 --- a/include/singa/utils/logging.h +++ b/include/singa/utils/logging.h @@ -40,7 +40,7 @@ void InitLogging(const char* argv); /// Make it so that all log messages go only to stderr void LogToStderr(); /// Make it so that all log messages of at least a particular severity are -/// logged to stderr (in addtion to logging to the usual log files) +/// logged to stderr (in addition to logging to the usual log files) void SetStderrLogging(int severity); /// Set the file name for logging (and disable logging to stderr) void SetLogDestination(int severity, const char* path); @@ -153,7 +153,7 @@ string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext); // A helper class for formatting "expr (V1 vs. V2)" in a CHECK_XX // statement. See MakeCheckOpString for sample usage. Other -// approaches were considered: use of a template method (e.g., +// approaches were considerred: use of a template method (e.g., // base::BuildCheckOpString(exprtext, base::Print, &v1, // base::Print, &v2), however this approach has complications // related to volatile arguments and function-pointer arguments). diff --git a/include/singa/utils/safe_queue.h b/include/singa/utils/safe_queue.h index ae79c85088..fa560be61d 100644 --- a/include/singa/utils/safe_queue.h +++ b/include/singa/utils/safe_queue.h @@ -51,7 +51,7 @@ class SafeQueue { /** * Pop an element from the queue. - * It will be blocked until one element is poped. + * It will be blocked until one element is popped. */ void Pop(T& e) { std::unique_lock lock(mutex_); @@ -60,7 +60,7 @@ class SafeQueue { queue_.pop(); } /** - * Pop an item from the queue until one element is poped or timout. + * Pop an item from the queue until one element is popped or timeout. * @param[in] timeout, return false after waiting this number of microseconds */ bool Pop(T& item, std::uint64_t timeout) { @@ -129,7 +129,7 @@ class PriorityQueue { /** * Pop an element from the queue with the highest priority. - * It blocks until one element is poped. + * It blocks until one element is popped. */ void Pop(T& e) { Element ele; @@ -138,8 +138,8 @@ class PriorityQueue { } /** * Pop the item with the highest priority from the queue until one element is - * poped or timeout. - * @param[in] timeout, return false if no element is poped after this number + * popped or timeout. + * @param[in] timeout, return false if no element is popped after this number * of microseconds. */ bool Pop(T& e, std::uint64_t timeout) { diff --git a/python/singa/autograd.py b/python/singa/autograd.py index e3459018d3..93a55e3272 100644 --- a/python/singa/autograd.py +++ b/python/singa/autograd.py @@ -38,7 +38,7 @@ def axis_helper(y_shape, x_shape): y_shape: the shape of result x_shape: the shape of x Return: - a tuple refering the axes + a tuple referring the axes """ res = [] j = len(x_shape) - 1 @@ -133,7 +133,7 @@ def backward(y, dy=None): dy: a number or a Tensor instance, for the gradient of the objective/loss w.r.t y, usually None, i.e., 1.0 Return: - yeild the parameter (tensor with stores_grad true) and the + yield the parameter (tensor with stores_grad true) and the gradient tensors. """ assert isinstance(y, Tensor), "wrong input type." @@ -180,7 +180,7 @@ def backward(y, dy=None): # not_ready[src_op][y_idx] records the intermediate gradient # of the y_idx'th output of src_op. 'intermediate gradient' # indicates that if this output is used in multiple children - # operations, then we have to add the graident (dx) from all these + # operations, then we have to add the gradient (dx) from all these # children operations. When src_op is ready, it means that # the gradient of all its outputs are available, i.e. all children # operations have been backwarded. @@ -191,7 +191,7 @@ def backward(y, dy=None): y_idx = src_op.y_id2idx[x_id] if src_op not in not_ready: - # src_op may have mulitple outputs + # src_op may have multiple outputs not_ready[src_op] = [None for _ in src_op.y_id2idx] not_ready[src_op][y_idx] = dx else: @@ -342,7 +342,7 @@ def get_params(self): class Dummy(Operator): - """Dummy operation whice serves as a placehoder for autograd + """Dummy operation whice serves as a placeholder for autograd Args: name(string): set it for debug """ @@ -556,7 +556,7 @@ def clip(x, min=None, max=None): class Identity(Operator): """ - Init a identity operator + Init an identity operator """ def __init__(self): @@ -583,7 +583,7 @@ def backward(self, dy): def identity(x): """ - Init a identity operator. + Init an identity operator. Args: x (Tensor): input tensor. Returns: @@ -1159,7 +1159,7 @@ def __init__(self, t): self.t = t.data """ - Calculte negative log likelihood loss for a batch of training data. + Calculate negative log likelihood loss for a batch of training data. """ def forward(self, x): @@ -1216,7 +1216,7 @@ def __init__(self, t): self.t = t.data """ - Calculte negative log likelihood loss for a batch of training data. + Calculate negative log likelihood loss for a batch of training data. """ def forward(self, x): @@ -1644,9 +1644,9 @@ def __init__(self, handle, odd_padding=(0, 0, 0, 0)): """ Args: handle (object): ConvHandle for cpu or CudnnConvHandle for gpu - odd_padding (tuple of four ints):, the odd paddding is the value + odd_padding (tuple of four ints):, the odd padding is the value that cannot be handled by the tuple padding (w, h) mode so - we need to firstly handle the input, then use the nomal padding + we need to firstly handle the input, then use the normal padding method. """ super(_Conv2d, self).__init__() @@ -1726,9 +1726,9 @@ def conv2d(handle, x, W, b=None, odd_padding=(0, 0, 0, 0)): x (Tensor): input W (Tensor): weight b (Tensor): bias - odd_padding (tuple of four ints):, the odd paddding is the value + odd_padding (tuple of four ints):, the odd padding is the value that cannot be handled by the tuple padding (w, h) mode so - we need to firstly handle the input, then use the nomal padding + we need to firstly handle the input, then use the normal padding method. """ if b is None: @@ -1854,7 +1854,7 @@ def __init__(self, handle, odd_padding=(0, 0, 0, 0)): Args: handle (object): PoolingHandle for cpu or CudnnPoolingHandle for gpu - odd_padding (tuple of four int): the odd paddding is the value + odd_padding (tuple of four int): the odd padding is the value that cannot be handled by the tuple padding (w, h) mode so it needs to firstly handle the input, then use the normal padding method. @@ -1908,7 +1908,7 @@ def pooling_2d(handle, x, odd_padding=(0, 0, 0, 0)): handle (object): PoolingHandle for cpu or CudnnPoolingHandle for gpu x (Tensor): input - odd_padding (tuple of four int): the odd paddding is the value + odd_padding (tuple of four int): the odd padding is the value that cannot be handled by the tuple padding (w, h) mode so it needs to firstly handle the input, then use the normal padding method. @@ -3712,7 +3712,7 @@ def __init__(self, alpha=1.0, beta=1.0, transA=0, transB=0): def forward(self, A, B, C=None): """ - forward propogation of Gemm + forward propagation of Gemm Args: A (CTensor): The shape of A should be (M, K) if transA is 0, or (K, M) if transA is non-zero. @@ -3735,7 +3735,7 @@ def forward(self, A, B, C=None): def backward(self, dy): """ - backward propogation of Gemm + backward propagation of Gemm Args: dy (CTensor): The shape of A should be (M, K) if transA is 0, or (K, M) if transA is non-zero. Returns: @@ -3816,7 +3816,7 @@ def __init__(self, data_format='channels_first'): def forward(self, x): """ - forward propogation of GlobalAveragePool + forward propagation of GlobalAveragePool Args: x (CTensor): the input tensor Returns: @@ -3848,7 +3848,7 @@ def forward(self, x): def backward(self, dy): """ - backward propogation of GlobalAveragePool + backward propagation of GlobalAveragePool Args: dy (CTensor): the gradient tensor from upper operations Returns: @@ -4992,7 +4992,7 @@ def backward(self, dy): ad = singa.Reshape(ad, list(ad.shape()) + [1]) # b * 1 bd = singa.Reshape(bd, list(bd.shape()) + [1]) # b * 1 ret = singa.Reshape(ret, list(ret.shape()) + [1]) # b * 1 - dy = singa.Reshape(dy, list(dy.shape()) + [1]) # boardcast + dy = singa.Reshape(dy, list(dy.shape()) + [1]) # broadcast da = singa.__sub__(singa.__div__(b, ab), singa.__div__(singa.__mul__(ret, a), ad)) db = singa.__sub__(singa.__div__(a, ab), @@ -5107,7 +5107,7 @@ def backward(self, dy): def expand(x, shape): """ - Produces a Expand operator + Produces an Expand operator Args: x (Tensor): input tensor. shape (list[int]: indicates the shape you want to expand to, @@ -5332,7 +5332,7 @@ def backward(self, dy): def upsample(x, mode, scales): """ - Produces a upsample operator + Produces an upsample operator Args: x (Tensor): input tensor. scales (list[int]): The scale array along each dimension. It takes diff --git a/python/singa/data.py b/python/singa/data.py index 8fb2ecdb47..cabbd03d53 100644 --- a/python/singa/data.py +++ b/python/singa/data.py @@ -62,7 +62,7 @@ def image_transform(img_path): class ImageBatchIter(object): - '''Utility for iterating over an image dataset to get mini-batches. + '''Utility for iterationg over an image dataset to get mini-batches. Args: img_list_file(str): name of the file containing image meta data; each diff --git a/python/singa/image_tool.py b/python/singa/image_tool.py index 346b29ab8d..66d097d241 100644 --- a/python/singa/image_tool.py +++ b/python/singa/image_tool.py @@ -539,10 +539,10 @@ def random_crop_resize(self, patch, inplace=True): return new_imgs def flip(self, num_case=1, inplace=True): - '''Randomly flip a img left to right. + '''Randomly flip an image left to right. Args: - num_case: num of cases, must be in {1,2}; if 2, then add the orignal + num_case: num of cases, must be in {1,2}; if 2, then add the original and flipped img inplace: inplace imgs or not (return new_imgs) ''' @@ -566,9 +566,9 @@ def flip(self, num_case=1, inplace=True): return new_imgs def flip_down(self, num_case=1, inplace=True): - '''Randomly flip a img top to bottom. + '''Randomly flip an image top to bottom. Args: - num_case: num of cases, must be in {1,2}; if 2, then add the orignal + num_case: num of cases, must be in {1,2}; if 2, then add the original and flip_down img inplace: inplace imgs or not (return new_imgs) ''' diff --git a/python/singa/initializer.py b/python/singa/initializer.py index c907736106..b301b989b6 100644 --- a/python/singa/initializer.py +++ b/python/singa/initializer.py @@ -233,7 +233,7 @@ def glorot(t): @deprecated(reason="Use he_normal") def msra(t): - '''Initialize the matrix parameter follow a Guassian distribution with + '''Initialize the matrix parameter follow a Gaussian distribution with mean = 0, std = math.sqrt(2.0 / nb_row). Ref [He, Zhang, Ren and Sun 2015]: Specifically accounts for ReLU diff --git a/python/singa/layer.py b/python/singa/layer.py index 0954b86602..d4d14b5792 100644 --- a/python/singa/layer.py +++ b/python/singa/layer.py @@ -127,7 +127,7 @@ def set_params(self, parameters): Args: parameters(dict): A dictionary contains parameter names - and corresponding values. The value shoud be either a + and corresponding values. The value should be either a PyTensor or numpy ndarray """ names = parameters.keys() @@ -157,7 +157,7 @@ def set_states(self, states): Args: states(dict): A dictionary contains state names and - corresponding values. The value shoud be either a + corresponding values. The value should be either a PyTensor or numpy ndarray """ names = states.keys() @@ -527,7 +527,7 @@ def __init__(self, nb_kernels (int): the channel of output, also is the number of filters kernel_size (int or tuple): kernel size for two direction of each axis. For example, (2, 3), the first 2 means will add 2 at the - beginning and also 2 at the end for its axis.and if a int is + beginning and also 2 at the end for its axis, and if an int is accepted, the kernel size will be initiated as (int, int) stride (int or tuple): stride, the logic is the same as kernel size. padding (int): tuple, list or None, padding, the logic is the same @@ -591,8 +591,8 @@ def __init__(self, elif len(padding) == 4: _h_mask = padding[0] - padding[1] _w_mask = padding[2] - padding[3] - # the odd paddding is the value that cannot be handled by the tuple padding (w, h) mode - # so we need to firstly handle the input, then use the nomal padding method. + # the odd padding is the value that cannot be handled by the tuple padding (w, h) mode + # so we need to firstly handle the input, then use the normal padding method. self.odd_padding = (max(_h_mask, 0), max(-_h_mask, 0), max(_w_mask, 0), max(-_w_mask, 0)) self.padding = ( @@ -715,7 +715,7 @@ def forward(self, x): == 0), "please set reasonable group." assert (self.nb_kernels >= self.group and self.nb_kernels % self.group - == 0), "nb_kernels and group dismatched." + == 0), "nb_kernels and group mismatched." y = autograd.conv2d(self.handle, x, self.W, self.b, self.odd_padding) @@ -754,7 +754,7 @@ def __init__(self, nb_kernels (int): the channel of output, also is the number of filters kernel_size (int or tuple): kernel size for two direction of each axis. For example, (2, 3), the first 2 means will add 2 at the - beginning and also 2 at the end for its axis.and if a int is + beginning and also 2 at the end for its axis, and if an int is accepted, the kernel size will be initiated as (int, int) stride (int or tuple): stride, the logic is the same as kernel size. padding (int): tuple, list or None, padding, the logic is the same @@ -851,7 +851,7 @@ def initialize(self, x): def forward(self, x): assert x.shape[1] == self.channels, ( - "number of channels dismatched. %d vs %d" % + "number of channels mismatched. %d vs %d" % (x.shape[1], self.channels)) self.device_check(x, self.scale, self.bias, self.running_mean, @@ -903,7 +903,7 @@ def __init__(self, Args: kernel_size (int or tuple): kernel size for two direction of each axis. For example, (2, 3), the first 2 means will add 2 at the - beginning and also 2 at the end for its axis.and if a int is + beginning and also 2 at the end for its axis, and if an int is accepted, the kernel size will be initiated as (int, int) stride (int or tuple): stride, the logic is the same as kernel size. padding (int): tuple, list or None, padding, the logic is the same @@ -947,8 +947,8 @@ def __init__(self, elif len(padding) == 4: _h_mask = padding[0] - padding[1] _w_mask = padding[2] - padding[3] - # the odd paddding is the value that cannot be handled by the tuple padding (w, h) mode - # so we need to firstly handle the input, then use the nomal padding method. + # the odd padding is the value that cannot be handled by the tuple padding (w, h) mode + # so we need to firstly handle the input, then use the normal padding method. self.odd_padding = (max(_h_mask, 0), max(-_h_mask, 0), max(_w_mask, 0), max(-_w_mask, 0)) self.padding = ( @@ -1013,7 +1013,7 @@ def __init__(self, kernel_size, stride=None, padding=0, pad_mode="NOTSET"): Args: kernel_size (int or tuple): kernel size for two direction of each axis. For example, (2, 3), the first 2 means will add 2 at the - beginning and also 2 at the end for its axis.and if a int is + beginning and also 2 at the end for its axis, and if an int is accepted, the kernel size will be initiated as (int, int) stride (int or tuple): stride, the logic is the same as kernel size. padding (int): tuple, list or None, padding, the logic is the same @@ -1037,7 +1037,7 @@ def __init__(self, kernel_size, stride=None, padding=0, pad_mode="NOTSET"): Args: kernel_size (int or tuple): kernel size for two direction of each axis. For example, (2, 3), the first 2 means will add 2 at the - beginning and also 2 at the end for its axis.and if a int is + beginning and also 2 at the end for its axis, and if an int is accepted, the kernel size will be initiated as (int, int) stride (int or tuple): stride, the logic is the same as kernel size. padding (int): tuple, list or None, padding, the logic is the same @@ -1064,7 +1064,7 @@ def __init__(self, kernel_size, stride=None, padding=0, pad_mode="NOTSET"): Args: kernel_size (int or tuple): kernel size for two direction of each axis. For example, (2, 3), the first 2 means will add 2 at the - beginning and also 2 at the end for its axis.and if a int is + beginning and also 2 at the end for its axis, and if an int is accepted, the kernel size will be initiated as (int, int) stride (int or tuple): stride, the logic is the same as kernel size. padding (int): tuple, list or None, padding, the logic is the same @@ -1085,7 +1085,7 @@ def __init__(self, kernel_size, stride=None, padding=0, pad_mode="NOTSET"): class AvgPool1d(Pooling2d): """ - Generate a Avg Pooling 1d operator + Generate an average Pooling 1d operator """ def __init__(self, kernel_size, stride=None, padding=0, pad_mode="NOTSET"): @@ -1093,7 +1093,7 @@ def __init__(self, kernel_size, stride=None, padding=0, pad_mode="NOTSET"): Args: kernel_size (int or tuple): kernel size for two direction of each axis. For example, (2, 3), the first 2 means will add 2 at the - beginning and also 2 at the end for its axis.and if a int is + beginning and also 2 at the end for its axis, and if an int is accepted, the kernel size will be initiated as (int, int) stride (int or tuple): stride, the logic is the same as kernel size. padding (int): tuple, list or None, padding, the logic is the same @@ -1426,7 +1426,7 @@ def forward(self, x): class Add(Layer): """ - Generate a Add operator + Generate an Add operator """ def __init__(self): @@ -1571,7 +1571,7 @@ def __init__(self, """ assert singa.USE_CUDA, "Not able to run without CUDA" assert num_layers > 0, "num layers should be > 0" - assert 0 <= dropout < 1, "dropout shouldbe >=0 and <1" + assert 0 <= dropout < 1, "dropout should be >=0 and <1" super(CudnnRNN, self).__init__() self.rnn_mode = rnn_mode diff --git a/python/singa/opt.py b/python/singa/opt.py index 1e4528e8f9..3c581a0e13 100755 --- a/python/singa/opt.py +++ b/python/singa/opt.py @@ -690,7 +690,7 @@ class DistOpt(object): on multiprocessing. Each process has an individual rank, which gives information of which GPU the individual process is using. The training data is partitioned, so that each process can evaluate the sub-gradient based on the partitioned training data. - Once the sub-graident is calculated on each processes, the overall stochastic gradient + Once the sub-gradient is calculated on each processes, the overall stochastic gradient is obtained by all-reducing the sub-gradients evaluated by all processes. The all-reduce operation is supported by the NVidia Collective Communication Library (NCCL). @@ -721,7 +721,7 @@ def __init__(self, buffSize=4194304): self.opt = opt if nccl_id is None: - # constructure for application using MPI + # constructor for application using MPI self.communicator = singa.Communicator(buffSize) else: # constructor for application using python multi-process module @@ -954,7 +954,7 @@ def backward_and_partial_update(self, loss, threshold=2097152): for p, g in autograd.backward(loss): # every parameters update locally self.opt.update(p, g) - # then do the partial parameter sychronization + # then do the partial parameter synchronization if p.size() > threshold: # larger than threshold -> reduced directly # k is the partition number of the full gradient set diff --git a/python/singa/snapshot.py b/python/singa/snapshot.py index 67f246bc59..3f18f77e48 100644 --- a/python/singa/snapshot.py +++ b/python/singa/snapshot.py @@ -18,8 +18,8 @@ ''' This script includes io::snapshot class and its methods. -Note: This module is depreated. Please use the model module for -checkpoing and restore. +Note: This module is deprecated. Please use the model module for +checkpoint and restore. Example usages:: diff --git a/python/singa/sonnx.py b/python/singa/sonnx.py index 625a30c299..c664d6dfba 100755 --- a/python/singa/sonnx.py +++ b/python/singa/sonnx.py @@ -74,13 +74,13 @@ def onnx_type_to_singa_type(onnx_type): class SingaFrontend(object): """ - This class provides mthods to convert model from singa to onnx. + This class provides methods to convert model from singa to onnx. """ # This number indicates the target onnx operator set version _target_opset_version = 11 - # beceuase singa's operators are different from onnx. + # because singa's operators are different from onnx. # we define a dict for the name projection # "singa op name": "onnx op name" _rename_operators = { @@ -217,7 +217,7 @@ class SingaFrontend(object): @classmethod def _create_onehot(cls, op, op_t): """ - get a onnx node from singa onthot + get an ONNX node from singa onthot Args: op: a given operator Args: @@ -237,7 +237,7 @@ def _create_onehot(cls, op, op_t): @classmethod def _create_cast(cls, op, op_t): """ - get a onnx node from singa cast + get an ONNX node from singa cast Args: op: a given operator Args: @@ -259,7 +259,7 @@ def _create_cast(cls, op, op_t): @classmethod def _create_tile(cls, op, op_t): """ - get a onnx node from singa tile + get an ONNX node from singa tile Args: op: a given operator Args: @@ -275,7 +275,7 @@ def _create_tile(cls, op, op_t): @classmethod def _create_gather(cls, op, op_t): """ - get a onnx node from singa gather + get an ONNX node from singa gather Args: op: a given operator Args: @@ -294,7 +294,7 @@ def _create_gather(cls, op, op_t): @classmethod def _create_split(cls, op, op_t): """ - get a onnx node from singa split + get an ONNX node from singa split Args: op: a given operator Args: @@ -313,7 +313,7 @@ def _create_split(cls, op, op_t): @classmethod def _create_slice(cls, op, op_t): """ - get a onnx node from singa slice + get an ONNX node from singa slice Args: op: a given operator Args: @@ -329,7 +329,7 @@ def _create_slice(cls, op, op_t): @classmethod def _create_squeeze(cls, op, op_t): """ - get a onnx node from singa squeeze and unsqueeze + get an ONNX node from singa squeeze and unsqueeze Args: op: a given operator Args: @@ -347,7 +347,7 @@ def _create_squeeze(cls, op, op_t): @classmethod def _create_reduceOp(cls, op, op_t): """ - get a onnx node from singa ReduceSum, ReduceMean, ReduceMax, ReduceMin, etc. + get an ONNX node from singa ReduceSum, ReduceMean, ReduceMax, ReduceMin, etc. Args: op: a given operator Args: @@ -366,7 +366,7 @@ def _create_reduceOp(cls, op, op_t): @classmethod def _create_dropout(cls, op, op_t): """ - get a onnx node from singa Dropout operator + get an ONNX node from singa Dropout operator Args: op: a given operator Args: @@ -384,7 +384,7 @@ def _create_dropout(cls, op, op_t): @classmethod def _create_constantOfShape(cls, op, op_t): """ - get a onnx node from singa ConstantOfShape operator + get an ONNX node from singa ConstantOfShape operator Args: op: a given operator Args: @@ -404,7 +404,7 @@ def _create_constantOfShape(cls, op, op_t): @classmethod def _create_transpose(cls, op, op_t): """ - get a onnx node from singa Transpose operator + get an ONNX node from singa Transpose operator Args: op: a given operator Args: @@ -422,7 +422,7 @@ def _create_transpose(cls, op, op_t): @classmethod def _create_clip(cls, op, op_t): """ - get a onnx node from singa clip operator + get an ONNX node from singa clip operator Args: op: a given operator Args: @@ -444,7 +444,7 @@ def _create_clip(cls, op, op_t): @classmethod def _create_hardsigmoid(cls, op, op_t): """ - get a onnx node from singa HardSigmoid operator + get an ONNX node from singa HardSigmoid operator Args: op: a given operator Args: @@ -463,7 +463,7 @@ def _create_hardsigmoid(cls, op, op_t): @classmethod def _create_elu(cls, op, op_t): """ - get a onnx node from singa elu operator + get an ONNX node from singa elu operator Args: op: a given operator Args: @@ -481,7 +481,7 @@ def _create_elu(cls, op, op_t): @classmethod def _create_selu(cls, op, op_t): """ - get a onnx node from singa SeLU operator + get an ONNX node from singa SeLU operator Args: op: a given operator Args: @@ -500,7 +500,7 @@ def _create_selu(cls, op, op_t): @classmethod def _create_reshape(cls, op, op_t): """ - get a onnx node from singa Concat operator + get an ONNX node from singa Concat operator Args: op: a given operator Args: @@ -518,7 +518,7 @@ def _create_reshape(cls, op, op_t): @classmethod def _create_concat(cls, op, op_t): """ - get a onnx node from singa Concat operator + get an ONNX node from singa Concat operator Args: op: a given operator Args: @@ -536,7 +536,7 @@ def _create_concat(cls, op, op_t): @classmethod def _create_softmax(cls, op, op_t): """ - get a onnx node from singa Concat operator + get an ONNX node from singa Concat operator Args: op: a given operator Args: @@ -554,7 +554,7 @@ def _create_softmax(cls, op, op_t): @classmethod def _create_flatten(cls, op, op_t): """ - get a onnx node from singa flatten operator + get an ONNX node from singa flatten operator Args: op: a given operator Args: @@ -572,7 +572,7 @@ def _create_flatten(cls, op, op_t): @classmethod def _create_gemm(cls, op, op_t): """ - get a onnx node from singa gemm operator + get an ONNX node from singa gemm operator Args: op: a given operator Args: @@ -594,7 +594,7 @@ def _create_gemm(cls, op, op_t): @classmethod def _create_batchnorm(cls, op, op_t): """ - get a onnx node from singa _BatchNorm2d operator + get an ONNX node from singa _BatchNorm2d operator Args: op: a given operator Args: @@ -622,7 +622,7 @@ def _create_batchnorm(cls, op, op_t): @classmethod def _create_conv_pool(cls, op, op_t): """ - get a onnx node from singa _Conv2d and _Pooling2d operator + get an ONNX node from singa _Conv2d and _Pooling2d operator Args: op: a given operator Args: @@ -690,7 +690,7 @@ def _get_singa_op_type(cls, op): @classmethod def _special_handle_batchnorm(cls, op, X, W): """ - hanlde the special operators + handle the special operators Args: op: a given operator Args: @@ -712,7 +712,7 @@ def _special_handle_batchnorm(cls, op, X, W): @classmethod def _special_handle_reshape(cls, op, X, W): """ - hanlde the special operators + handle the special operators Args: op: a given operator Args: @@ -729,7 +729,7 @@ def _special_handle_reshape(cls, op, X, W): @classmethod def _special_handle_clip(cls, op, X, W): """ - hanlde the special operators + handle the special operators Args: op: a given operator Args: @@ -750,7 +750,7 @@ def _special_handle_clip(cls, op, X, W): @classmethod def _special_handle_slice(cls, op, X, W): """ - hanlde the special operators + handle the special operators Args: op: a given operator Args: @@ -775,7 +775,7 @@ def _special_handle_slice(cls, op, X, W): @classmethod def _special_handle_gather(cls, op, X, W): """ - hanlde the special operators + handle the special operators Args: op: a given operator Args: @@ -796,7 +796,7 @@ def _special_handle_gather(cls, op, X, W): @classmethod def _special_handle_tile(cls, op, X, W): """ - hanlde the special operators + handle the special operators Args: op: a given operator Args: @@ -817,7 +817,7 @@ def _special_handle_tile(cls, op, X, W): @classmethod def _special_handle_onehot(cls, op, X, W): """ - hanlde the special operators + handle the special operators Args: op: a given operator Args: @@ -839,8 +839,8 @@ def _special_handle_onehot(cls, op, X, W): @classmethod def handle_special_ops(cls, op, X, W): """ - hanlde the special operators, - because the inputs of batchnorm and reshape are differnet with onnx + handle the special operators, + because the inputs of batchnorm and reshape are different with onnx we need to add these inputs into onnx model mannully Args: op: a given operator @@ -863,7 +863,7 @@ def handle_special_ops(cls, op, X, W): @classmethod def _common_singa_tensor_to_onnx_node(cls, op, op_t): """ - get a onnx node from singa operator, prepare its type, inputs and outputs + get an ONNX node from singa operator, prepare its type, inputs and outputs Args: op: a given operator Args: @@ -885,7 +885,7 @@ def _common_singa_tensor_to_onnx_node(cls, op, op_t): @classmethod def singa_op_to_onnx_node(cls, op, op_t): """ - get a onnx node from singa operator + get an ONNX node from singa operator Args: op: a given operator Args: @@ -894,7 +894,7 @@ def singa_op_to_onnx_node(cls, op, op_t): the onnx node """ optype = cls._get_singa_op_type(op) - # wether the operator needs special handler + # whether the operator needs special handler if optype in cls._special_operators: translator = getattr(cls, cls._special_operators[optype]) else: @@ -1041,7 +1041,7 @@ class SingaBackend(Backend): _ir_version = 0x0000000000000006 - # beceuase singa's operators are different from onnx. + # because singa's operators are different from onnx. # we define a dict for the name projection _rename_operators = { # common op @@ -1729,7 +1729,7 @@ def _create_scatter_elements(cls, @classmethod def _onnx_constant_to_np(cls, onnx_node, opset_version=_opset_version): """ - parse onnx constatn node to numpy array + parse onnx constant node to numpy array Args: onnx_node (OnnxNode): a given onnx node opset_version (int): the opset version @@ -1743,7 +1743,7 @@ def _onnx_constant_to_np(cls, onnx_node, opset_version=_opset_version): @classmethod def _onnx_node_to_singa_op(cls, onnx_node, opset_version=_opset_version): """ - get singa operator from a onnx node + get singa operator from an ONNX node Args: onnx_node (OnnxNode): a given onnx node opset_version (int): the opset version @@ -1771,7 +1771,7 @@ def _onnx_node_to_singa_op(cls, onnx_node, opset_version=_opset_version): @classmethod def run_node(cls, node, inputs, device='CPU', opset_version=_opset_version): """ - run a single singa operator from a onnx node + run a single singa operator from an ONNX node Args: node (NodeProto): a given onnx node inputs (ndarray[]): a list of numpy ndarray @@ -1932,14 +1932,14 @@ def prepare(cls, model, device='CPU', **kwargs): opset_version = imp.version if imp.version > cls._opset_version: warnings.warn( - "The imported opertor set verion {} is larger than the supported version {}." + "The imported operator set version {} is larger than the supported version {}." .format(imp.version, cls._opset_version)) else: warnings.warn("Unrecognized operator set {}".format(imp.domain)) if model.ir_version > cls._ir_version: warnings.warn( - "The imported ir verion {} is larger than the supported version {}." + "The imported ir version {} is larger than the supported version {}." .format(cls._ir_version, imp.version)) graph = model.graph @@ -2061,7 +2061,7 @@ def get_s(self, name, node, tensor_dict): def handle_special_ops(self, node, op, tensor_dict): """ - hanlde some special operations + handle some special operations Args: name (str): name of the state node (ONNXNode): ONNX node @@ -2215,7 +2215,7 @@ def forward(self, *input, aux_output=(), **kwargs): aux_output (string()): a set of required output name Returns: - a OrderedDict of Tensor + an OrderedDict of Tensor """ return self.sg_ir.run(input, aux_output=aux_output, **kwargs) diff --git a/python/singa/tensor.py b/python/singa/tensor.py index 963ad1a002..748fa6aa49 100755 --- a/python/singa/tensor.py +++ b/python/singa/tensor.py @@ -235,7 +235,7 @@ def reshape(self, shape): Args: shape (list): new shape, which should have the same - volumn as the original shape. + volume as the original shape. Returns: new tensor reshaped @@ -533,7 +533,7 @@ def uniform(self, low, high, inplace=True): Args: low (float): the lower bound - high (float): the hight bound + high (float): the high bound inplace: inplace flag Returns: @@ -837,7 +837,7 @@ def reshape(tensor, shape): Args: tensor (Tensor): the tensor to be changed - shape (list): the new shape, which should have the same volumn as the + shape (list): the new shape, which should have the same volume as the old shape. Returns: @@ -1338,7 +1338,7 @@ def einsum(ops, *args): 2.repeat(A,repeats) 3.transpose(A,axes = None) Do the matrix to matrix einsum calculation according to the operands - Warning : this function could only support two matrix' einsum calcultion + Warning : this function could only support two matrix' einsum calculation Args: ops(string): the string specifies the subscripts for summation such as @@ -1347,7 +1347,7 @@ def einsum(ops, *args): but here only support two tensors. Returns: - Singa.Tensor the output matirx of the einsum calculation + Singa.Tensor the output matrix of the einsum calculation The best way to understand this function is to try the examples below: A_ = [0,1,2,3,4,5,6,7,8,9,10,11] @@ -1366,7 +1366,7 @@ def einsum(ops, *args): A = A_.reshape(4,3) B = A_.reshape(4,3) - Here the einsum calculation is the same as normol 'eltwise_mult' + Here the einsum calculation is the same as normal 'eltwise_mult' Res = einsum('ki,ki->ki',A,B) >>> [[ 0 1 4] diff --git a/python/singa/utils.py b/python/singa/utils.py index 7dcf8fb52f..4b370f899a 100644 --- a/python/singa/utils.py +++ b/python/singa/utils.py @@ -131,7 +131,7 @@ def same_pad_shape_check(handle, pad_mode, x): def re_new_handle(handle, x, is_pool=False): """ - re-new a handle by useing the new input tensor + re-new a handle by using the new input tensor Args: handle, the handle x, input tensor @@ -171,8 +171,8 @@ def get_padding_shape(pad_mode, input_spatial_shape, kernel_spatial_shape, kernel_spatial_shape, strides_spatial) pad_shape = [0] * len(input_spatial_shape) * 2 # 2 means left and right - # the odd paddding is the value that cannot be handled by the tuple padding (w, h) mode - # so we need to firstly handle the input, then use the nomal padding method. + # the odd padding is the value that cannot be handled by the tuple padding (w, h) mode + # so we need to firstly handle the input, then use the normal padding method. odd_padd_shape = [0] * len(input_spatial_shape) * 2 for i in range(len(input_spatial_shape)): whole_pad = (output_spatial_shape[i] - 1) * strides_spatial[i] + \ @@ -243,7 +243,7 @@ def post_order_recursive(root, root_t): def recursive(root, yid, root_t): if root: - # srcop: operator for a input of root + # srcop: operator for an input of root # yid: id(output of this operator) # y: output of this operator for srcop, yid, y, _ in root.src: diff --git a/setup.py b/setup.py index 1bbbd1d1aa..bb6a0d0544 100644 --- a/setup.py +++ b/setup.py @@ -22,17 +22,17 @@ # launch docker container $ nvidia-docker run -v :/root/singa -it apache/singa:manylinux2014-cuda10.2 - # build the wheel packag; replace cp36-cp36m to compile singa for other py version + # build the wheel package; replace cp36-cp36m to compile singa for other py version $ /opt/python/cp36-cp36m/bin/python setup.py bdist_wheel $ /opt/python/cp37-cp37m/bin/python setup.py bdist_wheel $ /opt/python/cp38-cp38/bin/python setup.py bdist_wheel -The generted wheel file should be repaired by the auditwheel tool to make it +The generated wheel file should be repaired by the auditwheel tool to make it compatible with PEP513. Otherwise, the dependent libs will not be included in the wheel package and the wheel file will be rejected by PYPI website during uploading due to file name error. - # repair the wheel pakage and upload to pypi + # repair the wheel package and upload to pypi $ /opt/python/cp36-cp36m/bin/python setup.py audit For the Dockerfile with CUDA and CUDNN installed, the CUDA version and @@ -309,7 +309,7 @@ def customize_compiler_for_nvcc(self): If you subclass UnixCCompiler, it's not trivial to get your subclass injected in, and still have the right customizations (i.e. distutils.sysconfig.customize_compiler) run on it. So instead of going - the OO route, I have this. Note, it's kindof like a wierd functional + the OO route, I have this. Note, it's kindof like a weird functional subclassing going on. """ @@ -342,7 +342,7 @@ def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts): class custom_build_ext(build_ext): - '''Customize the process for building the extension by chaning + '''Customize the process for building the extension by changing the options for compiling swig files and cu files. Ref: https://github.com/python/cpython/blob/master/Lib/distutils/command/build_ext.py diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5f302992ba..1002ebef56 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -110,7 +110,7 @@ IF(CODE_COVERAGE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g --coverage") ENDIF(CODE_COVERAGE) -#pass configure infor to swig +#pass configure info to swig FILE(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/api/config.i") CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/api/config.i.in" "${CMAKE_CURRENT_SOURCE_DIR}/api/config.i") diff --git a/src/api/core_device.i b/src/api/core_device.i index a5a9644b32..05c168ea10 100644 --- a/src/api/core_device.i +++ b/src/api/core_device.i @@ -57,7 +57,7 @@ class Device { void PrintTimeProfiling(); void SetVerbosity(int verbosity); void SetSkipIteration(int skip_iteration); - static void EnableLazyAlloc(bool enbale); + static void EnableLazyAlloc(bool enable); }; class Platform { diff --git a/src/api/numpy.i b/src/api/numpy.i index de4203ee4f..34fcecc9e6 100644 --- a/src/api/numpy.i +++ b/src/api/numpy.i @@ -124,7 +124,7 @@ if (PyInstance_Check(py_obj)) return "instance" ; %#endif - return "unkown type"; + return "unknown type"; } /* Given a NumPy typecode, return a string describing the type. diff --git a/src/core/scheduler/scheduler.cc b/src/core/scheduler/scheduler.cc index 0172ee86ce..b188d22352 100644 --- a/src/core/scheduler/scheduler.cc +++ b/src/core/scheduler/scheduler.cc @@ -391,7 +391,7 @@ void Graph::RunInSerial() { } /* - // Wait for calculation to complete and then recyle the data + // Wait for calculation to complete and then recycle the data CBData *cb_data = new CBData(this, curNode); CHECK(cudaStreamAddCallback(device_->ctx_.stream, Graph::Callback, (void *)(cb_data), 0)); @@ -677,8 +677,8 @@ void Graph::AnalyzeEdges() { int node_id = blkInfo->used_nodes_.back()->id_; BlockType type = blkInfo->type_; - // if the block belongs to a inter tensor - // and isn't refered on the Python Side + // if the block belongs to an Inter tensor + // and isn't referred on the Python Side if ((type == BlockType::kInter || type == BlockType::kEnd) && blkInfo->graph_ref_ >= blk->ref_count()) { free_blocks_[node_id].push_back(blk); diff --git a/src/core/tensor/math_kernel.cu b/src/core/tensor/math_kernel.cu index f25f7ab8b1..03f963aaca 100644 --- a/src/core/tensor/math_kernel.cu +++ b/src/core/tensor/math_kernel.cu @@ -624,7 +624,7 @@ __global__ void KernelHalf2Float(const size_t n, const __half *in, float *out) { } } -// kernal used by the threshold based sparsification +// kernel used by the threshold based sparsification __global__ void KernelSparsAbs(const size_t n, const float threshold, const float *in, float *out) { for (size_t i = blockIdx.x * blockDim.x + threadIdx.x; i < n; @@ -633,7 +633,7 @@ __global__ void KernelSparsAbs(const size_t n, const float threshold, } } -// kernal used by the threshold based sparsification +// kernel used by the threshold based sparsification __global__ void KernelSparsIndex(const size_t n, const float *in, int *out) { for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; i += blockDim.x * gridDim.x) { @@ -641,7 +641,7 @@ __global__ void KernelSparsIndex(const size_t n, const float *in, int *out) { } } -// kernal used by the topK based sparsification +// kernel used by the topK based sparsification __global__ void KernelGenerateIndex(const size_t n, int *out) { for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n; i += blockDim.x * gridDim.x) { diff --git a/src/core/tensor/tensor.cc b/src/core/tensor/tensor.cc index 46b82aac98..b54b9388a3 100644 --- a/src/core/tensor/tensor.cc +++ b/src/core/tensor/tensor.cc @@ -525,7 +525,7 @@ Tensor &Tensor::Transpose() { // transpose with axes Tensor &Tensor::Transpose(const vector &axes) { CHECK_EQ(axes.size(), shape_.size()) - << "Tranpose axes's length should be equal to shape"; + << "Transpose axes's length should be equal to shape"; auto shape = shape_; auto stride = stride_; @@ -718,7 +718,7 @@ void RepeatDataToFrom(bool broadcast_flag, const vector &repeats, } //============================================================================ -/// typedef DType accroding to type value. +/// typedef DType according to type value. /// DType would be used in the code block __VA_ARGS__. #define TYPE_SWITCH(type, DType, ...) \ do { \ @@ -749,7 +749,7 @@ void RepeatDataToFrom(bool broadcast_flag, const vector &repeats, break; \ } \ default: \ - LOG(FATAL) << "Unknow data type = " << DataType_Name(type); \ + LOG(FATAL) << "Unknown data type = " << DataType_Name(type); \ } \ } while (0) @@ -868,7 +868,7 @@ template void Tensor::get_value(SType *value, const size_t num) const { CHECK(device_ == defaultDevice); Tensor t(shape_, device_, data_type_); - // transform function arrange data in memory considering stride + // transform function arrange data in memory considerring stride singa::Transform(*this, &t); auto ptr = static_cast(t.block()->data()); for (size_t i = 0; i < num; i++) value[i] = ptr[i]; @@ -1194,8 +1194,8 @@ Tensor Average(const Tensor &M, int axis) { // D CastTo(S x) { // return D(x); // } - // for speical types, e.g., fp16: - // tempalte<> + // for special types, e.g., fp16: + // template<> // fp16 CastType(float x) { // .... // } @@ -1207,7 +1207,7 @@ Tensor Average(const Tensor &M, int axis) { LOG(FATAL) << "Not currently support Sum over axis = " << axis; } } -// TODO(wangwei) conside async exec +// TODO(wangwei) consider async exec template <> float Sum(const Tensor &in) { float s = 0.0f; @@ -1700,7 +1700,7 @@ void Mult(const SType alpha, const Tensor &A, const Tensor &B, const SType beta, read_blocks, {C->block()}, "GEMMBatched"); }); } else { - LOG(FATAL) << "Un-supported tensor dimentions " << A.nDim() << "d matmul " + LOG(FATAL) << "Un-supported tensor dimensions " << A.nDim() << "d matmul " << B.nDim() << "d\n"; } } @@ -1774,7 +1774,7 @@ Tensor Contiguous(const Tensor &in) { // if tensor is not transposed yet, we change the shape and generate new stride // if tensor is already transposed, we reallocate the memory and generate stride Tensor &Tensor::Reshape(const Shape &shape) { - // Check original volumn with the new one + // Check original volume with the new one // do not use Product(shape_) due to stride 0 from broadcasting. // printf("reshape loc b\n"); CHECK_EQ(Product(shape), Size()); diff --git a/src/core/tensor/tensor_math.h b/src/core/tensor/tensor_math.h index c294c4ea18..7a0843ed7e 100644 --- a/src/core/tensor/tensor_math.h +++ b/src/core/tensor/tensor_math.h @@ -431,7 +431,7 @@ void GEMV(const DType alpha, const Tensor &A, const Tensor &v, const DType beta, LOG_FATAL("GEMV", DType, Lang); } -/// multiply a matrix with a diagnoal matrix constructed using values from 'v'. +/// multiply a matrix with a diagonal matrix constructed using values from 'v'. /// if matrix_lef_side is true, do M*v; else do v*M template void DGMM(const bool side_right, const Tensor &M, const Tensor &v, Tensor *out, diff --git a/src/core/tensor/tensor_math_cpp.h b/src/core/tensor/tensor_math_cpp.h index b3113abc3e..80bf3174f2 100644 --- a/src/core/tensor/tensor_math_cpp.h +++ b/src/core/tensor/tensor_math_cpp.h @@ -741,7 +741,7 @@ void Uniform(const float low, const float high, Tensor *out, // ====================Blas operations====================================== -// warning, this function has block M overwritting to block M itself +// warning, this function has block M overwriting to block M itself template <> void DGMM(const bool side_right, const Tensor &M, const Tensor &v, Tensor *out, Context *ctx) { @@ -832,7 +832,7 @@ void Dot(const Tensor &in1, const Tensor &in2, float *out, const float *in2Ptr = static_cast(in2.block()->data()); *out = cblas_sdot(in1.Size(), in1Ptr, 1, in2Ptr, 1); } else { - LOG(FATAL) << "Dot, one of the input is tranposed. Not implemented yet."; + LOG(FATAL) << "Dot, one of the input is transposed. Not implemented yet."; } } template <> @@ -845,7 +845,7 @@ void Dot(const Tensor &in1, const Tensor &in2, Tensor *out, float *outPtr = static_cast(out->block()->mutable_data()); *outPtr = cblas_sdot(in1.Size(), in1Ptr, 1, in2Ptr, 1); } else { - LOG(FATAL) << "Dot, one of the input is tranposed. Not implemented yet."; + LOG(FATAL) << "Dot, one of the input is transposed. Not implemented yet."; } } diff --git a/src/io/communicator.cc b/src/io/communicator.cc index 97ac18d40d..9c8eeecf48 100644 --- a/src/io/communicator.cc +++ b/src/io/communicator.cc @@ -54,14 +54,14 @@ NcclIdHolder::~NcclIdHolder() {} Communicator::Communicator(int local_rank, int world_size, const NcclIdHolder &holder, int buffSize) { maxSize = (size_t)buffSize; - // this contructor is for NCCL WITHOUT MPI + // this constructor is for NCCL WITHOUT MPI UseMPI = false; // Determine the rank of the collective communication this->world_size = world_size; this->local_rank = local_rank; this->global_rank = local_rank; - // copy the nccl unqiue id from the input id holder + // copy the nccl unique id from the input id holder id = holder.id; // setup cuda stream and nccl communicator @@ -72,7 +72,7 @@ Communicator::Communicator(int local_rank, int world_size, // contructer for application with MPI Communicator::Communicator(int buffSize) { maxSize = (size_t)buffSize; - // this contructor is for NCCL WITH MPI + // this constructor is for NCCL WITH MPI UseMPI = true; // MPI initialization @@ -114,7 +114,7 @@ void Communicator::setup() { } void Communicator::halfInit() { - // initialze the buffer + // initialize the buffer CUDA_CHECK(cudaMalloc(&fusedSendBuffHalf, maxSize * sizeof(__half))); CUDA_CHECK(cudaMalloc(&fusedRecvBuffHalf, maxSize * sizeof(__half))); halfInitialized = true; diff --git a/src/io/image_transformer.cc b/src/io/image_transformer.cc index d9a8be1d77..a8348aa67c 100644 --- a/src/io/image_transformer.cc +++ b/src/io/image_transformer.cc @@ -30,7 +30,7 @@ Tensor ImageTransformer::Apply(int flag, Tensor& input) { CHECK_LE(input.nDim(), 4u); CHECK_GE(input.nDim(), 2u); CHECK_EQ(input.data_type(), kFloat32) << "Data type " << input.data_type() - << " is invalid for an raw image"; + << " is invalid for a raw image"; srand((unsigned int)time(NULL)); /// TODO /// currently only consider one sample each time @@ -52,7 +52,7 @@ Tensor ImageTransformer::Apply(int flag, Tensor& input) { else if (image_dim_order_ == "HWC") height = temp1.shape(input.nDim() - 3), width = temp1.shape(input.nDim() - 2); else - LOG(FATAL) << "Unknow dimension order for images " << image_dim_order_ + LOG(FATAL) << "Unknown dimension order for images " << image_dim_order_ << " Only support 'HWC' and 'CHW'"; } else /// input is 2D gray image height = temp1.shape(0), width = temp1.shape(1); @@ -129,7 +129,7 @@ Tensor resize(Tensor& input, const size_t resize_height, mat.at>(i, j)[0] = in[i * width + j]; } else LOG(FATAL) << "Invalid channel size: " << channel; } else { - LOG(FATAL) << "Unknow dimension order for images " << image_dim_order + LOG(FATAL) << "Unknown dimension order for images " << image_dim_order << " Only support 'HWC' and 'CHW'"; } } else { /// 2D gray image @@ -248,7 +248,7 @@ Tensor crop(Tensor& input, const size_t crop_height, const size_t crop_width, output.CopyDataFromHostPtr(out, crop_height * crop_width * channel); delete[] out; } else { - LOG(FATAL) << "Unknow dimension order for images " << image_dim_order + LOG(FATAL) << "Unknown dimension order for images " << image_dim_order << " Only support 'HWC' and 'CHW'"; } } else { /// 2D gray image @@ -326,7 +326,7 @@ Tensor mirror(Tensor& input, const bool horizontal_mirror, output.CopyDataFromHostPtr(out, height * width * channel); delete[] out; } else { - LOG(FATAL) << "Unknow dimension order for images " << image_dim_order + LOG(FATAL) << "Unknown dimension order for images " << image_dim_order << " Only support 'HWC' and 'CHW'"; } } else { /// 2D gray image diff --git a/src/io/jpg_decoder.cc b/src/io/jpg_decoder.cc index c6aca19810..16c1383432 100644 --- a/src/io/jpg_decoder.cc +++ b/src/io/jpg_decoder.cc @@ -57,7 +57,7 @@ std::vector JPGDecoder::Decode(std::string value) { data[i * width * channel + j * channel + k] = static_cast(static_cast(mat.at(i, j)[k])); } else { - LOG(FATAL) << "Unknow dimension order for images " << image_dim_order_ + LOG(FATAL) << "Unknown dimension order for images " << image_dim_order_ << " Only support 'HWC' and 'CHW'"; } image.CopyDataFromHostPtr(data, image.Size()); diff --git a/src/io/jpg_encoder.cc b/src/io/jpg_encoder.cc index e4ab1440d0..e9081c4218 100644 --- a/src/io/jpg_encoder.cc +++ b/src/io/jpg_encoder.cc @@ -32,7 +32,7 @@ std::string JPGEncoder::Encode(vector& data) { const Tensor& image = data.at(0); CHECK_EQ(image.nDim(), 3u); CHECK_EQ(image.data_type(), kUChar) << "Data type " << image.data_type() - << " is invalid for an raw image"; + << " is invalid for a raw image"; const auto* raw = image.data(); cv::Mat mat; if (image_dim_order_ == "HWC") { @@ -53,7 +53,7 @@ std::string JPGEncoder::Encode(vector& data) { for (size_t k = 0; k < channel; k++) mat.at(i, j)[k] = raw[k * height * width + i * width + j]; } else { - LOG(FATAL) << "Unknow dimension order for images " << image_dim_order_ + LOG(FATAL) << "Unknown dimension order for images " << image_dim_order_ << " Only support 'HWC' and 'CHW'"; } diff --git a/src/io/network/endpoint.cc b/src/io/network/endpoint.cc index f88edbf354..4915dcf1d6 100644 --- a/src/io/network/endpoint.cc +++ b/src/io/network/endpoint.cc @@ -227,7 +227,7 @@ void NetworkThread::doWork() { LOG(FATAL) << "Bind Error: " << strerror(errno); } - // TODO(wangwei) remove the hardcode setting, which would result erros if + // TODO(wangwei) remove the hardcode setting, which would result errors if // there are more than 10 connections // reported by yaochang if (listen(socket_fd_, 10)) { @@ -276,7 +276,7 @@ void NetworkThread::onNewEp() { this->fd_ep_map_[fd] = ep; - // initialize the addess + // initialize the address ep->addr_.sin_family = AF_INET; ep->addr_.sin_port = htons(port_); bzero(&(ep->addr_.sin_zero), 8); @@ -440,8 +440,8 @@ void NetworkThread::afterConnEst(EndPoint *ep, int fd, bool active) { if (sfd == fd) { // this fd is a reuse of a previous socket fd - // so we first need to clean the resouce for that fd - // we duplicate this fd to let the resouce of the oldf fd can be freed + // so we first need to clean the resource for that fd + // we duplicate this fd to let the resource of the oldf fd can be freed // also indicate there is no need to reconnect fd = dup(fd); handleConnLost(sfd, ep, false); @@ -458,7 +458,7 @@ void NetworkThread::afterConnEst(EndPoint *ep, int fd, bool active) { ep->last_msg_time_ = ev_now(loop_); - // see whether there is already a established connection for this fd + // see whether there is already an established connection for this fd if (ep->conn_status_ == CONN_EST && sfd >= 0) { // check if fd and sfd are associate with the same socket struct sockaddr_in addr; diff --git a/src/model/feed_forward_net.cc b/src/model/feed_forward_net.cc index ff781d5038..9d5230fde1 100644 --- a/src/model/feed_forward_net.cc +++ b/src/model/feed_forward_net.cc @@ -128,7 +128,7 @@ void FeedForwardNet::AsType(DataType dtype) { void FeedForwardNet::Train(size_t batchsize, int nb_epoch, const Tensor& x, const Tensor& y, float val_split) { - CHECK_EQ(x.shape(0), y.shape(0)) << "Diff num of sampels in x and y"; + CHECK_EQ(x.shape(0), y.shape(0)) << "Diff num of samples in x and y"; size_t num_train = (size_t) (x.shape(0) * val_split); if (val_split == 0.0f) { Tensor dummy; @@ -145,7 +145,7 @@ void FeedForwardNet::Train(size_t batchsize, int nb_epoch, const Tensor& x, void FeedForwardNet::Train(size_t batchsize, int nb_epoch, const Tensor& x, const Tensor& y, const Tensor& val_x, const Tensor& val_y) { - CHECK_EQ(x.shape(0), y.shape(0)) << "Diff num of sampels in x and y"; + CHECK_EQ(x.shape(0), y.shape(0)) << "Diff num of samples in x and y"; int num_extra_samples = (int)x.shape(0) % batchsize; if (num_extra_samples != 0) LOG(WARNING) << "Pls set batchsize to make num_total_samples " @@ -240,7 +240,7 @@ const vector FeedForwardNet::Backward(int flag, const Tensor& grad) { std::pair FeedForwardNet::Evaluate(const Tensor& x, const Tensor& y, size_t batchsize) { - CHECK_EQ(x.shape(0), y.shape(0)) << "Diff num of sampels in x and y"; + CHECK_EQ(x.shape(0), y.shape(0)) << "Diff num of samples in x and y"; CHECK_GE(x.shape(0), batchsize); int num_extra_samples = (int)x.shape(0) % batchsize; Tensor loss(Shape{x.shape(0)}), metric(Shape{x.shape(0)}); diff --git a/src/model/layer/activation.cc b/src/model/layer/activation.cc index 8e09f59743..90b5613d0d 100644 --- a/src/model/layer/activation.cc +++ b/src/model/layer/activation.cc @@ -42,7 +42,7 @@ void Activation::Setup(const Shape& in_sample, const LayerConf& conf) { << conf.type(); mode_ = ToLowerCase(conf.type().substr(pos + 1)); if (mode_ != "relu" && mode_ != "sigmoid" && mode_ != "tanh") - LOG(FATAL) << "Unkown activation type: " << conf.type() << " " << mode_ + LOG(FATAL) << "Unknown activation type: " << conf.type() << " " << mode_ << ". Please use singa_relu, singa_sigmoid, or singa_tanh"; if (mode_ == "relu") { neg_slope_ = conf.relu_conf().negative_slope(); @@ -80,7 +80,7 @@ const std::pair> Activation::Backward( input_grad = grad * (inout * inout * (-1.f) + 1.f); else if (mode_ == "relu") input_grad = grad * (inout > 0.f) + (inout <= 0.f) * neg_slope_; - else LOG(FATAL) << "Unkown activation: " << mode_; + else LOG(FATAL) << "Unknown activation: " << mode_; return std::make_pair(input_grad, param_grad); } diff --git a/src/model/layer/batchnorm.cc b/src/model/layer/batchnorm.cc index a4b9b24a3b..237a90a64a 100644 --- a/src/model/layer/batchnorm.cc +++ b/src/model/layer/batchnorm.cc @@ -96,7 +96,7 @@ const Tensor BatchNorm::Forward(int flag, const Tensor& input) { buf_.push(var); buf_.push(xnorm); } else { // batchnorm_spatial mode - LOG(FATAL) << "Trainning SpatialBatchNormalization has not been " + LOG(FATAL) << "Training SpatialBatchNormalization has not been " "implemented yet..."; } } else { // forward for test @@ -234,7 +234,7 @@ const std::pair> BatchNorm::Backward( param_grad.push_back(dummy); param_grad.push_back(dummy); } else { - LOG(FATAL) << "Trainning SpatialBatchNormalization has not been " + LOG(FATAL) << "Training SpatialBatchNormalization has not been " "implemented yet..."; } } else { diff --git a/src/model/layer/cudnn_activation.cc b/src/model/layer/cudnn_activation.cc index 806e71405c..43001ddcc7 100644 --- a/src/model/layer/cudnn_activation.cc +++ b/src/model/layer/cudnn_activation.cc @@ -46,7 +46,7 @@ void CudnnActivation::InitCudnn(size_t size, DataType dtype) { else if (mode_ == "relu") cudnn_mode_ = CUDNN_ACTIVATION_RELU; else - LOG(FATAL) << "Unkown activation: " << mode_; + LOG(FATAL) << "Unknown activation: " << mode_; CUDNN_CHECK(cudnnSetActivationDescriptor( acti_desc_, cudnn_mode_, CUDNN_PROPAGATE_NAN, 0.0f)); diff --git a/src/model/operation/convolution.cc b/src/model/operation/convolution.cc index 96313d20b1..de4d25475e 100644 --- a/src/model/operation/convolution.cc +++ b/src/model/operation/convolution.cc @@ -175,7 +175,7 @@ Tensor CpuConvForward(const Tensor &x, Tensor &W, Tensor &b, {DNNL_ARG_TO, conv_weights_memory}}); } - // execuete forward + // execute forward convolution_forward(conv_pd).execute( s, {{DNNL_ARG_SRC, conv_src_memory}, {DNNL_ARG_WEIGHTS, conv_weights_memory}, diff --git a/src/model/operation/rnn.cc b/src/model/operation/rnn.cc index bc8edfd013..bba612bb4f 100644 --- a/src/model/operation/rnn.cc +++ b/src/model/operation/rnn.cc @@ -181,7 +181,7 @@ vector GpuRNNForwardInference(const Tensor &x, const Tensor &hx, // out // y in shape {seq, bs, ..} - h.batch_size = x.shape(1); // update batch size to accomodate bs change + h.batch_size = x.shape(1); // update batch size to accommodate bs change h.seq_length = x.shape(0); Tensor y(Shape{h.seq_length, h.batch_size, @@ -250,7 +250,7 @@ vector GpuRNNForwardTraining(const Tensor &x, const Tensor &hx, // out // y in shape {seq, bs, ..} - // update batch size to accomodate bs change + // update batch size to accommodate bs change h.batch_size = x.shape(1); h.seq_length = x.shape(0); diff --git a/src/model/updater/updater.cc b/src/model/updater/updater.cc index d386d30dc0..7a1e742da2 100644 --- a/src/model/updater/updater.cc +++ b/src/model/updater/updater.cc @@ -29,4 +29,4 @@ void Updater::Register(const string& name, const ParamSpec& specs) { void Updater::Apply(int step, const string& name, Tensor& grad, Tensor& value) { opt_->Apply(step, name, grad, value); } -} // namesapce singa +} // namespace singa diff --git a/test/python/test_onnx.py b/test/python/test_onnx.py index 504fbcffb1..956394e341 100644 --- a/test/python/test_onnx.py +++ b/test/python/test_onnx.py @@ -49,7 +49,7 @@ class TestPythonOnnx(unittest.TestCase): def check_shape(self, actual, expect): self.assertEqual( actual, expect, 'shape mismatch, actual shape is %s' - ' exepcted is %s' % + ' expected is %s' % (_tuple_to_string(actual), _tuple_to_string(expect))) def _conv2d_helper(self, dev): diff --git a/test/python/test_onnx_backend.py b/test/python/test_onnx_backend.py index 0e7bb658a5..a68d9e2a51 100644 --- a/test/python/test_onnx_backend.py +++ b/test/python/test_onnx_backend.py @@ -64,7 +64,7 @@ r'(test_greater_equal)', # interrupt greater r'(test_negative_log)', # interrupt negative r'(test_softmax_cross_entropy)', # interrupt softmax - r'(test_reduce_sum_square)', # interrupt reduce sum squre + r'(test_reduce_sum_square)', # interrupt reduce sum square r'(test_log_softmax)', # interrupt log softmax r'(test_maxunpool)', # interrupt max unpool r'(test_gather_elements)', # interrupt gather elements diff --git a/test/python/test_operation.py b/test/python/test_operation.py index 54d251325c..1652d01b4f 100755 --- a/test/python/test_operation.py +++ b/test/python/test_operation.py @@ -47,7 +47,7 @@ def axis_helper(y_shape, x_shape): y_shape: the shape of result x_shape: the shape of x Return: - a tuple refering the axes + a tuple referring the axes """ res = [] j = len(x_shape) - 1 @@ -89,7 +89,7 @@ class TestPythonOperation(unittest.TestCase): def check_shape(self, actual, expect): self.assertEqual( actual, expect, 'shape mismatch, actual shape is %s' - ' exepcted is %s' % + ' expected is %s' % (_tuple_to_string(actual), _tuple_to_string(expect))) def _greater_helper(self, dev): @@ -2428,7 +2428,7 @@ def _div_broadcast_helper(self, dev): result = autograd.div(x, x1) dx0, dx1 = result.creator.backward(dy.data) - # use realtive and total error instead of demical number + # use relative and total error instead of demical number np.testing.assert_allclose(tensor.to_numpy(result), y, rtol=1e-4, @@ -2904,7 +2904,7 @@ def test_floor_gpu(self): self.floor_test(gpu_dev) def _test_scatter_elements(self, dev): - # testing witout axis + # testing without axis data = np.zeros((3, 3), dtype=np.float32) indices = np.array([[1, 0, 2], [0, 2, 1]], dtype=np.int32) updates = np.array([[1.0, 1.1, 1.2], [2.0, 2.1, 2.2]], dtype=np.float32) diff --git a/test/singa/test_activation.cc b/test/singa/test_activation.cc index d320b143d2..0672917b87 100644 --- a/test/singa/test_activation.cc +++ b/test/singa/test_activation.cc @@ -72,7 +72,7 @@ TEST(Activation, Forward) { } else if (acti.Mode() == "relu") { for (size_t i = 0; i < n; i++) y[i] = (x[i] >= 0.f) ? x[i] : 0.f; } else { - LOG(FATAL) << "Unkown activation: " << acti.Mode(); + LOG(FATAL) << "Unknown activation: " << acti.Mode(); } EXPECT_FLOAT_EQ(y[0], yptr[0]); EXPECT_FLOAT_EQ(y[4], yptr[4]); @@ -119,7 +119,7 @@ TEST(Activation, Backward) { for (size_t i = 0; i < n; i++) dx[i] = grad[i] * (x[i] > 0.f) + acti.Negative_slope() * (x[i] <= 0.f); } else { - LOG(FATAL) << "Unkown activation: " << acti.Mode(); + LOG(FATAL) << "Unknown activation: " << acti.Mode(); } EXPECT_FLOAT_EQ(dx[0], xptr[0]); EXPECT_FLOAT_EQ(dx[4], xptr[4]); diff --git a/test/singa/test_cudnn_activation.cc b/test/singa/test_cudnn_activation.cc index fdf225b035..fda083249a 100644 --- a/test/singa/test_cudnn_activation.cc +++ b/test/singa/test_cudnn_activation.cc @@ -76,7 +76,7 @@ TEST(CudnnActivation, Forward) { } else if (acti.Mode() == "relu") { for (size_t i = 0; i < n; i++) y[i] = (x[i] >= 0.f) ? x[i] : 0.f; } else { - LOG(FATAL) << "Unkown activation: " << acti.Mode(); + LOG(FATAL) << "Unknown activation: " << acti.Mode(); } EXPECT_FLOAT_EQ(y[0], yptr[0]); EXPECT_FLOAT_EQ(y[4], yptr[4]); @@ -126,7 +126,7 @@ TEST(CudnnActivation, Backward) { dx[i] = grad[i] * (x[i] > 0.f); //+ acti.Negative_slope() * (x[i] <= 0.f); } else { - LOG(FATAL) << "Unkown activation: " << acti.Mode(); + LOG(FATAL) << "Unknown activation: " << acti.Mode(); } for (size_t i = 0; i < n; i++) { EXPECT_NEAR(dx[i], xptr[i], 1e-7); diff --git a/tool/code-format/README.md b/tool/code-format/README.md index 758f79bb84..79a7b33393 100644 --- a/tool/code-format/README.md +++ b/tool/code-format/README.md @@ -19,10 +19,10 @@ # How to format code -This guide is for singa devoloper who should sanitize the code +This guide is for singa developer who should sanitize the code before merging into the main branch. -## tools to auto formating code +## tools to auto formatting code Install clang-format for C++: @@ -35,13 +35,13 @@ Install yapf for Python: `pip install yapf` -## Formating a single file +## Formatting a single file - C++: `clang-format -i path/to/file` - Python: `yapf -i path/to/file` -## Formating the whole project +## Formatting the whole project usage: `bash tool/code-format/format.sh` ## Configuration: diff --git a/tool/conda/docker/cpu/Dockerfile b/tool/conda/docker/cpu/Dockerfile index f8e6b30155..f9c217af02 100644 --- a/tool/conda/docker/cpu/Dockerfile +++ b/tool/conda/docker/cpu/Dockerfile @@ -15,7 +15,7 @@ # limitations under the License. # -# 18.04 has erros in ssh +# 18.04 has errors in ssh FROM ubuntu:18.04 # install dependencies diff --git a/tool/conda/docker/cuda10.2/Dockerfile b/tool/conda/docker/cuda10.2/Dockerfile index 7526b2fd77..58f1dac08f 100644 --- a/tool/conda/docker/cuda10.2/Dockerfile +++ b/tool/conda/docker/cuda10.2/Dockerfile @@ -15,7 +15,7 @@ # limitations under the License. # -# 18.04 has erros in ssh +# 18.04 has errors in ssh FROM nvidia/cuda:10.2-devel-ubuntu16.04 # install dependencies diff --git a/tool/conda/docker/cuda10/Dockerfile b/tool/conda/docker/cuda10/Dockerfile index 5899aab291..a0ad3a7a12 100644 --- a/tool/conda/docker/cuda10/Dockerfile +++ b/tool/conda/docker/cuda10/Dockerfile @@ -15,7 +15,7 @@ # limitations under the License. # -# 18.04 has erros in ssh +# 18.04 has errors in ssh FROM nvidia/cuda:10.0-devel-ubuntu16.04 # install dependencies diff --git a/tool/conda/singa/build.sh b/tool/conda/singa/build.sh index 7eb5287fa4..32f77adc02 100644 --- a/tool/conda/singa/build.sh +++ b/tool/conda/singa/build.sh @@ -15,7 +15,7 @@ # limitations under the License. # -# to compile swig api files which depdend on numpy.i +# to compile swig api files which depend on numpy.i # export CPLUS_INCLUDE_PATH=`python -c "from __future__ import print_function; import numpy; print(numpy.get_include())"`:$CPLUS_INCLUDE_PATH # to let cmake use the dependent libs installed by conda, including python diff --git a/tool/docker/README.md b/tool/docker/README.md index 740735eee0..8caaddb201 100644 --- a/tool/docker/README.md +++ b/tool/docker/README.md @@ -65,7 +65,7 @@ Here are some example tags: `devel-cuda9-cudnn7`, `devel-cuda9-cudnn7`, `devel-cuda10-cudnn7`, `devel-cpu`, `runtime-gpu` and `runtime-cpu` -Please follow the existing Dockefiles under tool/docker/ to create other Dockefiles. +Please follow the existing Dockerfiles under tool/docker/ to create other Dockerfiles. The folder structure is like level1: devel|runtime diff --git a/tool/docker/build.sh b/tool/docker/build.sh index 3f0ab05a7b..826ba9af3e 100755 --- a/tool/docker/build.sh +++ b/tool/docker/build.sh @@ -18,7 +18,7 @@ # * limitations under the License. # */ -# build all docker images, must be exected under the root directory, i.e., singa/ +# build all docker images, must be executed under the root directory, i.e., singa/ # ./build.sh PUSH would push the images to dockerhub/nusdbsystem and then delete the local image # (used by Jenkins to avoid dangling images from multiple building) diff --git a/tool/jenkins/README.md b/tool/jenkins/README.md index 1bb737c08f..b775de9fbf 100644 --- a/tool/jenkins/README.md +++ b/tool/jenkins/README.md @@ -110,7 +110,7 @@ To add the container into a network for easy access docker network create docker network connect -After connecting both the jenkins and node contaniners into the same network, we can ssh to the node from jenkins container like +After connecting both the jenkins and node containers into the same network, we can ssh to the node from jenkins container like # inside jenkins container @@ -119,7 +119,7 @@ After connecting both the jenkins and node contaniners into the same network, we You need execute the above command manually for the first ssh login. In the Jenkins node configuration page, the container name is used to configure the `Host` field. -Notice that Oracle username and account are required to luanch the node by Jenkins. +Notice that Oracle username and account are required to launch the node by Jenkins. The working nodes (or Docker containers) are configured in Jenkins-Manage Jenkins-Mange Nodes. Each node should configure the following environment variable diff --git a/tool/jenkins/test.sh b/tool/jenkins/test.sh index 9b223f2e87..78862186cb 100644 --- a/tool/jenkins/test.sh +++ b/tool/jenkins/test.sh @@ -23,7 +23,7 @@ echo Compile and test Singa... echo workspace: `pwd` echo OS version: `cat /etc/issue` -echo kernal version: `uname -a` +echo kernel version: `uname -a` echo parameters: $1 echo parameters: $2 COMMIT=`git rev-parse --short HEAD` diff --git a/tool/linting/README.md b/tool/linting/README.md index f36f859769..a0beccb81c 100644 --- a/tool/linting/README.md +++ b/tool/linting/README.md @@ -19,7 +19,7 @@ # Linting check -This guide is for singa devoloper who should sanitize the code +This guide is for singa developer who should sanitize the code before merging into the main branch. ## linting tools diff --git a/tool/release/README.md b/tool/release/README.md index 024b73945c..38b201f09c 100644 --- a/tool/release/README.md +++ b/tool/release/README.md @@ -23,7 +23,7 @@ ### Option: - `[-y]` - - In interactive mode, it is for user to confirm. Could be used in sript. + - In interactive mode, it is for user to confirm. Could be used in script. ### Argument: - `` @@ -53,7 +53,7 @@ ## In the release.py Internally, the script retrieve latest git tag by `git describe`, -and increment the version accroding to semantic versioning, +and increment the version according to semantic versioning, then push latest tag to remote master. ## Next step