Browse Source

cpu add support int64

tags/v1.6.0
VectorSL 4 years ago
parent
commit
e21ce8a5e6
6 changed files with 23 additions and 40 deletions
  1. +1
    -0
      mindspore/ccsrc/backend/kernel_compiler/cpu/rl/tensor_array_write_kernel.cc
  2. +15
    -4
      mindspore/ccsrc/backend/kernel_compiler/cpu/tensoradd_cpu_kernel.h
  3. +1
    -0
      mindspore/ccsrc/backend/kernel_compiler/gpu/rl/tensor_array_write_kernel.cc
  4. +6
    -2
      mindspore/ccsrc/runtime/framework/actor/kernel_actor.cc
  5. +0
    -1
      mindspore/ops/_op_impl/cpu/__init__.py
  6. +0
    -33
      mindspore/ops/_op_impl/cpu/add.py

+ 1
- 0
mindspore/ccsrc/backend/kernel_compiler/cpu/rl/tensor_array_write_kernel.cc View File

@@ -43,6 +43,7 @@ void TensorArrayCPUWriteKernel::InitKernel(const CNodePtr &kernel_node) {
}
input_size_list_.push_back(sizeof(int64_t));
input_size_list_.push_back(sizeof(int64_t));
input_size_list_.push_back(sizeof(value_size_));
output_size_list_.push_back(sizeof(int64_t));
}



+ 15
- 4
mindspore/ccsrc/backend/kernel_compiler/cpu/tensoradd_cpu_kernel.h View File

@@ -41,10 +41,21 @@ class TensorAddCPUKernel : public CPUKernel {
std::vector<size_t> output_shape_;
};

MS_REG_CPU_KERNEL_T(Add, KernelAttr(), TensorAddCPUKernel, int32_t);
MS_REG_CPU_KERNEL_T(Add, KernelAttr(), TensorAddCPUKernel, uint32_t);
MS_REG_CPU_KERNEL_T(Add, KernelAttr(), TensorAddCPUKernel, float);
MS_REG_CPU_KERNEL_T(Add, KernelAttr(), TensorAddCPUKernel, double);
MS_REG_CPU_KERNEL_T(
Add, KernelAttr().AddInputAttr(kNumberTypeInt64).AddInputAttr(kNumberTypeInt64).AddOutputAttr(kNumberTypeInt64),
TensorAddCPUKernel, int64_t);
MS_REG_CPU_KERNEL_T(
Add, KernelAttr().AddInputAttr(kNumberTypeInt32).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
TensorAddCPUKernel, int32_t);
MS_REG_CPU_KERNEL_T(
Add, KernelAttr().AddInputAttr(kNumberTypeUInt32).AddInputAttr(kNumberTypeUInt32).AddOutputAttr(kNumberTypeUInt32),
TensorAddCPUKernel, uint32_t);
MS_REG_CPU_KERNEL_T(
Add, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32),
TensorAddCPUKernel, float);
MS_REG_CPU_KERNEL_T(
Add, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64),
TensorAddCPUKernel, double);
} // namespace kernel
} // namespace mindspore



+ 1
- 0
mindspore/ccsrc/backend/kernel_compiler/gpu/rl/tensor_array_write_kernel.cc View File

@@ -48,6 +48,7 @@ bool TensorArrayWriteKernel::Init(const CNodePtr &kernel_node) {
void TensorArrayWriteKernel::InitSizeLists() {
input_size_list_.push_back(sizeof(int64_t));
input_size_list_.push_back(sizeof(int64_t));
input_size_list_.push_back(sizeof(value_size_));
output_size_list_.push_back(sizeof(int64_t));
}



+ 6
- 2
mindspore/ccsrc/runtime/framework/actor/kernel_actor.cc View File

@@ -88,7 +88,9 @@ void KernelActor::Run(OpContext<DeviceTensor> *const context) {
try {
device_contexts_[0]->UpdateDynamicShape(kernel_);
} catch (const std::exception &e) {
MsException::Instance().SetException();
if (strategy_ == GraphExecutionStrategy::kPipeline) {
MsException::Instance().SetException();
}
std::string error_info = "Update Dynamic shape exception: " + kernel_->fullname_with_scope();
SET_OPCONTEXT_FAIL_RET_WITH_ERROR_BY_STRATEGY(strategy_, (*context), error_info);
}
@@ -197,7 +199,9 @@ void KernelActor::OnMemoryAllocFinish(OpContext<DeviceTensor> *const context) {
SET_OPCONTEXT_FAIL_RET_WITH_ERROR_BY_STRATEGY(strategy_, (*context), error_info);
}
} catch (const std::exception &e) {
MsException::Instance().SetException();
if (strategy_ == GraphExecutionStrategy::kPipeline) {
MsException::Instance().SetException();
}
std::string error_info = "Launch kernel exception: " + kernel_->fullname_with_scope();
SET_OPCONTEXT_FAIL_RET_WITH_ERROR_BY_STRATEGY(strategy_, (*context), error_info);
}


+ 0
- 1
mindspore/ops/_op_impl/cpu/__init__.py View File

@@ -64,7 +64,6 @@ from .reduce_any import _reduce_any_cpu
from .transpose import _transpose_cpu
from .tile import _tile_cpu
from .top_k import _top_k_cpu
from .add import _add_cpu
from .one_hot import _one_hot_cpu
from .pad import _pad_cpu
from .range import _range_cpu


+ 0
- 33
mindspore/ops/_op_impl/cpu/add.py View File

@@ -1,33 +0,0 @@
# Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================

"""Add op"""
from mindspore.ops.op_info_register import op_info_register, CpuRegOp, DataType

add_op_info = CpuRegOp("Add") \
.input(0, "x1", "required") \
.input(1, "x2", "required") \
.output(0, "y", "required") \
.dtype_format(DataType.I32_Default, DataType.I32_Default, DataType.I32_Default) \
.dtype_format(DataType.U32_Default, DataType.U32_Default, DataType.U32_Default) \
.dtype_format(DataType.F32_Default, DataType.F32_Default, DataType.F32_Default) \
.dtype_format(DataType.F64_Default, DataType.F64_Default, DataType.F64_Default) \
.get_op_info()


@op_info_register(add_op_info)
def _add_cpu():
"""Add cpu register"""
return

Loading…
Cancel
Save