Majid Al-RaimiMACs, FLOPs and operationsعمليات MAC وFLOP والعمليات

COE 592Lecture 03المحاضرة 03Part 04الجزء 04

MACs, FLOPs and operationsعمليات MAC وFLOP والعمليات

Counting computation as multiply-accumulate operations for matrix products and each layer type, AlexNet's 724M MACs, and converting to FLOPs, FLOPS, OPs and OPS.عدّ الحساب بوصفه عمليات ضرب وتجميع (MAC) لضرب المصفوفات ولكل نوع من الطبقات، و724M عملية MAC في AlexNet، والتحويل إلى FLOPs وFLOPS وOPs وOPS.

Conceptsالمفاهيم
5
Slidesالشرائح
23-29
Readingمدة القراءة
30 min30 دقيقة
Understoodما فهمته
0/5 conceptsمفاهيم

Why this part mattersلماذا يهمّ هذا الجزء

Part 02 measured what a network stores and part 03 what it must hold in memory. This part measures what it must compute. That number is the numerator of computation time in the Latency model of slide 8, the figure every accelerator datasheet is quoted against, and the figure you will report for any model in the research project.

The counting unit is the multiply-accumulate, and everything else is bookkeeping on top of it: how many MACs a matrix product costs, how many each layer type costs, what AlexNet adds up to, and how the count becomes FLOPs, OPs and finally milliseconds on a specific chip. The surprise waiting at the centre of the part is that the layers holding almost all of AlexNet's weights do almost none of its arithmetic. Every exam question on efficiency metrics circles back to that inversion.

قاس الجزء 02 ما تخزّنه الشبكة، وقاس الجزء 03 ما يجب أن تحمله في الذاكرة. أما هذا الجزء فيقيس ما يجب أن تحسبه. هذا الرقم هو بسط زمن الحساب computation time في نموذج latency (زمن التأخير) في الشريحة 8، وهو الرقم الذي تُقاس عليه كل نشرة بيانات (datasheet) لأي مسرّع، والرقم الذي ستذكره لأي نموذج في مشروع البحث.

وحدة العدّ هي عملية الضرب والتجميع (multiply-accumulate)، وكل ما عداها حسابات مبنية فوقها: كم MAC يكلف ضرب المصفوفات، وكم يكلف كل نوع من الطبقات، وما مجموع AlexNet، وكيف يتحول العدد إلى FLOPs وOPs ثم إلى ملّي ثوانٍ على شريحة محددة. المفاجأة التي تنتظرك في قلب هذا الجزء أن الطبقات التي تحمل تقريبًا كل أوزان AlexNet لا تؤدي تقريبًا أي شيء من حساباته. كل سؤال امتحان عن مقاييس الكفاءة يعود إلى هذا الانقلاب.

By the end you canفي نهاية هذا الجزء ستستطيع

  1. Define a multiply-accumulate operation and count MACs for a matrix-vector product and a matrix-matrix product.تعرّف عملية الضرب والتجميع (multiply-accumulate) وتحسب عدد MACs لضرب مصفوفة في متجه ولضرب مصفوفة في مصفوفة.
  2. Fill the MACs table for linear, convolution, grouped and depthwise layers, and explain why conv MACs equal parameters times h_o·w_o.تملأ جدول MACs للطبقات الخطية والالتفافية والمجمّعة (grouped) والعمقية (depthwise)، وتشرح لماذا تساوي MACs الالتفاف عدد المعاملات مضروبًا في h_o·w_o.
  3. Reproduce AlexNet's 724M MACs layer by layer and explain why convolutions dominate compute while linear layers dominate parameters.تعيد حساب الـ 724M MACs في AlexNet طبقةً طبقة، وتشرح لماذا تهيمن طبقات الالتفاف على الحساب بينما تهيمن الطبقات الخطية على المعاملات.
  4. Convert MACs to FLOPs and OPs, and tell a count (FLOPs, OPs) apart from a rate (FLOPS, OPS).تحوّل MACs إلى FLOPs و OPs، وتميّز العدد (FLOPs و OPs) عن المعدل (FLOPS و OPS).
  5. Estimate T_computation for a model on a device from the model's OPs and the device's OPS.تقدّر T_computation لنموذج على جهاز معين من عدد OPs للنموذج ومن OPS للجهاز.

Start with one neuron that has four inputs. Its output before the activation function is w₁x₁ + w₂x₂ + w₃x₃ + w₄x₄. A processor evaluates that as four identical steps: multiply a weight by an input, add the product to a running total. Each step is one multiply-accumulate operation, and the whole of neural network inference is this step repeated a few hundred million times.

ابدأ بعصبون واحد له أربعة مدخلات. مخرجه قبل دالة التفعيل هو w₁x₁ + w₂x₂ + w₃x₃ + w₄x₄. يحسب المعالج ذلك في أربع خطوات متطابقة: اضرب وزنًا في مدخل، ثم أضف الناتج إلى مجموع جارٍ. كل خطوة هي عملية ضرب وتجميع واحدة (multiply-accumulate operation)، والاستدلال (inference) في الشبكة العصبية بأكمله هو هذه الخطوة مكررة بضع مئات من ملايين المرات.

a←a+b⋅ca \leftarrow a + b \cdot c
One MAC: multiply b by c and accumulate into aعملية MAC واحدة: اضرب b في c وراكم الناتج في a

The definition is standard well beyond this course. The Wikipedia entry on the multiply-accumulate operation gives exactly a ← a + (b × c), and notes that IEEE 754-2008 defines a fused multiply-add that performs the whole step with a single rounding. Sze, Chen, Yang and Emer call the MAC "the fundamental component" of DNN processing in their survey of efficient DNN hardware. Counting MACs is therefore counting what the hardware executes, not an abstraction layered over it.

هذا التعريف معتمد على نطاق أوسع بكثير من هذا المقرر. مدخل ويكيبيديا عن عملية الضرب والتجميع يعطي بالضبط a ← a + (b × c)، ويذكر أن IEEE 754-2008 يعرّف عملية ضرب وجمع مدمجة (fused multiply-add) تنفّذ الخطوة كلها بتقريب واحد فقط. ويصف Sze وChen وYang وEmer عملية MAC بأنها "المكوّن الأساسي" (the fundamental component) لمعالجة الشبكات العصبية العميقة (DNN) في مسحهم لعتاد DNN الكفء. لذلك فإن عدّ MACs هو عدّ لما ينفّذه العتاد فعلًا، وليس تجريدًا مبنيًا فوقه.

