Skip to content

mindspore.ops.real fails on empty complex tensor while paddle.as_real succeeds (CPU) #362

Description

@tingPetty

When input is an empty complex tensor with shape (10, 0), paddle.as_real succeeds but mindspore.ops.real fails with CPU kernel CreateKernel RuntimeError. This looks like a robustness issue in empty-tensor handling.

Environment

Hardware Environment(Ascend/GPU/CPU):

/device cpu

Software Environment:

  • MindSpore version (source or binary): 2.8.0 (binary)
  • Python version (e.g., Python 3.7.5): 3.10.18
  • OS platform and distribution (e.g., Linux Ubuntu 16.04): Windows 10 (10.0.26200)
  • GCC/Compiler version (if compiled from source): N/A

Describe the current behavior

mindspore.ops.real on complex128 tensor with shape (10, 0) fails with RuntimeError and C++ CreateKernel stack. Paddle reference succeeds.

Describe the expected behavior

mindspore.ops.real should support empty complex tensors and return an empty real tensor, or at least raise a clear user-facing validation error instead of internal kernel creation failure.

Steps to reproduce the issue

  1. Run pd_ms_test_1/simple_tests/ms_error_only_candidate_053_as_real.py.
  2. Observe [PD] success and [OTHER] error.
  3. Error includes UnaryOpCpuKernelMod::Init and CPUKernelExecutor::CreateKernel.

Related log / screenshot

[ERROR] ... For 'Real', it got empty inputs or outputs, which is invalid.
RuntimeError:
- C++ Call Stack:
mindspore\ccsrc\plugin\cpu\cpu_device_context.cc:543 mindspore::device::cpu::CPUKernelExecutor::CreateKernel

Special notes for this issue

  • Paddle version in repro: 3.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions