我要评分
获取效率
正确性
完整性
易理解

Less

Scenario Description

Based on two input tensors input0 and input1, and the length value, a Boolean tensor is returned element by element, indicating whether the first input is less than the second input. The comparison results are stored in the output tensor. For example:

input0: [5,7,15,3]
input1: [8,6,20,0]
output: [true,false,true,false]
length: 4

Code Example

#include <cmath>
#include <random>
#include <cstdint>
#include <iostream>

#include "ktfop.h"
int main()
{  
    using namespace ktfop;
    size_t length = 4;
    int64_t input0Array[] = {5, 7, 15, 3};                           
    int64_t input1Array[] = {8, 6, 20, 0};                         
    auto *input0 = input0Array;                                   
    auto *input1 = input1Array;                                        
    auto *output = new bool[4];                                  
    int ret = -1;
    // Call the Less operator and store the results in the output array. The first and second parameters are arrays.
    ret = Less(input0, input1, output, length);         
    std::cout << "output: [";
    for (int i = 0; i < 4; ++i) {
        std::cout << output[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << "]" << std::endl;
    // Enter a null pointer and print the log "ERROR Parameter verification failed for the Less Op."
    ret = Less(static_cast<int64_t *>(nullptr), input1, output, length); 
    // Enter a null pointer and print the log "ERROR Parameter verification failed for the Less Op."
    ret = Less(input0, input1, nullptr, length);                   
    // right
    // Call the Less operator and store the results in the output array. The first parameter is an array, and the second parameter is an element.
    ret = Less(input0, input1[0], output, length);                 
    // Enter a null pointer and print the log "ERROR Parameter verification failed for the Less Op."
    ret = Less(static_cast<int64_t *>(nullptr), input1[0], output, length); 
    // left
    // Call the Less operator and store the results in the output array. The first parameter is an element, and the second parameter is an array.
    ret = Less(input0[0], input1, output, length);          
    // Enter a null pointer and print the log "ERROR Parameter verification failed for the Less Op."
    ret = Less(input0[0], static_cast<int64_t *>(nullptr), output, length); 
    delete[] output;
}