From one neuron to a matrix-vector productمن عصبون واحد إلى ضرب مصفوفة في متجه

A layer of m neurons that each read the same n inputs is a matrix-vector multiplication: an m × n weight matrix times an n-vector. Each of the m outputs needs n MACs, one per weight in its row, so the product costs m · n MACs. Notice that this is also the number of weights. In a matrix-vector product, every weight is touched exactly once.

طبقة من m عصبون يقرأ كل منها المدخلات نفسها البالغ عددها n هي ضرب مصفوفة في متجه (matrix-vector multiplication): مصفوفة أوزان حجمها m × n مضروبة في متجه طوله n. كل مخرج من المخرجات الـ m يحتاج n من MACs، واحدة لكل وزن في صفه، لذا يكلف الضرب m · n من MACs. لاحظ أن هذا هو أيضًا عدد الأوزان. في ضرب مصفوفة في متجه، يُستخدم كل وزن مرة واحدة بالضبط.

Feed the layer a batch of inputs at once and the vector becomes a matrix. The slide renames the dimensions here: the input count becomes k and the letter n is reused for the batch, the number of columns of B. The result is a general matrix-matrix multiplication: A of size m × k times B of size k × n gives C of size m × n. Every one of the m · n cells of C is a dot product over the shared dimension k, so it costs k MACs, and the whole product costs m · n · k.

إذا أدخلت إلى الطبقة دفعة (batch) من المدخلات مرة واحدة يصبح المتجه مصفوفة. هنا تعيد الشريحة تسمية الأبعاد: عدد المدخلات يصبح k، ويُعاد استخدام الحرف n للدفعة، أي عدد أعمدة B. الناتج هو الضرب العام لمصفوفة في مصفوفة (general matrix-matrix multiplication): A بحجم m × k مضروبة في B بحجم k × n تعطي C بحجم m × n. كل خلية من خلايا C البالغ عددها m · n هي ضرب نقطي (dot product) على البعد المشترك k، فتكلف k من MACs، ويكلف الضرب كله m · n · k.

MACsMV=m⋅nMACsGEMM=m⋅n⋅k\text{MACs}_{MV} = m \cdot n \qquad \text{MACs}_{GEMM} = m \cdot n \cdot k
Rows times columns for a vector, rows times columns times the shared dimension for a matrixالصفوف في الأعمدة للمتجه، والصفوف في الأعمدة في البعد المشترك للمصفوفة
Each cell of C is one dot product over the shared dimension: k pairs, k MACs. There are m × n such cells.كل خلية في C هي ضرب نقطي واحد على البعد المشترك: k من الأزواج، أي k من MACs. وهناك m × n خلية من هذا النوع.

Dimensions used in the GEMM countالأبعاد المستخدمة في عدّ GEMM

m
Rows of A and of C: the number of outputs (neurons)صفوف A وصفوف C: عدد المخرجات (العصبونات)
k
Columns of A and rows of B: the shared dimension summed over, the number of inputs per neuronأعمدة A وصفوف B: البعد المشترك الذي يُجمع عليه، أي عدد المدخلات لكل عصبون
n
Columns of B and of C: the number of input vectors, the batchأعمدة B وأعمدة C: عدد متجهات المدخل، أي الدفعة (batch)

Why a whole network reduces to thisلماذا تُختزل الشبكة كلها إلى هذا

A Linear layer is literally a matrix-vector product at batch size one and a GEMM for a batch. Convolution looks different but is executed the same way: frameworks reorder the input patches into columns (the im2col trick described in the CS231n notes) so that a convolution becomes one large GEMM, and the MobileNets paper points out that this is why convolutions can ride on "highly optimized general matrix multiply (GEMM) functions". NVIDIA's performance guide states the cost of a GEMM as 2 · M · N · K floating point operations because "each FMA is 2 operations, a multiply and an add", which previews the FLOP conversion at the end of this part. Once you can count MACs for a matrix product, you can count them for every layer.

الطبقة الخطية (linear layer) هي حرفيًا ضرب مصفوفة في متجه عندما يكون حجم الدفعة (batch size) واحدًا، وهي GEMM عند وجود دفعة. الالتفاف يبدو مختلفًا لكنه يُنفّذ بالطريقة نفسها: تعيد أطر العمل ترتيب رقع المدخل (patches) في أعمدة (حيلة im2col الموصوفة في ملاحظات CS231n) فيصبح الالتفاف عملية GEMM واحدة كبيرة، وتشير ورقة MobileNets إلى أن هذا هو سبب قدرة الالتفاف على الاعتماد على "دوال ضرب المصفوفات العامة (GEMM) المحسّنة للغاية". ويذكر دليل الأداء من NVIDIA أن كلفة GEMM هي 2 · M · N · K عملية فاصلة عائمة لأن "كل FMA عبارة عن عمليتين، ضرب وجمع"، وهذا تمهيد لتحويل FLOP في آخر هذا الجزء. بمجرد أن تستطيع عدّ MACs لضرب المصفوفات، تستطيع عدّها لكل طبقة.

Recall

Write the MAC operation, and state how many MACs an m × n matrix times an n-vector costs.اكتب عملية MAC، واذكر كم MAC يكلف ضرب مصفوفة m × n في متجه طوله n.

a ← a + b · c. The product costs m · n MACs, one for every weight in the matrix.
a ← a + b · c. يكلف الضرب m · n من MACs، واحدة لكل وزن في المصفوفة.

Take the first layer of AlexNet. One filter spans all 3 input channels with an 11 × 11 window, so it holds 3 × 11 × 11 = 363 weights. Producing a single output pixel is one dot product of those 363 weights against a patch of the image: 363 MACs. But the filter does not produce one pixel. It slides to every one of the 55 × 55 = 3,025 output positions, and there are 96 filters. So the layer costs 363 × 3,025 × 96 = 105,415,200 MACs from only 34,848 weights.

خذ الطبقة الأولى من AlexNet. يمتد المرشح (filter) الواحد على قنوات المدخل الـ 3 كلها بنافذة 11 × 11، فيحمل 3 × 11 × 11 = 363 وزنًا. إنتاج بكسل واحد في المخرج هو ضرب نقطي واحد لهذه الأوزان الـ 363 مع رقعة من الصورة: 363 من MACs. لكن المرشح لا ينتج بكسلًا واحدًا، بل ينزلق إلى كل موضع من مواضع المخرج البالغة 55 × 55 = 3,025، وهناك 96 مرشحًا. لذا تكلف الطبقة 363 × 3,025 × 96 = 105,415,200 من MACs انطلاقًا من 34,848 وزنًا فقط.

That example contains the whole rule. In a convolution layer every weight is applied once per output position, so the MAC count is the parameter count from part 02 multiplied by the output height and width:

هذا المثال يحتوي القاعدة كلها. في طبقة الالتفاف (convolution layer) يُطبَّق كل وزن مرة واحدة لكل موضع في المخرج، لذا فإن عدد MACs هو عدد المعاملات (parameter count) من الجزء 02 مضروبًا في ارتفاع المخرج وعرضه (output height and width):

MACsconv=co⋅ci⋅kh⋅kw⏟parameters⋅ho⋅wo\text{MACs}_{conv} = \underbrace{c_o \cdot c_i \cdot k_h \cdot k_w}_{\text{parameters}} \cdot h_o \cdot w_o
Parameters times output positions, at batch size n = 1 and ignoring biasالمعاملات مضروبة في مواضع المخرج، بحجم دفعة n = 1 ومع تجاهل الانحياز
Nine weights stamped onto twenty-five output positions: 225 MACs from 9 parameters. The filter is reused, never copied.تسعة أوزان تُطبع على خمسة وعشرين موضعًا في المخرج: 225 من MACs انطلاقًا من 9 معاملات. المرشح يُعاد استخدامه ولا يُنسخ أبدًا.

The other rows of the slide's table follow from the same idea. A Linear layer has h_o = w_o = 1, so its MACs equal its parameters, c_o · c_i. A Grouped convolution splits the channels into g groups, so each filter sees only c_i / g input channels and both parameters and MACs are divided by g. A Depthwise convolution is the extreme case g = c_i = c_o: each filter sees exactly one channel, so c_i disappears from the formula entirely and only c_o · k_h · k_w weights remain, each still applied h_o · w_o times.

بقية صفوف جدول الشريحة تنتج من الفكرة نفسها. الطبقة الخطية (linear layer) لها h_o = w_o = 1، لذا فإن MACs فيها تساوي معاملاتها، c_o · c_i. والالتفاف المجمّع (grouped convolution) يقسم القنوات إلى g groups (أي g من المجموعات)، فلا يرى كل مرشح إلا c_i / g من قنوات المدخل، وتُقسم المعاملات وMACs كلاهما على g. أما الالتفاف العمقي (depthwise convolution) فهو الحالة القصوى g = c_i = c_o: كل مرشح يرى قناة واحدة بالضبط، فيختفي c_i من الصيغة تمامًا ولا يبقى إلا c_o · k_h · k_w وزنًا، كل منها لا يزال يُطبَّق h_o · w_o مرة.

LayerالطبقةParametersالمعاملاتMACsMACsMACs per parameterMACs لكل معامل
Linearخطية (Linear)c_o · c_ic_o · c_ic_o · c_ic_o · c_i11
Convolutionالتفاف (Convolution)c_o · c_i · k_h · k_wc_o · c_i · k_h · k_wc_o · c_i · k_h · k_w · h_o · w_oc_o · c_i · k_h · k_w · h_o · w_oh_o · w_oh_o · w_o
Grouped convolutionالتفاف مجمّع (Grouped convolution)c_o · c_i · k_h · k_w / gc_o · c_i · k_h · k_w / gc_o · c_i · k_h · k_w · h_o · w_o / gc_o · c_i · k_h · k_w · h_o · w_o / gh_o · w_oh_o · w_o
Depthwise convolutionالتفاف عمقي (Depthwise convolution)c_o · k_h · k_wc_o · k_h · k_wc_o · k_h · k_w · h_o · w_oc_o · k_h · k_w · h_o · w_oh_o · w_oh_o · w_o
Parameters and MACs per layer type (batch size n = 1, bias ignored)المعاملات و MACs لكل نوع من الطبقات (حجم الدفعة n = 1، مع إهمال الانحياز)

How a convolution slides, how padding and stride set the output size, and how groups partition channels were covered in lecture 02, part 02 and part 03. This part only counts, and it takes the kernel size and output shape of each layer as given.

كيف ينزلق الالتفاف، وكيف يحدد الحشو (padding) والخطوة (stride) حجم المخرج، وكيف تقسّم المجموعات القنوات، كل ذلك شُرح في المحاضرة 02، الجزء 02 والجزء 03. هذا الجزء يكتفي بالعدّ، ويأخذ حجم النواة (kernel size) وشكل المخرج لكل طبقة كمعطيات.

Why this mirrors part 02لماذا يعكس هذا الجزء صورة الجزء 02

Goodfellow, Bengio and Courville explain parameter sharing in one sentence that is the whole story of this part: sharing "does not affect the runtime of forward propagation, it is still O(k × n), but it does further reduce the storage requirements of the model to k parameters". Convolution saves storage by reusing weights, and reusing weights is exactly what makes the arithmetic grow. That is why parts 02 and 04 are mirror images. The layers cheapest to store are the most expensive to run.

يشرح Goodfellow وBengio وCourville مشاركة المعاملات (parameter sharing) في جملة واحدة هي قصة هذا الجزء كلها: المشاركة "لا تؤثر في زمن تشغيل الانتشار الأمامي، فهو لا يزال O(k × n)، لكنها تقلل أكثر متطلبات تخزين النموذج إلى k من المعاملات". الالتفاف يوفّر التخزين بإعادة استخدام الأوزان، وإعادة استخدام الأوزان هي بالضبط ما يجعل الحسابات تكبر. لهذا فإن الجزأين 02 و04 صورتان متعاكستان. الطبقات الأرخص تخزينًا هي الأغلى تشغيلًا.

Worked example: the MobileNet block that makes depthwise worth itمثال محلول: كتلة MobileNet التي تجعل الالتفاف العمقي (depthwise) مجديًا

The MobileNets paper replaces one standard 3 × 3 convolution with a depthwise 3 × 3 followed by a pointwise 1 × 1. Its equations 4 and 5 give the depthwise and separable costs, and dividing by the standard cost gives the ratio 1 / N + 1 / D_K², where N is the number of output channels and D_K the kernel size. The formulas in the table let you reproduce that with real numbers.

تستبدل ورقة MobileNets التفافًا قياسيًا واحدًا 3 × 3 بالتفاف عمقي 3 × 3 يتبعه التفاف نقطي (pointwise) 1 × 1. معادلتاها 4 و5 تعطيان كلفة الالتفاف العمقي وكلفة الالتفاف المنفصل (separable)، والقسمة على كلفة الالتفاف القياسي تعطي النسبة 1 / N + 1 / D_K²، حيث N عدد قنوات المخرج وD_K حجم النواة. الصيغ في الجدول تتيح لك إعادة إنتاج ذلك بأرقام حقيقية.

Worked exampleمثال محلول

Standard versus depthwise separable at 112 × 112, 32 to 64 channelsالالتفاف القياسي مقابل الالتفاف العمقي المنفصل عند 112 × 112، من 32 إلى 64 قناة

  1. Standard 3 × 3 convolutionالتفاف قياسي 3 × 3

    64 × 32 × 3 × 3 × 112 × 112 = 231,211,008 MACs.
    64 × 32 × 3 × 3 × 112 × 112 = 231,211,008 من MACs.
  2. Depthwise 3 × 3التفاف عمقي 3 × 3

    32 × 3 × 3 × 112 × 112 = 3,612,672 MACs. No c_i factor.
    32 × 3 × 3 × 112 × 112 = 3,612,672 من MACs. لا يوجد عامل c_i.
  3. Pointwise 1 × 1التفاف نقطي 1 × 1

    64 × 32 × 1 × 1 × 112 × 112 = 25,690,112 MACs. A convolution with k = 1.
    64 × 32 × 1 × 1 × 112 × 112 = 25,690,112 من MACs. إنه التفاف فيه k = 1.
  4. Ratioالنسبة

    (3,612,672 + 25,690,112) / 231,211,008 = 0.1267, and 1 / 64 + 1 / 9 = 0.1267.
    (3,612,672 + 25,690,112) / 231,211,008 = 0.1267، و1 / 64 + 1 / 9 = 0.1267.
  5. Resultالنتيجة

    About 7.9× fewer MACs at 64 output channels, approaching the paper's "between 8 to 9 times less computation" as the channel count grows and the 1 / D_K² = 1 / 9 pointwise term is all that remains.
    عدد MACs أقل بنحو 7.9× عند 64 قناة مخرج، ويقترب من عبارة الورقة "حساب أقل بما بين 8 و9 مرات" كلما زاد عدد القنوات ولم يبق إلا حد الالتفاف النقطي 1 / D_K² = 1 / 9.

The calculator below lets you scrub every symbol in the table. Its FLOPs, OPs and hardware rows are explained in the last concept of this part; for now watch how parameters and MACs move apart as the output size grows.

تتيح لك الحاسبة أدناه تحريك كل رمز في الجدول. صفوف FLOPs وOPs والعتاد فيها تُشرح في المفهوم الأخير من هذا الجزء؛ أما الآن فراقب كيف يتباعد عدد المعاملات وعدد MACs كلما كبر حجم المخرج.

SimulatorمحاكيLayer compute calculator: MACs, FLOPs and computation timeحاسبة حوسبة الطبقة: MACs وFLOPs وزمن الحساب
Layer presetsإعدادات الطبقة المسبقة
k_h = k_wKernel sizeحجم النواة
Parameters34,848weightsc_o · c_i · k_h · k_w
MACsMACs105,415,200(105.42 M)parameters × h_o × w_o = parameters × 3,025
MACs per parameter3,025uses per weightequal to h_o × w_oيساوي h_o × w_o
FLOPs210.83 MFLOPs2 × MACs: one multiply and one add2 × MACs: عملية ضرب واحدة وعملية جمع واحدة
OPs210.83 MOPssame count for integer weights and activationsالعدد نفسه للأوزان والتنشيطات الصحيحة
Share of AlexNet14.6% of 724M MACsthis one layer against the whole networkهذه الطبقة وحدها مقارنةً بالشبكة كلها
Hardware: processor throughputالعتاد: إنتاجية المعالج100.0 GOPS
10^11.0 OPS

illustrative mobile GPU-class figureرقم توضيحي بمستوى معالجات GPU المحمولة

T computation2.11msOPs of the layer ÷ OPS of the processorOPs الطبقة ÷ OPS المعالج
Reading210.83 MOPs ÷ 100.0 GOPSthe numerator is a count, the denominator a rateالبسط عدد، والمقام معدل

Drag h_o = w_o and watch MACs climb while parameters stay put: a convolution reuses every weight at every output position. Switch to linear and the two counts collapse into one. The hardware box only divides: the same layer takes 1000× longer at 1 GFLOPS than at 1 TFLOPS, and marketing peak TOPS are rarely sustained, so treat the time as a floor.اسحب h_o = w_o وراقب ارتفاع MACs بينما تبقى المعاملات ثابتة: فالالتفاف يعيد استخدام كل وزن عند كل موضع في المُخرج. انتقل إلى الطبقة الخطية فيندمج العددان في عدد واحد. صندوق العتاد يقسم فقط: الطبقة نفسها تستغرق وقتًا أطول بمقدار 1000× عند 1 GFLOPSمقارنةً بـ1 TFLOPS، وقيم TOPS التسويقية القصوى نادرًا ما تتحقق باستمرار، فتعامل مع الزمن على أنه حد أدنى.

Quick checkاختبار سريع

A grouped convolution has c_i = 96, c_o = 256, a 5 × 5 kernel, a 27 × 27 output and g = 2. How many MACs does it perform?التفاف مجمّع فيه c_i = 96 و c_o = 256، ونواة 5 × 5، ومخرج 27 × 27، و g = 2. كم عدد MACs التي ينفّذها؟

Recall

A grouped convolution has 384 filters over 384 input channels, a 3 × 3 kernel, a 13 × 13 output and g = 2. How many MACs, how many parameters, and what is their ratio?التفاف مجمّع فيه 384 مرشحًا على 384 قناة مدخل، ونواة 3 × 3، ومخرج 13 × 13، و g = 2. كم عدد MACs، وكم عدد المعاملات، وما النسبة بينهما؟

MACs: 384 · 384 · 9 · 169 / 2 = 112,140,288. Parameters: 384 · 384 · 9 / 2 = 663,552. The ratio is 169 = 13 × 13, one use of each weight per output position. This is AlexNet conv4.
MACs: 384 · 384 · 9 · 169 / 2 = 112,140,288. المعاملات: 384 · 384 · 9 / 2 = 663,552. النسبة هي 169 = 13 × 13، أي استخدام واحد لكل وزن لكل موضع في المخرج. هذه هي conv4 في AlexNet.

Slide 25 hands you the eight weighted layers of AlexNet with their output shapes and an empty MACs column. Slide 26 fills it in, except for one layer hidden behind a question mark. Work through the column yourself before you read the answers. Every entry is the formula from the previous concept with the layer's numbers substituted, and the pooling layers contribute nothing because they hold no weights.

