已合并
modify some describtion in python_syntax_support.md #83
ca1kw创建于 3月9日
modify some describtion in python_syntax_support.md #83
已合并
ca1kw创建于 3月9日
1 个文件变更+13-12
@@ -557,24 +557,25 @@
557 ```python557 ```python
558 import numpy as np558 import numpy as np
559 @asc.jit559 @asc.jit
560- def cmpi_function(mask1: np.uint64, mask2: np.uint64):560+ def cmpi_function(mask_low: np.uint64, mask_high: np.uint64):
561- if mask1 > 0 and mask2 > 0:561+ if mask_low > 0 and mask_high > 0: # 数字0也为无符号整数类型
562- mask = [mask1, mask2]562+ mask = [mask_low, mask_high]
563 asc.add(z, x, y, mask=mask, repeat_time=1, repeat_params=asc.BinaryRepeatParams(1, 1, 1, 8, 8, 8))563 asc.add(z, x, y, mask=mask, repeat_time=1, repeat_params=asc.BinaryRepeatParams(1, 1, 1, 8, 8, 8))
564 564 
565- mask1 = np.uint64(2**64-1)565+ mask_low = np.uint64(2**64-1)
566- mask2 = np.uint64(2**64-1)566+ mask_high = np.uint64(2**64-1)
567 ```567 ```
568- 注:mask作为一个特殊的uint64场景,由框架进行处理,在进行`if mask1 > 0 and mask2 > 0`逻辑判断时可以使用 `if mask1 and mask2`,或使用np.int64代替,568+ 注:mask作为一个特殊的uint64场景,由框架进行处理,在进行`if mask_low > 0 and mask_high > 0`逻辑判断时可以使用 `if mask_low and mask_high`,
569- 代码下:569+果和非0数字进行比较则只能使用np.int64代替。
570+ 上述代码使用np.int64后代码如下:
570 ```python571 ```python
571 import numpy as np572 import numpy as np
572 @asc.jit573 @asc.jit
573- def cmpi_function(mask1: np.int64, mask2: np.int64):574+ def cmpi_function(mask_low: np.int64, mask_high: np.int64):
574- if mask1 != 0 and mask2 != 0:575+ if mask_low != 0 and mask_high != 0:
575- mask = [mask1, mask2]576+ mask = [mask_low, mask_high]
576 asc.add(z, x, y, mask=mask, repeat_time=1, repeat_params=asc.BinaryRepeatParams(1, 1, 1, 8, 8, 8))577 asc.add(z, x, y, mask=mask, repeat_time=1, repeat_params=asc.BinaryRepeatParams(1, 1, 1, 8, 8, 8))
577 578 
578- mask1 = np.int64(-1) # int64(-1)在强转为uint64时等于2**64-1579+ mask_low = np.int64(-1) # int64(-1)在强转为uint64时等于2**64-1
579- mask2 = np.int64(-1)580+ mask_high = np.int64(-1)
580 ```581 ```