This commit is contained in:
Changming Sun 2018-12-21 15:44:35 -08:00
parent b93eba17c7
commit f3df7e5d32
4 changed files with 12 additions and 5 deletions

View file

@ -26,6 +26,7 @@ ONNX_CPU_OPERATOR_KERNEL(
Status MaxUnpool::Compute(OpKernelContext* context) const {
// Get pooled values tensor
const Tensor* X = context->Input<Tensor>(0);
if (X == nullptr) return Status(common::ONNXRUNTIME, common::FAIL, "input count mismatch");
const TensorShape& X_shape = X->Shape();
const float* X_data = X->template Data<float>();
@ -62,12 +63,13 @@ Status MaxUnpool::Compute(OpKernelContext* context) const {
bool padsInferred = false;
if (num_inputs_ == 3) {
auto& tensor_shape = *context->Input<Tensor>(2);
ORT_RETURN_IF_NOT(tensor_shape.Shape().GetDims().size() == 1, "Shape must be 1 dimensional as it's tensor data is a shape");
auto tensor_shape = context->Input<Tensor>(2);
if (tensor_shape == nullptr) return Status(common::ONNXRUNTIME, common::FAIL, "input count mismatch");
ORT_RETURN_IF_NOT(tensor_shape->Shape().GetDims().size() == 1, "Shape must be 1 dimensional as it's tensor data is a shape");
// Turn the shape tensor data into an actual shape
const int64_t* p_shape = tensor_shape.template Data<int64_t>();
std::vector<int64_t> shape{p_shape, p_shape + tensor_shape.Shape().Size()};
const int64_t* p_shape = tensor_shape->template Data<int64_t>();
std::vector<int64_t> shape{p_shape, p_shape + tensor_shape->Shape().Size()};
givenOutputShape = shape;
inferredPads.resize(inferredOutputShape.size() * 2, 0);

View file

@ -17,6 +17,7 @@ class IdentityOp final : public CudaKernel {
Status ComputeInternal(OpKernelContext* context) const override {
const Tensor* X = context->Input<Tensor>(0);
if (X == nullptr) return Status(common::ONNXRUNTIME, common::FAIL, "input count mismatch");
const TensorShape& shape = X->Shape();
Tensor* Y = context->Output(0, shape);
auto X_type = X->DataType();

View file

@ -21,7 +21,9 @@ namespace cuda {
template <typename T>
Status Transpose<T>::ComputeInternal(OpKernelContext* ctx) const {
const Tensor& X = *ctx->Input<Tensor>(0);
const Tensor* X_ptr = ctx->Input<Tensor>(0);
if (X_ptr == nullptr) return Status(common::ONNXRUNTIME, common::FAIL, "input count mismatch");
const Tensor& X = *X_ptr;
const TensorShape& input_shape = X.Shape();
const std::vector<int64_t>& input_dims = input_shape.GetDims();
size_t rank = input_dims.size();

View file

@ -192,6 +192,7 @@ Status Sum<T>::Compute(OpKernelContext* context) const {
std::vector<mkldnn::memory::dims> src_dims;
const Tensor* X1 = context->Input<Tensor>(0);
if (X1 == nullptr) return Status(common::ONNXRUNTIME, common::FAIL, "input count mismatch");
Tensor* Y = context->Output(0, X1->Shape());
int dimensions = static_cast<int>(X1->Shape().NumDimensions());
@ -204,6 +205,7 @@ Status Sum<T>::Compute(OpKernelContext* context) const {
for (int i = 0; i < num_inputs; i++) {
const Tensor* X = context->Input<Tensor>(i);
if (X == nullptr) return Status(common::ONNXRUNTIME, common::FAIL, "input count mismatch");
mkldnn::memory::dims src_dims_mkl(
X->Shape().GetDims().begin(), X->Shape().GetDims().end());
src_dims.push_back(src_dims_mkl);