تعطيك الشريحة 25 الطبقات الثماني ذات الأوزان في AlexNet مع أشكال مخرجاتها وعمود MACs فارغ. وتملؤه الشريحة 26، باستثناء طبقة واحدة مخفية خلف علامة استفهام. احسب العمود بنفسك قبل أن تقرأ الإجابات. كل خانة هي الصيغة من المفهوم السابق بعد التعويض بأرقام الطبقة، وطبقات التجميع (pooling) لا تضيف شيئًا لأنها لا تحمل أوزانًا.

Worked exampleمثال محلول

AlexNet, layer by layer (batch size 1, bias ignored)AlexNet طبقةً طبقة (حجم الدفعة 1، مع إهمال الانحياز)

  1. conv1: 11 × 11, 3 to 96 channels, output 55 × 55conv1: نواة 11 × 11، من 3 إلى 96 قناة، المخرج 55 × 55

    96 × 3 × 11 × 11 × 55 × 55 = 105,415,200
    96 × 3 × 11 × 11 × 55 × 55 = 105,415,200
  2. conv2: 5 × 5, 96 to 256 channels, groups 2, output 27 × 27conv2: نواة 5 × 5، من 96 إلى 256 قناة، مجموعتان، المخرج 27 × 27

    256 × 96 × 5 × 5 × 27 × 27 / 2 = 223,948,800. Without the groups it would be 447,897,600; g = 2 halves it.
    256 × 96 × 5 × 5 × 27 × 27 / 2 = 223,948,800. بدون المجموعات سيكون العدد 447,897,600؛ وg = 2 ينصّفه.
  3. conv3: 3 × 3, 256 to 384 channels, output 13 × 13conv3: نواة 3 × 3، من 256 إلى 384 قناة، المخرج 13 × 13

    384 × 256 × 3 × 3 × 13 × 13 = 149,520,384
    384 × 256 × 3 × 3 × 13 × 13 = 149,520,384
  4. conv4: 3 × 3, 384 to 384 channels, groups 2, output 13 × 13conv4: نواة 3 × 3، من 384 إلى 384 قناة، مجموعتان، المخرج 13 × 13

    384 × 384 × 3 × 3 × 13 × 13 / 2 = 112,140,288
    384 × 384 × 3 × 3 × 13 × 13 / 2 = 112,140,288
  5. conv5: 3 × 3, 384 to 256 channels, groups 2, output 13 × 13conv5: نواة 3 × 3، من 384 إلى 256 قناة، مجموعتان، المخرج 13 × 13

    This is the entry the slide hides. Compute it before revealing.

    Recall

    conv5 MACs?كم عدد MACs في conv5؟

    256 × 384 × 3 × 3 × 13 × 13 / 2 = 74,760,192
    256 × 384 × 3 × 3 × 13 × 13 / 2 = 74,760,192
    هذه هي الخانة التي تخفيها الشريحة. احسبها قبل كشف الإجابة.

    Recall

    conv5 MACs?كم عدد MACs في conv5؟

    256 × 384 × 3 × 3 × 13 × 13 / 2 = 74,760,192
    256 × 384 × 3 × 3 × 13 × 13 / 2 = 74,760,192
  6. fc6: 256 × 6 × 6 = 9,216 inputs to 4,096 outputsfc6: من 256 × 6 × 6 = 9,216 مدخلًا إلى 4,096 مخرجًا

    4,096 × 9,216 = 37,748,736. The flattened pooling output is the input vector.
    4,096 × 9,216 = 37,748,736. مخرج طبقة التجميع بعد تسطيحه (flatten) هو متجه المدخل.
  7. fc7: 4,096 to 4,096fc7: من 4,096 إلى 4,096

    4,096 × 4,096 = 16,777,216
    4,096 × 4,096 = 16,777,216
  8. fc8: 4,096 to 1,000 classesfc8: من 4,096 إلى 1,000 فئة

    1,000 × 4,096 = 4,096,000
    1,000 × 4,096 = 4,096,000
  9. Totalالمجموع

    724,406,816 MACs, the slide's "724M in total". Sze et al. list the same figure, 724M MACs and 61M weights, in their survey table.
    724,406,816 من MACs، وهو "724M في المجموع" في الشريحة. ويذكر Sze وزملاؤه الرقم نفسه، 724M من MACs و61M من الأوزان، في جدول مسحهم.

Put the parameters next to the MACsضع المعاملات بجانب MACs

The total is not the interesting number. The interesting number appears when you place the parameter counts from part 02 beside the MACs and add a column for their ratio, which by the previous concept is just h_o · w_o.

المجموع ليس الرقم المثير للاهتمام. الرقم المثير يظهر عندما تضع أعداد المعاملات من الجزء 02 بجانب MACs وتضيف عمودًا للنسبة بينهما، وهي بحسب المفهوم السابق مجرد h_o · w_o.

LayerالطبقةShapeالشكلParametersالمعاملاتMACsMACsMACs per parameterMACs لكل معامل
conv1conv196 × 3 × 11 × 11, out 55 × 5596 × 3 × 11 × 11، المخرج 55 × 5534,84834,848105,415,200105,415,2003,0253,025
conv2conv2256 × 96 × 5 × 5 / 2, out 27 × 27256 × 96 × 5 × 5 / 2، المخرج 27 × 27307,200307,200223,948,800223,948,800729729
conv3conv3384 × 256 × 3 × 3, out 13 × 13384 × 256 × 3 × 3، المخرج 13 × 13884,736884,736149,520,384149,520,384169169
conv4conv4384 × 384 × 3 × 3 / 2, out 13 × 13384 × 384 × 3 × 3 / 2، المخرج 13 × 13663,552663,552112,140,288112,140,288169169
conv5conv5256 × 384 × 3 × 3 / 2, out 13 × 13256 × 384 × 3 × 3 / 2، المخرج 13 × 13442,368442,36874,760,19274,760,192169169
fc6fc64096 × (256 × 6 × 6)4096 × (256 × 6 × 6)37,748,73637,748,73637,748,73637,748,73611
fc7fc74096 × 40964096 × 409616,777,21616,777,21616,777,21616,777,21611
fc8fc81000 × 40961000 × 40964,096,0004,096,0004,096,0004,096,00011
conv1 to conv5من conv1 إلى conv5five convolutionsخمس طبقات التفاف2,332,704 (3.8%)2,332,704 (3.8%)665,784,864 (91.9%)665,784,864 (91.9%)
fc6 to fc8من fc6 إلى fc8three linear layersثلاث طبقات خطية58,621,952 (96.2%)58,621,952 (96.2%)58,621,952 (8.1%)58,621,952 (8.1%)
Totalالمجموعeight weighted layersثماني طبقات ذات أوزان60,954,65660,954,656724,406,816724,406,816
AlexNet: parameters and MACs per layerAlexNet: المعاملات و MACs لكل طبقة
The last column of the table, drawn. Each layer's slice of the MAC bar is its slice of the parameter bar stretched by h_o · w_o: conv1 grows 3,025 times, the linear layers not at all, so the convolution segments take over the lower bar.العمود الأخير من الجدول مرسومًا. نصيب كل طبقة من شريط MACs هو نصيبها من شريط المعاملات بعد مطّه بمقدار h_o · w_o: تكبر conv1 بمقدار 3,025 مرة، ولا تكبر الطبقات الخطية إطلاقًا، فتستولي مقاطع الالتفاف على الشريط السفلي.

