Skip to content

Conversation

@Manfredss
Copy link
Contributor

@Manfredss Manfredss commented Nov 2, 2025

PR Category

Environment Adaptation

PR Types

Bug fixes

Description

fix compile error in paddle/phi/core/framework/data_type_transform.cc

before:

 template <typename InType, typename OutType>
 struct CastDataTypeFunctor {
   HOSTDEVICE inline OutType operator()(InType in) const {
     return static_cast<OutType>(in);
  }
};

after:

template <typename InType, typename OutType>
struct CastDataTypeFunctor {
  HOSTDEVICE inline OutType operator()(InType in) const {
    #if defined(_MSC_VER)
        // 屏蔽 MSVC 不支持的从 float/bfloat8/float16 -> complex 的转换
        if constexpr (
            (std::is_same_v<OutType, phi::dtype::complex<float>> ||
            std::is_same_v<OutType, phi::dtype::complex<double>>) &&
            (std::is_same_v<InType, phi::dtype::float8_e4m3fn> ||
            std::is_same_v<InType, phi::dtype::float8_e5m2> ||
            std::is_same_v<InType, phi::dtype::bfloat16> ||
            std::is_same_v<InType, phi::dtype::float16>)) {
          return OutType(0);  // 默认返回值,仅防止编译错误
        } else
    #endif
        {
          return static_cast<OutType>(in);
        }
      }
};

Manfredss and others added 4 commits October 10, 2025 20:25
- Add negative index detection and conversion in DealWithIndex function
- Support negative indexing in advanced indexing like tensor[[-1]]
- Fix issue75574: negative indexing in strided slice operations
- Maintain backward compatibility with existing positive indexing
- Add comprehensive test cases for negative indexing scenarios

Fixes: #issue75574
@paddle-bot
Copy link

paddle-bot bot commented Nov 2, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Nov 2, 2025
@Manfredss
Copy link
Contributor Author

#76161 的修复

@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers HappyOpenSource 快乐开源活动issue与PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants