|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT license. |
| 3 | + |
| 4 | +import {FLOAT_TYPES, NUMBER_TYPES} from '../../operators'; |
| 5 | +import {OpSet} from '../../opset'; |
| 6 | + |
| 7 | +import {CpuArgMax} from './ops/argMax'; |
| 8 | +import {CpuBatchNormalization} from './ops/batch-normalization'; |
| 9 | +import {CpuBinaryOp} from './ops/binary-op'; |
| 10 | +import {CpuConcat} from './ops/concat'; |
| 11 | +import {CpuConv} from './ops/conv'; |
| 12 | +import {CpuDropout} from './ops/dropout'; |
| 13 | +import {CpuFlatten} from './ops/flatten'; |
| 14 | +import {CpuGather} from './ops/gather'; |
| 15 | +import {CpuGemm} from './ops/gemm'; |
| 16 | +import {CpuImageScaler} from './ops/image-scaler'; |
| 17 | +import {CpuInstanceNormalization} from './ops/instance-normalization'; |
| 18 | +import {CpuLrn} from './ops/lrn'; |
| 19 | +import {CpuMatMul} from './ops/matmul'; |
| 20 | +import {CpuAveragePool, CpuGlobalAveragePool, CpuGlobalMaxPool, CpuMaxPool} from './ops/pool'; |
| 21 | +import * as cpuReduce from './ops/reduce'; |
| 22 | +import {CpuReshape} from './ops/reshape'; |
| 23 | +import {CpuSlice} from './ops/slice'; |
| 24 | +import {CpuSoftmax} from './ops/softmax'; |
| 25 | +import {CpuSqueeze} from './ops/squeeze'; |
| 26 | +import {CpuSum} from './ops/sum'; |
| 27 | +import {CpuTile} from './ops/tile'; |
| 28 | +import {CpuTranspose} from './ops/transpose'; |
| 29 | +import * as unaryOps from './ops/unary-op'; |
| 30 | +import {CpuUnsqueeze} from './ops/unsqueeze'; |
| 31 | + |
| 32 | +export const CPU_OP_RESOLVE_RULES: ReadonlyArray<OpSet.ResolveRule> = [ |
| 33 | + ['Abs', '', '6+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.abs)], |
| 34 | + ['Acos', '', '7+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.acos)], |
| 35 | + ['Add', '', '7+', () => new CpuBinaryOp(NUMBER_TYPES, (e1, e2) => (e1 + e2))], |
| 36 | + ['And', '', '7+', () => new CpuBinaryOp(['bool'], (e1, e2) => (e1 && e2))], |
| 37 | + ['ArgMax', '', '1+', () => new CpuArgMax()], |
| 38 | + ['Asin', '', '7+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.asin)], |
| 39 | + ['Atan', '', '7+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.atan)], |
| 40 | + ['AveragePool', '', '7+', () => new CpuAveragePool()], // TODO: support new attributes for AveragePool-10 |
| 41 | + ['BatchNormalization', '', '7+', () => new CpuBatchNormalization()], |
| 42 | + ['Ceil', '', '6+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.ceil)], |
| 43 | + ['Clip', '', '6+', () => new unaryOps.CpuUnaryOp(FLOAT_TYPES, unaryOps.clip)], |
| 44 | + ['Concat', '', '4+', () => new CpuConcat()], |
| 45 | + ['Conv', '', '1+', () => new CpuConv()], |
| 46 | + ['Cos', '', '7+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.cos)], |
| 47 | + ['Div', '', '7+', () => new CpuBinaryOp(NUMBER_TYPES, (e1, e2) => (e1 / e2))], |
| 48 | + ['Dropout', '', '7+', () => new CpuDropout()], |
| 49 | + ['Elu', '', '6+', () => new unaryOps.CpuUnaryOp(FLOAT_TYPES, unaryOps.elu)], |
| 50 | + ['Exp', '', '6+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.exp)], |
| 51 | + ['Flatten', '', '1+', () => new CpuFlatten()], |
| 52 | + ['Floor', '', '6+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.floor)], |
| 53 | + ['Gather', '', '1+', () => new CpuGather()], |
| 54 | + ['Gemm', '', '7+', () => new CpuGemm()], |
| 55 | + ['GlobalAveragePool', '', '1+', () => new CpuGlobalAveragePool()], |
| 56 | + ['GlobalMaxPool', '', '1+', () => new CpuGlobalMaxPool()], |
| 57 | + ['ImageScaler', '', '1+', () => new CpuImageScaler()], |
| 58 | + ['InstanceNormalization', '', '6+', () => new CpuInstanceNormalization()], |
| 59 | + ['LeakyRelu', '', '6+', () => new unaryOps.CpuUnaryOp(FLOAT_TYPES, unaryOps.leakyRelu)], |
| 60 | + ['Log', '', '6+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.log)], |
| 61 | + ['LRN', '', '1+', () => new CpuLrn()], |
| 62 | + ['MatMul', '', '1+', () => new CpuMatMul()], |
| 63 | + ['MaxPool', '', '1+', () => new CpuMaxPool()], // TODO: support new attributes for MaxPool-8 and MaxPool-10 |
| 64 | + ['Mul', '', '7+', () => new CpuBinaryOp(NUMBER_TYPES, (e1, e2) => (e1 * e2))], |
| 65 | + ['Neg', '', '6+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.neg)], |
| 66 | + ['Or', '', '7+', () => new CpuBinaryOp(['bool'], (e1, e2) => (e1 || e2))], |
| 67 | + ['PRelu', '', '7+', () => new CpuBinaryOp(NUMBER_TYPES, (e1, e2) => (e1 >= 0 ? e1 : e1 * e2))], |
| 68 | + ['ReduceLogSum', '', '1+', () => new cpuReduce.CpuReduceLogSum()], |
| 69 | + ['ReduceMax', '', '1+', () => new cpuReduce.CpuReduceMax()], |
| 70 | + ['ReduceMean', '', '1+', () => new cpuReduce.CpuReduceMean()], |
| 71 | + ['ReduceMin', '', '1+', () => new cpuReduce.CpuReduceMin()], |
| 72 | + ['ReduceProd', '', '1+', () => new cpuReduce.CpuReduceProd()], |
| 73 | + ['ReduceSum', '', '1+', () => new cpuReduce.CpuReduceSum()], |
| 74 | + ['ReduceSumSquare', '', '1+', () => new cpuReduce.CpuReduceSumSquare()], |
| 75 | + ['Relu', '', '6+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.relu)], |
| 76 | + ['Reshape', '', '5+', () => new CpuReshape()], |
| 77 | + ['Sigmoid', '', '6+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.sigmoid)], |
| 78 | + ['Sin', '', '7+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.sin)], |
| 79 | + ['Slice', '', '1+', () => new CpuSlice()], |
| 80 | + ['Softmax', '', '1+', () => new CpuSoftmax()], |
| 81 | + ['Sqrt', '', '6+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.sqrt)], |
| 82 | + ['Squeeze', '', '1+', () => new CpuSqueeze()], |
| 83 | + ['Sub', '', '7+', () => new CpuBinaryOp(NUMBER_TYPES, (e1, e2) => (e1 - e2))], |
| 84 | + ['Sum', '', '6+', () => new CpuSum()], // TODO: support multidirectional broadcast for Sum-8 |
| 85 | + ['Tan', '', '7+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.tan)], |
| 86 | + ['Tanh', '', '6+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.tanh)], |
| 87 | + ['Tile', '', '6+', () => new CpuTile()], |
| 88 | + ['Transpose', '', '1+', () => new CpuTranspose()], |
| 89 | + ['Unsqueeze', '', '1+', () => new CpuUnsqueeze()], |
| 90 | + ['Xor', '', '7+', () => new CpuBinaryOp(['bool'], (e1, e2) => (e1 ^ e2))], |
| 91 | +]; |
0 commit comments