The five convolutions hold 2,332,704 parameters, under 4% of the network, yet perform 665,784,864 MACs, 92% of the compute. The three linear layers hold 58,621,952 parameters, 96% of the network, yet perform only 58,621,952 MACs, 8% of the compute. The last column explains it: each conv1 weight is used 3,025 times, each conv3 to conv5 weight 169 times, each linear weight once. Large spatial maps early in the network make convolution compute heavy. Large c_i · c_o products late in the network make the linear layers parameter heavy.

الالتفافات الخمسة تحمل 2,332,704 من المعاملات، أي أقل من 4% من الشبكة، ومع ذلك تنفّذ 665,784,864 من MACs، أي 92% من الحساب. والطبقات الخطية الثلاث تحمل 58,621,952 من المعاملات، أي 96% من الشبكة، ومع ذلك لا تنفّذ إلا 58,621,952 من MACs، أي 8% من الحساب. العمود الأخير يفسّر ذلك: كل وزن في conv1 يُستخدم 3,025 مرة، وكل وزن في conv3 إلى conv5 يُستخدم 169 مرة، وكل وزن خطي مرة واحدة. الخرائط المكانية الكبيرة في بداية الشبكة تجعل الالتفاف ثقيلًا في الحساب. وحواصل الضرب الكبيرة c_i · c_o في نهاية الشبكة تجعل الطبقات الخطية ثقيلة في المعاملات.

InteractiveتفاعليWhere AlexNet spends parameters versus computeأين ينفق AlexNet المعاملات مقابل الحوسبة
total 60,954,656 weightsالمجموع 60,954,656 وزن
fc6fc7fc8
conv1 to conv5conv1 إلى conv53.8%2.3M
fc6 to fc8fc6 إلى fc896.2%58.6M

Flip the toggle and watch which single layer is largest. Under parameters it is fc6, about 62% of the network on its own. Under MACs it is conv2, about 31%, while conv1, invisible on the parameter bar at 0.06%, grows to 15% because its 34,848 weights each fire 3,025 times. Each layer's exact count is listed below the bar.بدّل المفتاح وراقب أي طبقة منفردة هي الأكبر. عند قياس المعاملات تكون fc6، وحدها نحو 62% من الشبكة. وعند قياس MACsتكون conv2، نحو 31%، بينما conv1 التي لا تكاد تظهر على شريط المعاملات عند 0.06% تكبر إلى 15%لأن كل وزن من أوزانها البالغة 34,848 يُستخدم 3,025 مرة. العدد الدقيق لكل طبقة مُدرج تحت الشريط.

  • conv134,848 (0.1%)
  • conv2307,200 (0.5%)
  • conv3884,736 (1.5%)
  • conv4663,552 (1.1%)
  • conv5442,368 (0.7%)
  • fc637,748,736 (61.9%)
  • fc716,777,216 (27.5%)
  • fc84,096,000 (6.7%)

What this means for making a model fasterماذا يعني هذا لجعل النموذج أسرع

The inversion sets the strategy for the rest of the course. Pruning or quantizing the linear layers shrinks Model size dramatically, because that is where the weights are, but it barely changes the MAC count and therefore barely changes computation time. To make inference faster you must attack the convolutions: fewer channels, grouped or depthwise filters as in MobileNet, or a lower input resolution so that h_o · w_o shrinks in every layer at once. The pruning lecture that follows will keep returning to this table, and when you profile a model for the research project, report both columns, not one.

هذا الانقلاب يحدد الاستراتيجية لبقية المقرر. التقليم (pruning) أو التكميم (quantization) للطبقات الخطية يقلّص حجم النموذج (model size) بشكل كبير، لأن الأوزان موجودة هناك، لكنه بالكاد يغيّر عدد MACs، وبالتالي بالكاد يغيّر زمن الحساب (computation time). لجعل الاستدلال أسرع يجب أن تستهدف الالتفافات: قنوات أقل، أو مرشحات مجمّعة أو عمقية كما في MobileNet، أو دقة مدخل أقل بحيث يصغر h_o · w_o في كل الطبقات دفعة واحدة. محاضرة التقليم التالية ستعود إلى هذا الجدول مرارًا، وعندما تحلّل نموذجًا في مشروع البحث، اذكر العمودين معًا لا عمودًا واحدًا.

Quick checkاختبار سريع

Pruning removes 90 percent of the weights in AlexNet's fc6 and fc7. Roughly how much does the network's total MAC count fall?يزيل التقليم 90 بالمئة من الأوزان في fc6 و fc7 من AlexNet. بكم ينخفض تقريبًا العدد الكلي لـ MACs في الشبكة؟

Recall

Which AlexNet layer family holds most of the parameters, which performs most of the MACs, and why?أي عائلة طبقات في AlexNet تحمل معظم المعاملات، وأيها تنفّذ معظم MACs، ولماذا؟

The linear layers hold about 96% of the 61M parameters. The convolutions perform about 92% of the 724M MACs. Convolution MACs equal parameters times h_o · w_o, which is 3,025 for conv1 and 1 for every linear layer.
الطبقات الخطية تحمل نحو 96% من المعاملات البالغة 61M. والالتفافات تنفّذ نحو 92% من MACs البالغة 724M. MACs الالتفاف تساوي المعاملات مضروبة في h_o · w_o، وهو 3,025 في conv1 و1 في كل طبقة خطية.

A MAC hides two arithmetic operations: a multiply and an add. When each is counted as one floating point operation, one MAC is two FLOPs, and AlexNet's 724,406,816 MACs become 1,448,813,632 FLOPs. The slide rounds that to 1.4G; the exact figure is 1.449G, and showing the factor of two matters more than the rounding.

تخفي عملية MAC عمليتين حسابيتين: ضربًا وجمعًا. عندما تُعدّ كل منهما عملية فاصلة عائمة (floating point operation) واحدة، تصبح عملية MAC الواحدة اثنتين من FLOPs، وتصبح MACs في AlexNet البالغة 724,406,816 عددًا قدره 1,448,813,632 من FLOPs. تقرّب الشريحة ذلك إلى 1.4G؛ والرقم الدقيق 1.449G، وإظهار معامل الاثنين أهم من التقريب.

FLOPs=2⋅MACs\text{FLOPs} = 2 \cdot \text{MACs}
One multiply plus one add per MACضرب واحد وجمع واحد لكل MAC

The count on its own says nothing about time. To get time you need to know how fast a processor can drain it, and that is a different quantity with an almost identical name. FLOPS, with a capital S, is floating point operations per second: a throughput that belongs to the hardware. FLOPs, with a lowercase s, is a plural count that belongs to the model. TOP500 ranks supercomputers by exactly this rate, reporting Linpack results as Rmax and Rpeak in Flop/s, and NVIDIA's GPU performance background guide writes the time a math-limited kernel takes as its number of operations divided by the processor's math bandwidth, which is FLOPs over FLOPS.

العدد وحده لا يقول شيئًا عن الزمن. لتحصل على الزمن تحتاج أن تعرف مدى سرعة المعالج في استهلاكه، وهذه كمية مختلفة باسم شبه مطابق. FLOPS، بحرف S كبير، هي عدد عمليات الفاصلة العائمة في الثانية: معدل إنتاجية (throughput) يخص العتاد. أما FLOPs، بحرف s صغير، فهي عدد بصيغة الجمع يخص النموذج. تصنّف قائمة TOP500 الحواسيب الفائقة بهذا المعدل بالضبط، إذ تذكر نتائج Linpack على شكل Rmax وRpeak بوحدة Flop/s، ويكتب دليل خلفية أداء وحدات GPU من NVIDIA زمن النواة (kernel) المحدودة بالحساب على أنه عدد عملياتها مقسومًا على عرض النطاق الحسابي للمعالج، أي FLOPs على FLOPS.

FLOPS=FLOPssecondTcomputation=FLOPs of the modelFLOPS of the processor\text{FLOPS} = \frac{\text{FLOPs}}{\text{second}} \qquad T_{computation} = \frac{\text{FLOPs of the model}}{\text{FLOPS of the processor}}
A rate is a count per second; dividing a count by a rate gives a timeالمعدل عدد في الثانية؛ وقسمة العدد على المعدل تعطي زمنًا
The hopper holds a count, the pipe drains at a rate, and the clock reads the quotient: 1.449 G FLOPs through 100 GFLOPS takes 14.5 ms.القمع يحمل عددًا، والأنبوب يُفرغه بمعدل، والساعة تقرأ خارج القسمة: 1.449 G FLOPs عبر 100 GFLOPS تستغرق 14.5 ms.

This is the computation time term of the latency model on slide 8, where the numerator is a network specification and the denominator a hardware specification. Run AlexNet's count through a few devices and the scale of the answer changes by orders of magnitude while the model does not change at all.

هذا هو حد زمن الحساب (computation time) في نموذج التأخير في الشريحة 8، حيث البسط هو مواصفة الشبكة (network specification) والمقام مواصفة العتاد. مرّر عدد AlexNet عبر عدة أجهزة وسترى أن مقياس الإجابة يتغير بعدة مراتب عشرية بينما لا يتغير النموذج إطلاقًا.

ProcessorالمعالجCount ÷ rateالعدد ÷ المعدلT_computationT_computation
1 GFLOPS1 GFLOPS1.449 × 10^9 / 10^91.449 × 10^9 / 10^91,449 ms1,449 ms
100 GFLOPS100 GFLOPS1.449 × 10^9 / 10^111.449 × 10^9 / 10^1114.5 ms14.5 ms
1 TFLOPS1 TFLOPS1.449 × 10^9 / 10^121.449 × 10^9 / 10^121.45 ms1.45 ms
67 TOPS (Orin Nano, INT8 sparse peak)67 TOPS (Orin Nano، القيمة القصوى المتفرقة بدقة INT8)1.449 × 10^9 / 6.7 × 10^131.449 × 10^9 / 6.7 × 10^130.022 ms0.022 ms
AlexNet's 1.449G FLOPs on different processors; the last row treats the count as OPs, as slide 28 allows for an INT8 modelعدد FLOPs في AlexNet البالغ 1.449G على معالجات مختلفة؛ الصف الأخير يعامل العدد على أنه OPs، كما تسمح الشريحة 28 لنموذج INT8

OPs: the same count for any data typeOPs: العدد نفسه لأي نوع من البيانات

The F in FLOP assumes floating point arithmetic. A quantized network, the kind you deploy on a microcontroller or an INT8 accelerator, stores weights and activations at an Bit width of 8 bits and multiplies integers. Those are not floating point operations, but they are still operations, and there are still two per MAC. The lecture therefore generalizes: an operation (OP) is one multiply or add of any data type, AlexNet is 724M × 2 = 1.4G OPs, and OPS is operations per second. The layer compute calculator in the second concept of this part uses OPS in its hardware box for exactly this reason: the formula for time does not care whether the operands were floats.

حرف F في FLOP يفترض حسابًا بالفاصلة العائمة. الشبكة المكمّمة، من النوع الذي تنشره على متحكم دقيق (microcontroller) أو على مسرّع INT8، تخزّن الأوزان والتنشيطات (activations) بعرض بت (bit-width) قدره 8 بتات وتضرب أعدادًا صحيحة. هذه ليست عمليات فاصلة عائمة، لكنها لا تزال عمليات، ولا يزال هناك اثنتان منها لكل MAC. لذلك تعمّم المحاضرة: العملية (operation (OP)) هي ضرب أو جمع واحد لأي نوع من البيانات، وAlexNet يساوي 724M × 2 = 1.4G من OPs، وOPS هي عدد العمليات في الثانية. حاسبة حساب الطبقة في المفهوم الثاني من هذا الجزء تستخدم OPS في خانة العتاد لهذا السبب بالضبط: صيغة الزمن لا تهتم بما إذا كانت المُعامَلات الحسابية (operands) أعدادًا عائمة.

OPS=OPssecond\text{OPS} = \frac{\text{OPs}}{\text{second}}
The general form; FLOPS is the floating point special caseالصيغة العامة؛ وFLOPS حالة خاصة للفاصلة العائمة
TermالمصطلحKindالنوعMeaningالمعنىBelongs toيخص
MACMACCountعددOne multiply accumulated into a sumعملية ضرب واحدة تُجمع في مجموع جارٍA model, per inferenceالنموذج، لكل استدلال
FLOPFLOPCountعددOne floating point multiply or add; a MAC is twoعملية ضرب أو جمع واحدة بالفاصلة العائمة، وعملية MAC تساوي اثنتينA model, per inferenceالنموذج، لكل استدلال
OPOPCountعددOne operation of any data type; a MAC is twoعملية واحدة لأي نوع من البيانات، وعملية MAC تساوي اثنتينA model, per inferenceالنموذج، لكل استدلال
FLOPSFLOPSRateمعدلFloating point operations per secondعدد عمليات الفاصلة العائمة في الثانيةA processorالمعالج
OPSOPSRateمعدلOperations per second, any data typeعدد العمليات في الثانية، لأي نوع من البياناتA processorالمعالج
Five terms, two kinds of quantityخمسة مصطلحات، ونوعان من الكميات

Quick checkاختبار سريع

A model needs 3.6G FLOPs and a chip sustains 400 GFLOPS. What is T_computation?يحتاج نموذج 3.6G FLOPs، وتحافظ شريحة على 400 GFLOPS. ما قيمة T_computation؟

Quick checkاختبار سريع

Why does the lecture generalize from FLOPs to OPs?لماذا تعمّم المحاضرة من FLOPs إلى OPs؟

Quick checkاختبار سريع

A datasheet advertises a board at 67 TOPS. What kind of quantity is that?تعلن نشرة بيانات أن لوحة ما تصل إلى 67 TOPS. ما نوع هذه الكمية؟

Recall

State the rule that turns a MAC count into a FLOP count and a FLOP count into a time, then apply it: AlexNet on a 1 TFLOPS processor.اذكر القاعدة التي تحوّل عدد MACs إلى عدد FLOPs، وعدد FLOPs إلى زمن، ثم طبّقها: AlexNet على معالج سرعته 1 TFLOPS.

FLOPs = 2 × MACs, and T_computation = FLOPs / FLOPS. 2 × 724,406,816 = 1,448,813,632 FLOPs; 1.449 × 10^9 / 10^12 = 1.45 ms.
FLOPs = 2 × MACs، وT_computation = FLOPs / FLOPS. 2 × 724,406,816 = 1,448,813,632 من FLOPs؛ 1.449 × 10^9 / 10^12 = 1.45 ms.

Recall

Why use OPs rather than FLOPs for an INT8 model, and how many OPs per MAC?لماذا نستخدم OPs بدلًا من FLOPs لنموذج INT8، وكم OP لكل MAC؟

Its multiplies and adds act on integers, so they are not floating point operations. OPs counts operations of any data type. There are still two per MAC, one multiply and one add.
عمليات الضرب والجمع فيه تعمل على أعداد صحيحة، لذا فهي ليست عمليات فاصلة عائمة. OPs تعدّ العمليات لأي نوع من البيانات. ولا يزال هناك اثنتان لكل MAC: ضرب واحد وجمع واحد.

Slide 29 lists the ten works the lecture draws on. Six were used directly in this lecture's counting and examples; the other four appear here as context for the architectures and normalization layers of lecture 02 and the pruning lectures ahead.

تسرد الشريحة 29 الأعمال العشرة التي تستند إليها المحاضرة. ستة منها استُخدمت مباشرة في العدّ والأمثلة في هذه المحاضرة؛ والأربعة الأخرى تظهر هنا كسياق للبنى المعمارية وطبقات التطبيع (normalization) في المحاضرة 02 ولمحاضرات التقليم القادمة.

Used in this lectureمستخدمة في هذه المحاضرة

Context for other lecturesسياق لمحاضرات أخرى

Recapالخلاصة

If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا

  • A MAC is a <- a + b·c. A matrix-vector product costs m·n MACs and a matrix-matrix product m·n·k MACs.عملية MAC هي a <- a + b·c. ضرب مصفوفة في متجه يكلف m·n من MACs، وضرب مصفوفة في مصفوفة يكلف m·n·k من MACs.
  • Linear: c_o·c_i. Convolution: c_o·c_i·k_h·k_w·h_o·w_o. Grouped: divide by g. Depthwise: c_o·k_h·k_w·h_o·w_o, with no c_i.الخطية: c_o·c_i. الالتفاف: c_o·c_i·k_h·k_w·h_o·w_o. المجمّع (grouped): اقسم على g. العمقي (depthwise): c_o·k_h·k_w·h_o·w_o، بدون c_i.
  • Convolution MACs equal parameters times h_o·w_o. Linear MACs equal parameters.MACs الالتفاف تساوي عدد المعاملات مضروبًا في h_o·w_o. و MACs الطبقة الخطية تساوي عدد معاملاتها.
  • AlexNet performs 724,406,816 MACs. Its convolutions hold 3.8 percent of the parameters but perform 92 percent of the MACs; the linear layers are the reverse.ينفّذ AlexNet عدد 724,406,816 من MACs. طبقات الالتفاف فيه تحمل 3.8 بالمئة من المعاملات لكنها تنفّذ 92 بالمئة من MACs، والطبقات الخطية عكس ذلك تمامًا.
  • One MAC is two FLOPs, so AlexNet is about 1.45G FLOPs, which the slide rounds to 1.4G.عملية MAC الواحدة تساوي اثنتين من FLOPs، لذا يحتاج AlexNet نحو 1.45G FLOPs، وتقرّبها الشريحة إلى 1.4G.
  • FLOPs and OPs are counts that belong to a model. FLOPS and OPS are rates that belong to a processor. T_computation = OPs / OPS.FLOPs و OPs أعداد تخص النموذج. أما FLOPS و OPS فمعدلات تخص المعالج. T_computation = OPs / OPS.
  • OPs generalizes FLOPs to quantized integer networks; the count per MAC stays two.تعمّم OPs مفهوم FLOPs على الشبكات المكمّمة التي تعمل بالأعداد الصحيحة، ويبقى العدد لكل MAC اثنين.
  • Conventions differ: many papers and tools report MACs under the label FLOPs. Check before comparing numbers.الاصطلاحات تختلف: كثير من الأوراق والأدوات تذكر MACs تحت اسم FLOPs. تحقّق من ذلك قبل مقارنة الأرقام.

Sourcesالمصادر